/* ---------------------------------------------------------------------
   Token system
   Color: dark control-room base. Status colors carry real meaning (they
   mirror the Signal Log statuses), not decoration — so they're used
   consistently everywhere a status appears, and nowhere else.
   Type: Space Grotesk (UI/display, has some character without being
   loud) + IBM Plex Mono (all data: prices, timestamps, symbols, status
   codes) — the mono face is doing real work here, not just texture.
   --------------------------------------------------------------------- */
:root {
  --bg: #0D1013;
  --panel: #151A20;
  --panel-2: #1B222A;
  --border: #262E38;
  --border-soft: #1E252D;
  --text: #E9ECF1;
  --text-dim: #8A93A3;
  --text-faint: #5B6472;

  --brand: #2FD9C4;
  --brand-dim: #1D8E81;

  --live: #33D17A;
  --live-bg: rgba(51, 209, 122, 0.12);
  --warn: #E0A63E;
  --warn-bg: rgba(224, 166, 62, 0.12);
  --danger: #E2596B;
  --danger-bg: rgba(226, 89, 107, 0.12);
  --info: #5B8DEF;
  --info-bg: rgba(91, 141, 239, 0.12);
  --neutral: #8A93A3;
  --neutral-bg: rgba(138, 147, 163, 0.12);

  --font-ui: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 8px;
  --radius-sm: 5px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: var(--font-mono);
  background: var(--panel-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--brand);
}

/* ---------------------------------------------------------------------
   Signature element: the live signal tape.
   A scrolling ticker of the most recent signals, terminal-style —
   the one thing this dashboard is remembered by. Reduced-motion users
   get a static, non-scrolling list instead.
   --------------------------------------------------------------------- */
.tape {
  height: 34px;
  background: #0A0C0F;
  border-bottom: 1px solid var(--border-soft);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
}
.tape::before {
  content: "LIVE";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  display: flex; align-items: center;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--bg);
  background: var(--brand);
  z-index: 2;
}
.tape-track {
  display: flex;
  gap: 28px;
  white-space: nowrap;
  padding-left: 76px;
  animation: tape-scroll 38s linear infinite;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.tape-track:hover { animation-play-state: paused; }
.tape-item { display: inline-flex; gap: 8px; align-items: center; }
.tape-item .sym { color: var(--text); font-weight: 500; }
.tape-empty { color: var(--text-faint); padding-left: 76px; font-family: var(--font-mono); font-size: 12px; }

@keyframes tape-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .tape-track { animation: none; overflow-x: auto; }
}

/* ---------------------------------------------------------------------
   Shell layout
   --------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: calc(100vh - 34px);
}

.rail {
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.rail-backdrop { display: none; }

.brand { display: flex; align-items: center; gap: 8px; padding: 0 8px 22px; }
.brand-mark { color: var(--brand); font-size: 18px; line-height: 1; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-dim { color: var(--text-faint); font-weight: 400; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  all: unset;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.nav-item.is-active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--brand); }

.rail-foot { border-top: 1px solid var(--border-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); padding: 0 8px; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.conn.is-live .conn-dot { background: var(--live); box-shadow: 0 0 0 3px var(--live-bg); }
.conn.is-down .conn-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.api-base-row { padding: 0 8px; display: flex; flex-direction: column; gap: 4px; }
.api-base-row label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.api-base-row input {
  font-family: var(--font-mono); font-size: 11px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text-dim); border-radius: var(--radius-sm);
  padding: 6px 8px;
}

/* ---------------------------------------------------------------------
   Stage / panels
   --------------------------------------------------------------------- */
.stage { overflow-y: auto; padding: 32px 40px 60px; }
.panel { display: none; max-width: 1100px; }
.panel.is-active { display: block; }

.panel-head { margin-bottom: 24px; }
.panel-head h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.panel-head .sub { color: var(--text-dim); font-size: 13.5px; margin: 0; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 28px; }
.empty-hint { color: var(--text-faint); font-size: 13px; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); grid-column: 1 / -1; }

