:root {
  --ink: #1f2a37;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --panel: #ffffff;
  --brand: #2563eb;
  --brand-deep: #1d4ed8;
  --brand-soft: #eff6ff;
  --accent: #ea580c;
  --accent-soft: #fff7ed;
  --code-bg: #1e2430;
  --code-fg: #e5e7eb;
  --note: #eff6ff;
  --note-border: #bfdbfe;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: Consolas, "SF Mono", Menlo, monospace;
  --nav-w: 240px;
  --sample-w: 380px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); font-family: var(--sans); background: var(--bg); line-height: 1.55; }

/* ---------- login ---------- */
.login-page { background: #fff; }
.login-split { display: grid; grid-template-columns: minmax(280px, 38%) 1fr; min-height: 100vh; }
.login-brand {
  background: linear-gradient(165deg, #eff6ff 0%, #f8fafc 55%, #fff7ed 100%);
  padding: 2rem 2.25rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.brand-mark {
  font-size: 1.45rem; letter-spacing: .02em; color: var(--brand-deep); font-weight: 700;
}
.brand-art {
  flex: 1; min-height: 180px; margin: 1rem 0; border-radius: 14px;
  background:
    radial-gradient(circle at 28% 38%, rgba(37,99,235,.18), transparent 52%),
    radial-gradient(circle at 78% 62%, rgba(234,88,12,.14), transparent 48%),
    linear-gradient(135deg, #dbeafe, #f8fafc);
  border: 1px solid #e2e8f0;
}
.login-brand h1 { font-size: 1.4rem; margin: 0; line-height: 1.35; color: var(--brand-deep); }
.login-brand p { margin: 0; color: var(--muted); max-width: 28rem; }
.login-main {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem;
}
.login-lang { position: absolute; top: 1.25rem; right: 1.5rem; color: var(--muted); font-size: .9rem; }
.login-form { width: min(380px, 100%); }
.login-form h2 { font-size: 1.5rem; margin: 0 0 1.25rem; text-align: center; color: var(--brand-deep); }
.login-form label { display: block; font-size: .85rem; color: var(--muted); margin: .75rem 0 .35rem; }
.login-form input, .login-form select {
  width: 100%; padding: .7rem .85rem; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 1rem; background: #fff;
}
.btn-primary {
  margin-top: 1.25rem; width: 100%; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff; padding: .8rem 1rem; font-size: 1rem; cursor: pointer;
}
.btn-primary:hover { background: var(--brand-deep); }
.alert { background: #fef2f2; color: #b91c1c; padding: .65rem .8rem; border-radius: 8px; font-size: .9rem; }
.login-foot { position: absolute; bottom: 1rem; color: #94a3b8; font-size: .75rem; }

/* ---------- docs layout (Advance-like) ---------- */
.doc-layout {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--sample-w);
  min-height: 100vh;
}
.doc-layout-account { grid-template-columns: var(--nav-w) minmax(0, 1fr); }

.nav-pane {
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow: auto;
}
.nav-logo {
  display: block; padding: 1.15rem 1.1rem 1rem;
  text-decoration: none; border-bottom: 1px solid var(--line);
}
.nav-logo-mark {
  display: block; font-weight: 700; font-size: 1.15rem; color: var(--brand-deep);
}
.nav-logo-sub {
  display: block; margin-top: .15rem; font-size: .75rem; color: var(--muted); letter-spacing: .04em;
}
.nav-menu { padding: .75rem .55rem 1rem; flex: 1; }
.nav-group {
  margin: .9rem .55rem .25rem; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: #94a3b8;
}
.nav-link {
  display: block; padding: .5rem .7rem; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: .92rem;
}
.nav-link:hover { background: #f8fafc; color: var(--brand); }
.nav-link.active {
  background: var(--brand-soft); color: var(--brand-deep); font-weight: 600;
}
.nav-foot {
  border-top: 1px solid var(--line); padding: .85rem 1rem;
  font-size: .8rem; color: var(--muted);
  display: flex; justify-content: space-between; gap: .5rem; align-items: center;
}
.nav-foot a { color: var(--brand); text-decoration: none; }
.nav-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-main {
  padding: 1.75rem 2rem 3rem;
  overflow: auto;
  background: #fff;
  max-width: 920px;
}
.doc-h1 {
  margin: 0 0 1rem; font-size: 1.85rem; font-weight: 700; color: var(--ink);
}
.doc-body { max-width: 860px; }
.doc-body h1 {
  margin: 0 0 1rem; font-size: 1.85rem; font-weight: 700; color: var(--ink);
}
.doc-body h2, .doc-body h3 {
  margin: 1.6rem 0 .7rem; font-weight: 650; color: var(--ink);
}
.doc-body h2 { font-size: 1.25rem; }
.doc-body h3 { font-size: 1.05rem; }
.doc-body p { margin: .6rem 0; color: #334155; }
.doc-body ul, .doc-body ol { padding-left: 1.2rem; color: #334155; }
.doc-body a { color: var(--brand); text-decoration: none; }
.doc-body a:hover { text-decoration: underline; }
.doc-body strong { color: var(--ink); }

.doc-body blockquote,
.note-box {
  margin: 1rem 0;
  padding: .85rem 1rem;
  background: var(--note);
  border: 1px solid var(--note-border);
  border-radius: 8px;
  color: #1e3a8a;
  font-size: .92rem;
}
.doc-body blockquote { border-left: 3px solid var(--brand); }

.doc-body table,
.param-table {
  width: 100%; border-collapse: collapse; margin: .8rem 0 1.2rem; font-size: .9rem;
}
.doc-body th, .doc-body td,
.param-table th, .param-table td {
  border-bottom: 1px solid var(--line);
  padding: .7rem .55rem;
  text-align: left; vertical-align: top;
}
.doc-body th, .param-table th {
  background: #f8fafc; color: #475569; font-weight: 600; width: 28%;
}
.doc-body code, .param-table code {
  font-family: var(--mono); font-size: .86em;
  background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px;
}
.doc-body pre {
  background: #0f172a; color: #e2e8f0;
  padding: .9rem 1rem; border-radius: 8px; overflow: auto;
  font-family: var(--mono); font-size: .82rem; line-height: 1.5;
}
.doc-body pre code { background: transparent; color: inherit; padding: 0; }

.sample-pane {
  background: var(--code-bg); color: var(--code-fg);
  border-left: 1px solid #111827;
  overflow: auto;
  position: sticky; top: 0; height: 100vh;
  padding: 0 0 2rem;
}
.sample-head {
  position: sticky; top: 0; z-index: 1;
  background: #151b27; padding: .95rem 1.1rem;
  font-size: .92rem; font-weight: 600; letter-spacing: .02em;
  border-bottom: 1px solid #2a3344;
}
.sample-block { padding: .9rem 1.1rem 0; }
.sample-meta {
  display: flex; justify-content: space-between; align-items: center;
  color: #94a3b8; font-size: .72rem; text-transform: uppercase; margin-bottom: .4rem;
}
.btn-copy {
  border: 1px solid #334155; background: #1f2937; color: #cbd5e1;
  border-radius: 4px; padding: .2rem .55rem; font-size: .72rem; cursor: pointer;
}
.btn-copy:hover, .btn-copy.copied { background: #334155; color: #fff; }
.sample-pane pre {
  margin: 0 0 .85rem; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: .78rem; line-height: 1.45;
  background: #141922; border: 1px solid #2a3140; border-radius: 8px; padding: .85rem;
  color: #e5e7eb;
}
.sample-empty { padding: 1rem 1.1rem; color: #94a3b8; font-size: .88rem; }

.muted { color: var(--muted); font-size: .88rem; }
.tip { margin: 0 0 .6rem; }

.account-card { max-width: 760px; }
.status-row { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.badge-ok, .badge-trial, .badge-live {
  padding: .15rem .55rem; border-radius: 999px; font-size: .82rem;
}
.badge-ok, .badge-trial { background: var(--accent-soft); color: #c2410c; }
.badge-live { background: #ecfdf5; color: #047857; }
.account-h { font-size: 1.1rem; margin: 1.4rem 0 .6rem; color: var(--ink); }
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { padding: .65rem 0; border-bottom: 1px solid var(--line); text-align: left; }
.kv th { width: 32%; color: var(--muted); font-weight: 500; }
.tag-list {
  list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem;
}
.tag-list li {
  background: var(--brand-soft); color: var(--brand-deep);
  padding: .35rem .7rem; border-radius: 999px; font-size: .88rem;
}
.product-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: .35rem 0;
}
.product-edit-row select { max-width: 140px; }

/* ---------- Ops ---------- */
.ops-page { background: #f8fafc; min-height: 100vh; }
.ops-topbar, .topbar {
  height: 52px; background: #0f172a; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.1rem; gap: 1rem;
}
.ops-brand, .topbar-brand { font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.ops-nav { display: flex; gap: .35rem; flex: 1; }
.ops-nav-link {
  color: rgba(255,255,255,.75); text-decoration: none;
  padding: .35rem .85rem; border-radius: 999px; font-size: .9rem;
}
.ops-nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.ops-nav-link.active { color: #fff; background: rgba(37,99,235,.85); font-weight: 600; }
.ops-page .doc-layout { min-height: calc(100vh - 52px); }
.ops-page .nav-pane { height: calc(100vh - 52px); }
.ops-page .sample-pane { height: calc(100vh - 52px); }

.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.chip {
  background: rgba(255,255,255,.12); border: 0; border-radius: 999px;
  padding: .3rem .75rem; font-size: .85rem; color: #fff; text-decoration: none; cursor: pointer;
}
.link-quiet { color: rgba(255,255,255,.85); text-decoration: none; font-size: .85rem; }
.ops-main { padding: 1.5rem 1.75rem 3rem; max-width: 1280px; margin: 0 auto; }
.ops-main.narrow { max-width: 640px; }
.ops-main h1 { color: #0f172a; font-size: 1.55rem; margin: 0 0 .5rem; }
.ops-h2 { margin: 2rem 0 .75rem; font-size: 1.15rem; color: #0f172a; }

.cred-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem; margin: 1rem 0 1.5rem;
}
.cred-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.cred-title { font-weight: 650; color: #0f172a; }
.cred-sub { font-size: .78rem; color: var(--muted); margin: .2rem 0 .75rem; }
.cred-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: .45rem; align-items: center;
  margin: .35rem 0; font-size: .88rem;
}
.cred-row > span { color: var(--muted); }
.cred-val {
  font-family: var(--mono); font-size: .85rem; background: #f1f5f9;
  padding: .25rem .45rem; border-radius: 4px; overflow: auto;
}
.btn-mini {
  border: 1px solid #cbd5e1; background: #fff; border-radius: 4px;
  padding: .15rem .4rem; font-size: .72rem; cursor: pointer; color: var(--brand);
}
.btn-mini:hover { background: var(--brand-soft); }
.cred-products { margin-top: .75rem; font-size: .8rem; color: #475569; line-height: 1.45; }
.cred-actions { display: flex; gap: .85rem; margin-top: .7rem; flex-wrap: wrap; }

.matrix-list { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0 1.5rem; }
.matrix-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.matrix-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: .85rem; flex-wrap: wrap;
}
.matrix-card-head .muted { display: block; margin-top: .2rem; font-size: .8rem; }
.matrix-card-actions { display: flex; gap: .65rem; align-items: center; }
.matrix-card-actions a { color: var(--brand); text-decoration: none; font-size: .88rem; }
.matrix-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem;
}
.matrix-cell {
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .75rem;
  background: #f8fafc;
}
.matrix-cell.is-on { background: #eff6ff; border-color: #bfdbfe; }
.matrix-cell.is-off { opacity: .72; }
.matrix-prod-name { font-weight: 650; margin-bottom: .45rem; font-size: .92rem; }
.matrix-cell select {
  width: 100%; margin: .35rem 0 .45rem; padding: .4rem .5rem;
  border: 1px solid #cbd5e1; border-radius: 6px; font-size: .88rem; background: #fff;
}
.matrix-sources { display: flex; flex-wrap: wrap; gap: .25rem .55rem; }
.check.tiny { font-size: .78rem; margin: 0; color: #475569; }
.btn-save {
  border: 0; background: var(--brand); color: #fff; border-radius: 8px;
  padding: .45rem .9rem; font-size: .88rem; cursor: pointer;
}
.btn-save:hover { background: var(--brand-deep); }
.matrix-card .check { display: flex; align-items: center; gap: .35rem; margin: .2rem 0; color: var(--ink); font-size: .88rem; }
.matrix-card .check input { width: auto; }


.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.ops-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ops-table th, .ops-table td {
  padding: .7rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
.ops-table th { background: #f8fafc; white-space: nowrap; }
.ops-table a { color: var(--brand); }
.ops-form label { display: block; margin: .75rem 0 .3rem; color: var(--muted); font-size: .88rem; }
.ops-form input, .ops-form select {
  width: 100%; padding: .65rem .75rem; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem;
}
.ops-form fieldset {
  margin: 1rem 0; border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem 1rem;
}
.ops-form legend { padding: 0 .35rem; color: var(--brand-deep); font-weight: 600; }
.ops-form .check { display: flex; align-items: center; gap: .45rem; margin: .35rem 0; color: var(--ink); }
.ops-form .check input { width: auto; }

@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .sample-pane { display: none; }
}
@media (max-width: 800px) {
  .login-split { grid-template-columns: 1fr; }
  .login-brand { min-height: 200px; }
  .doc-layout, .doc-layout-account { grid-template-columns: 1fr; }
  .nav-pane { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}
