/* ============================================================
   Promenthus — trading terminal UI
   One file, no build step, no external assets.
   Dark terminal aesthetic · ember brand accent · tabular numerals
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* surfaces */
  --bg: #0b0e14;
  --bg-soft: #0d1119;
  --panel: #121722;
  --panel-2: #161d2b;
  --inset: #0e1320;
  --line: rgba(148, 163, 184, 0.10);
  --line-strong: rgba(148, 163, 184, 0.20);

  /* text */
  --text: #e7ecf5;
  --text-2: #9aa7bd;
  --text-3: #5d6b84;

  /* brand — the ember (Prometheus stole fire) */
  --brand: #ff7a1a;
  --brand-2: #ffb257;
  --brand-dim: rgba(255, 122, 26, 0.14);
  --brand-ink: #20100a;

  /* semantic */
  --pos: #34d399;  --pos-dim: rgba(52, 211, 153, 0.13);
  --neg: #fb7185;  --neg-dim: rgba(251, 113, 133, 0.13);
  --warn: #fbbf24; --warn-dim: rgba(251, 191, 36, 0.13);
  --info: #7dd3fc; --info-dim: rgba(125, 211, 252, 0.13);
  --muted: #94a3b8; --muted-dim: rgba(148, 163, 184, 0.12);

  /* shape */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 12px 32px rgba(2, 4, 10, 0.45);
  --shadow-soft: 0 4px 14px rgba(2, 4, 10, 0.30);

  /* type */
  --font-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", "SF Mono", ui-monospace, "Consolas", monospace;

  --topbar-h: 58px;
  --sidebar-w: 224px;
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  /* faint dot grid + top ember vignette — atmosphere without imagery */
  background-image:
    radial-gradient(1100px 420px at 72% -12%, rgba(255, 122, 26, 0.07), transparent 62%),
    radial-gradient(rgba(231, 236, 245, 0.028) 1px, transparent 1px);
  background-size: auto, 26px 26px;
  color: var(--text);
  font: 13.5px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
/* The UA rule is display:none, but .btn's inline-flex outranks it — without this,
   elements toggled via the `hidden` property (e.g. Settings → Discard) stay visible. */
[hidden] { display: none !important; }

::selection { background: rgba(255, 122, 26, 0.35); color: #fff; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: -48px; left: 14px; z-index: 200;
  background: var(--brand); color: var(--brand-ink);
  padding: 8px 14px; border-radius: var(--radius-xs);
  font-weight: 600; transition: top 0.15s ease;
}
.skip-link:focus-visible { top: 10px; }

/* ---------- 3. Typography helpers ---------- */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ta-r { text-align: right; }

.micro {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3);
}

.pos-text { color: var(--pos); }
.neg-text { color: var(--neg); }
.info-text { color: var(--info); }
.warn-text { color: var(--warn); }
.muted-text { color: var(--text-3); }

.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 26px; height: 26px; }

/* ---------- 4. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.shell { min-width: 0; display: flex; flex-direction: column; }

/* ----- sidebar ----- */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 0 12px;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: linear-gradient(180deg, #1a1006, #120b05);
  border: 1px solid rgba(255, 122, 26, 0.35);
  display: grid; place-items: center;
  box-shadow: 0 0 18px rgba(255, 122, 26, 0.18), inset 0 0 10px rgba(255, 122, 26, 0.12);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name {
  font-family: var(--font-mono);
  font-size: 14.5px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  line-height: 1.1;
}
.brand-name em {
  font-style: normal; color: var(--brand);
}
.brand-domain {
  display: block;
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.nav { padding: 14px 0; display: grid; gap: 3px; flex: 1; align-content: start; }
.nav-label, .nav-section {
  display: block;
}
.nav-section {
  padding: 4px 10px 8px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3);
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: rgba(148, 163, 184, 0.07); color: var(--text); }
.nav-item .icon { color: var(--text-3); transition: color 0.14s ease; }
.nav-item:hover .icon { color: var(--text-2); }

.nav-item.active {
  background: linear-gradient(90deg, rgba(255, 122, 26, 0.13), rgba(255, 122, 26, 0.02));
  color: var(--text);
}
.nav-item.active .icon { color: var(--brand); }
.nav-item.active::before {
  content: "";
  position: absolute; left: -12px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  box-shadow: 0 0 10px rgba(255, 122, 26, 0.6);
}

.sidebar-foot {
  padding: 12px 4px 14px;
  border-top: 1px solid var(--line);
  display: grid; gap: 8px;
}
.sidebar-version {
  padding: 0 10px;
  font-size: 10.5px; color: var(--text-3);
  font-family: var(--font-mono); letter-spacing: 0.04em;
}
.logout-btn {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-3); font-weight: 500;
  transition: background 0.14s ease, color 0.14s ease;
}
.logout-btn:hover { background: rgba(251, 113, 133, 0.09); color: var(--neg); }