.acc-card {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 16px;
}
.acc-card .acc-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.acc-card .acc-broker { color: var(--text-faint); font-size: 11.5px; margin-bottom: 12px; }
.acc-card .acc-balance { font-family: var(--font-mono); font-size: 20px; font-weight: 500; }
.acc-card .acc-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 11px; color: var(--text-dim); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; }

.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--panel-2); border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.mini-row .mr-main { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); }
.mini-row .mr-time { color: var(--text-faint); font-size: 11px; }

.ghost-btn, .solid-btn {
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; cursor: pointer;
  border-radius: var(--radius-sm); padding: 7px 12px; transition: opacity 0.12s ease;
}
.ghost-btn { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.ghost-btn:hover { color: var(--text); border-color: var(--text-faint); }
.solid-btn { background: var(--brand); border: none; color: #06201C; font-weight: 600; }
.solid-btn:hover { opacity: 0.88; }

/* Busy state for an in-flight save/create/update action — see app.js
   withBusy(). The spinner replaces the button's own text via ::after so
   the original label (and the button's width) doesn't jump around. */
.ghost-btn:disabled, .solid-btn:disabled { opacity: 0.6; cursor: default; pointer-events: none; }
.is-busy { color: transparent !important; position: relative; }
.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 13px; height: 13px;
  margin: -6.5px 0 0 -6.5px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text-dim); animation: btn-spin 0.6s linear infinite;
}
.solid-btn.is-busy::after { color: #06201C; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .is-busy::after { animation: none; border-top-color: currentColor; opacity: 0.6; }
}

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-row input, .filter-row select {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--panel);
  border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.filter-row input { flex: 1; }

.table-wrap { border: 1px solid var(--border-soft); border-radius: var(--radius); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  text-align: left; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 10.5px; color: var(--text-faint); background: var(--panel-2);
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
}
.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); font-family: var(--font-mono); color: var(--text-dim); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table td.strong { color: var(--text); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border-radius: 999px; font-size: 10.5px; font-weight: 500; font-family: var(--font-mono);
  text-transform: lowercase; letter-spacing: 0.01em;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.pill.st-live { background: var(--live-bg); color: var(--live); }
.pill.st-live::before { background: var(--live); }
.pill.st-warn { background: var(--warn-bg); color: var(--warn); }
.pill.st-warn::before { background: var(--warn); }
.pill.st-danger { background: var(--danger-bg); color: var(--danger); }
.pill.st-danger::before { background: var(--danger); }
.pill.st-info { background: var(--info-bg); color: var(--info); }
.pill.st-info::before { background: var(--info); }
.pill.st-neutral { background: var(--neutral-bg); color: var(--neutral); }
.pill.st-neutral::before { background: var(--neutral); }

/* The browser's built-in `[hidden] { display: none }` UA rule loses to any
   author rule at equal specificity (e.g. `.form-stack { display: flex }`),
   so `hidden` silently stops working the moment an element also carries a
   class that sets `display`. Force it to always win. */
[hidden] { display: none !important; }

.form-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.form-row { flex-direction: row; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }
.form-stack input, .form-stack select, .form-stack textarea {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 10px; width: 100%;
}
.form-stack textarea { resize: vertical; font-family: var(--font-mono); }
.checkbox-label {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim);
  font-family: var(--font-ui);
}
.checkbox-label input[type="checkbox"] { width: auto; flex: none; }
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus,
.filter-row input:focus, .filter-row select:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent;
}

.result-box {
  margin-top: 12px; background: #0A0C0F; border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  min-height: 20px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------------
   Top bar (mirrors the reference product's status strip)
   --------------------------------------------------------------------- */
.topbar {
  height: 46px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
.menu-toggle {
  all: unset; display: none; cursor: pointer; font-size: 18px; line-height: 1;
  color: var(--text-dim); padding: 4px 2px;
}
.menu-toggle:hover { color: var(--text); }
.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-select {
  font-family: var(--font-mono); font-size: 12px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 5px 8px;
}
.tb-icon { font-size: 14px; color: var(--text-faint); }
.tb-live-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
  background: var(--panel-2); border-radius: 999px; padding: 4px 10px;
}
.tb-pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); display: inline-block; margin-right: 2px; }
.tb-spacer { flex: 1; }
.tb-badge {
  font-size: 11.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid transparent;
}
.tb-badge.is-enabled { background: var(--live-bg); color: var(--live); }
.tb-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand-dim);
  color: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: none; cursor: pointer; font-family: inherit;
}
.tb-avatar:hover { background: var(--brand); }

