/* Gold Desk — application stylesheet.
   Design tokens first; every component uses tokens so light and dark stay consistent. */

:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #1b1d22;
  --ink-2: #3c4049;
  --muted: #6b707a;
  --line: #e4e2dc;
  --line-2: #eeece6;
  --accent: #a87a0a;
  --accent-ink: #1b1400;
  --accent-soft: #f6edd5;
  --up: #157347;
  --up-soft: #e3f3ea;
  --down: #b42318;
  --down-soft: #fbe8e6;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --info: #2f5bd3;
  --info-soft: #e7eefc;
  --chip: #f0eee8;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 2px 8px rgba(20, 20, 20, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 228px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114; --panel: #17191d; --panel-2: #1c1f24; --ink: #e9e7e2; --ink-2: #c9c7c2;
    --muted: #9298a2; --line: #2a2e35; --line-2: #22252b; --accent: #d9ab33; --accent-ink: #1b1400;
    --accent-soft: #2e2510; --up: #3cb37a; --up-soft: #12271c; --down: #f0706a; --down-soft: #2e1614;
    --warn: #e3a447; --warn-soft: #2d2210; --info: #7aa2ff; --info-soft: #18213a; --chip: #23262c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #101114; --panel: #17191d; --panel-2: #1c1f24; --ink: #e9e7e2; --ink-2: #c9c7c2;
  --muted: #9298a2; --line: #2a2e35; --line-2: #22252b; --accent: #d9ab33; --accent-ink: #1b1400;
  --accent-soft: #2e2510; --up: #3cb37a; --up-soft: #12271c; --down: #f0706a; --down-soft: #2e1614;
  --warn: #e3a447; --warn-soft: #2d2210; --info: #7aa2ff; --info-soft: #18213a; --chip: #23262c;
  --shadow: none;
}

/* ---------------------------------------------------------------- base -- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--panel-2); border: 1px solid var(--line);
      padding: 12px; border-radius: var(--radius-sm); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }

/* -------------------------------------------------------------- layout -- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel);
           border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 15px; }
.brand .dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
              background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.nav-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
             padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
         color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--chip); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--ink); }
.nav a .ico { width: 18px; text-align: center; opacity: .8; }
.sidebar .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 4px 0;
                 border-top: 1px solid var(--line); }
.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1440px; margin: 0 auto; padding: 24px 28px 48px; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; box-shadow: var(--shadow); }
  .sidebar.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; padding: 10px 16px;
            background: var(--panel); border-bottom: 1px solid var(--line); }
  .content { padding: 16px 16px 40px; }
}

/* --------------------------------------------------------- page header -- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
             margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 760px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------------------- cards -- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
        box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
             margin: -2px 0 12px; }
.card h2, .card-head h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase;
                          letter-spacing: .07em; margin: 0 0 12px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 18px 0; margin: 0 0 8px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid > .card + .card { margin-top: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.section { margin-top: 16px; }

/* --------------------------------------------------------------- KPIs --- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
       box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* -------------------------------------------------------------- tables -- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top;
         white-space: nowrap; }
thead th, tr:first-child > th { position: sticky; top: 0; background: var(--panel); color: var(--muted);
         font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
tbody tr:hover td, table tr:hover > td { background: var(--panel-2); }
td.wrap, th.wrap { white-space: normal; min-width: 200px; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 18px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 18px; }
table.kv th { width: 38%; color: var(--muted); font-weight: 500; position: static; background: none; border-bottom: 1px solid var(--line-2); }
table.kv td { white-space: normal; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; }

/* ------------------------------------------------------- chips/badges -- */
.chip, .badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
                background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 500; line-height: 1.6; }
.chip.up, .badge.ok { background: var(--up-soft); color: var(--up); }
.chip.down, .badge.err { background: var(--down-soft); color: var(--down); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--accent-soft); color: var(--accent); }
.badge .pip { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------- buttons -- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
       border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: var(--radius-sm);
       font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--chip); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* --------------------------------------------------------------- forms -- */
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); }
textarea { font-family: var(--mono); font-size: 12.5px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; }
.form-grid { display: grid; gap: 4px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field.check > label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field ul.choices, .field div > div { list-style: none; padding: 0; margin: 0; }
.checks { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.help { color: var(--muted); font-size: 12px; margin-top: 5px; }
.errorlist { color: var(--down); margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.form-section { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
                margin: 8px 0 12px; padding-top: 8px; border-top: 1px solid var(--line-2); grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line-2); }

/* ------------------------------------------------------------ messages -- */
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm);
       margin-bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; }
.msg.error { border-left-color: var(--down); } .msg.success { border-left-color: var(--up); }
.msg.warning { border-left-color: var(--warn); } .msg.info { border-left-color: var(--info); }
.banner { background: var(--down); color: #fff; padding: 9px 16px; text-align: center; font-weight: 500; }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line);
           color: var(--ink-2); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* ---------------------------------------------------------- status list -- */
.status-list { display: grid; gap: 6px; font-size: 12.5px; }
.status-list .row { display: flex; gap: 8px; align-items: baseline; }
.status-list .row .k { color: var(--muted); min-width: 64px; }
.status-list .row .v { white-space: normal; }

/* -------------------------------------------------------------- market -- */
.mkt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; }
.mkt-head .meta { color: var(--muted); display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.mkt-head .meta b { color: var(--ink); font-weight: 600; }
.chart-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a:hover { text-decoration: none; background: var(--chip); }
.seg a.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px; font: 500 13px var(--font);
              cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.chart-bar label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); cursor: pointer;
                   user-select: none; font-size: 13px; }
.chart-bar .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
#chart { height: 480px; }
@media (max-width: 600px) { #chart { height: 340px; } }

/* --------------------------------------------------------------- login -- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 380px; }
