/* ExtremeTradeCopier - design tokens first, components after. */
/* Palette mirrors https://extremetrades.ai (static/css/theme.css) so the panel and the site read as one product. */
:root {
  --bg: #0a0c12; --surface: #10131c; --surface-2: #151925; --surface-3: #1b2030; --inset: #080a0f;
  --border: #212637; --border-strong: #2e3549;
  --text: #e9ebf2; --text-2: #949bb0; --muted: #6a7186;
  --accent: #4f7df9; --accent-hover: #6b91ff; --accent-ink: #fff; --accent-soft: rgba(79, 125, 249, .12); --accent-ring: rgba(79, 125, 249, .35);
  --grad-cta: linear-gradient(90deg, #4f7df9 0%, #7d63f5 100%); --grad-cta-hover: linear-gradient(90deg, #6b91ff 0%, #8d76ff 100%);
  --glow-accent: 0 8px 22px rgba(79, 125, 249, .28);
  --pos: #22c55e; --pos-soft: rgba(34, 197, 94, .13);
  --neg: #ef4444; --neg-soft: rgba(239, 68, 68, .13);
  --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .13);
  --info: #9b8cff; --info-soft: rgba(125, 99, 245, .16);
  --danger: #ef4444; --danger-hover: #dc2626;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --radius: 10px; --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
/* The site itself is dark-only; the light theme keeps the same blue brand on pale surfaces. */
:root[data-theme="light"] {
  --bg: #f3f5fa; --surface: #ffffff; --surface-2: #f4f6fb; --surface-3: #e9edf6; --inset: #ffffff;
  --border: #dfe3ee; --border-strong: #c6cce0;
  --text: #10131c; --text-2: #485069; --muted: #767e96;
  --accent: #3d6ae8; --accent-hover: #4f7df9; --accent-soft: rgba(61, 106, 232, .1); --accent-ring: rgba(61, 106, 232, .3);
  --glow-accent: 0 6px 16px rgba(61, 106, 232, .22);
  --pos: #15803d; --pos-soft: rgba(21, 128, 61, .1);
  --neg: #dc2626; --neg-soft: rgba(220, 38, 38, .09);
  --warn: #b45309; --warn-soft: rgba(245, 158, 11, .16);
  --info: #6d4fe0; --info-soft: rgba(109, 79, 224, .1);
  --danger: #dc2626; --danger-hover: #b91c1c;
  --shadow: 0 12px 40px rgba(20, 25, 50, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 20px; } h3 { font-size: 15px; }
p { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); } .dim { color: var(--text-2); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-size: 15px; letter-spacing: -.02em; color: var(--text-2); }
.brand b, .login-card h1 b { color: var(--text); font-weight: 750; }
.brand img { border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 520; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav em { margin-left: auto; font: 600 11px var(--mono); font-style: normal; padding: 1px 6px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); }
.nav em:empty { display: none; }
.nav em.alert { background: var(--neg-soft); color: var(--neg); }
.sidebar-ready { margin-top: auto; }
.sidebar-foot { display: flex; gap: 6px; }
.ready { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-align: left; color: #fff; font: 600 13px var(--font); background: linear-gradient(90deg, #16a34a, #22c55e); box-shadow: 0 8px 22px rgba(34, 197, 94, .22); transition: filter .12s; }
.ready:hover { filter: brightness(1.08); }
.ready:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ready:disabled { opacity: .6; cursor: progress; }
.ready small { display: block; font-weight: 450; font-size: 11.5px; opacity: .9; }
.ready.pending { background: var(--grad-cta); box-shadow: var(--glow-accent); animation: ready-pulse 1.8s ease-in-out infinite; }
.ready.warn { background: var(--surface-2); border-color: var(--warn); color: var(--text); box-shadow: none; }
.ready.warn svg { color: var(--warn); }
.ready.compact { width: auto; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; }
.ready.compact small { display: none; }
@keyframes ready-pulse { 50% { box-shadow: 0 0 0 5px var(--accent-ring); } }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.pills { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.pill b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.dot.live { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.view { padding: 22px; display: flex; flex-direction: column; gap: 18px; outline: none; max-width: 1680px; width: 100%; }
.view-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.view-head .grow { flex: 1; min-width: 200px; }
.view-head p { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 18px; align-items: start; }

/* ---------- banners ---------- */
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 22px; border-bottom: 1px solid var(--border); font-size: 13px; }
.banner.warn { background: var(--warn-soft); color: var(--text); }
.banner.bad { background: var(--neg-soft); }
.banner .grow { flex: 1; min-width: 220px; }

/* ---------- cards / kpis ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { flex: 1; min-width: 120px; }
.card-head .count { font: 600 12px var(--mono); color: var(--text-2); background: var(--surface-3); padding: 1px 7px; border-radius: 20px; margin-left: 6px; }
.card-body { padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi-scope { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.kpi-scope b { color: var(--text); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi .value { font: 650 23px/1.25 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
th.num { text-align: right; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .sub { display: block; font-size: 11.5px; color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 4px; }
tfoot td { font-weight: 600; background: var(--surface-2); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge.long, .badge.ok { background: var(--pos-soft); color: var(--pos); }
.badge.short, .badge.bad { background: var(--neg-soft); color: var(--neg); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: 550 13px var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad-cta); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow-accent); }
.btn.primary:hover { background: var(--grad-cta-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); }
.btn.danger-ghost { color: var(--neg); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--neg-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; padding: 10px; }
.btn.flatten { font-weight: 650; letter-spacing: .01em; }
.btn svg { width: 15px; height: 15px; }
label { display: block; font-size: 12px; font-weight: 550; color: var(--text-2); min-width: 0; }
label > input:not([type="checkbox"]):not([type="radio"]), label > select, label > textarea, label > .code { display: block; margin-top: 5px; }
label > input ~ .hint, label > select ~ .hint, label > textarea ~ .hint { display: block; margin-top: 4px; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--inset); color: var(--text); font: 13px var(--font); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
input.num-input { font-family: var(--mono); text-align: right; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 450; color: var(--text); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.form-grid.checks { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px 16px; align-items: start; }
.form-grid:has(> label > .hint:last-child) { align-items: start; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { background: var(--neg-soft); color: var(--neg); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; }
.note { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); }
.note.warn { background: var(--warn-soft); border-color: var(--warn); }
.note.bad { background: var(--neg-soft); border-color: var(--neg); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.table-more { padding: 10px; text-align: center; border-top: 1px solid var(--border); }
.filters label { flex: 1 1 140px; max-width: 240px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border-strong); font-size: 12px; cursor: pointer; user-select: none; color: var(--text-2); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 34px; height: 20px; border-radius: 20px; border: 0; background: var(--border-strong); cursor: pointer; padding: 0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--pos); }
.switch[aria-checked="true"]::after { transform: translateX(14px); }

/* ---------- copy groups ---------- */
.group-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.group-head:last-child { border-bottom: 0; }
.group-title { flex: 1; min-width: 220px; }
.group-title h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.flow { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; margin-top: 3px; flex-wrap: wrap; }
.pick-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pick-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 96px 96px; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.pick-row:last-child { border-bottom: 0; }
.pick-row.head { position: sticky; top: 0; background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; z-index: 1; }
.pick-row input:not([type="checkbox"]) { padding: 4px 7px; min-height: 30px; }
.pick-group { padding: 6px 10px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 10, .66); backdrop-filter: blur(3px); overflow-y: auto; }
.modal { width: min(100%, 560px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal.wide { width: min(100%, 820px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 13px 18px; border-top: 1px solid var(--border); }
.modal-foot .grow { flex: 1; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); box-shadow: var(--shadow); font-size: 13px; animation: slide-in .18s ease-out; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--pos); } .toast.bad { border-left-color: var(--neg); } .toast.warn { border-left-color: var(--warn); }
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.code { font: 12.5px var(--mono); background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: auto; stroke: none; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--font); stroke: none; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .zero { stroke: var(--border-strong); stroke-width: 1; }
.chart .bar-pos { fill: var(--pos); } .chart .bar-neg { fill: var(--neg); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { filter: brightness(1.2); }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 12px; white-space: nowrap; }
.chart-tip b { display: block; font: 600 13px var(--mono); }
.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .3s; }
.meter > i.warn { background: var(--warn); } .meter > i.bad { background: var(--neg); }
.tree { display: flex; flex-direction: column; gap: 12px; }
.tree-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 8px; }
.tree-leaf { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; min-width: 0; }
.tree-leaf span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 16px; background: radial-gradient(900px 520px at 50% -10%, rgba(79, 125, 249, .2), transparent 70%), radial-gradient(700px 420px at 85% 30%, rgba(34, 197, 94, .06), transparent 70%), var(--bg); }
.login-card { width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px; padding: 30px 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); text-align: center; }
.login-card img { margin: 0 auto; border-radius: 12px; }
.login-card h1 { font-size: 21px; color: var(--text-2); letter-spacing: -.02em; }
.login-card label { text-align: left; }
.chip { position: relative; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: auto 0 0 0; z-index: 30; height: auto; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); gap: 0; }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; position: relative; flex: 1; min-width: 0; }
  .nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .nav a .full { display: none; } .nav a .short { display: inline; }
  .nav em { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; }
  .main { padding-bottom: 66px; }
  .topbar, .banner { padding-left: 16px; padding-right: 16px; }
  .view { padding: 16px; }
  .toasts { bottom: 76px; }
  .pick-row { grid-template-columns: minmax(0, 1fr) 64px 78px 78px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 18px; }
  .filters label { max-width: none; }
  .mobile-only { display: inline-flex !important; }
}
.mobile-only, .nav .short { display: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