/* ----- topbar (status is always visible) ----- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-status {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1; overflow: hidden;
}

.status-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  font-size: 12px; color: var(--text-2);
  white-space: nowrap;
}
.status-chip .chip-detail {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-3);
  max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.status-chip[data-state="on"] .chip-detail { color: var(--text-2); }

.dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent;
}
.dot[data-state="on"] {
  background: var(--pos);
  box-shadow: 0 0 7px rgba(52, 211, 153, 0.7);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.dot[data-state="off"] {
  background: var(--neg);
  box-shadow: 0 0 7px rgba(251, 113, 133, 0.6);
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px rgba(52, 211, 153, 0.5); }
  50%      { box-shadow: 0 0 10px rgba(52, 211, 153, 0.85); }
}

.mode-badge {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em;
  border: 1px solid transparent;
}
.mode-badge[data-mode="dry"] {
  color: var(--info); background: var(--info-dim); border-color: rgba(125, 211, 252, 0.3);
}
.mode-badge[data-mode="live"] {
  color: #0b0e14; background: linear-gradient(180deg, var(--brand-2), var(--brand));
  box-shadow: 0 0 14px rgba(255, 122, 26, 0.4);
}
.mode-badge[data-mode="live"]::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #7c2d08;
  animation: blink 1.6s steps(2, start) infinite;
}
.mode-badge[data-mode="paused"] {
  color: var(--warn); background: var(--warn-dim); border-color: rgba(251, 191, 36, 0.3);
}
@keyframes blink { to { visibility: hidden; } }

.topbar-side {
  display: flex; align-items: center; gap: 8px;
  flex: none;
}
.env-chip {
  padding: 5px 10px; border-radius: 99px;
  border: 1px dashed var(--line-strong);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-3); white-space: nowrap;
}

/* ----- main column ----- */
.main {
  flex: 1;
  padding: 24px 26px 46px;
  min-width: 0;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 {
  font-family: var(--font-mono);
  font-size: 19px; font-weight: 700;
  letter-spacing: 0.02em;
}
.page-head .page-sub {
  margin-top: 3px;
  color: var(--text-3); font-size: 12.5px;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 5. Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.panel + .panel { margin-top: 16px; }

.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-2);
}
.panel-head .icon { color: var(--text-3); }
.panel-head .spacer { flex: 1; }
.panel-head .panel-meta {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
}
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  font-weight: 600; font-size: 13px;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
  white-space: nowrap;
}
.btn:hover { background: #1b2436; border-color: rgba(148, 163, 184, 0.3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-color: rgba(255, 122, 26, 0.5);
  color: var(--brand-ink);
  box-shadow: 0 4px 16px rgba(255, 122, 26, 0.22);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ffc47a, #ff8a33);
  border-color: rgba(255, 122, 26, 0.7);
}

.btn-danger {
  background: var(--neg-dim);
  border-color: rgba(251, 113, 133, 0.4);
  color: var(--neg);
}
.btn-danger:hover { background: rgba(251, 113, 133, 0.2); border-color: rgba(251, 113, 133, 0.6); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }

.btn .spinner { display: none; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-icon { display: none; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 7. Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); background: var(--muted-dim);
  white-space: nowrap;
}

.badge[data-decision="opened"]  { color: var(--pos);  background: var(--pos-dim); }
.badge[data-decision="dry_run"] { color: var(--info); background: var(--info-dim); }
.badge[data-decision="managed"] { color: var(--warn); background: var(--warn-dim); }
.badge[data-decision="rejected"],
.badge[data-decision="error"]   { color: var(--neg);  background: var(--neg-dim); }
.badge[data-decision="ignored"] { color: var(--text-3); background: var(--muted-dim); }

