/* xinyuan-edge consoles — Obsidian Slate + Emerald/Teal design system.
   Single zero-build stylesheet, no external CDNs or web fonts (CSP compliant).
   Dark mode is default; supports explicit light/dark/system via <html data-theme>. */

:root {
  --bg: #080c12;
  --bg-2: #0c121c;
  --panel: #101723;
  --panel-2: #151f2f;
  --panel-3: #1c283b;
  --line: rgba(148, 163, 184, .14);
  --line-2: rgba(148, 163, 184, .25);
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #8494ab;
  --accent: #10b981;
  --accent-2: #14b8a6;
  --accent-3: #34d399;
  --accent-text: #ffffff;
  --accent-soft: rgba(16, 185, 129, .13);
  --accent-soft-2: rgba(16, 185, 129, .22);
  --grad: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --grad-hero: linear-gradient(135deg, #064e3b 0%, #0f4c5c 52%, #0c2d3e 100%);
  --grad-text: linear-gradient(90deg, #34d399 0%, #2dd4bf 100%);
  --ok: #34d399; --ok-bg: rgba(16, 185, 129, .14);
  --warn: #fbbf24; --warn-bg: rgba(245, 158, 11, .14);
  --bad: #f87171; --bad-bg: rgba(239, 68, 68, .15);
  --info: #38bdf8; --info-bg: rgba(56, 189, 248, .14);
  --code-bg: #0b1019;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .72);
  --ring: 0 0 0 3px rgba(16, 185, 129, .30);
  --glass: rgba(12, 18, 28, .86);
  --header-h: 56px;
  --side-w: 224px;
  --side-w-collapsed: 64px;
  --bottom-nav: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f7f9;
    --bg-2: #ffffff;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-3: #eef2f6;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --accent: #059669;
    --accent-2: #0d9488;
    --accent-3: #10b981;
    --accent-text: #ffffff;
    --accent-soft: rgba(5, 150, 105, .10);
    --accent-soft-2: rgba(5, 150, 105, .18);
    --grad: linear-gradient(135deg, #059669 0%, #0d9488 100%);
    --grad-hero: linear-gradient(135deg, #065f46 0%, #0f766e 60%, #115e59 100%);
    --grad-text: linear-gradient(90deg, #059669 0%, #0d9488 100%);
    --ok: #047857; --ok-bg: #dcfce7;
    --warn: #b45309; --warn-bg: #fef3c7;
    --bad: #dc2626; --bad-bg: #fee2e2;
    --info: #0284c7; --info-bg: #e0f2fe;
    --code-bg: #0f172a;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-lg: 0 24px 60px -16px rgba(15, 23, 42, .22);
    --ring: 0 0 0 3px rgba(5, 150, 105, .24);
    --glass: rgba(255, 255, 255, .88);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f4f7f9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #eef2f6;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #059669;
  --accent-2: #0d9488;
  --accent-3: #10b981;
  --accent-text: #ffffff;
  --accent-soft: rgba(5, 150, 105, .10);
  --accent-soft-2: rgba(5, 150, 105, .18);
  --grad: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --grad-hero: linear-gradient(135deg, #065f46 0%, #0f766e 60%, #115e59 100%);
  --grad-text: linear-gradient(90deg, #059669 0%, #0d9488 100%);
  --ok: #047857; --ok-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #dc2626; --bad-bg: #fee2e2;
  --info: #0284c7; --info-bg: #e0f2fe;
  --code-bg: #0f172a;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px -16px rgba(15, 23, 42, .22);
  --ring: 0 0 0 3px rgba(5, 150, 105, .24);
  --glass: rgba(255, 255, 255, .88);
  color-scheme: light;
}

/* --- base ------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
pre {
  background: var(--code-bg); color: #e2e8f0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0 0 10px; line-height: 1.6;
}
h1 { font-size: 21px; line-height: 1.3; margin: 0; letter-spacing: -.015em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 16px 0 8px; font-weight: 650; color: var(--text-2); }
p { margin: 0 0 10px; }
ol, ul { margin: 0 0 10px; padding-left: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 650; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hide-mobile { display: initial; }
.only-mobile { display: none; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
::selection { background: var(--accent-soft-2); }

/* --- icons ------------------------------------------------------------------------ */
.ic { width: 1.18em; height: 1.18em; stroke: currentColor; fill: none; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.24em; }
.ic.lg { width: 1.5em; height: 1.5em; }
.ic.xl { width: 2.1em; height: 2.1em; }

/* --- shell: full-width 56px topbar + grouped collapsible sidebar (APIHub style) --- */
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 8px; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; overflow: hidden;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); padding: 3px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; filter: invert(1) brightness(1.3); }
:root[data-theme="light"] .brand-mark img { filter: none; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .brand-mark img { filter: none; }
}
.brand-name { font-weight: 700; font-size: 14.5px; line-height: 1.2; letter-spacing: -.01em; }
.brand-pill {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.header-icon-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  display: inline-grid; place-items: center; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.header-icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--panel-2); text-decoration: none; }
.header-user {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 4px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line); max-width: 240px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 999px; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none;
}
.header-user .uname { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-user .umeta { font-size: 11px; color: var(--muted); white-space: nowrap; }

.shell-body {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: calc(100dvh - var(--header-h)); transition: grid-template-columns .18s ease;
}
.shell-body.collapsed { grid-template-columns: var(--side-w-collapsed) minmax(0, 1fr); }

.side {
  position: sticky; top: var(--header-h); height: calc(100dvh - var(--header-h));
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-2); border-right: 1px solid var(--line); padding: 12px 10px 10px;
}
.side-back { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group {
  font-size: 10.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em;
  padding: 12px 10px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-group:first-child { padding-top: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px; position: relative;
  transition: background .14s, color .14s; white-space: nowrap;
}
.nav a .ic { width: 17px; height: 17px; opacity: .82; flex: none; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.nav a.active .ic { opacity: 1; color: var(--accent); }
.nav a .count { margin-left: auto; }
.side-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.collapse-btn {
  width: 100%; justify-content: flex-start; border-color: transparent; background: transparent;
  color: var(--muted); font-size: 12.5px; padding: 7px 10px; min-height: 34px;
}
.collapse-btn:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }

.shell-body.collapsed .nav-group { display: none; }
.shell-body.collapsed .nav a { justify-content: center; padding: 9px; }
.shell-body.collapsed .nav a .nav-text,
.shell-body.collapsed .nav a .count,
.shell-body.collapsed .collapse-btn .nav-text { display: none; }
.shell-body.collapsed .collapse-btn { justify-content: center; }

.main { padding: 24px 28px 56px; min-width: 0; max-width: 1360px; width: 100%; margin: 0 auto; }
.bottom-nav { display: none; }
.mobile-menu-btn { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; max-width: 78ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.crumb:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 900px) {
  .hide-mobile { display: none !important; }
  .only-mobile { display: initial; }
  .mobile-menu-btn { display: inline-grid; }
  .brand-pill, .header-user .umeta { display: none; }
  .shell-body, .shell-body.collapsed { display: block; padding-bottom: calc(var(--bottom-nav) + var(--safe-b)); }
  .side {
    position: fixed; inset: var(--header-h) auto 0 0; width: min(82vw, 290px); height: auto; z-index: 50;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
    padding-bottom: calc(14px + var(--safe-b));
  }
  .side.open { transform: none; }
  .side-back { display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 45; background: rgba(4, 8, 14, .6); opacity: 0; pointer-events: none; transition: opacity .18s; }
  .side-back.open { opacity: 1; pointer-events: auto; }
  .collapse-btn { display: none; }
  .main { padding: 16px 14px 32px; }
  h1 { font-size: 19px; }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--bottom-nav) + var(--safe-b)); padding: 6px 6px calc(6px + var(--safe-b));
    background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: none;
    color: var(--muted); font-size: 10.5px; font-weight: 500; border-radius: var(--radius-sm); padding: 4px 2px; position: relative; min-width: 0; min-height: 0;
  }
  .bottom-nav a .ic, .bottom-nav button .ic { width: 20px; height: 20px; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav .dot { position: absolute; top: 3px; right: calc(50% - 16px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--grad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
  .bottom-nav span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
}

/* --- cards, stats, hero ------------------------------------------------------------ */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.card.tight { padding: 13px 16px; }
.card.flat { background: var(--panel-2); }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px;
  display: flex; align-items: center; gap: 14px; transition: border-color .15s;
}
.stat:hover { border-color: var(--line-2); }
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.stat.ok .stat-icon { background: var(--ok-bg); color: var(--ok); }
.stat.warn .stat-icon { background: var(--warn-bg); color: var(--warn); }
.stat.bad .stat-icon { background: var(--bad-bg); color: var(--bad); }
.stat.info .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-body { min-width: 0; flex: 1; }
.stat .k { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.stat .v { font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .v a { color: inherit; }
.stat .v .badge { font-size: 12.5px; vertical-align: middle; }
.stat.warn .v { color: var(--warn); } .stat.bad .v { color: var(--bad); } .stat.ok .v { color: var(--ok); }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.two { grid-template-columns: 1fr; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 34px; height: 34px; }
  .stat .v { font-size: 18px; }
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.spacer { flex: 1; }
.stack { display: grid; gap: 10px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .n { width: 24px; height: 24px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; margin-top: 1px; }
.steps li.done .n { background: var(--ok-bg); color: var(--ok); }

.hero {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px;
  color: #f8fafc; background: var(--grad-hero); border: 1px solid rgba(52, 211, 153, .28);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(520px 220px at 96% 0%, rgba(52, 211, 153, .22), transparent 65%),
              radial-gradient(320px 180px at 8% 100%, rgba(20, 184, 166, .18), transparent 65%);
}
.hero > * { position: relative; }
.hero h2 { color: #ffffff; font-size: 18px; margin: 0 0 4px; font-weight: 700; }
.hero p { color: rgba(241, 245, 249, .84); margin: 0; font-size: 13.5px; }
.hero .btn, .hero button { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .26); color: #ffffff; }
.hero .btn:hover, .hero button:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .45); }
.hero .btn.primary { background: #10b981; border-color: #10b981; color: #04130d; font-weight: 650; }
.hero .btn.primary:hover { background: #34d399; }

/* --- Model Marketplace (APIHub-inspired 2-column card grid + filter bar) ----------- */
.pill-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  font-size: 12.5px; font-weight: 500; cursor: pointer; min-height: 30px; transition: all .14s;
}
.pill:hover { border-color: var(--line-2); color: var(--text); }
.pill.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); font-weight: 600; }
.pill .pcount { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }

.model-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); margin-bottom: 16px; }
.model-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px;
  display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.model-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--panel-2); }
.model-card-head { display: flex; align-items: flex-start; gap: 10px; }
.model-icon {
  width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
}
.model-name { font-weight: 650; font-size: 13.5px; color: var(--text); word-break: break-all; }
.model-price-box {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 8px 10px; font-size: 12.5px; color: var(--text-2); display: grid; gap: 4px;
}
.model-card:hover .model-price-box { background: var(--panel); }
.model-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* --- Interactive Per-User API Docs (2-pane workspace) ----------------------------- */
.docs-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 16px; align-items: start; }
.docs-nav {
  position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 36px);
  overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