.shell { height: calc(100vh - 34px - 46px); }

/* ---------------------------------------------------------------------
   Nav separators
   --------------------------------------------------------------------- */
.nav-sep { height: 1px; background: var(--border-soft); margin: 8px 4px; }

/* ---------------------------------------------------------------------
   Muted note / status rows
   --------------------------------------------------------------------- */
.muted-card { opacity: 0.85; }
.muted-note { color: var(--text-faint); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.sub-inline { color: var(--text-dim); font-size: 12px; }
.status-row { margin-bottom: 12px; }
.status-row-main { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }

/* ---------------------------------------------------------------------
   Health row (connection heatmap, simplified as a status strip)
   --------------------------------------------------------------------- */
.health-row { display: flex; gap: 3px; margin: 10px 0; flex-wrap: wrap; }
.health-cell { width: 16px; height: 24px; border-radius: 3px; background: var(--border-soft); }
.health-cell.ok { background: var(--live); }
.health-cell.warn { background: var(--warn); }
.health-cell.bad { background: var(--danger); }

/* ---------------------------------------------------------------------
   Tab bar (Settings sub-navigation)
   --------------------------------------------------------------------- */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 20px; }
.tab-btn {
  all: unset; cursor: pointer; padding: 10px 14px; font-size: 13px; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--text); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------------------------------------------------------------------
   Entries & Targets — signature preview panel
   --------------------------------------------------------------------- */
.entries-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .entries-layout { grid-template-columns: 1fr; } }

