/* Quantara Copy Trading - built on the Quantara client-portal theme
   (quantara-crm-branding.html): same tokens, rail, topbar, tables and pills.
   Dark is the default; light is opt-in (data-qm-theme="light", set by
   static/theme.js). No inline styles or scripts: the CSP forbids them. */
:root {
  --qm-gold: #D4A24B; --qm-gold-strong: #D4A24B; --qm-gold-soft: #E8C07A;
  --qm-gold-wash: rgba(212, 162, 75, 0.12);
  --bg: #0A0A0A; --surface: #141413; --surface-2: #1C1B19; --rail: #050505;
  --line: #2B2A27; --line-soft: #201F1D;
  --text: #F3F2F0; --text-2: #C2C0BB; --muted: #8B8884;
  --good: #2FBE86; --good-bg: rgba(47, 190, 134, 0.12);
  --warn: #E0A33C; --warn-bg: rgba(224, 163, 60, 0.12);
  --bad: #E8655B; --bad-bg: rgba(232, 101, 91, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 32px -20px rgba(0, 0, 0, .8);
  --logo-dark-display: block; --logo-light-display: none;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --rail-w: 252px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  color-scheme: dark;
}
:root[data-qm-theme="light"] {
  --qm-gold: #B8862F; --qm-gold-strong: #D4A24B; --qm-gold-soft: #E8C07A;
  --qm-gold-wash: rgba(212, 162, 75, 0.10);
  --bg: #F7F6F4; --surface: #FFFFFF; --surface-2: #F1F0ED; --rail: #FFFFFF;
  --line: #E5E3DF; --line-soft: #EEEDEA;
  --text: #141312; --text-2: #4A4844; --muted: #6E6B66;
  --good: #12855C; --good-bg: rgba(18, 133, 92, 0.10);
  --warn: #9A6410; --warn-bg: rgba(201, 138, 29, 0.12);
  --bad: #C0392F; --bad-bg: rgba(192, 57, 47, 0.10);
  --shadow: 0 1px 2px rgba(16, 20, 24, .06), 0 8px 24px -12px rgba(16, 20, 24, .18);
  --logo-dark-display: none; --logo-light-display: block;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--qm-gold); }
