/* NuviQ Wealth OMS — one stylesheet for /login and /app.
   Gold on black. Dark is the default; light follows prefers-color-scheme unless the
   user picked a theme ([data-theme] on <html>). Tokens are the ARCHITECTURE §9 values. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #131316;
  --panel-2: #1b1b20;
  --border: #2c2c33;
  --text: #f4efe4;
  --muted: #a49c8d;
  --accent: #e5b84e;
  --accent-fg: #14110a;
  --profit: #2fbf90;
  --loss: #f0625c;
  --warn: #e0a83c;
  --profit-bg: rgb(47 191 144 / .12);
  --loss-bg: rgb(240 98 92 / .12);
  --warn-bg: rgb(224 168 60 / .12);
  --accent-bg: rgb(229 184 78 / .12);
  --gold-grad: linear-gradient(100deg, #f6d98a 0%, var(--accent) 45%, #a9791d 100%);
  --glow-a: rgb(229 184 78 / .20);
  --glow-b: rgb(229 184 78 / .12);
  --grid-line: rgb(229 184 78 / .05);
  --shadow: 0 18px 50px rgb(0 0 0 / .45);
  --topbar-bg: rgb(10 10 11 / .78);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --gutter: clamp(16px, 2.4vw, 48px);
  /* motion: one easing family so every movement feels related */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --t-fast: .16s;
  --t-med: .28s;
  --t-slow: .5s;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f7f5f0; --panel: #ffffff; --panel-2: #f1ece3; --border: #e2dbcd; --text: #191510; --muted: #6b6357;
    --accent: #8a6a12; --accent-fg: #ffffff; --profit: #0f7a55; --loss: #c0392f; --warn: #8a5f08;
    --profit-bg: rgb(15 122 85 / .10); --loss-bg: rgb(192 57 47 / .10); --warn-bg: rgb(138 95 8 / .10);
    --accent-bg: rgb(138 106 18 / .12);
    --glow-a: rgb(138 106 18 / .14); --glow-b: rgb(138 106 18 / .09); --grid-line: rgb(138 106 18 / .06);
    --shadow: 0 18px 50px rgb(60 45 10 / .14); --topbar-bg: rgb(247 245 240 / .82);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5f0; --panel: #ffffff; --panel-2: #f1ece3; --border: #e2dbcd; --text: #191510; --muted: #6b6357;
  --accent: #8a6a12; --accent-fg: #ffffff; --profit: #0f7a55; --loss: #c0392f; --warn: #8a5f08;
  --profit-bg: rgb(15 122 85 / .10); --loss-bg: rgb(192 57 47 / .10); --warn-bg: rgb(138 95 8 / .10);
  --accent-bg: rgb(138 106 18 / .12);
  --glow-a: rgb(138 106 18 / .14); --glow-b: rgb(138 106 18 / .09); --grid-line: rgb(138 106 18 / .06);
  --shadow: 0 18px 50px rgb(60 45 10 / .14); --topbar-bg: rgb(247 245 240 / .82);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-gutter: stable; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast) var(--ease-out); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); }
.num, .mono, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.gold-text { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.profit { color: var(--profit); }
.loss { color: var(--loss); }
.warn-text { color: var(--warn); }
.accent { color: var(--accent); }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-fg); }
.skip-link:focus { top: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* thin scrollbars that match the panels */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ live backdrop */
.live-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; color: var(--accent); }
.live-bg-glow { position: absolute; display: block; border-radius: 9999px; filter: blur(80px); opacity: .5; will-change: transform; }
.live-bg-glow.a { top: -22rem; right: -14rem; width: 52rem; height: 42rem;
  background: radial-gradient(circle, var(--glow-a), transparent 70%); animation: nvq-drift-a 26s var(--ease-in-out) infinite alternate; }
.live-bg-glow.b { bottom: -26rem; left: -16rem; width: 46rem; height: 38rem;
  background: radial-gradient(circle, var(--glow-b), transparent 70%); animation: nvq-drift-b 34s var(--ease-in-out) infinite alternate; }
.live-bg-grid { position: absolute; inset: calc(-10% - 64px) -10% -10% calc(-10% - 64px); will-change: transform; display: block; opacity: .35;
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 20%, transparent 100%);
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 20%, transparent 100%);
  animation: nvq-pan 40s linear infinite; }