.badge[data-trade-status="open"]     { color: var(--info); background: var(--info-dim); }
.badge[data-trade-status="closed"]   { color: var(--pos);  background: var(--pos-dim); }
.badge[data-trade-status="error"]    { color: var(--neg);  background: var(--neg-dim); }

.side-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.07em;
}
.side-badge[data-side="LONG"]  { color: var(--pos); background: var(--pos-dim); }
.side-badge[data-side="SHORT"] { color: var(--neg); background: var(--neg-dim); }
.side-badge .icon-sm { width: 11px; height: 11px; }

.pill {
  display: inline-block;
  padding: 2px 7px; border-radius: var(--radius-xs);
  background: var(--muted-dim); color: var(--text-2);
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.05em;
}
.pill-target { color: var(--info); background: var(--info-dim); }

/* ---------- 8. Stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 15px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.tile::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--tile-accent, var(--brand)), transparent);
  opacity: 0.55;
}
.tile[data-tone="pos"]  { --tile-accent: var(--pos); }
.tile[data-tone="neg"]  { --tile-accent: var(--neg); }
.tile[data-tone="warn"] { --tile-accent: var(--warn); }
.tile[data-tone="info"] { --tile-accent: var(--info); }
.tile[data-tone="brand"]{ --tile-accent: var(--brand); }

.tile-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 9px;
}
.tile-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 27px; font-weight: 700; line-height: 1.05;
  letter-spacing: -0.02em;
}
.tile-sub {
  margin-top: 6px;
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 5px;
}
.tile-value[data-tone="pos"] { color: var(--pos); }
.tile-value[data-tone="neg"] { color: var(--neg); }

/* ---------- 9. Account strip ---------- */
.account-strip {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.account-item { display: grid; gap: 2px; }
.account-item .account-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 700;
}
.account-item .account-value small {
  font-size: 11px; color: var(--text-3); font-weight: 500; margin-left: 3px;
}
.account-divider { width: 1px; align-self: stretch; background: var(--line); }
.account-updated {
  margin-left: auto;
  font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
}

/* ---------- 10. Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; }

.table-card thead th {
  padding: 10px 14px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3); text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: rgba(148, 163, 184, 0.025);
}
.table-card tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}
.table-card tbody tr:last-child td { border-bottom: 0; }
.table-card tbody tr { transition: background 0.12s ease; }
.table-card tbody tr:hover { background: rgba(148, 163, 184, 0.045); }

th.ta-r, td.ta-r { text-align: right; }
.cell-symbol {
  font-weight: 700; letter-spacing: 0.04em;
  font-family: var(--font-mono); font-size: 12.5px;
}
.cell-reason {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-3); font-size: 12.5px;
}

/* expandable drawer rows */
.drawer-row > td {
  padding: 0 !important;
  border-bottom: 1px solid var(--line);
  background: var(--inset);
}
.drawer {
  display: none;
  padding: 15px 18px;
}
.drawer.open { display: block; animation: drawer-in 0.18s ease; }
@keyframes drawer-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}
.drawer-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  margin-bottom: 9px;
}
.raw-msg {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: 12.5px/1.6 var(--font-mono);
  color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
}

.row-toggle {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-xs);
  color: var(--text-3);
  transition: background 0.12s ease, color 0.12s ease, transform 0.16s ease;
}
.row-toggle:hover { background: rgba(148, 163, 184, 0.1); color: var(--text); }
.row-toggle .icon { transition: transform 0.16s ease; }
.row-toggle[aria-expanded="true"] { color: var(--brand); }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }

/* ---------- 11. Forms & fields ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .toggle-text label {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
}
.field .unit {
  font-weight: 500; color: var(--text-3); font-size: 11px;
}

.control {
  width: 100%;
  padding: 8px 11px;
  background: var(--inset);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.control:hover { border-color: rgba(148, 163, 184, 0.32); }
.control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.16);
}
textarea.control { resize: vertical; min-height: 140px; line-height: 1.55; }
select.control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa7bd' stroke-width='2' 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 10px center;
  background-size: 15px;
  padding-right: 32px;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .control { padding-right: 58px; }
.input-suffix {
  position: absolute; right: 11px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-3); pointer-events: none;
}

.help {
  font-size: 11.5px; line-height: 1.45;
  color: var(--text-3);
}

/* toggle switch */
.switch {
  position: relative;
  display: inline-block;
  flex: none;
  width: 40px; height: 22px;
  cursor: pointer;
}
.switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.switch-track {
  position: absolute; inset: 0;
  border-radius: 99px;
  background: #232b3d;
  border: 1px solid var(--line-strong);
  transition: background 0.16s ease, border-color 0.16s ease;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #8b97ac;
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch input:checked + .switch-track {
  background: rgba(52, 211, 153, 0.25);
  border-color: rgba(52, 211, 153, 0.5);
}
.switch input:checked + .switch-track::after {
  transform: translateX(18px);
  background: var(--pos);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 0;
}
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }

/* chips preview for list fields */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips:not(:empty) { margin-top: 2px; }
.chip {
  padding: 2px 8px;
  background: var(--brand-dim);
  border: 1px solid rgba(255, 122, 26, 0.25);
  border-radius: 99px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--brand-2);
}

/* ---------- 12. Settings ---------- */
.settings-groups { display: grid; gap: 16px; }

.settings-card .panel-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px 22px;
}
.settings-card .field-toggle { grid-column: 1 / -1; }

.group-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
}
.group-icon {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--brand-dim);
  border: 1px solid rgba(255, 122, 26, 0.25);
  color: var(--brand);
}
.group-head h2 { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.group-head p { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.save-bar {
  position: sticky; bottom: 14px;
  z-index: 25;
  display: flex; align-items: center; gap: 14px;
  margin-top: 18px;
  padding: 12px 18px;
  background: rgba(18, 23, 34, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.save-bar .save-hint { font-size: 11.5px; color: var(--text-3); }
.save-bar .spacer { flex: 1; }
.save-state {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-3);
}
.save-state::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.save-bar.dirty {
  border-color: rgba(255, 122, 26, 0.45);
  box-shadow: var(--shadow), 0 0 22px rgba(255, 122, 26, 0.08);
}
.save-bar.dirty .save-state { color: var(--brand-2); font-weight: 600; }
.save-bar.dirty .save-state::before {
  background: var(--brand);
  box-shadow: 0 0 8px rgba(255, 122, 26, 0.7);
  animation: pulse-dot 2s ease-in-out infinite;
}
.save-bar .btn-primary { opacity: 0.55; transition: opacity 0.2s ease; }
.save-bar.dirty .btn-primary { opacity: 1; }

.secrets-note {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-3); line-height: 1.5;
}
.secrets-note .icon { color: var(--warn); margin-top: 1px; }
.secrets-note code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--inset); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px;
}

.secret-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
}
.secret-row + .secret-row { border-top: 1px solid var(--line); }
.secret-label { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.secret-masked {
  font-family: var(--font-mono); font-size: 12.5px;
  color: var(--text-2); letter-spacing: 0.14em;
}
.secret-state {
  flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
}
.secret-state[data-configured="true"]  { color: var(--pos); background: var(--pos-dim); }
.secret-state[data-configured="false"] { color: var(--text-3); background: var(--muted-dim); }

/* ---------- 12b. Telegram connection ---------- */
.settings-card .panel-body.tg-body {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.group-head .tg-pill {
  margin-left: auto; flex: none; align-self: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3); background: var(--muted-dim);
  white-space: nowrap;
}
.group-head .tg-pill[data-state="on"]      { color: var(--pos);  background: var(--pos-dim); }
.group-head .tg-pill[data-state="pending"] { color: var(--warn); background: var(--warn-dim); }

.tg-step { display: grid; gap: 12px; min-width: 0; }
.tg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; line-height: 1.45; color: var(--text-2);
}
.tg-line-ok { color: var(--pos); }
.tg-line .spinner { flex: none; }
.tg-code { max-width: 220px; letter-spacing: 0.22em; font-size: 15px; }
#tg-phone { max-width: 320px; }
#tg-password { max-width: 340px; }

.tg-alert {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(251, 113, 133, 0.35);
  background: var(--neg-dim); color: var(--neg);
  border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.45;
}
.tg-alert .icon { flex: none; margin-top: 1px; }