.strategy-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.strategy-card {
  all: unset; cursor: pointer; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px;
}
.strategy-card:hover { border-color: var(--text-faint); }
.strategy-card.is-active { border-color: var(--brand); background: rgba(47, 217, 196, 0.06); }
.sc-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.sc-badge { font-size: 9px; font-family: var(--font-mono); color: var(--brand); background: rgba(47,217,196,0.12); padding: 1px 6px; border-radius: 999px; }
.sc-desc { font-size: 11.5px; color: var(--text-faint); }

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.field-row label { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.field-row input, .field-row select {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 7px 9px; width: 140px; text-align: right;
}

.layer-picker { display: flex; gap: 4px; }
.layer-picker button {
  all: unset; cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
}
.layer-picker button.is-active { background: var(--brand); color: #06201C; border-color: var(--brand); font-weight: 700; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.stat-val { font-family: var(--font-mono); font-size: 17px; font-weight: 500; }
.stat-val.danger { color: var(--danger); }
.stat-val.live { color: var(--live); }

.preview-chart-wrap { background: #0A0C0F; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); margin-bottom: 14px; }
.preview-chart { width: 100%; height: auto; display: block; font-family: var(--font-mono); }

.tp-breakdown { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.tpb-row { display: flex; align-items: center; gap: 10px; font-size: 12px; font-family: var(--font-mono); }
.tpb-label { width: 90px; color: var(--live); flex-shrink: 0; }
.tpb-bar-track { flex: 1; height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.tpb-bar-fill { height: 100%; background: var(--live); }
.tpb-gain { width: 70px; text-align: right; color: var(--live); flex-shrink: 0; }

.footer-stats { display: flex; flex-wrap: wrap; gap: 10px 24px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.footer-stats > div { display: flex; flex-direction: column; gap: 2px; }
.fs-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.fs-val { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }

/* ---------------------------------------------------------------------
   Trade Log day groups
   --------------------------------------------------------------------- */
.day-group { margin-bottom: 18px; }
.day-head {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 4px;
  font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em;
}
.day-head .day-pnl.pos { color: var(--live); }
.day-head .day-pnl.neg { color: var(--danger); }

/* ---------------------------------------------------------------------
   Signal Tester
   --------------------------------------------------------------------- */
.safe-mode-banner {
  background: var(--live-bg); color: var(--live); border: 1px solid rgba(51,209,122,0.3);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; margin-bottom: 14px; font-weight: 500;
}
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.checkbox-row input { width: auto; }
.try-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.try-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; }
.chip {
  all: unset; cursor: pointer; font-size: 11.5px; padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
}
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.tester-result { margin-top: 14px; }

/* ---------------------------------------------------------------------
   Equity chart
   --------------------------------------------------------------------- */
.equity-chart { width: 100%; height: 200px; display: block; }

/* ---------------------------------------------------------------------
   Skeleton loader (used while a section has no data source yet)
   --------------------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--panel-2) 25%, var(--border-soft) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: skeleton-sweep 1.6s ease-in-out infinite; border-radius: 4px; }
@keyframes skeleton-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------------------------------------------------------------
   Auth gate
   --------------------------------------------------------------------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 500; display: flex; align-items: center;
  justify-content: center; background: var(--bg); padding: 16px;
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(320px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px;
}
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card .sub { color: var(--text-dim); font-size: 12.5px; margin: 0 0 18px; }
.auth-error {
  color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12.5px; margin: 10px 0 0;
}
.auth-error[hidden] { display: none; }
.auth-links { color: var(--text-dim); font-size: 12.5px; margin: 14px 0 0; text-align: center; }
.auth-links a { color: var(--brand); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Mobile / small screens
   The desktop shell is a fixed 232px sidebar + content grid — below
   860px that sidebar becomes an off-canvas drawer (toggled via
   #menuToggle in the topbar, see app.js openMobileNav/closeMobileNav)
   instead of squeezing the stage into a sliver. Below 480px, dense
   multi-column rows (stat strip, form rows) stack to a single column.
   --------------------------------------------------------------------- */
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; align-items: center; }

  .shell { grid-template-columns: 1fr; height: calc(100vh - 34px - 46px); }

  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 600;
    width: 260px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 28px rgba(0, 0, 0, 0.45);
    padding-top: max(20px, env(safe-area-inset-top, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
  .rail.is-open { transform: translateX(0); }

  .rail-backdrop {
    display: block; position: fixed; inset: 0; z-index: 590;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .rail-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .stage { padding: 18px 16px 48px; }
  .panel-head h1 { font-size: 19px; }

  .topbar { padding: 0 10px; gap: 8px; }
  .tb-select { max-width: 120px; }
  .tb-badge { padding: 5px 9px; font-size: 10.5px; }
  .tape-empty { padding-left: 16px; }

  /* Wrap rather than horizontal-scroll — with 6 tabs, a scrolling row
     hides the last one(s) off-screen with no visual hint there's more,
     which is exactly what made the "Konto" tab seem to disappear. */
  .tab-bar { flex-wrap: wrap; gap: 2px 4px; }
  .tab-btn { padding: 8px 10px; font-size: 12.5px; }

  .entries-layout { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------------
   Toasts — brief confirmation/error feedback for save/create/update
   actions (see app.js showToast/withBusy). Stack bottom-center, above
   the mobile drawer's z-index so it's never hidden behind it.
   --------------------------------------------------------------------- */
.toast-stack {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 700; display: flex; flex-direction: column-reverse; gap: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: none; width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 12.5px; color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0; transform: translateY(6px); transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--live); }
.toast.error { border-color: var(--danger); }
.toast.error::before { background: var(--danger); }

@media (max-width: 480px) {
  .form-row { flex-direction: column; }
  .form-row > * { min-width: 0; width: 100%; }

  .grid-cards { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }

  .field-row { flex-wrap: wrap; }
  .field-row input, .field-row select { width: 100%; }

  .footer-stats { gap: 8px 16px; }
}