.live-bg-line { position: absolute; left: 0; right: 0; bottom: 12%; width: 100%; height: 34vh; opacity: .14; }
.live-bg-track { animation: nvq-scroll 38s linear infinite; will-change: transform; }
@keyframes nvq-drift-a { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-6rem,4rem,0) scale(1.12); } }
@keyframes nvq-drift-b { from { transform: translate3d(0,0,0) scale(1.05); } to { transform: translate3d(5rem,-3rem,0) scale(.95); } }
@keyframes nvq-pan { from { transform: translate3d(0,0,0); } to { transform: translate3d(64px,64px,0); } }
@keyframes nvq-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ------------------------------------------------------------------ logo */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo img { display: block; height: 28px; width: auto; }
.logo.lg img { height: 40px; }
.logo .logo-tag { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border-left: 1px solid var(--border); padding-left: 10px; }
.logo-on-light { display: none !important; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-on-dark { display: none !important; }
  :root:not([data-theme="dark"]) .logo-on-light { display: block !important; }
}
:root[data-theme="light"] .logo-on-dark { display: none !important; }
:root[data-theme="light"] .logo-on-light { display: block !important; }

/* ------------------------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--border); background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.topbar-inner { width: 100%; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 var(--gutter); }
.topbar-left, .topbar-right { flex: 1 1 0; display: flex; align-items: center; min-width: 0; }
.topbar-right { justify-content: flex-end; gap: 8px; }
.mainnav { display: none; align-items: center; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border-radius: 999px; border: 0;
  background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out); }
.tab:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.tab.active, .tab[aria-current="page"] { background: var(--accent-bg); color: var(--accent); }
.tab .chev { width: 10px; height: 10px; opacity: .7; transition: transform var(--t-med) var(--ease-out); }
.tab[aria-expanded="true"] .chev { transform: rotate(180deg); }
.dd { position: relative; }
.dd-menu { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 6px); z-index: 40; min-width: 232px;
  padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow);
  transform-origin: top center; animation: nvq-pop-c var(--t-med) var(--ease-out); }
.dd-menu a, .menu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 6px;
  color: var(--text); font-size: 13px; text-decoration: none; border: 0; background: none; width: 100%; text-align: left; font: inherit; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out); }
.dd-menu a:hover, .menu-item:hover, .dd-menu a:focus-visible { background: var(--panel-2); text-decoration: none; }
.dd-menu a.active { color: var(--accent); background: var(--accent-bg); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; position: relative; padding: 0;
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--loss);
  color: #fff; font-size: 10px; font-weight: 700; line-height: 18px; text-align: center; font-family: var(--mono); }
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 3px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: border-color var(--t-fast) var(--ease-out); }
.avatar-btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: 12px; font-weight: 700; }
.avatar-name { display: none; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow); z-index: 40;
  transform-origin: top right; animation: nvq-pop var(--t-med) var(--ease-out); }
@keyframes nvq-pop { from { opacity: 0; transform: translate3d(0, -6px, 0) scale(.97); } }
@keyframes nvq-pop-c { from { opacity: 0; transform: translate3d(-50%, -6px, 0) scale(.97); } to { opacity: 1; transform: translate3d(-50%, 0, 0); } }
.user-menu .who { padding: 4px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hamburger { display: inline-grid; }
.sheet { border-top: 1px solid var(--border); background: var(--panel); padding: 12px var(--gutter) 16px; max-height: calc(100vh - 56px); overflow-y: auto; overscroll-behavior: contain;
  animation: nvq-sheet var(--t-med) var(--ease-out); }
@keyframes nvq-sheet { from { opacity: 0; transform: translate3d(0, -8px, 0); } }
.sheet a { display: block; padding: 9px 10px; border-radius: 6px; color: var(--text); font-size: 14px; text-decoration: none; transition: background-color var(--t-fast) var(--ease-out); }
.sheet a:hover { background: var(--panel-2); }
.sheet a.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.sheet .sheet-group { margin-top: 12px; padding: 0 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
@media (min-width: 1100px) {
  .mainnav { display: flex; }
  .hamburger, .sheet { display: none !important; }
}
@media (min-width: 1280px) { .avatar-name { display: inline; } }

/* ------------------------------------------------------------------ page layout */
.page { width: 100%; padding: clamp(16px, 1.6vw, 28px) var(--gutter) 48px; }
/* route change: one soft entrance for the whole page, not per card */
.page.route-in { animation: nvq-route var(--t-slow) var(--ease-out) backwards; }
@keyframes nvq-route { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .sub { margin-top: 4px; color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ------------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px; min-width: 0; }
.card-body.flush { padding: 0; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 2000px) { .grid-2, .grid-3, .stack { gap: 20px; } }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0;
  transition: border-color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out); }