/* dashboard hint while the Telegram session is unauthorised */
.tg-hint {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 2px 0 10px;
  padding: 9px 12px;
  border: 1px solid rgba(125, 211, 252, 0.3);
  background: var(--info-dim); color: var(--info);
  border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.45;
}
.tg-hint .icon { flex: none; margin-top: 1px; }
.tg-hint a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 700px) {
  #telegram-card .group-head { flex-wrap: wrap; }
  #telegram-card .tg-pill { margin-left: 44px; }
}

/* ---------- 13. Indicators & kill switch ---------- */
.indicator {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0;
}
.indicator + .indicator { border-top: 1px solid var(--line); }
.indicator .icon { color: var(--text-3); }
.indicator-main { flex: 1; min-width: 0; }
.indicator-main .indicator-name { font-weight: 600; font-size: 13px; }
.indicator-main .indicator-detail {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.indicator-state {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
}
.indicator-state[data-state="on"]  { color: var(--pos); background: var(--pos-dim); }
.indicator-state[data-state="off"] { color: var(--neg); background: var(--neg-dim); }

/* inline failure reason under a failing status row */
.indicator-error {
  margin-top: 4px;
  font-size: 11px; line-height: 1.5; color: var(--text-3);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; word-break: break-word; min-width: 0;
}
.indicator-error .err-code {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: -0.01em;
}
.indicator-error .err-msg { opacity: 0.9; }

.kill-row {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.055), transparent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 14px;
}
.kill-row .kill-text { flex: 1; min-width: 0; }
.kill-row .kill-title {
  font-weight: 700; font-size: 13px; color: var(--warn);
  display: flex; align-items: center; gap: 6px;
}
.kill-row .kill-help { font-size: 11.5px; color: var(--text-3); margin-top: 1px; line-height: 1.45; }

.panic-zone {
  margin-top: 12px;
  display: grid; gap: 8px;
}

/* ---------- 14. Recent signals list ---------- */
.sig-list { display: grid; }
.sig-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
}
.sig-list-item:last-child { border-bottom: 0; }
.sig-list-item .sig-sym {
  font-family: var(--font-mono); font-weight: 700; font-size: 12.5px;
  width: 52px; flex: none;
}
.sig-list-item .sig-reason {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-3); font-size: 12.5px;
}
.sig-list-item .sig-time { flex: none; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

/* dashboard split: main column + bot status card */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.dash-main, .dash-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
@media (max-width: 1220px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 15. Empty states ---------- */
.empty {
  display: grid; justify-items: center; gap: 10px;
  padding: 44px 22px;
  text-align: center;
}
.empty-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--muted-dim);
  border: 1px dashed var(--line-strong);
  color: var(--text-3);
}
.empty h3 { font-size: 14px; font-weight: 700; }
.empty p { font-size: 12.5px; color: var(--text-3); max-width: 340px; line-height: 1.5; }
.empty .btn { margin-top: 4px; }

/* ---------- 16. Filter bar ---------- */
.filter-bar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.filter-bar .field { min-width: 130px; flex: none; }
.filter-bar .field-grow { flex: 1; min-width: 160px; }
.filter-bar .filter-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- 17. Tools ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.parse-result { margin-top: 14px; display: grid; gap: 12px; }
.result-error {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 15px;
  background: var(--neg-dim);
  border: 1px solid rgba(251, 113, 133, 0.35);
  border-radius: var(--radius-sm);
  color: var(--neg); font-size: 13px; line-height: 1.5;
}
.result-error .icon { color: var(--neg); margin-top: 2px; }

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 18px;
  font-size: 13px;
}
.kv dt {
  color: var(--text-3);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  padding-top: 2px;
}
.kv dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 0; word-break: break-word; }
.kv dd.targets { display: flex; flex-wrap: wrap; gap: 5px; }
.target-pill {
  padding: 2px 8px; border-radius: var(--radius-xs);
  background: var(--muted-dim); color: var(--text-2);
  font-size: 11.5px;
}
.target-pill.selected {
  background: var(--brand-dim); color: var(--brand-2);
  border: 1px solid rgba(255, 122, 26, 0.4);
  font-weight: 700;
}

.result-divider {
  height: 1px; background: var(--line);
  margin: 4px 0;
}
.result-caption {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 9px; display: flex; align-items: center; gap: 7px;
}