a:hover { color: var(--qm-gold-soft); }
:focus-visible { outline: 2px solid var(--qm-gold-strong); outline-offset: 2px; border-radius: 4px; }
h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .01em; margin: 0 0 4px; }
h2 { font-size: 14px; font-weight: 600; letter-spacing: .01em; margin: 26px 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ico { width: 17px; height: 17px; flex: none; }

/* ---------- logo ---------- */
.brand { display: flex; align-items: center; padding: 0 8px; text-decoration: none; }
.brand img { height: 32px; width: auto; display: block; }
.brand .logo-dark { display: var(--logo-dark-display); }
.brand .logo-light { display: var(--logo-light-display); }
.brand-role { display: block; padding: 8px 8px 0; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--qm-gold); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.nav-toggle, .nav-open, .nav-close, .nav-scrim { display: none; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 22px 14px 14px; background: var(--rail); border-right: 1px solid var(--line); overflow-y: auto; }
.sidebar-head { position: relative; padding-bottom: 16px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { padding: 16px 10px 6px; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; text-decoration: none; transition: background-color .14s ease, color .14s ease; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--qm-gold-wash); color: var(--qm-gold); font-weight: 600; }
.nav-item.on::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--qm-gold-strong); }
.nav-item .badge { margin-left: auto; }
.rail-spacer { flex: 1; min-height: 16px; }
.rail-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 8px; }
.pref { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.pref:hover { border-color: var(--qm-gold-strong); color: var(--text); }
.pref .ico { width: 15px; height: 15px; }
.when-light { display: none; }
:root[data-qm-theme="light"] .when-light { display: inline; }
:root[data-qm-theme="light"] .when-dark { display: none; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin: 0; }
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(140deg, var(--qm-gold-strong), #9A6C1F); color: #1A1304; font-weight: 700; font-size: 12px; letter-spacing: .02em; }
.user-card .who { min-width: 0; line-height: 1.3; }
.user-card .who b { display: block; font-size: 13px; font-weight: 600; }
.user-card .who span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { margin-left: auto; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border: 0; }
.icon-btn .ico { width: 16px; height: 16px; }

/* ---------- main + topbar ---------- */
.main { min-width: 0; padding: 0 0 56px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 20px 28px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-titles { display: flex; align-items: flex-end; gap: 14px; min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.page-title { margin: 4px 0 0; font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: .01em; line-height: 1.15; text-wrap: balance; }
.greeting { color: var(--text-2); font-size: 13px; }
.greeting b { color: var(--text); font-weight: 600; }

/* logged-out pages */
.guest-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--rail); flex-wrap: wrap; }
.guest-brand { display: flex; flex-direction: column; }
.guest-brand .brand { padding: 0; }
.guest-nav { display: flex; align-items: center; gap: 18px; }
.guest-nav a:not(.button) { color: var(--text-2); text-decoration: none; font-weight: 500; }
.guest-nav a.on, .guest-nav a:not(.button):hover { color: var(--qm-gold); }

/* ---------- page layout ---------- */
.wrap { padding: 22px 28px 0; max-width: 1480px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 48px 16px; }
.guest.narrow { padding-top: 56px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.wrap > .card { max-width: 760px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.head-row h1 + p, .head-row p { margin: 4px 0 0; }
.crumbs { color: var(--muted); margin: 0 0 8px; font-size: 13px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--qm-gold); }

/* ---------- forms ---------- */
form label { display: block; margin: 0 0 16px; font-weight: 500; font-size: 13px; color: var(--text); }
form label small { display: block; font-weight: 400; color: var(--muted); margin-top: 5px; font-size: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; transition: border-color .14s ease; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--qm-gold-strong) 35%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--qm-gold-strong); box-shadow: 0 0 0 3px var(--qm-gold-wash); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input[type=checkbox], input[type=radio] { accent-color: var(--qm-gold-strong); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--text-2); }
label.check input { width: auto; margin-top: 3px; flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px 4px; margin: 0 0 16px; min-width: 0; /* browsers default fieldsets to min-content: they won't shrink on phones */ }
legend { font-weight: 600; padding: 0 6px; font-size: 13px; }

/* ---------- buttons ---------- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; transition: border-color .14s ease, background-color .14s ease, filter .14s ease; }
button:hover, .button:hover { border-color: var(--qm-gold-strong); color: var(--text); }
button.primary, .button.primary { background: linear-gradient(135deg, var(--qm-gold-strong), #B8862F); border-color: transparent; color: #1A1304; }
button.primary:hover, .button.primary:hover { filter: brightness(1.05); border-color: transparent; color: #1A1304; }
button.danger, .button.danger-link { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
button.danger:hover, .button.danger-link:hover { border-color: var(--bad); color: var(--bad); }
button.ghost, .button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
button.wide { width: 100%; margin-top: 4px; padding: 11px 16px; }
button.link { background: none; border: 0; padding: 0; color: var(--qm-gold); font-weight: 500; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns form { margin: 0; }
.search { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search input, .search select { margin: 0; width: auto; min-width: 220px; }
.search .button { white-space: nowrap; }
.links { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.notes { color: var(--muted); padding-left: 18px; margin: 20px 0 0; }
.secret { font-size: 17px; letter-spacing: .08em; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); text-align: center; word-break: break-all; }

/* ---------- messages ---------- */
.flash { padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 16px; border: 1px solid transparent; font-size: 13.5px; }
.flash.ok { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 13px; border: 1px dashed var(--line); border-radius: var(--r-md); margin-bottom: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.banner strong { color: var(--text-2); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.warn strong, .banner.bad strong, .banner.warn a, .banner.bad a { color: inherit; }

/* ---------- KPI tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 18px 0 22px; }
.tile { padding: 16px 17px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.tile .value { margin-top: 8px; font-size: 25px; font-weight: 600; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.tile .value.small { font-size: 17px; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.good { border-color: color-mix(in srgb, var(--qm-gold-strong) 40%, var(--line)); background: radial-gradient(120% 140% at 0% 0%, var(--qm-gold-wash), transparent 62%), var(--surface); box-shadow: var(--shadow); }
.tile.good .label { color: var(--qm-gold); }
.tile.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: radial-gradient(120% 140% at 0% 0%, var(--bad-bg), transparent 62%), var(--surface); }
.tile.bad .label { color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; }
thead th, th { padding: 11px 18px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th.num, td.num { text-align: right; }
td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
td.actions form { margin: 0; }
.empty { text-align: center; padding: 44px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg); }
.empty h2 { margin-top: 0; font-family: var(--serif); font-size: 23px; }
.empty p { color: var(--muted); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .04em; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.on { background: var(--good-bg); color: var(--good); }
.pill.off { background: var(--bad-bg); color: var(--bad); }
tr.lvl-error .pill.lvl, tr.res-failed .pill.res, tr.st-failed .pill.st, tr.st-review .pill.st, tr.st-short .pill.st { background: var(--bad-bg); color: var(--bad); }
tr.lvl-warn .pill.lvl, tr.res-skipped .pill.res, tr.st-pending .pill.st, tr.st-withdrawing .pill.st, tr.st-withdrawn .pill.st, tr.st-depositing .pill.st { background: var(--warn-bg); color: var(--warn); }
tr.res-copied .pill.res, tr.st-done .pill.st { background: var(--good-bg); color: var(--good); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--qm-gold-strong); color: #1A1304; font-size: 10.5px; font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 22px 0 18px; align-items: center; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--qm-gold); border-bottom-color: var(--qm-gold-strong); font-weight: 600; }
.tab-note { color: var(--muted); font-size: 12.5px; margin-left: auto; }
details.mail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 8px; padding: 10px 14px; }
details.mail pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; color: var(--text-2); }

/* ---------- admin forms ---------- */
.form-card { margin: 16px 0 24px; max-width: none !important; }
.row-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row-form label { flex: 1; min-width: 200px; margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
.grid2 > section h2 { margin-top: 20px; }
input.inline, label input.inline { display: inline-block; width: 7rem; max-width: 100%; margin: 6px 0 0 8px; padding: 5px 8px; }
input.tiny { display: inline-block; width: 5.5rem; margin: 0; padding: 5px 7px; font-size: 12.5px; }
.inline-form { display: inline-flex; gap: 5px; align-items: center; margin: 0 6px 5px 0; }

/* ---------- providers ---------- */
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin: 18px 0; }
.offer-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: var(--text); transition: border-color .14s ease, transform .14s ease; }
.offer-card:hover { border-color: var(--qm-gold-strong); transform: translateY(-1px); color: var(--text); }
.offer-card h2 { margin: 0; font-family: var(--serif); font-size: 21px; }
.offer-top, .offer-hero, .review-head { display: flex; gap: 14px; align-items: center; }
.offer-hero { margin: 8px 0 4px; }
.offer-desc { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.offer-meta { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.offer-meta strong { color: var(--text); }
.offer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
.offer-stats div { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); }
.offer-stats strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.logo { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); border: 1px solid var(--line); }
.logo.big { width: 76px; height: 76px; border-radius: 16px; }
.logo.placeholder { display: inline-grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 24px; color: var(--qm-gold); }
.logo.big.placeholder { font-size: 34px; }
.prose p { margin: 0 0 12px; white-space: pre-line; color: var(--text-2); }
.prose h2 { margin-top: 0; }
.wrap > .card.prose, .wrap > .card.subscribe-box, .wrap > .card.review, .wrap > .card.track { max-width: none; }
.small-prose { font-size: 13px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.gallery img { width: 100%; height: 160px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line); display: block; }
.subscribe-box { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin: 20px 0 12px; border-color: color-mix(in srgb, var(--qm-gold-strong) 40%, var(--line)); background: radial-gradient(120% 140% at 0% 0%, var(--qm-gold-wash), transparent 62%), var(--surface); }
.subscribe-box h2 { margin: 0 0 4px; font-family: var(--serif); font-size: 23px; }
.subscribe-box p { margin: 0; max-width: 60ch; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.thumbs img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.thumbs img.new { outline: 2px solid var(--warn); outline-offset: 1px; }
.thumbs figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.thumb-pick { display: flex; flex-direction: column; gap: 4px; font-weight: 400; margin: 0; }
.thumb-pick span { display: flex; align-items: center; gap: 5px; font-size: 12.5px; }
.thumb-pick input { width: auto; margin: 0; display: inline; }
.review { margin: 12px 0 20px; }
.review h3 { margin: 0 0 3px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 16px 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.review-form textarea { min-height: 2.6rem; }
tr.changed td { background: var(--warn-bg); }
td.pre { white-space: pre-line; max-width: 40ch; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0 8px; }

/* ---------- subscribing ---------- */
label.choice { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; font-weight: 400; cursor: pointer; background: var(--surface); transition: border-color .14s ease; }
label.choice:hover { border-color: color-mix(in srgb, var(--qm-gold-strong) 50%, var(--line)); }
label.choice:has(input:checked) { border-color: var(--qm-gold-strong); background: var(--qm-gold-wash); }
label.choice input[type=radio] { width: auto; margin-top: 4px; flex: none; }
label.choice small, label.check small { display: block; color: var(--muted); margin-top: 3px; }
label.choice.disabled { opacity: .5; cursor: not-allowed; }
.inline-field { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.inline-field input { width: 8rem; margin: 0; }
.warn-text { color: var(--warn) !important; }
.round-up { margin-top: 6px; }
.terms-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px 4px; margin: 0 0 16px; }
.terms-box ul { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 8px; }
.terms-box li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); font-size: 13px; }
.terms-box li::before { content: ""; margin-top: 7px; width: 6px; height: 6px; flex: none; border-radius: 2px; background: var(--qm-gold-strong); }
.terms-page { max-width: 820px; }

/* ---------- performance ---------- */
.pos { color: var(--good) !important; }
.neg { color: var(--bad) !important; }
.wrap > .card.track { margin: 16px 0 20px; }
.track h2 { margin-top: 0; font-family: var(--serif); font-size: 23px; }
.chart { margin: 8px 0 16px; }
.chart svg { width: 100%; height: 170px; display: block; background: var(--surface-2); border-radius: var(--r-md); }
.chart .line { fill: none; stroke: var(--qm-gold-strong); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--qm-gold-strong); opacity: .16; stroke: none; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11.5px; margin-top: 6px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin: 8px 0 16px; }
.stat-grid dt { color: var(--muted); font-size: 12px; }
.stat-grid dd { margin: 2px 0 0; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.month { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 8px 10px; display: flex; flex-direction: column; font-size: 12px; }
.month span { color: var(--muted); }
.month strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.month.pos strong { color: var(--good); }
.month.neg strong { color: var(--bad); }
nav.tabs { margin-top: 22px; }

/* ---------- notifications ---------- */
.notes-list { display: grid; gap: 10px; margin-top: 16px; max-width: 760px; }
.note { position: relative; padding: 14px 16px 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.note::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--line); }
.note.good::before { background: var(--good); }
.note.bad::before { background: var(--bad); }
.note.unread { border-color: color-mix(in srgb, var(--qm-gold-strong) 40%, var(--line)); background: radial-gradient(120% 140% at 0% 0%, var(--qm-gold-wash), transparent 62%), var(--surface); }
.note-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.note p { margin: 6px 0; color: var(--text-2); white-space: pre-line; }
.note a { font-size: 12.5px; font-weight: 600; }

/* ---------- admin tools ---------- */
.kill-form label { max-width: 520px; }
.kill h3 { display: flex; gap: 10px; align-items: center; }
table.explain td, table.explain th { min-width: 150px; }
table.explain td:first-child, table.explain th:first-child { min-width: 70px; }
.cell-copied { background: var(--good-bg); }
.cell-skipped { background: var(--warn-bg); }
.cell-failed, .cell-missing { background: var(--bad-bg); color: var(--bad); }
tr.hl td { outline: 2px solid var(--qm-gold-strong); outline-offset: -2px; }
.explain-form input[type=date] { width: auto; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: min(var(--rail-w), 86vw); transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); }
  .nav-open { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; flex: none; color: var(--text-2); }
  .nav-close { display: block; position: absolute; right: 2px; top: -4px; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
  .topbar { padding: 14px 16px 12px; align-items: center; }
  .page-title { font-size: 24px; }
  .greeting { display: none; }
  .wrap { padding: 18px 16px 0; }
}
/* ---------- phones ---------- */
@media (max-width: 640px) {
  /* iOS zooms into any field under 16px when it's tapped */
  input, select, textarea, input.mono, textarea.mono { font-size: 16px; }
  /* thumb-sized tap targets */
  button, .button { min-height: 42px; }
  button.small { min-height: 38px; padding: 7px 12px; font-size: 13px; }
  .icon-btn { min-height: 0; width: 36px; height: 36px; }
  input.tiny, input.inline { min-height: 38px; }
  .head-row { align-items: stretch; }
  .head-row > .button, .head-row > .btns { width: 100%; }
  .head-row > .btns > * { flex: 1; }
  .btns > form { flex: 1; }
  .btns > form > button, .btns > .button { width: 100%; }
  .card form > button.primary, .card form > button.danger { width: 100%; }
  /* filter bars: search box on its own row, everything else shares the next */
  .search input:not([type=hidden]):not([type=date]) { flex: 1 1 100%; min-width: 0; }
  .search select, .search input[type=date] { flex: 1 1 45%; min-width: 0; width: auto; }
  .search button, .search .button { flex: 1 1 auto; }
  .search > select:first-child { flex-basis: 100%; }
  .explain-form input[type=date] { flex: 1 1 55%; }
  .page-title { font-size: 22px; }
  h1 { font-size: 23px; }
  /* tabs: one row that scrolls sideways, not a wrapped pile */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; flex: none; padding: 10px 12px; }
  .tab-note { display: none; }

  /* stacked tables: each row a card of "Heading  value" lines (labels are
     filled in from the column headings by static/tables.js) */
  .table-wrap:has(table:not(.no-stack)) { background: none; border: 0; border-radius: 0; overflow: visible; }
  table:not(.no-stack), table:not(.no-stack) tbody, table:not(.no-stack) tr, table:not(.no-stack) td { display: block; width: 100%; }
  table:not(.no-stack) thead { display: none; }
  table:not(.no-stack) tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 14px; margin-bottom: 10px; }
  table:not(.no-stack) tbody tr:hover td { background: none; }
  /* label floats left, the cell's own content (however many pieces) stays
     together on the right */
  table:not(.no-stack) td { padding: 8px 0; border-bottom: 1px solid var(--line-soft); text-align: right; min-height: 0; overflow-wrap: anywhere; }
  table:not(.no-stack) td::after { content: ""; display: block; clear: both; }
  table:not(.no-stack) td:last-child { border-bottom: 0; }
  table:not(.no-stack) td::before { content: attr(data-label); float: left; max-width: 45%; margin: 2px 14px 0 0; text-align: left; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
  table:not(.no-stack) td[data-label=""]::before, table:not(.no-stack) td:not([data-label])::before { display: none; }
  table:not(.no-stack) td[data-label=""], table:not(.no-stack) td:not([data-label]) { text-align: left; }
  table:not(.no-stack) td[colspan] { text-align: center; }
  table:not(.no-stack) td.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
  table:not(.no-stack) td.actions::before { margin-right: auto; }
  table:not(.no-stack) td.actions::after { display: none; }
  table:not(.no-stack) td.pre { max-width: none; }
  table:not(.no-stack) tr.changed td { background: none; }
  table:not(.no-stack) tr.changed { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
  table:not(.no-stack) tr.hl { outline: 2px solid var(--qm-gold-strong); }
  table:not(.no-stack) .cell-copied, table:not(.no-stack) .cell-skipped,
  table:not(.no-stack) .cell-failed, table:not(.no-stack) .cell-missing { padding-left: 8px; padding-right: 8px; border-radius: var(--r-sm); }
  td .inline-form { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 13px 14px; }
  .tile .value { font-size: 20px; }
  .card { padding: 18px; }
  .narrow { padding: 28px 16px; }
  .search input, .search select { min-width: 0; flex: 1; }
  .guest-head { padding: 12px 16px; }
  .guest-nav { gap: 12px; }
  .guest-head .brand img { height: 26px; }
  td, thead th, th { padding: 10px 12px; }
}