.kpi .k { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi .v { margin-top: 6px; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .s { margin-top: 2px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); text-decoration: none; transform: translate3d(0, -2px, 0); }
.kv { display: grid; gap: 10px 16px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv .v { margin-top: 2px; word-break: break-word; }
pre.code { margin: 0; padding: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: auto;
  font-size: 12px; max-height: 420px; white-space: pre; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out); }
.btn:not(:disabled):active { transform: scale(.97); }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: var(--accent); box-shadow: 0 8px 22px -10px var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--loss-bg); border-color: color-mix(in srgb, var(--loss) 45%, var(--border)); color: var(--loss); }
.btn-danger:hover { border-color: var(--loss); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: nvq-spin .7s linear infinite; }
@keyframes nvq-spin { to { transform: rotate(360deg); } }
.btn-row { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* segmented control (in-page tabs) */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); max-width: 100%; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: background-color var(--t-med) var(--ease-out), color var(--t-fast) var(--ease-out); }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--accent-bg); color: var(--accent); }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }
.badge.profit { background: var(--profit-bg); color: var(--profit); border-color: transparent; }
.badge.loss { background: var(--loss-bg); color: var(--loss); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.accent { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.badge.live { background: var(--loss-bg); color: var(--loss); border-color: color-mix(in srgb, var(--loss) 50%, transparent); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: nvq-pulse 1.6s ease-in-out infinite; }
@keyframes nvq-pulse { 50% { opacity: .35; } }

/* ------------------------------------------------------------------ banners */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-2); font-size: 13px; }
.banner b { white-space: nowrap; }
.banner.loss { background: var(--loss-bg); border-color: color-mix(in srgb, var(--loss) 45%, transparent); color: var(--text); }
.banner.loss b { color: var(--loss); }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.banner.warn b { color: var(--warn); }
.banner.info { background: var(--accent-bg); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.banner.ok { background: var(--profit-bg); border-color: color-mix(in srgb, var(--profit) 35%, transparent); }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field.span-2 { grid-column: 1 / -1; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], input[type="time"],
input:not([type]), select, textarea {
  width: 100%; min-width: 0; height: 36px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 13.5px;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), background-color var(--t-fast) var(--ease-out); }
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--loss); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.secret { position: relative; }
.secret input { padding-right: 64px; font-family: var(--mono); }
.secret .reveal { position: absolute; right: 4px; top: 4px; height: 28px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; cursor: pointer; transition: color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out); }
.secret .reveal:hover { color: var(--text); background: var(--panel); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.toolbar .field { min-width: 140px; flex: 1 1 140px; max-width: 240px; }
.form-error { color: var(--loss); font-size: 13px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; min-width: 0; }
legend { padding: 0 6px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ tables */
.tbl { display: grid; gap: 0; min-width: 0; }
.tbl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl-tools input[type="search"] { max-width: 260px; height: 30px; font-size: 13px; }
.tbl-tools .count { font-size: 12px; color: var(--muted); }
.table-wrap { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.table-wrap.tall { max-height: 70vh; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.t th { position: sticky; top: 0; z-index: 1; background: var(--panel); text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--text); }
table.t th .arrow { display: inline-block; width: 10px; margin-left: 2px; color: var(--accent); }
table.t th button.th-btn { all: unset; cursor: pointer; }
table.t th button.th-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background-color var(--t-fast) var(--ease-out); }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
table.t tr.clickable { cursor: pointer; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
table.t td.wrap { white-space: normal; min-width: 200px; }
table.t td .reason { display: block; font-size: 11.5px; color: var(--muted); white-space: normal; max-width: 360px; }
table.t td .reason.bad { color: var(--loss); }
table.t tfoot td { font-weight: 600; background: var(--panel-2); }
table.t.compact td { padding: 6px 10px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; margin: 0 auto 8px; opacity: .6; color: var(--accent); }
.empty b { display: block; color: var(--text); margin-bottom: 2px; }

/* skeletons */
.skel { position: relative; overflow: hidden; background: var(--panel-2); border-radius: 6px; height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 10%, transparent), transparent); animation: nvq-shimmer 1.4s var(--ease-in-out) infinite; }
@keyframes nvq-shimmer { to { transform: translateX(100%); } }
.skel-rows { display: grid; gap: 10px; padding: 16px; }

/* ------------------------------------------------------------------ dialogs */
dialog.modal { padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: var(--shadow);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.modal[open] { animation: nvq-modal var(--t-med) var(--ease-out); }
dialog.modal[open]::backdrop { animation: nvq-fade var(--t-med) var(--ease-out); }
@keyframes nvq-modal { from { opacity: 0; transform: translate3d(0, 12px, 0) scale(.98); } }
@keyframes nvq-fade { from { opacity: 0; } }
dialog.modal.wide { width: min(1040px, calc(100vw - 24px)); }
dialog.modal.xwide { width: min(1400px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgb(0 0 0 / .6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 16px; overflow: auto; display: grid; gap: 14px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.secret-once { padding: 12px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px dashed var(--accent); font-family: var(--mono); word-break: break-all; user-select: all; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 1000; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); box-shadow: var(--shadow); font-size: 13px; animation: nvq-in var(--t-med) var(--ease-out); }
.toast.ok { border-left-color: var(--profit); }
.toast.err { border-left-color: var(--loss); }
.toast.warn { border-left-color: var(--warn); }
.toast .x { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
@keyframes nvq-in { from { transform: translate3d(0, 12px, 0) scale(.98); opacity: 0; } }

/* ------------------------------------------------------------------ misc */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 4px; }
.bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width var(--t-slow) var(--ease-out); }
.bar > span.ok { background: var(--profit); } .bar > span.warn { background: var(--warn); } .bar > span.critical { background: var(--loss); }
.leg-table input, .leg-table select { height: 30px; font-size: 12.5px; min-width: 80px; }
.dl-link { font-size: 12px; }
.spark { width: 100%; height: 120px; display: block; }
.live-flag { font-weight: 700; color: var(--loss); }

/* ------------------------------------------------------------------ sign-in
   One composition: the state of today's NSE session is the loud thing, the form is quiet,
   and a single session bar along the bottom shows where "now" sits in the trading day. */
body.signin { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; }
/* Header, content and session bar share one column so their left edges line up. */
.signin-top, .signin-main, .session { width: 100%; max-width: calc(1680px + 2 * clamp(16px, 5vw, 72px)); margin: 0 auto;
  padding-left: clamp(16px, 5vw, 72px); padding-right: clamp(16px, 5vw, 72px); }
.signin-top { display: flex; align-items: center; justify-content: space-between; padding-top: 20px; padding-bottom: 20px; }
.signin-main { display: grid; gap: 48px; align-content: center; padding-top: 24px; padding-bottom: 40px;
  grid-template-columns: minmax(0, 1fr); }

.market-clock { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.market-state { margin: 14px 0 0; max-width: 14ch; font-size: clamp(40px, 7.2vw, 88px); font-weight: 600;
  line-height: .98; letter-spacing: -.045em; text-wrap: balance; }
.market-detail { margin-top: 20px; max-width: 44ch; color: var(--muted); font-size: 16px; line-height: 1.55; }
.market[data-phase="open"] .market-state { color: var(--accent); }

.signin-form { display: grid; gap: 18px; align-content: start; width: 100%; max-width: 420px; }
.signin-form h1 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
.signin-form input { height: 44px; font-size: 15px; }
.signin-form .secret .reveal { top: 8px; }
.signin-form #login-btn { height: 44px; font-size: 15px; font-weight: 600; margin-top: 4px; }
.who { margin: 6px 0 0; display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.who > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; }
.who dt { font-weight: 600; }
.who dd { margin: 0; color: var(--muted); }

.session { padding-bottom: 28px; }
.session-track { position: relative; height: 56px; }
.session-band { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--border); }
.session-fill { position: absolute; top: 0; height: 2px; left: 27.08%; width: 0; background: var(--accent);
  transition: width 1.2s var(--ease-out); }
.session-tick { position: absolute; top: -5px; left: calc(var(--at) * 100%); width: 1px; height: 12px; background: var(--muted); }
.session-tick::after { content: attr(data-label); position: absolute; top: 18px; left: 0; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.session-tick.t-pre::after { transform: translateX(calc(-100% + 4px)); }
.session-tick.t-open::after { transform: translateX(-4px); }
.session-tick.t-close::after { transform: translateX(-50%); }
.session-now { position: absolute; top: -6px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); transition: left 1.2s var(--ease-out); }
.session-note { margin-top: 4px; max-width: 80ch; color: var(--muted); font-size: 12px; }

@media (min-width: 900px) {
  .signin-main { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: clamp(48px, 8vw, 160px); align-items: end; }
  .signin-form { justify-self: end; }
}
@media (max-width: 560px) {
  .session-tick::after { font-size: 11px; }
  .session-tick::after { content: attr(data-short); }
  .session-tick.t-pre::after { content: none; }      /* 09:00 and 09:15 sit 4px apart on a phone */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .live-bg-glow, .live-bg-grid, .live-bg-track { animation: none !important; }
}
@media print { .topbar, .live-bg, .toasts { display: none !important; } }
@media (max-width: 420px) {
  .logo .logo-tag { display: none; }
  .topbar-inner { gap: 6px; }
  .topbar-right { gap: 6px; }
  .kpi .v { font-size: 18px; }
}

/* ------------------------------------------------------------------ manual trading desk
   The ticket is a real sequence (instrument, legs, accounts, preview), so its steps are numbered;
   the right rail keeps the summary and the two buttons in view while the ticket scrolls. */
.mt-desk { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; margin-bottom: 16px; }
@media (min-width: 1100px) { .mt-desk { grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px); } }

.mt-ticket { padding: 4px 0; }
.mt-step { position: relative; padding: 18px 20px 20px 64px; }
.mt-step + .mt-step { border-top: 1px solid var(--border); }
/* the line between step numbers fills in as the ticket progresses */
.mt-step::before { content: ""; position: absolute; left: 31px; top: 50px; bottom: -18px; width: 1px; background: var(--border); transition: background-color var(--t-med) var(--ease-out); }
.mt-step:last-child::before { display: none; }
.mt-step.done::before { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.mt-step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.mt-step-n { position: absolute; left: 18px; top: 18px; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-family: var(--mono); font-size: 12px; font-weight: 600;
  transition: background-color var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out); }
.mt-step.done .mt-step-n { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.mt-step-head h2 { font-size: 15px; letter-spacing: -.01em; }
.mt-step-head .sub { margin-top: 2px; color: var(--muted); font-size: 12.5px; max-width: 72ch; }
@media (max-width: 640px) {
  .mt-step { padding: 16px; }
  .mt-step::before { display: none; }
  .mt-step-n { position: static; flex: none; }
}

/* step 1: search */
.mt-search { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-search input[type="search"] { height: 42px; font-size: 15px; padding: 0 14px; }
.mt-search select { flex: 0 1 170px; width: auto; height: 42px; }
.mt-search .btn { height: 42px; padding: 0 18px; }
.mt-combo { position: relative; flex: 1 1 280px; min-width: 0; }
.mt-combo input[type="search"] { width: 100%; }
.mt-suggest { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  max-height: min(380px, 60vh); overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); box-shadow: var(--shadow); }
.mt-suggest.loading { opacity: .6; }
.mt-sg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.mt-sg[aria-selected="true"] { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.mt-sg-main { display: grid; gap: 2px; min-width: 0; }
.mt-sg-sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-sg-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-sg-act { display: flex; gap: 6px; flex: none; }
.mt-sg-act .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.mt-sg-note { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.mt-keys { margin-top: 6px; }
@media (max-width: 560px) { .mt-keys { display: none; } }
.mt-results { margin-top: 10px; border-radius: var(--radius-sm); transition: opacity var(--t-fast) var(--ease-out); }
.mt-results.loading { opacity: .45; }
.mt-results:not(:empty) { border: 1px solid var(--border); overflow: hidden; animation: nvq-fade var(--t-med) var(--ease-out); }
.mt-results .table-wrap { max-height: 320px; }
.btn-buy { background: var(--profit-bg); border-color: color-mix(in srgb, var(--profit) 40%, var(--border)); color: var(--profit); }
.btn-buy:hover { border-color: var(--profit); }
.btn-sell { background: var(--loss-bg); border-color: color-mix(in srgb, var(--loss) 40%, var(--border)); color: var(--loss); }
.btn-sell:hover { border-color: var(--loss); }

/* step 2: one row per leg; the side is carried by the coloured left edge */
.mt-legs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mt-leg { display: grid; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel-2); border-left: 3px solid var(--profit);
  grid-template-columns: minmax(160px, 1.4fr) auto minmax(120px, .8fr) minmax(110px, .8fr) auto auto;
  transition: border-color var(--t-med) var(--ease-out); }
.mt-leg.is-sell { border-left-color: var(--loss); }
.mt-leg-id { display: grid; min-width: 0; }
.mt-sym { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-leg select, .mt-leg input { height: 32px; }
.mt-side { flex-wrap: nowrap; }
.mt-side button[data-side="BUY"][aria-checked="true"] { background: var(--profit-bg); color: var(--profit); }
.mt-side button[data-side="SELL"][aria-checked="true"] { background: var(--loss-bg); color: var(--loss); }
.mt-ltp { display: grid; justify-items: end; min-width: 76px; padding: 2px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font: inherit; cursor: pointer; line-height: 1.25; transition: background-color var(--t-fast) var(--ease-out); }
.mt-ltp:hover { background: var(--panel); }
.mt-rm { width: 30px; height: 30px; font-size: 18px; line-height: 1; color: var(--muted); }
.mt-rm:hover { color: var(--loss); border-color: var(--loss); }
@media (max-width: 860px) {
  .mt-leg { grid-template-columns: minmax(0, 1fr) auto; }
  .mt-leg-id { grid-column: 1 / -1; }
  .mt-leg .mt-ltp { justify-items: start; }
}
.mt-hint { padding: 14px 16px; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; }

/* step 3 reuses the accounts editor */
.mt-ticket .leg-table input, .mt-ticket .leg-table select { height: 32px; }

/* step 4: preview */
.mt-preview-head { display: grid; gap: 8px; margin-bottom: 12px; }
.mt-ready { font-size: 14px; }
.mt-ready .mono { font-size: 20px; font-weight: 600; }
.mt-ready-bar { height: 6px; }
.mt-preview-t { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
#tk-preview-out > * { animation: nvq-fade var(--t-med) var(--ease-out); }

/* right rail */
.mt-rail { position: sticky; top: 72px; }
.mt-rail-body { display: grid; gap: 14px; padding: 18px; }
.mt-product { display: flex; width: 100%; }
.mt-product button { flex: 1 1 0; }
.mt-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mt-rail .tiny { margin-top: -8px; }
.mt-sum { margin: 0; padding: 12px 0; display: grid; gap: 8px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.mt-sum > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.mt-sum dt { color: var(--muted); }
.mt-sum dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.mt-live { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--loss-bg);
  border: 1px solid color-mix(in srgb, var(--loss) 45%, transparent); font-size: 12.5px; animation: nvq-fade var(--t-med) var(--ease-out); }
.mt-live b { color: var(--loss); }
.mt-cta { display: grid; gap: 8px; }
.mt-cta .btn { height: 42px; font-size: 14px; }
@media (max-width: 1099px) {
  /* narrow screens: the rail follows the ticket and its buttons stay reachable at the bottom */
  .mt-rail { position: static; }
  .mt-cta { position: sticky; bottom: 0; padding: 10px 0 2px; background: var(--panel); }
}

/* records: positions, orders and strategies in one tabbed card */
.mt-tabs-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.mt-tabs-bar .seg button { height: 32px; padding: 0 14px; font-size: 13px; }
.mt-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--panel-2);
  color: var(--muted); font-family: var(--mono); font-size: 11px; line-height: 18px; text-align: center; }
.mt-count:empty { display: none; }
.mt-tabs-bar .seg button[aria-selected="true"] .mt-count { background: var(--accent); color: var(--accent-fg); }
.mt-pnl { font-size: 13px; margin-right: 8px; }
.mt-pnl .profit, .mt-pnl .loss { font-family: var(--mono); font-weight: 600; }
.mt-book [role="tabpanel"]:not([hidden]) { animation: nvq-fade var(--t-med) var(--ease-out); }