.test-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0;
}
.test-row + .test-row { border-top: 1px solid var(--line); }
.test-row .test-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--inset); border: 1px solid var(--line);
  color: var(--text-2);
}
.test-row .test-main { flex: 1; min-width: 0; }
.test-row .test-name { font-weight: 700; font-size: 13px; }
.test-row .test-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }
.test-status {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--text-3); line-height: 1.45;
  padding-top: 6px; border-top: 1px dashed var(--line);
  min-height: 20px;
}
.test-status[data-ok="true"]  { color: var(--pos); }
.test-status[data-ok="false"] { color: var(--neg); }

/* ---------- 18. Logs ---------- */
.logs-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px;
  margin-bottom: 14px;
}
.logs-toolbar .toggle-inline {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
}
.logs-toolbar .spacer { flex: 1; }
.logs-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

.log-view {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font: 12.5px/1.62 var(--font-mono);
  overflow: auto;
  max-height: calc(100vh - 250px);
  min-height: 300px;
}
.log-line { display: block; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.log-line.lvl-error   { color: var(--neg); }
.log-line.lvl-warning { color: var(--warn); }
.log-line.lvl-info    { color: var(--info); }
.log-line.lvl-debug   { color: var(--text-3); }
.log-line.lvl-success { color: var(--pos); }

/* ---------- 19. Modal (dialog) ---------- */
dialog.modal {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog.modal::backdrop {
  background: rgba(5, 7, 12, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 0;
}
.modal-icon {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--neg-dim);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: var(--neg);
}
.modal-icon[data-tone="warn"] {
  background: var(--warn-dim);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--warn);
}
.modal-head h2 { font-size: 15px; font-weight: 700; padding-top: 6px; }
.modal-body {
  padding: 12px 20px 4px;
  font-size: 13px; line-height: 1.6; color: var(--text-2);
}
.modal-body ul { list-style: disc; padding-left: 18px; display: grid; gap: 4px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 16px 20px 18px;
}

/* ---------- 20. Toasts & live region ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: grid; gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 12.5px; line-height: 1.45;
  animation: toast-in 0.2s ease;
}
.toast[data-kind="success"] { border-left-color: var(--pos); }
.toast[data-kind="error"]   { border-left-color: var(--neg); }
.toast .icon { margin-top: 1px; color: var(--text-2); }
.toast[data-kind="success"] .icon { color: var(--pos); }
.toast[data-kind="error"] .icon { color: var(--neg); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 21. Flash banners ---------- */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  animation: toast-in 0.2s ease;
}
.flash .icon { margin-top: 2px; flex: none; }
.flash[data-level="success"] { border-color: rgba(52, 211, 153, 0.35); background: var(--pos-dim); color: var(--pos); }
.flash[data-level="error"]   { border-color: rgba(251, 113, 133, 0.35); background: var(--neg-dim); color: var(--neg); }
.flash[data-level="info"]    { border-color: rgba(125, 211, 252, 0.3);  background: var(--info-dim); color: var(--info); }
.flash .flash-msg { flex: 1; }
.flash .flash-close { color: inherit; opacity: 0.6; padding: 2px; }
.flash .flash-close:hover { opacity: 1; }

/* compact worker-offline alert inside the bot status card (reuses .flash look) */
.worker-alert {
  align-items: center; gap: 9px;
  padding: 9px 12px; margin-bottom: 4px;
  font-size: 12px;
  animation: none;
}
.worker-alert .icon { margin-top: 0; }
.worker-alert .flash-msg {
  min-width: 0; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
  color: var(--neg);
}
.worker-alert .flash-msg strong { font-weight: 700; }
.worker-alert .flash-msg .mono { font-size: 11px; opacity: 0.85; }

/* ---------- 22. Summary strip (trades) ---------- */
.summary-strip {
  display: flex; gap: 26px; flex-wrap: wrap;
  padding: 16px 18px;
  margin-bottom: 16px;
}

