/* TradeBridge dashboard — design tokens
   Ink-blue base, periwinkle accent, soft layered surfaces.
   Type: Plus Jakarta Sans (interface), JetBrains Mono (code and ids). */

@font-face {
  font-family: "Jakarta";
  src: url("/assets/fonts/jakarta.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "JBMono";
  src: url("/assets/fonts/mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #eef1f7;
  --panel: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e9edf5;
  --border: #e3e7f0;
  --border-strong: #cfd6e4;
  --text: #0e1525;
  --text-2: #36405a;
  --muted: #68728c;
  --faint: #98a1b8;
  --accent: #4059e8;
  --accent-2: #7a5cf0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(64, 89, 232, .09);
  --green: #0c9a6c;
  --amber: #b86a00;
  --red: #d93848;
  --blue: #2b6fe0;
  --purple: #7446e0;
  --glow: rgba(64, 89, 232, .10);
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .05);
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 8px 24px -12px rgba(20, 30, 60, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 25, 60, .35);
  --r-xl: 22px;
  --r-lg: 16px;
  --r: 12px;
  --r-sm: 9px;
  --sidebar: 244px;
  --sans: "Jakarta", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "JBMono", "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #090d18;
  --panel: #0d1220;
  --surface: #131a2c;
  --surface-2: #182038;
  --surface-3: #1f2946;
  --border: #212a44;
  --border-strong: #2f3a5c;
  --text: #edf0f8;
  --text-2: #c3cadd;
  --muted: #8791ad;
  --faint: #5f6a88;
  --accent: #7f95ff;
  --accent-2: #b08cff;
  --accent-ink: #0a0f1e;
  --accent-soft: rgba(127, 149, 255, .13);
  --green: #3ddc9f;
  --amber: #ffb84d;
  --red: #ff6b7a;
  --blue: #6aa8ff;
  --purple: #b294ff;
  --glow: rgba(127, 149, 255, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .75);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 450;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
code, pre, .mono { font-family: var(--mono); font-feature-settings: normal; }
svg { flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; z-index: 30; padding: 10px 0 10px 10px;
  transition: transform .25s var(--ease);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 14px 12px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px var(--accent);
}
.brand-name { font-weight: 750; font-size: 15.5px; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -1px; }
.nav { padding: 0 4px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 16px 10px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 550; text-decoration: none; transition: color .15s, background .15s;
}
.nav a svg { width: 18px; height: 18px; }
.nav a:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.nav a.active svg { color: var(--accent); }
.nav a.active::before { content: ""; position: absolute; left: -4px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav .nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { padding: 10px 6px 4px; display: flex; flex-direction: column; gap: 8px; }
.side-card { padding: 12px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.status-line { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.foot-row { display: flex; gap: 8px; }

.main {
  flex: 1; margin: 10px 10px 10px calc(var(--sidebar) + 6px); min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-xl); position: relative;
  background-image: radial-gradient(900px 340px at 78% -120px, var(--glow), transparent 70%);
  background-repeat: no-repeat;
}
.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 26px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: color-mix(in srgb, var(--panel) 78%, transparent); backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.top-status { display: flex; gap: 8px; align-items: center; }
.content { padding: 8px 26px 56px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); max-width: 72ch; }

/* ------------------------------------------------------------------ cards / grid */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 10px 0 6px; }
.section-gap { margin-top: 16px; }

.kpi { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 550; }
.kpi-top svg { width: 15px; height: 15px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.035em; line-height: 1.2; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--faint); letter-spacing: -.01em; }
.kpi-foot { font-size: 12.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.kpi-foot b { font-weight: 650; color: var(--text-2); }
.kpi .spark { position: absolute; right: 14px; top: 16px; width: 92px; height: 34px; opacity: .95; }
.kpi-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
.kpi-icon svg { width: 18px; height: 18px; }

.tone-indigo { background: var(--accent-soft); color: var(--accent); }
.tone-green { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); }
.tone-amber { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.tone-red { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); }
.tone-blue { background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); }
.tone-purple { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.tone-gray { background: var(--surface-3); color: var(--muted); }

/* ------------------------------------------------------------------ signal path (dashboard hero) */
.path { padding: 22px 22px 20px; position: relative; overflow: hidden; }
.path::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(520px 200px at 12% 0%, var(--glow), transparent 70%), radial-gradient(520px 220px at 92% 110%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%); }
.path-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; position: relative; }
.path-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.025em; }
.path-head p { margin: 2px 0 0; color: var(--muted); }
.path-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 90px minmax(0, 1fr) 90px minmax(0, 1fr); align-items: center; margin-top: 18px; }
.node { display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-radius: var(--r); background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  border: 1px solid var(--border); min-width: 0; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s var(--ease); }
a.node:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); }
.node-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.node-icon svg { width: 19px; height: 19px; }
.node-text { min-width: 0; }
.node-text b { display: block; font-weight: 650; font-size: 14.5px; }
.node-text span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .state { margin-left: auto; }
.wire { height: 2px; position: relative; background: var(--border-strong); border-radius: 2px; margin: 0 6px; }
.wire.ok { background: color-mix(in srgb, var(--green) 35%, transparent); }
.wire.warn { background: color-mix(in srgb, var(--amber) 40%, transparent); }
.wire.off { background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px); }
.wire.ok::after, .wire.warn::after { content: ""; position: absolute; top: -3px; left: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 22%, transparent); animation: travel 2.4s var(--ease) infinite; }
.wire.warn::after { background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 22%, transparent); }
@keyframes travel { 0% { left: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 8px); opacity: 0; } }