button.docs-nav-item {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 3px;
  width: 100%; text-align: left; white-space: normal; overflow: hidden;
  padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; min-height: 0; margin-bottom: 4px;
}
button.docs-nav-item:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
button.docs-nav-item.on {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}
button.docs-nav-item .row { flex-wrap: nowrap; width: 100%; min-width: 0; }
button.docs-nav-item .m { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.docs-nav-item .t { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; width: 100%; }
button.docs-nav-item.on .t { color: var(--accent-3); }
.endpoint-bar code { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: normal; }

.endpoint-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; margin: 12px 0;
}
.method-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); letter-spacing: .03em;
}
.method-pill.get { background: var(--info-bg); color: var(--info); }

.code-box {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px;
}
.code-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid rgba(148, 163, 184, .14); background: rgba(255, 255, 255, .02);
}
.code-tabs { display: inline-flex; gap: 4px; }
.code-tabs button {
  min-height: 26px; padding: 3px 10px; font-size: 12px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: #94a3b8;
}
.code-tabs button:hover { color: #f8fafc; background: rgba(255, 255, 255, .06); border-color: transparent; }
.code-tabs button.on { background: rgba(16, 185, 129, .18); color: #34d399; border-color: rgba(16, 185, 129, .32); }
.code-box pre { margin: 0; border: none; border-radius: 0; background: transparent; padding: 13px 15px; }

@media (max-width: 960px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: 260px; }
}

/* --- Right Slide-Over Detail Drawer (Semi SideSheet style) ------------------------ */
.drawer-back {
  position: fixed; inset: 0; background: rgba(4, 8, 14, .58); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 65; display: flex; justify-content: flex-end; animation: fade .14s ease;
}
.drawer {
  width: min(100vw, 520px); height: 100dvh; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideIn .18s ease;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Manual Pricing Review Panel (Req #4) ----------------------------------------- */
.review-box {
  background: var(--panel-2); border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line));
  border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 14px;
}
.review-box h3 { margin: 0 0 8px; color: var(--warn); display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.model-picker {
  display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  max-height: 200px; overflow-y: auto; padding: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.model-pick-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12.5px;
}
.model-pick-item.on { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.model-pick-item input { margin: 0; }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* --- tables ----------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 14px; }
.card .table-wrap, .review-box .table-wrap { margin-bottom: 0; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
th { background: var(--panel-2); font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; letter-spacing: .02em; }
td { font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 8px; }
.empty .ic { width: 34px; height: 34px; opacity: .5; }
.empty .t { font-weight: 600; color: var(--text-2); }
.empty.card { margin-bottom: 14px; }

@media (max-width: 900px) {
  .table-wrap { overflow: visible; background: transparent; border: none; }
  .card .table-wrap, .review-box .table-wrap { margin: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 13px; margin-bottom: 10px; }
  .card tr, .review-box tr { background: var(--panel-2); }
  td { border-bottom: 1px solid var(--line); padding: 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
  td:last-child { border-bottom: none; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; max-width: 42%; }
  td.actions { justify-content: flex-end; padding-top: 9px; }
  td.actions::before { display: none; }
  td.actions .row { flex-wrap: wrap; }
  td .mono { word-break: break-all; }
  td.primary-cell { display: block; text-align: left; font-weight: 650; font-size: 14.5px; padding-top: 10px; }
  td.primary-cell::before { display: none; }
  tr.click:hover td { background: transparent; }
}

/* --- buttons ---------------------------------------------------------------------- */
button, .btn {
  font: inherit; font-weight: 550; font-size: 13.5px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1.3; min-height: 36px; transition: background .14s, border-color .14s, color .14s; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); background: var(--panel-2); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--grad); border-color: transparent; color: var(--accent-text); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
button.soft { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--accent); }
button.soft:hover { background: var(--accent-soft-2); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button.link { border: none; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.sm, .btn.sm { padding: 4px 10px; min-height: 29px; font-size: 12px; border-radius: var(--radius-xs); }
button.block { width: 100%; }
button.icon-btn, .icon-btn { width: 34px; height: 34px; padding: 0; min-height: 34px; }
button .ic { width: 16px; height: 16px; }

/* --- forms ------------------------------------------------------------------------ */
form { margin: 0; }
.form { max-width: 560px; }
.form.narrow { max-width: 420px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
input, select, textarea {
  font: inherit; font-size: 13.5px; width: 100%; padding: 8px 11px; min-height: 38px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); transition: border-color .14s, box-shadow .14s, background .14s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .78; }
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); background: var(--panel); }
input[type="file"] { padding: 6px 10px; font-size: 13px; }
input[type="file"]::file-selector-button { font: inherit; font-size: 12px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); padding: 4px 10px; border-radius: var(--radius-xs); margin-right: 10px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; padding: 0; accent-color: var(--accent); vertical-align: middle; margin: 0 6px 0 0; }
input[type="date"] { min-width: 145px; }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238494ab' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 11px center; background-size: 13px 13px; background-repeat: no-repeat;
}
.inline input, .inline select { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.input-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input-group > input, .input-group > select { flex: 1 1 180px; width: auto; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters > input, .filters > select { width: auto; flex: 1 1 160px; max-width: 300px; }
.filters .sep { color: var(--muted); }
.search { position: relative; flex: 1 1 200px; max-width: 360px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 34px; width: 100%; max-width: none; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.check input { width: 17px; flex: none; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 22px; letter-spacing: .38em; text-align: center; min-height: 50px; }

/* --- badges, chips, banners ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-3); color: var(--muted); white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.chip button.link { color: var(--muted); display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.chip button.link:hover { background: var(--bad-bg); color: var(--bad); text-decoration: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); line-height: 1.5; font-size: 13px; }
.banner .ic { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.banner > div { flex: 1; min-width: 0; }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 32%, transparent); color: var(--warn); }
.banner.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 32%, transparent); color: var(--ok); }
.banner.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 32%, transparent); color: var(--bad); }
.banner.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 32%, transparent); color: var(--info); }
.banner a { color: inherit; font-weight: 650; text-decoration: underline; }
.secret { background: var(--panel-2); border: 1px dashed var(--line-2); color: var(--text); padding: 11px 13px; border-radius: var(--radius-sm); word-break: break-all; font-size: 13px; line-height: 1.55; }
.kv { display: grid; grid-template-columns: minmax(120px, 165px) 1fr; gap: 8px 16px; align-items: baseline; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 12.5px; }
.kv > div:nth-child(even) { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv > div:nth-child(odd) { font-size: 12px; margin-top: 8px; }
  .kv > div:nth-child(odd):first-child { margin-top: 0; }
}

/* --- tabs ------------------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 14px; max-width: 100%; overflow-x: auto; }
.tabs button { border: none; background: none; border-radius: 6px; padding: 5px 13px; min-height: 30px; color: var(--muted); font-weight: 550; font-size: 13px; flex: none; }
.tabs button:hover { color: var(--text); background: transparent; border: none; }
.tabs button.on { background: var(--panel-3); color: var(--accent); font-weight: 600; }
.tabs button .count { margin-left: 6px; }
.tabs.block { display: flex; }
.tabs.block button { flex: 1; }

/* --- modal ------------------------------------------------------------------------ */
.modal-back { position: fixed; inset: 0; background: rgba(4, 8, 14, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 70; overflow: auto; animation: fade .14s ease; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; width: 100%; max-width: 580px; padding: 20px 22px; box-shadow: var(--shadow-lg); animation: rise .16s ease; }
.modal.wide { max-width: 840px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { transform: none; opacity: 1; } }
@media (max-width: 600px) {
  .modal-back { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92dvh; overflow: auto; padding: 18px 16px calc(18px + var(--safe-b)); }
  .modal-foot { position: sticky; bottom: 0; background: var(--panel); padding-top: 10px; }
  .modal-foot button { flex: 1; }
}

/* --- toasts ----------------------------------------------------------------------- */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; max-width: min(92vw, 390px); pointer-events: none; }
.toast div { display: flex; align-items: center; gap: 8px; background: var(--panel-3); color: var(--text); border: 1px solid var(--line-2); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); animation: rise .16s ease; font-weight: 500; font-size: 13px; }
.toast div .ic { width: 17px; height: 17px; color: var(--ok); }
.toast div.bad { background: #7f1d1d; border-color: #ef4444; color: #fff; }
.toast div.bad .ic { color: #fca5a5; }
@media (max-width: 900px) { .toast { left: 14px; right: 14px; bottom: calc(var(--bottom-nav) + var(--safe-b) + 12px); max-width: none; justify-items: center; } }

/* --- loading ---------------------------------------------------------------------- */
.skeleton { display: grid; gap: 10px; }
.skeleton div { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.skeleton div:nth-child(2) { width: 84%; } .skeleton div:nth-child(3) { width: 64%; } .skeleton div:nth-child(4) { width: 74%; }
.skeleton.tall div { height: 42px; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.splash { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); gap: 12px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- auth pages ------------------------------------------------------------------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background-image:
    radial-gradient(640px 360px at 50% -10%, rgba(16, 185, 129, .14), transparent 70%),
    radial-gradient(500px 320px at 85% 100%, rgba(20, 184, 166, .10), transparent 70%);
}
.auth-box { width: 100%; max-width: 420px; }
.auth-box.wide { max-width: 540px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; text-align: center; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; padding: 6px; }
.auth-brand h1 { font-size: 24px; }
.auth-brand p { color: var(--muted); margin: 0; font-size: 13.5px; }
.auth .card { padding: 24px; margin: 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 14px; }
@media (max-width: 600px) { .auth { align-items: start; padding-top: 8vh; } .auth .card { padding: 20px 16px; } }

/* --- misc ------------------------------------------------------------------------- */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin: 4px 0 14px; }
.pager .muted { margin-right: auto; }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 10px; align-items: center; margin-bottom: 8px; }
.price-row .unit { font-size: 12px; color: var(--muted); display: block; }
@media (max-width: 600px) { .price-row { grid-template-columns: 1fr; gap: 4px; margin-bottom: 12px; } }
.tier-list { display: grid; gap: 4px; }
.tier-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 12.5px; line-height: 1.45; }
.tier-line .tier-lbl { color: var(--muted); }
.tier-line .tier-val { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.strike { text-decoration: line-through; color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: 4px; }
.profit-pos { color: var(--ok); font-weight: 600; }
.profit-neg { color: var(--bad); font-weight: 700; }
.econ-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.ch-model-block { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ch-model-block:last-child { border-bottom: 0; padding-bottom: 0; }
.ch-model-block:first-child { padding-top: 0; }
.sim-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 16px; }
.sim-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-input { width: 84px !important; padding: 5px 8px !important; font-family: var(--mono); text-align: right; }
.price-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 10px; }
.price-sec-head h2 { margin: 0; font-size: 15px; }
.quote-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 600px) { .quote-grid { grid-template-columns: 1fr; } }
.quote-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.quote-card.inverted { border-color: rgba(239, 68, 68, .55); }
.quote-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.quote-table-wrap { overflow-x: auto; margin: 0 -2px; }
.quote-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.quote-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 11.5px; background: transparent; }
.quote-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.quote-table tr:last-child td { border-bottom: 0; }
.quote-table th.num, .quote-table td.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
@media (max-width: 900px) {
  .quote-table { display: table; width: 100%; }
  .quote-table thead { display: table-header-group; }
  .quote-table tbody { display: table-row-group; }
  .quote-table tr { display: table-row; background: transparent; border: none; padding: 0; margin: 0; }
  .quote-table th, .quote-table td { display: table-cell; width: auto; padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
  .quote-table th.num, .quote-table td.num { text-align: right; }
  .quote-table td::before { display: none; }
}
.quote-ref { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); padding: 6px 10px; border-radius: var(--radius-sm); background: var(--panel-2); }
.inline-mult { width: 78px !important; min-height: 30px !important; padding: 4px 7px !important; font-family: var(--mono); font-size: 12.5px !important; }
.mini-presets { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.mini-presets button { padding: 1px 6px; min-height: 21px; font-size: 11px; border-radius: 4px; }
details.adv-expr { margin-top: 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 8px 12px; }
details.adv-expr summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 500; }
details.adv-expr[open] summary { margin-bottom: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: block; }
.cell-clamp { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (max-width: 900px) { .cell-clamp { max-width: 60vw; white-space: normal; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