/* ---------- 23. Login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 28px 16px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
}
.login-brand { display: grid; justify-items: center; gap: 12px; text-align: center; margin-bottom: 24px; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
.login-brand .brand-mark svg { width: 28px; height: 28px; }
.login-brand h1 {
  font-family: var(--font-mono); font-size: 19px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
}
.login-brand h1 em { font-style: normal; color: var(--brand); }
.login-brand p { font-size: 12px; color: var(--text-3); }
.login-field { display: grid; gap: 7px; margin-bottom: 18px; }
.login-field label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.03em; }
.login-error {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 13px; margin-bottom: 16px;
  background: var(--neg-dim);
  border: 1px solid rgba(251, 113, 133, 0.35);
  border-radius: var(--radius-sm);
  color: var(--neg); font-size: 12.5px;
}
.login-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid; gap: 4px;
  text-align: center;
  font-size: 11px; color: var(--text-3);
}
.login-foot .mono { font-size: 10.5px; letter-spacing: 0.06em; }

/* ---------- 24. Responsive ---------- */
@media (max-width: 1060px) {
  .app { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding: 0 9px; }
  .brand { justify-content: center; padding: 16px 0 14px; }
  .brand-text { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item .nav-label, .nav-section, .sidebar-version { display: none; }
  .logout-btn { justify-content: center; }
  .status-chip .chip-detail { display: none; }
  .env-chip { display: none; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 0 14px; gap: 7px; }
  .topbar .status-chip { padding: 5px 8px; gap: 0; }
  .topbar .status-chip .chip-label { display: none; }
  .main { padding: 18px 14px calc(72px + 30px); }
  .page-head h1 { font-size: 17px; }
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-auto-flow: column;
  background: rgba(13, 17, 25, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav a {
  display: grid; justify-items: center; gap: 3px;
  padding: 5px 2px;
  border-radius: var(--radius-xs);
  color: var(--text-3);
}
.bottom-nav a span { font-size: 9.5px; font-weight: 600; letter-spacing: 0.04em; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active::after {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--brand);
}

@media (min-width: 821px) {
  .bottom-nav { display: none; }
}

/* tables → cards on narrow screens */
@media (max-width: 700px) {
  /* Settings save bar: status left, actions right — the long hint
     collapses so the bar fits 375-414px viewports without overflow. */
  .save-bar {
    flex-wrap: wrap;
    row-gap: 10px;
    padding: 12px 14px;
    /* Float the stuck bar above the fixed bottom nav (72px allowance,
       same as .main's mobile padding-bottom) plus the original 14px gap. */
    bottom: calc(72px + 14px);
  }
  .save-bar .save-hint { display: none; }
  .save-bar .spacer { display: none; }
  .save-state {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Save gets a deliberate full-width row beneath status + Discard. */
  .save-bar .btn-primary { flex: 1 1 100%; }
  .table-card thead { display: none; }
  .table-card, .table-card tbody { display: block; }
  .table-card tbody tr {
    display: block;
    margin: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 4px 0;
  }
  .table-card tbody tr:hover { background: var(--panel-2); }
  .table-card tbody td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px;
    white-space: normal;
    border-bottom: 1px dashed var(--line);
    padding: 8px 12px;
    text-align: right;
  }
  .table-card tbody td:last-child { border-bottom: 0; }
  .table-card tbody td::before {
    content: attr(data-label);
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-3);
    text-align: left; flex: none;
  }
  .table-card tbody td.ta-r { text-align: right; }
  .table-card tr.drawer-row {
    margin: -4px 12px 10px;
    background: var(--inset);
    border-top: 0;
  }
  .table-card tr.drawer-row td { justify-content: flex-start; }
  .table-card tr.drawer-row td::before { display: none; }
}

@media (max-width: 900px) {
  .tools-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 25. Print ---------- */
@media print {
  body { background: #fff; color: #111; font-size: 11px; }
  .sidebar, .topbar, .bottom-nav, .btn, .flash, .toasts,
  .filter-bar, .logs-toolbar, .save-bar, .row-toggle,
  .page-actions, .panic-zone, .kill-row { display: none !important; }
  .main { padding: 0; }
  .panel { box-shadow: none; border-color: #bbb; background: #fff; }
  .table-card tbody td, .table-card thead th { border-color: #ccc; color: #111; }
  a { color: #111; text-decoration: underline; }
  .pos-text, .badge[data-decision="opened"], .side-badge[data-side="LONG"] { color: #047857; }
  .neg-text, .badge[data-decision="rejected"], .side-badge[data-side="SHORT"] { color: #b91c1c; }
}

/* ---------- 26. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