/* ------------------------------------------------------------------ banners */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: var(--r); margin-bottom: 14px;
  background: color-mix(in srgb, currentColor 9%, var(--surface)); border: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.banner svg { width: 18px; height: 18px; margin-top: 1px; }
.banner b { font-weight: 650; }
.banner .grow { flex: 1; min-width: 0; }
.banner.amber { color: var(--amber); }
.banner.red { color: var(--red); }
.banner.blue { color: var(--blue); }
.banner.green { color: var(--green); }
.banner .text { color: var(--text-2); }
.banner .btn { color: var(--text); }

/* ------------------------------------------------------------------ badges / pills */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain { padding-left: 10px; }
.badge.plain::before { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px; border-radius: 999px; font-size: 12.5px;
  font-weight: 650; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap; text-decoration: none; }
a.pill:hover { text-decoration: none; border-color: var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex-shrink: 0; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 20%, transparent); }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 20%, transparent); }
.dot.blue { background: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.dot.pulse { animation: pulse 1.8s infinite; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); }
.tag.live { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.tag.dry { background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); }
.side-buy { color: var(--green); font-weight: 700; }
.side-sell { color: var(--red); font-weight: 700; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 8px 20px -10px var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--red); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px var(--red); }
:root[data-theme="dark"] .btn.danger { color: #1a0509; }
.btn.danger:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.round { border-radius: 999px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .hint.session-hint { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 8px; row-gap: 2px; line-height: 1.45; align-items: start; }
.field .hint.session-hint .dot { margin-top: 5px; }
.field .hint.session-hint a, .field .hint.session-hint div { grid-column: 2; }
.field .hint.session-hint a { color: var(--accent); font-weight: 600; justify-self: start; }
.input, select.input, textarea.input {
  height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); outline: none; width: 100%; transition: border-color .15s, box-shadow .15s, background .15s;
}
select.input { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238791ad' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; }
.filters .input { width: auto; min-width: 150px; }
.filters .search { min-width: 220px; flex: 1; max-width: 360px; padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238791ad' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; }

.segmented { display: inline-flex; padding: 4px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.segmented button { border: 0; background: transparent; padding: 6px 18px; border-radius: 9px; font-weight: 650; font-size: 13px;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented button.active.buy { color: var(--green); }
.segmented button.active.sell { color: var(--red); }

.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .22s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-soft); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-top: 1px solid var(--border); }
.setting-row:first-child { border-top: 0; padding-top: 4px; }
.setting-row:last-child { padding-bottom: 2px; }
.setting-row .info { min-width: 0; flex: 1; }
.setting-row .info b { display: block; font-weight: 650; }
.setting-row .info span { color: var(--muted); font-size: 13px; }
.setting-row .control { flex-shrink: 0; width: 250px; display: flex; justify-content: flex-end; }
.setting-row .control .input { width: 100%; }
.changed-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }

.savebar { position: sticky; bottom: 18px; margin: 18px auto 0; max-width: 560px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; border-radius: 999px; background: var(--text); color: var(--panel); box-shadow: var(--shadow-lg); font-weight: 600;
  animation: rise .25s var(--ease); z-index: 5; }
.savebar .btn { border-color: transparent; border-radius: 999px; }
.savebar .btn:not(.primary) { background: color-mix(in srgb, var(--panel) 14%, transparent); color: var(--panel); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 20px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable td { transition: background .12s; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; }
td .strong { color: var(--text); font-weight: 650; }
td .sub { color: var(--muted); font-size: 12px; }
.cell-trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-cell { white-space: nowrap; color: var(--muted); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.compact td, .compact th { padding: 10px 20px; }
.compact .cell-trunc { max-width: 240px; }
.inner-table { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 22px; height: 22px; color: var(--muted); padding: 13px; box-sizing: content-box; border-radius: 16px; background: var(--surface-2); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-weight: 650; margin-bottom: 2px; }

/* ------------------------------------------------------------------ key/value, code */
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; font-weight: 550; }
.kv.wide { grid-template-columns: 210px minmax(0, 1fr); }

pre.json { margin: 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  font-size: 12.5px; line-height: 1.6; overflow: auto; max-height: 420px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.json .k { color: var(--accent); }
.json .s { color: var(--green); }
.json .n { color: var(--amber); }
.json .b { color: var(--purple); }

/* ------------------------------------------------------------------ chart */
.chart-box { position: relative; }
.chart { width: 100%; height: 330px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke-width: 2.25; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 4; }
.chart-y { position: absolute; left: 0; top: -8px; font-size: 11.5px; color: var(--faint); }
.chart-x { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.chart-dot { position: absolute; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); transform: translate(-50%, -50%); pointer-events: none; }
.chart-tip { position: absolute; top: 0; pointer-events: none; min-width: 150px; width: max-content; max-width: 280px; white-space: nowrap; padding: 10px 12px; border-radius: var(--r); background: var(--text); color: var(--panel);
  font-size: 12.5px; box-shadow: var(--shadow-lg); transform: translateX(-50%); z-index: 3; }
.chart-tip b { display: block; margin-bottom: 4px; }
/* app-wide tooltip (replaces the browser's own title tooltip) */
.tip { position: fixed; z-index: 90; left: 0; top: 0; max-width: min(300px, calc(100vw - 16px)); padding: 8px 12px; border-radius: 10px;
  background: var(--text); color: var(--panel); font-size: 12.5px; font-weight: 550; line-height: 1.45; box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0; visibility: hidden; transform: translateY(3px); transition: opacity .12s, transform .12s var(--ease); overflow-wrap: anywhere; }
.tip.below { transform: translateY(-3px); }
.tip.show { opacity: 1; visibility: visible; transform: none; }
.tip::after { content: ""; position: absolute; left: var(--arrow, 50%); top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--text); }
.tip.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--text); }

.chart-tip div { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-item { display: flex; flex-direction: column; gap: 6px; }
.bar-item .row { display: flex; justify-content: space-between; font-size: 13px; }
.bar-item .track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-item .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-item .fill.warn { background: var(--amber); }
.bar-item .fill.bad { background: var(--red); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-tile { display: flex; flex-direction: column; gap: 4px; padding: 13px 15px; border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.stat-tile span { font-size: 12.5px; color: var(--muted); }
.stat-tile b { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-list { display: flex; flex-direction: column; }
.stat-list .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.stat-list .row:first-child { border-top: 0; padding-top: 0; }
.stat-list .row span { color: var(--muted); }
.stat-list .row b { font-weight: 650; text-align: right; }

/* ------------------------------------------------------------------ feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; align-items: center; gap: 13px; padding: 11px 20px; cursor: pointer; transition: background .12s; }
.feed-item:hover { background: var(--surface-2); }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.feed-icon svg { width: 16px; height: 16px; }
.feed-main { min-width: 0; flex: 1; }
.feed-main b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-main > span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.feed-side time { font-size: 12px; color: var(--faint); }

/* ------------------------------------------------------------------ tabs */
.tabs { display: inline-flex; gap: 3px; padding: 4px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; max-width: 100%; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; border-radius: 9px; white-space: nowrap; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ setup guide */
.steps-list { display: flex; flex-direction: column; }
.step { display: flex; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.step:first-child { border-top: 0; padding-top: 2px; }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
  background: var(--surface-3); color: var(--muted); }
.step.done .step-num { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.step.next .step-num { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 5px var(--accent-soft); }
.step-num svg { width: 15px; height: 15px; }
.step-body { flex: 1; min-width: 0; }
.step-body b { font-weight: 650; }
.step.done .step-body b { color: var(--muted); }
.step-body p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }

/* ------------------------------------------------------------------ drawer / modal */
.overlay { position: fixed; inset: 0; background: rgba(6, 9, 20, .5); backdrop-filter: blur(3px); z-index: 50; opacity: 0; animation: fade .18s forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer { position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(660px, calc(100vw - 20px)); background: var(--surface); z-index: 51;
  border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(28px); opacity: 0; animation: slide .26s var(--ease) forwards; }
@keyframes slide { to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 17px; }
.drawer-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.drawer-body { padding: 20px 22px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.drawer-body .banner { margin-bottom: 0; }
.drawer-section h4 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }

.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(.97); opacity: 0; z-index: 52; width: min(460px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: pop .2s var(--ease) forwards; }
@keyframes pop { to { transform: translate(-50%, -50%); opacity: 1; } }
.modal-body { padding: 24px 24px 8px; display: flex; flex-direction: column; gap: 12px; }
.modal-body h3 { font-size: 17px; display: flex; align-items: center; gap: 12px; }
.modal-body p { margin: 0; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 24px 22px; }
.modal-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.modal-icon svg { width: 19px; height: 19px; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(460px, calc(100vw - 32px)); padding: 9px 10px 9px 14px; border-radius: 999px;
  background: var(--text); color: var(--panel); box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); font-weight: 600; font-size: 13.5px; }
.toast svg { width: 17px; height: 17px; }
.toast.success > svg { color: var(--green); }
.toast.error > svg { color: var(--red); }
.toast.info > svg { color: var(--blue); }
.toast .msg { flex: 1; word-break: break-word; }
.toast .btn { color: inherit; height: 26px; width: 26px; border-radius: 50%; }
.toast .btn:hover { background: color-mix(in srgb, var(--panel) 16%, transparent); }

/* ------------------------------------------------------------------ logs */
.log-list { font-family: var(--mono); font-size: 12.5px; max-height: calc(100vh - 300px); min-height: 300px; overflow-y: auto; border-top: 1px solid var(--border); }
.log-line { display: grid; grid-template-columns: 148px 78px 92px minmax(0, 1fr); gap: 12px; padding: 8px 20px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.log-line:hover { background: var(--surface-2); }
.log-line .t { color: var(--faint); white-space: nowrap; }
.log-line .lv { font-weight: 700; }
.log-line .lv span { padding: 1px 7px; border-radius: 6px; font-size: 11px; }
.log-line .lg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line .m { color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.lv-INFO span { background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); }
.lv-WARNING span { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.lv-ERROR span, .lv-CRITICAL span { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.lv-DEBUG span { background: var(--surface-3); color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------------------------ misc */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hr { height: 1px; background: var(--border); margin: 4px 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 56px; color: var(--muted); }
.copy-box { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; min-height: 38px; }
.copy-box > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-item { padding: 14px 20px; border-top: 1px solid var(--border); cursor: pointer; display: flex; gap: 14px; align-items: flex-start; transition: background .12s; }
.tool-item:hover { background: var(--surface-2); }
.tool-item .name { font-family: var(--mono); font-weight: 600; font-size: 13px; color: var(--text); }
.tool-item .desc { color: var(--muted); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-item .args { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; }
.tool-item .args .tag { font-weight: 500; }
.result-card { border: 1px solid var(--border); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.result-card .banner { margin: 0; }
.result-card pre.json { background: var(--surface); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(700px 360px at 50% 0%, var(--glow), transparent 70%); }
.login-card { width: min(390px, 100%); padding: 30px; display: flex; flex-direction: column; gap: 18px; border-radius: var(--r-xl); }
/* ---------- accounts: sign in, sign up, connect */
.auth-card { width: min(430px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 18px; border-radius: var(--r-xl); }
.auth-card.connect-card { width: min(520px, 100%); }
.auth-title { font-size: 24px; font-weight: 750; letter-spacing: -.03em; margin: 6px 0 0; }
.auth-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-switch { margin: 0; font-size: 13.5px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 650; }
.form-error { color: var(--red); font-size: 13px; font-weight: 550; min-height: 18px; margin: -6px 0; }
.input-wrap { position: relative; }
.input-wrap .input { width: 100%; padding-right: 44px; }
.input-wrap .in-input { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.connect-body { display: flex; flex-direction: column; gap: 14px; }
.connect-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.connect-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.connect-points svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.connect-points b { color: var(--text); }
.connect-wait, .connect-done { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); }
.paste-box { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--r); }
.paste-help { font-size: 13px; color: var(--muted); line-height: 1.5; }
.paste-help b { color: var(--text-2); }
.paste-row { display: flex; gap: 8px; }
.paste-row .input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-sm); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; font-size: 13.5px;
  color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; color: inherit; text-decoration: none; }
.user-text b { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-form { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: flex-end; }
.pw-form .input { width: 100%; }
.steps { margin: 0; padding-left: 18px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
details summary { cursor: pointer; }
kbd { font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); }
.enter { animation: enter .35s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.trade-side { position: sticky; top: 76px; }
@media (max-width: 1180px) { .trade-side { position: static; } .grid.main-side[style] { grid-template-columns: minmax(0, 1fr) !important; } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-side { grid-template-columns: minmax(0, 1fr); }
  .top-status .pill span.long { display: none; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); background: var(--bg); box-shadow: var(--shadow-lg); padding-right: 10px; }
  .sidebar.open { transform: none; }
  .main { margin: 0; border-radius: 0; border: 0; }
  .topbar { border-radius: 0; padding: 0 14px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 8px 14px 40px; }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .setting-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-row .control { width: 100%; justify-content: flex-start; }
  .log-line { grid-template-columns: 1fr; gap: 2px; }
  .kv, .kv.wide { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .path-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .wire { width: 2px; height: 22px; margin: 0 0 0 35px; }
  .wire.ok::after, .wire.warn::after { display: none; }
  .wire.off { background: repeating-linear-gradient(180deg, var(--border-strong) 0 5px, transparent 5px 10px); }
  .top-status .pill.hide-sm { display: none; }
  th, td, .compact td, .compact th { padding-left: 14px; padding-right: 14px; }
  .drawer { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
}
@media (max-width: 560px) {
  .grid.kpis { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: 6px; }
  .topbar h1 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .topbar > .btn-row { display: none; }
  .filters .input, .filters .search { min-width: 0; width: 100%; max-width: none; flex: 1 1 100%; }
}

/* ---------- Portfolio (dashboard) */
.pf { margin-bottom: 16px; }
.pf .banner { margin-bottom: 16px; }
.grid.pf-top { grid-template-columns: minmax(0, 2.15fr) minmax(0, 1fr); align-items: stretch; }
.pf-main { padding: 22px 24px 18px; display: flex; flex-direction: column; }
.pf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pf-label { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--muted); }
.pf-live { display: inline-flex; align-items: center; gap: 7px; font-weight: 550; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pf-value { font-size: clamp(34px, 4.2vw, 46px); font-weight: 750; letter-spacing: -.045em; line-height: 1.12; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.pf-value.tick-up { animation: tick-up .9s var(--ease); }
.pf-value.tick-down { animation: tick-down .9s var(--ease); }
@keyframes tick-up { 0% { color: var(--green); } 100% { color: var(--text); } }
@keyframes tick-down { 0% { color: var(--red); } 100% { color: var(--text); } }
.pf-change { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; }
.pf-change-note { color: var(--muted); font-size: 13px; }
.delta { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 3px 9px 3px 7px;
  border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.delta svg { width: 10px; height: 10px; fill: currentColor; }
.delta.up { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.delta.down { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.delta-pct { font-weight: 600; }
.num-up { color: var(--green); }
.num-down { color: var(--red); }
.segmented.pf-range button { padding: 5px 13px; font-size: 12.5px; }
.pf-chart-slot { margin-top: 18px; flex: 1; min-height: 240px; display: flex; flex-direction: column; justify-content: center; }
.pf-chart-box { display: flex; gap: 12px; }
.pf-y { display: flex; flex-direction: column; justify-content: space-between; font-size: 11.5px; color: var(--faint); text-align: right;
  padding: 6px 0 30px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-plot-wrap { flex: 1; min-width: 0; }
.pf-plot { position: relative; touch-action: pan-y; }
.chart.pf-chart { height: 240px; }
.chart .base-line { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 5; }
.chart-dot.pf-end { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); display: block; }
.pf-empty { text-align: center; color: var(--muted); padding: 34px 20px; max-width: 460px; margin: 0 auto; font-size: 13.5px; }
.pf-empty svg { width: 22px; height: 22px; padding: 13px; box-sizing: content-box; border-radius: 16px; background: var(--surface-2); margin-bottom: 10px; }
.pf-empty b { display: block; color: var(--text); font-weight: 650; margin-bottom: 4px; font-size: 14.5px; }
.pf-split { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.pf-split:empty { display: none; }
.pf-split div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-split span { font-size: 12px; color: var(--muted); }
.pf-split b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.pf-tiles { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.pf-tile { padding: 16px 20px; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.pf-tile-label { font-size: 13px; font-weight: 550; color: var(--muted); }
.pf-tile-value { font-size: 26px; font-weight: 700; letter-spacing: -.035em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.pf-tile-foot { display: flex; gap: 4px 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.pf-tile-foot b { font-weight: 650; color: var(--text-2); }
.pf-meter { display: flex; gap: 2px; height: 6px; margin: 5px 0 4px; }
.pf-meter i { display: block; border-radius: 99px; min-width: 6px; }
.pf-meter .won { background: var(--green); }
.pf-meter .lost { background: var(--red); }
.pf-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.pf-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 20px; white-space: nowrap; }
.pf-table td { padding: 11px 20px; border-top: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
.pf-table th.num, .pf-table td.num { text-align: right; }
.btn.close-pos { color: var(--red); border-color: color-mix(in srgb, var(--red) 38%, var(--border)); background: color-mix(in srgb, var(--red) 6%, var(--surface)); font-weight: 650; }
.btn.close-pos svg { width: 15px; height: 15px; }
.btn.close-pos:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 14%, var(--surface)); border-color: var(--red); }
.btn.close-pos:disabled { opacity: .55; cursor: not-allowed; }
.only-phone { display: none; }
.pf-table td { white-space: nowrap; }
.pf-table th, .pf-table td { padding-left: 8px; padding-right: 8px; }
.pf-table th:first-child, .pf-table td:first-child { padding-left: 20px; }
.pf-table td.pf-act { padding-right: 20px; }
.pf-table td.pf-act { vertical-align: middle; width: 1%; padding-left: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.modal.ca-modal { width: min(500px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; }
.ca-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--border); }
.ca-head h3 { flex: 1; font-size: 17px; }
.ca-body { padding: 18px 24px; display: flex; flex-direction: column; gap: 12px; }
.ca-body p { margin: 0; color: var(--text-2); }
.ca-body p.muted { color: var(--muted); font-size: 13.5px; }
.ca-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r); max-height: 190px; overflow-y: auto; font-variant-numeric: tabular-nums; }
.ca-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; font-size: 13.5px; border-top: 1px solid var(--border); color: var(--text-2); }
.ca-list li:first-child { border-top: 0; }
.ca-list i { font-style: normal; margin-left: 8px; }
.ca-option { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; }
.ca-option-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ca-option-text span { color: var(--muted); font-size: 13px; }
.ca-progress { padding: 16px 24px; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.ca-progress .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.ca-progress .row span { color: var(--muted); font-weight: 600; }
.ca-progress .fill { transition: width .3s var(--ease); background: var(--red); }
.ca-progress .banner { margin: 0; }
.ca-foot { padding: 18px 24px 22px; display: flex; flex-direction: column; gap: 10px; }
.btn.block { width: 100%; justify-content: center; height: 44px; font-size: 14.5px; }
/* ---------- order going out: timeline popup and last-order card */
.modal.flow-modal { width: min(400px, calc(100vw - 24px)); }
.flow-body { padding: 26px 26px 24px; display: flex; flex-direction: column; gap: 18px; }
.flow-what { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); }
.flow-what b { font-size: 15px; }
.flow-what span { font-size: 13px; color: var(--muted); }
.flow-what.center { text-align: center; width: 100%; }
.flow-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.flow-step { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--faint); transition: color .2s; }
.flow-step.now { color: var(--text); font-weight: 600; }
.flow-step.done { color: var(--text-2); }
.flow-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; border: 2px solid var(--border-strong); }
.flow-step.now .flow-mark { border-color: transparent; }
.flow-step.now .flow-mark .spinner { width: 20px; height: 20px; }
.flow-step.done .flow-mark { border-color: transparent; background: var(--green); color: var(--surface); }
.flow-step.done .flow-mark svg { width: 14px; height: 14px; stroke-width: 3; }
.flow-result { align-items: center; text-align: center; gap: 12px; animation: enter .25s var(--ease); }
.flow-result h3 { font-size: 20px; font-weight: 750; letter-spacing: -.02em; margin: 0; }
.flow-result p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.flow-result .flow-reason { color: var(--red); font-weight: 600; font-size: 14px; }
.flow-big { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; animation: pop-in .35s var(--ease); }
.flow-big svg { width: 28px; height: 28px; stroke-width: 2.6; }
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } }
.flow-timer { width: 100%; height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.flow-timer i { display: block; height: 100%; width: 100%; background: var(--green); }
.last-order { display: flex; flex-direction: column; gap: 6px; }
.last-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 2px; }
.last-order > b { font-size: 15px; }
.last-line { margin-top: 6px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.last-line.good { color: var(--green); }
.last-line.bad { color: var(--red); }
.last-line .muted { font-weight: 500; margin-top: 3px; color: var(--muted); }
.last-order .btn-row { margin-top: 4px; }
.last-order details { margin-top: 6px; }
/* ---------- auto trading and tickers */
.sec-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; letter-spacing: -.01em; }
.stat-tile.card { background: var(--surface); }
.tk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tk-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.tk-card.paused { opacity: .78; }
.tk-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tk-symbol { font-size: 22px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.tk-name { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tk-price { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 2px; }
.tk-price span { font-size: 12px; color: var(--muted); font-weight: 500; }
.amount-row { display: flex; align-items: center; gap: 8px; }
.amount-prefix { font-weight: 700; color: var(--muted); font-size: 16px; }
.amount-input { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tk-error { margin: -2px 0 0; min-height: 0; line-height: 1.45; }
.tk-error:empty { display: none; }
.tk-card > .btn { align-self: flex-start; }
.tk-help { margin: 0; font-size: 12.5px; color: var(--muted); }
.tk-money { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); }
.tk-money div, .tk-facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-money span, .tk-facts span { font-size: 12px; color: var(--muted); }
.tk-money b { font-size: 18px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tk-money small { font-size: 12.5px; font-weight: 600; }
.tk-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tk-facts b { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tk-note { font-size: 12.5px; color: var(--text-2); padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.tk-note.warn { color: var(--amber); }
.tk-note.closing, .tk-note.good { display: flex; gap: 9px; align-items: flex-start; line-height: 1.45; }
.tk-note.closing .spinner { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }
.tk-note.good { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.tk-note.good svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.tk-card .btn-row { margin-top: 2px; }
.tk-actions { margin-top: 2px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row .input:nth-child(3) { flex: 1; min-width: 160px; }
.ticker-check { display: flex; align-items: center; gap: 8px; min-height: 20px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.ticker-check:empty { display: none; }
.ticker-check svg { width: 16px; height: 16px; flex-shrink: 0; }
.ticker-check .spinner { width: 14px; height: 14px; }
.ticker-check.good { color: var(--green); }
.ticker-check.good b { color: var(--text); }
.ticker-check.good span { color: var(--text-2); }
.ticker-check.bad { color: var(--red); }
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg-item { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg-item pre.json { margin: 0; max-height: 170px; }
.feed-item.static { cursor: default; }
.feed-item.static:hover { background: transparent; }
.feed-side b { font-variant-numeric: tabular-nums; font-size: 13.5px; }
@media (max-width: 1180px) {
  .grid.pf-top { grid-template-columns: minmax(0, 1fr); }
  .pf-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 901px) and (max-width: 1380px) { .pf-table th:nth-child(3), .pf-table td:nth-child(3) { display: none; } }
@media (min-width: 901px) and (max-width: 1260px) {
  .pf-table th:nth-child(2), .pf-table td:nth-child(2) { display: none; }
  .only-phone { display: inline; }
  .not-phone { display: none; }
  .pf-table .close-pos span:not(.spinner) { display: none; }
  .pf-table .close-pos { width: 36px; padding: 0; justify-content: center; }
}
@media (max-width: 1040px) { .pf .grid.two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .pf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .pf-main { padding: 18px 16px 14px; }
  .pf-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-y { display: none; }
  .pf-table th, .pf-table td { padding-left: 10px; padding-right: 10px; }
  .pf-table th:nth-child(2), .pf-table td:nth-child(2), .pf-table th:nth-child(3), .pf-table td:nth-child(3) { display: none; }
  .only-phone { display: inline; }
  .pf-table .close-pos span:not(.spinner) { display: none; }
  .pf-table .close-pos { width: 36px; padding: 0; justify-content: center; }
  .not-phone { display: none; }
  .pf-table th:first-child, .pf-table td:first-child { padding-left: 16px; }
  .pf-table td.pf-act { padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .wire.ok::after, .wire.warn::after { display: none; }
}

/* ---------------------------------------------------------------- country picker (Connect page) */
.country-pick { display: flex; flex-direction: column; gap: 10px; }
.country-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left;
  cursor: pointer; border: 1px solid var(--line); background: var(--card); color: inherit; font: inherit; }
.country-card:hover { border-color: var(--accent); background: var(--hover, var(--card)); }
.country-card.active { border-color: var(--accent); }
.country-card .grow { flex: 1; min-width: 0; }
.country-card b { display: block; font-size: 15px; }
.country-card svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.country-flag { font-size: 26px; line-height: 1; flex-shrink: 0; }

/* ---------------------------------------------------------------- Groww API key form */
.groww-form { margin-top: 16px; }
.groww-form .label { display: block; margin-bottom: 6px; }
.groww-form .input { width: 100%; }
.groww-form .grid.two { gap: 12px; }
@media (max-width: 520px) { .groww-form .grid.two { grid-template-columns: 1fr; } }

/* a ticker added for the other country, so it could not be checked here */
.ticker-check.warn { color: var(--amber); }
.ticker-check.warn b { color: var(--text); }

/* the Groww access token is one very long line: let it wrap and keep it readable */
.mono-input { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 12.5px;
  line-height: 1.5; resize: vertical; word-break: break-all; }
.groww-form textarea.input { width: 100%; }
.groww-form .banner { align-items: flex-start; }
.groww-form .btn[disabled] { opacity: .75; cursor: progress; }
