/* Crypto Scanner dashboard. Graphite surfaces; colour carries meaning only:
   green/red = up/down, blue = selection/focus, amber/blue tints = RSI zones.
   Numbers and headings use Bahnschrift (built into Windows, DIN-like); other
   systems fall back to their own UI font. No web fonts, no CDN.
   chart.js reads --surface, --border and --muted and appends a hex alpha,
   so keep those three as 6-digit hex. */
:root {
  --bg: #eceef2;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #d9dde3;
  --border-soft: #e8eaee;
  --text: #1a1e26;
  --muted: #5d6573;
  --accent: #2f5bea;
  --accent-soft: #e7edfd;
  --up: #0a7f4f;
  --down: #cc3324;
  --low: #1f63c7;
  --low-bg: #e4eefc;
  --high: #a35207;
  --high-bg: #fcefdc;
  --new: #6d3fd6;
  --new-bg: #efe8fd;
  --shadow: 0 1px 2px rgba(20, 26, 38, .05);
  --overlay: rgba(14, 17, 22, .5);
  --radius: 10px;
  --radius-sm: 6px;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-num: Bahnschrift, "DIN Alternate", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

/* Dark: chosen with the theme button (data-theme="dark"), or Windows' own
   dark mode while the button is on Auto (no data-theme). The two blocks
   must stay identical. */
:root[data-theme="dark"] {
  --bg: #12151a;
  --surface: #191d23;
  --surface-2: #20252d;
  --border: #2d333d;
  --border-soft: #252a33;
  --text: #e3e6eb;
  --muted: #939baa;
  --accent: #7092f5;
  --accent-soft: #1d2745;
  --up: #3cb67f;
  --down: #f0695b;
  --low: #6fa7f4;
  --low-bg: #172a43;
  --high: #f0a24c;
  --high-bg: #35260f;
  --new: #ad90f6;
  --new-bg: #281f40;
  --shadow: none;
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151a;
    --surface: #191d23;
    --surface-2: #20252d;
    --border: #2d333d;
    --border-soft: #252a33;
    --text: #e3e6eb;
    --muted: #939baa;
    --accent: #7092f5;
    --accent-soft: #1d2745;
    --up: #3cb67f;
    --down: #f0695b;
    --low: #6fa7f4;
    --low-bg: #172a43;
    --high: #f0a24c;
    --high-bg: #35260f;
    --new: #ad90f6;
    --new-bg: #281f40;
    --shadow: none;
    --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--font-num); font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 22px; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; min-height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-num); font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: none; }
.brand rect { fill: var(--text); }
.brand path { stroke: var(--surface); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; align-self: stretch; gap: 2px; }
.tabs button {
  position: relative; border: 0; background: none; padding: 0 12px; cursor: pointer;
  color: var(--muted); font-weight: 600;
}
.tabs button:hover { color: var(--text); }
/* the open menu: an underline sitting on the bar's bottom edge */
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  border-radius: 2px 2px 0 0; background: var(--accent);
}
.tabs button:focus-visible { outline-offset: -4px; border-radius: 8px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Settings: apart from the menus, top right */
.settings-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.settings-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.settings-btn:hover { color: var(--text); background: var(--surface-2); }
/* theme: Auto / Dark / Light (theme.js); the account menu: the same small square */
.theme-btn, .account-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; padding: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer;
}
.theme-btn svg, .account-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn:hover, .account-btn:hover { color: var(--text); background: var(--surface-2); }
.settings-btn[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.live .dot { background: var(--up); }
.status.stale { color: var(--down); }
.status.stale .dot { background: var(--down); }
@media (prefers-reduced-motion: no-preference) {
  .status.live .dot { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 40%, transparent); }
    50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--up) 0%, transparent); }
  }
}

.view { padding: 18px 20px 48px; max-width: 1400px; margin: 0 auto; }

/* ---------- controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.segmented button {
  border: 0; background: none; padding: 4px 10px; min-height: 28px; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums;
}
.segmented button:hover:not(:disabled):not(.active) { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.segmented button:disabled { opacity: .4; cursor: not-allowed; }
input[type="search"], input[type="number"], input[type="text"], input[type="email"], input[type="password"], select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; min-height: 34px;
}
input[type="number"] { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
input[type="search"] { width: 190px; }
/* alert history filters: type, token, timeframe */
.history-filters select { min-width: 150px; max-width: 280px; }
.history-filters #hf-count { margin-left: auto; }
input[type="search"]:focus, input[type="number"]:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 3px 11px; min-height: 28px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500;
}
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip .count { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 12px; opacity: .75; }
.chip .count:empty { display: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 5px 14px; min-height: 34px; cursor: pointer; font-weight: 600; color: var(--text); text-decoration: none;
}
.btn:not(:disabled):hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 22%, var(--border)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.link { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 0; min-height: 0; font-weight: 500; }
.btn.link:hover { color: var(--text); background: none; }
.btn.small { min-height: 28px; padding: 2px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, var(--border)); }
.btn.danger:not(:disabled):hover { background: color-mix(in srgb, var(--down) 10%, transparent); border-color: var(--down); }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; width: 28px; height: 28px;
  border-radius: 6px; font-size: 15px; line-height: 1; vertical-align: middle; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.delete:hover { color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.message { margin: 10px 0 0; font-size: 13px; }
.message:empty { display: none; }
.message.ok { color: var(--up); }
.message.err { color: var(--down); }
.input-suffix { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.input-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input-suffix input { border: 0; width: 110px; background: transparent; box-shadow: none !important; }
.input-suffix span { padding: 0 10px 0 2px; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border-soft); }
th:first-child, td:first-child { text-align: left; }
th.left, td.left { text-align: left; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted); border-bottom-color: var(--border);
  font-weight: 600; font-size: 12.5px; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text); }
thead th.sorted { color: var(--text); }
thead th .arrow { font-size: 9px; margin-left: 4px; color: var(--accent); vertical-align: 1px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
td:first-child, th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
thead th:first-child { background: var(--surface-2); z-index: 3; }
.num, td { font-variant-numeric: tabular-nums; }
th.num, td.num { text-align: right; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); margin: 0; }

/* symbols */
.sym { font-family: var(--font-num); font-weight: 600; letter-spacing: .01em; }
a.sym-link, button.sym-link {
  color: inherit; text-decoration: none; font: inherit; font-family: var(--font-num); font-weight: 600;
  background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
}
a.sym-link:hover, button.sym-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 5px;
  font-size: 11px; font-weight: 600; line-height: 1.5; vertical-align: 1px; white-space: nowrap;
}
.badge.new { background: var(--new-bg); color: var(--new); }
.badge.live, .badge.off { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border-soft); }
.badge.ok { background: color-mix(in srgb, var(--up) 13%, transparent); color: var(--up); }
.badge.warn { background: var(--high-bg); color: var(--high); }
.badge.danger { background: color-mix(in srgb, var(--down) 13%, transparent); color: var(--down); }
a.badge { text-decoration: none; }
a.badge:hover { box-shadow: inset 0 0 0 1px currentColor; }
.news-dates { margin-bottom: 8px; }
.news-dates h2 { margin: 0; font-size: 16px; }
.news-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.news-dates .table-wrap { margin-top: 10px; }
.news-dates + .news-dates { margin-top: 16px; }
.news-dates .chips { margin-top: 10px; }
#news-table td.tok { white-space: normal; max-width: 260px; }
#news-table .sym-link { margin-right: 6px; }
#news-table .other-tok { color: var(--muted); font-size: 12px; margin-right: 6px; }
#news-table td.kind .badge { margin-left: 0; }
#news-search { min-width: 220px; }
.up { color: var(--up); }
.down { color: var(--down); }
.near { text-decoration: underline dotted; text-underline-offset: 3px; }
.muted { color: var(--muted); }

/* ---------- scanner table (compact: fits a 1366px laptop screen) ---------- */
#table { font-size: 13.5px; font-family: var(--font-num); }
#table th, #table td { padding: 6px 10px; }
#table thead th { font-family: var(--font-ui); font-size: 12px; }
#table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
#table .sym { font-size: 14px; }
.ma { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.ma .pct { font-weight: 600; }
.ma .val { color: var(--muted); font-size: 12px; }
.ma .sub, .stack-left .sub { color: var(--muted); font-size: 11.5px; font-family: var(--font-ui); }
.stack-left { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.2; }
td.updated { font-size: 12px; }
td.updated.stale { color: var(--high); }
.alerts-cell { text-align: left; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.alert-pill {
  display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
  padding: 1px 7px; border-radius: 5px; font-size: 12px; font-family: var(--font-ui);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-soft);
}
.alert-pill .tf-tag { font-family: var(--font-num); font-weight: 600; margin-right: 4px; }
.columns-btn { margin-left: auto; }

/* market movers: two ranked lists above the scanner (about 6 rows, then scroll) */
.movers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1000px) { .movers { grid-template-columns: 1fr; } }
.mover-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column;
}
.mover-panel header { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border-soft); }
.mover-panel h2 { font-size: 15px; }
.mv-sub { color: var(--muted); font-size: 12.5px; }
.mv-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mv-icon.up { stroke: var(--up); }
.mv-icon.down { stroke: var(--down); }
.mv-scope { margin-left: auto; }
.mv-scope svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.mv-scope[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.mv-scope[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--accent) 30%, transparent); }
.mover-list { list-style: none; margin: 0; padding: 4px 0; max-height: calc(6 * 29px + 8px); overflow-y: auto; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mover-list li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 76px; align-items: center; gap: 8px;
  min-height: 29px; padding: 0 14px; font-size: 13.5px;
}
.mover-list li:hover { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.mv-rank { color: var(--muted); font-size: 12.5px; }
.mover-list .sym-link { justify-self: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.mv-val { color: var(--muted); text-align: right; }
.mv-chg { text-align: right; font-weight: 600; }
.mv-note { margin: 0; padding: 0 14px 8px; color: var(--muted); font-size: 12px; }
.mv-note:empty { display: none; }
.mv-note.err { color: var(--high); }

/* RSI: the value with a small 0–100 meter under it; the ticks are the
   oversold/overbought levels, the marker is the RSI. Tinted inside a zone. */
.rsi { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 46px; padding: 2px 5px; border-radius: 5px; font-weight: 600; line-height: 1.1; }
.rsi.low { background: var(--low-bg); color: var(--low); }
.rsi.high { background: var(--high-bg); color: var(--high); }
.rsi .meter {
  position: relative; display: block; width: 36px; height: 4px; border-radius: 2px;
  background:
    linear-gradient(var(--muted), var(--muted)) calc(var(--lo, 30) * 1%) 0 / 1px 100% no-repeat,
    linear-gradient(var(--muted), var(--muted)) calc(var(--hi, 70) * 1%) 0 / 1px 100% no-repeat,
    color-mix(in srgb, var(--muted) 22%, transparent);
}
.rsi .meter::after {
  content: ""; position: absolute; top: -1px; left: clamp(0px, calc(var(--v) * 1% - 1.5px), calc(100% - 3px));
  width: 3px; height: 6px; border-radius: 1px; background: var(--text);
}
.rsi.low .meter::after { background: var(--low); }
.rsi.high .meter::after { background: var(--high); }

/* trend word: tinted like the up/down colours; range stays neutral */
.trend {
  display: inline-block; min-width: 58px; padding: 1px 7px; border-radius: 5px; text-align: center;
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 600;
}
.trend.bullish { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.trend.bearish { color: var(--down); background: color-mix(in srgb, var(--down) 11%, transparent); }
.trend.range { color: var(--muted); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-soft); }

/* ---------- section heads ---------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 16px; }
.section-head .hint { max-width: 760px; line-height: 1.5; }
.section-head.sub { margin-top: 36px; margin-bottom: 12px; }

/* ---------- alerts: rows ---------- */
.rows th { cursor: default; text-align: left; }
.rows th:hover { color: var(--muted); }
.rows td { text-align: left; vertical-align: middle; }
.rows tr.off td { color: var(--muted); }
.rows tr.off .tf { background: var(--surface-2); color: var(--muted); }
.rows tr.selected td { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.alert-cell b { display: block; font-weight: 600; }
.alert-cell .sub { display: block; color: var(--muted); font-size: 12px; white-space: normal; max-width: 340px; }
.tf-list { display: flex; gap: 4px; flex-wrap: wrap; }
.tf { padding: 1px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; font-family: var(--font-num); }
.mode { font-size: 12.5px; font-weight: 600; }
.mode.live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--up); vertical-align: 1px; }
.tokens-cell { max-width: 260px; white-space: normal; }
.actions { white-space: nowrap; text-align: right !important; }
.actions .btn { margin-left: 4px; }
.rows thead th.actions { padding-top: 5px; padding-bottom: 5px; }
/* an alert row's state: Active fires, Paused stays in the list but never fires */
.row-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.row-state.active { color: var(--up); }
.row-state.active::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.row-state.paused { padding: 1px 8px; border-radius: 999px; color: var(--high); background: var(--high-bg); }
.pause-btn, .resume-btn { min-width: 84px; }
.resume-btn { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, var(--border)); }
.rows tr.off .alert-cell b { color: var(--muted); }
.row-check { width: 16px; height: 16px; margin: 0 0 0 8px; vertical-align: middle; cursor: pointer; accent-color: var(--accent); }
.problems { color: var(--down); margin: 10px 0 0; padding: 10px 14px 10px 30px; border-radius: 8px; background: color-mix(in srgb, var(--down) 8%, transparent); }
.reset-row { margin: 12px 0 0; display: flex; gap: 20px; flex-wrap: wrap; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, var(--border)); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 999px; }

/* ---------- alerts: history ---------- */
.history th { cursor: default; text-align: left; }
.history th:hover { color: var(--muted); }
.history td { text-align: left; }
.history th.num, .history td.num { text-align: right; }
.history td.time { color: var(--muted); font-size: 13px; }
.history td.tfc { font-family: var(--font-num); font-weight: 600; }
.history td.wide { white-space: normal; min-width: 260px; }
.facts { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 13px; color: var(--muted); }
.facts b { font-weight: 600; color: var(--text); margin-right: 5px; }
.facts .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- alerts: editor ---------- */
.editor { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.editor { scroll-margin-top: 68px; }  /* clear the sticky top bar */
.editor h2 { margin-bottom: 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 24px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step.wide { grid-column: 1 / -1; }
.step > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.step-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); color: var(--muted); font-family: var(--font-num); font-size: 12px; font-weight: 600; margin-top: 1px;
}
.step-title { font-weight: 600; }
.step-settings { display: flex; flex-direction: column; gap: 8px; }
.step-settings label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.step-settings input[type="number"] { width: 90px; }
.step-settings .input-suffix input { width: 70px; }
.ma-pick { display: inline-flex; gap: 4px; }
.ma-pick input[type="number"] { width: 72px; }
.tf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tf-chips label {
  position: relative;
  border: 1px solid var(--border); border-radius: 7px; padding: 3px 10px; cursor: pointer;
  font-size: 13px; font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted);
}
.tf-chips label:hover { color: var(--text); }
/* visually hidden but still focusable and announced */
.tf-chips input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tf-chips label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.tf-chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-family: var(--font-num); font-weight: 600; font-size: 13px; }
.pick button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.pick button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.token-search { width: 100%; max-width: 360px; }
.token-list {
  width: 100%; max-height: 260px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--border); border-radius: 8px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.token { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border-soft); cursor: pointer; font-size: 13px; min-width: 0; white-space: nowrap; }
.token .sym { overflow: hidden; text-overflow: ellipsis; }
.token .muted { font-family: var(--font-num); }
.token .badge { margin-left: auto; white-space: nowrap; }
.token:hover { background: var(--surface-2); }
.token:has(input:checked) { background: var(--accent-soft); }
.token-list > p { padding: 10px; margin: 0; }
.editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-soft); }

/* ---------- settings: background work; uptime: resource line ---------- */
.jobs { display: grid; gap: 8px; max-width: 860px; }
.job { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.job .switch { margin-top: 2px; }
.job b { font-weight: 600; }
.job p { margin: 3px 0 0; font-size: 13px; line-height: 1.45; }
.job.off b { color: var(--muted); }
/* downtime log: a short cause label, then the full sentence */
.cause-tag { display: inline-block; margin-right: 8px; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); color: var(--text); }
.up-cause { color: var(--muted); }

/* ---------- uptime: the Server panel ----------
   Rings = health (status colours, always with a word + icon); bars = what
   uses memory / disk / the database (categorical slots 1-3, the same blue /
   orange / aqua as the downtime kinds, grey = other, empty track = free). */
.sys { margin-bottom: 18px; --s1: var(--dt-connection); --s2: var(--dt-asleep); --s3: var(--dt-stopped);
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; }
.sys-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sys-head h2 { margin: 0 0 2px; }
.sys-head .hint { margin: 0; }
.sys-head .btn { display: inline-flex; align-items: center; gap: 6px; }
.sys-head .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sys-gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.sys-gauge {
  display: grid; justify-items: center; grid-template-rows: 108px auto auto auto; row-gap: 2px;
  padding: 14px 10px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface-2);
}
.sys-gauge svg { grid-area: 1 / 1; width: 108px; height: 108px; transform: rotate(-90deg); }
.sys-gauge circle { fill: none; stroke-width: 9; }
.sys-gauge .track { stroke: color-mix(in srgb, var(--muted) 18%, transparent); }
.sys-gauge .arc { stroke-linecap: round; stroke-dashoffset: var(--off); stroke: var(--good); }
.sys-gauge.warning .arc { stroke: var(--warning); }
.sys-gauge.critical .arc { stroke: var(--critical); }
.sys-val { grid-area: 1 / 1; align-self: center; font-family: var(--font-num); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.sys-val small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.sys-label { font-weight: 600; margin-top: 6px; }
.sys-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.sys-state svg { width: 14px; height: 14px; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke: var(--good); }
.sys-gauge.warning .sys-state svg { stroke: var(--warning); }
.sys-gauge.critical .sys-state svg { stroke: var(--critical); }
.sys-detail { font-size: 12.5px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.sys-gauge.na .sys-val { color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .sys-gauge .arc { animation: sys-fill .9s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes sys-fill { from { stroke-dashoffset: var(--full); } to { stroke-dashoffset: var(--off); } }
}

.sys-bars { display: grid; gap: 16px; margin-top: 18px; }
.sys-bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sys-bar-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.sys-bar-head span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sys-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.sys-seg { min-width: 3px; height: 100%; }
.sys-seg.s1, .sys-legend i.s1 { background: var(--s1); }
.sys-seg.s2, .sys-legend i.s2 { background: var(--s2); }
.sys-seg.s3, .sys-legend i.s3 { background: var(--s3); }
.sys-seg.other, .sys-legend i.other {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 45%, transparent) 0 2px, color-mix(in srgb, var(--muted) 22%, transparent) 2px 5px);
}
.sys-seg.free { min-width: 0; background: color-mix(in srgb, var(--muted) 12%, transparent); }
.sys-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.sys-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sys-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.sys-legend b { color: var(--text); font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; }

.sys-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin: 18px 0 0;
  padding-top: 14px; border-top: 1px solid var(--border-soft); }
.sys-facts div { min-width: 0; }
.sys-facts dt { font-size: 12px; color: var(--muted); }
.sys-facts dd { margin: 1px 0 0; font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- settings: telegram chats ---------- */
.settings-layout { max-width: 1180px; }
.settings-layout .section-head .hint, .settings-layout .tg-env { max-width: 860px; }
.tg-env { background: var(--surface-2); }
.tg-env-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tg-env-head h2 { margin: 0 0 4px; }
.tg-env-head .hint { margin: 0; }
.lock-tag { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.lock-tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.tg-env-list { margin: 14px 0 0; display: grid; gap: 0; }
.tg-env-list > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--border-soft); align-items: baseline; }
.tg-env-list dt { color: var(--muted); font-size: 13px; }
.tg-env-list dd { margin: 0; font-size: 13.5px; }
.tg-env-list dd .btn { margin-left: 8px; }
.tg-env-list dd .message { margin-top: 6px; }
.secret { letter-spacing: 2px; color: var(--muted); }
.who b { font-weight: 600; }
.who-about { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; max-width: 60ch; white-space: normal; }
.who-err { color: var(--down); font-size: 13px; }
.who-cell { white-space: normal; min-width: 200px; font-size: 13px; }
/* people known in a group */
.people { display: flex; flex-wrap: wrap; gap: 4px; max-width: 340px; }
.person { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-soft); font-size: 12.5px; }
.person.bot { color: var(--muted); }
.person .role { font-style: normal; font-size: 11px; color: var(--accent); font-weight: 600; }
.people-note { display: block; margin-top: 3px; font-size: 12px; }
/* where the bot is */
.bot-sub { margin: 22px 0 8px; font-size: 15px; font-weight: 600; }
.bot-sub .muted { font-weight: 400; font-size: 13px; }
.bot-since { grid-column: 1 / -1; margin: 0; }
#bot-groups td .sub, #bot-direct td .sub { display: block; font-size: 12px; }
#bot-groups td.nowrap, #bot-direct td.nowrap { white-space: nowrap; }
#bot-groups .switch, #bot-direct .switch { margin-right: 6px; }
#bot-groups td.time, #bot-direct td.time { color: var(--muted); font-size: 13px; white-space: nowrap; }
#bot-direct th.num, #bot-direct td.num { text-align: right; font-family: var(--font-num); }
.section-head > .btn { white-space: nowrap; flex: none; }
.tg-off { list-style: none; padding-left: 14px; }
.tg-form { margin-bottom: 14px; }
.tg-form .settings-form input[type="text"] { width: 240px; }
.tg-id { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--muted); }
#tg-table td > .row-check { margin: 0; }
.tg-sends { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 14px; }
.tg-recent { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--surface-2); }
.tg-recent .hint { margin: 0; }
.tg-recent ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tg-recent li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.tg-recent li .muted { font-family: var(--font-num); }
.tg-help { margin-top: 24px; }
.tg-help summary { cursor: pointer; font-weight: 600; }
.tg-help ol { margin: 12px 0 0; padding-left: 22px; line-height: 1.55; max-width: 72ch; }
.tg-help li + li { margin-top: 6px; }
.tg-help .hint { margin: 12px 0 0; max-width: 72ch; line-height: 1.5; }
@media (max-width: 640px) {
  .tg-form .settings-form input[type="text"] { width: 100%; }
  .tg-form .settings-form .field { flex: 1 1 100%; }
}

/* ---------- volume filter ---------- */
.settings-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: 13px; }
.volume-layout { max-width: 820px; }
.vol-cell { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
/* where this token sits against the minimum: the tick is the minimum, log scale */
.vol-bar { position: relative; width: 120px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 16%, transparent); flex: none; }
.vol-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); border-radius: 3px; background: color-mix(in srgb, var(--muted) 55%, transparent); }
.vol-bar.passing i { background: color-mix(in srgb, var(--up) 70%, transparent); }
.vol-bar.kept i { background: color-mix(in srgb, var(--high) 70%, transparent); }
.vol-bar::after { content: ""; position: absolute; left: var(--min); top: -3px; bottom: -3px; width: 1.5px; background: var(--text); opacity: .55; }

/* ---------- backtest ---------- */
.bt-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.bt-form select, .bt-form input { min-width: 180px; }
.bt-form #bt-rule { min-width: 260px; max-width: 100%; }
.bt-form .message { flex-basis: 100%; margin: 0; }
.bt-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.bt-stat {
  display: flex; align-items: baseline; gap: 7px; padding: 7px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.bt-stat b { font-family: var(--font-num); font-size: 18px; font-weight: 600; color: var(--text); }
.bt-stat.ok b { color: var(--up); }
.bt-stat.bad b { color: var(--down); }
.bt-stat.sent b { color: #ab47bc; }
.bt-chart-tools { margin: 0 0 8px; }

/* searchable token picker */
.combo { position: relative; display: flex; }
.combo input { width: 220px; padding-right: 30px; min-height: 34px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding-left: 10px; }
.combo input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.combo-toggle { position: absolute; right: 2px; top: 2px; bottom: 2px; width: 28px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.combo-toggle:hover { color: var(--text); background: var(--surface-2); }
.combo-pop {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16); overflow: hidden;
}
.combo-count { margin: 0; padding: 7px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border-soft); }
.combo-list { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; }
.combo-list li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.combo-list li .sym { font-size: 13.5px; }
.combo-list li .badge { margin-left: 0; }
.combo-vol { margin-left: auto; color: var(--muted); font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.combo-list li.active { background: var(--accent-soft); }
.combo-list li:hover:not(.combo-none) { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.combo-none { color: var(--muted); cursor: default; white-space: normal; }
/* indicator buttons (same look as the chart page's layer buttons) */
.chip.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--c, currentColor); }
.chip.legend i.dashed { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.chip.legend i.pane { height: 9px; width: 12px; border-radius: 2px; background: none; border: 2px solid var(--c); border-top-width: 3px; }
.chip.legend.off { opacity: .45; text-decoration: line-through; }
.bt-chart-wrap { background: #131722; border: 1px solid #2a2e39; border-radius: var(--radius); overflow: hidden; }
.bt-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 0; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.bt-legend li { display: inline-flex; align-items: center; gap: 6px; }
.lg { font-size: 12px; line-height: 1; }
.lg.hit { color: #26a69a; }
.lg.miss { color: #ef5350; }
.lg.flat { color: #787b86; }
.lg.pending { color: #2962ff; }
.lg.sent { color: #ab47bc; }
/* the result's tinted column, as in the chart */
.lg.col { display: inline-block; width: 9px; height: 14px; border-radius: 2px; }
.lg.col.hit { background: #26a69a66; }
.lg.col.miss { background: #ef535066; }
.lg.col.flat { background: #787b8666; }
.lg.col.pending { background: #2962ff66; }
.bt-legend .sep { flex-basis: 100%; height: 0; }
.bt-table tbody tr { cursor: pointer; }
.bt-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bt-table tr.selected td { background: color-mix(in srgb, var(--accent-soft) 75%, var(--surface)); }
.bt-arrow.bullish { color: var(--up); }
.bt-arrow.bearish { color: var(--down); }
.badge.verdict { margin-left: 0; }
.badge.verdict.bad { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.badge.verdict.wait { background: var(--accent-soft); color: var(--accent); }
.badge.sent { background: color-mix(in srgb, #ab47bc 14%, transparent); color: #8e3aa3; }

/* ---------- uptime ---------- */
/* downtime kinds: the first three slots of the validated categorical palette
   (blue / orange / aqua; all-pairs safe for colour-blind readers), stepped per mode */
:root { --dt-connection: #2a78d6; --dt-asleep: #eb6834; --dt-stopped: #1baf7a; }
:root[data-theme="dark"] { --dt-connection: #3987e5; --dt-asleep: #d95926; --dt-stopped: #199e70; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --dt-connection: #3987e5; --dt-asleep: #d95926; --dt-stopped: #199e70; }
}
.k-connection { --k: var(--dt-connection); }
.k-asleep { --k: var(--dt-asleep); }
.k-stopped { --k: var(--dt-stopped); }
.up-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.up-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.up-tile b { font-family: var(--font-num); font-size: 24px; font-weight: 600; line-height: 1.15; }
.up-tile span { color: var(--muted); font-size: 12.5px; }
.up-tile.ok b { color: var(--up); }
.up-tile.bad b { color: var(--down); }
.up-timeline { position: relative; }
.up-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.up-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.up-legend li { display: inline-flex; align-items: center; gap: 6px; }
.up-legend i { width: 14px; height: 10px; border-radius: 3px; background: var(--k); }
.up-legend i.k-untracked, .up-untracked {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 35%, transparent) 0 2px, transparent 2px 5px);
}
.up-grid { --day: 92px; --pct: 64px; }
.up-axis, .up-row { display: grid; grid-template-columns: var(--day) minmax(0, 1fr) var(--pct); align-items: center; gap: 10px; }
.up-hours { position: relative; height: 16px; font-size: 11px; color: var(--muted); font-family: var(--font-num); }
.up-hours b { position: absolute; transform: translateX(-50%); font-weight: 500; }
.up-hours b:first-child { transform: none; }
.up-hours b:last-child { transform: translateX(-100%); }
.up-pct-head { font-size: 11px; color: var(--muted); text-align: right; }
.up-row { padding: 3px 0; }
.up-day { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar {
  position: relative; height: 20px; border-radius: 4px; overflow: hidden;
  background: linear-gradient(90deg, transparent calc(25% - .5px), var(--border-soft) calc(25% - .5px) calc(25% + .5px), transparent calc(25% + .5px),
      transparent calc(50% - .5px), var(--border-soft) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px),
      transparent calc(75% - .5px), var(--border-soft) calc(75% - .5px) calc(75% + .5px), transparent calc(75% + .5px)),
    color-mix(in srgb, var(--up) 10%, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--border-soft);
}
.up-bar > i, .up-seg { position: absolute; top: 0; bottom: 0; }
.up-future { background: var(--surface); }
.up-seg {
  min-width: 3px; border: 0; padding: 0; margin: 0; background: var(--k); cursor: pointer;
  box-shadow: 0 0 0 1px var(--surface);  /* a surface ring between neighbouring blocks */
}
.up-seg:hover, .up-seg:focus-visible { filter: brightness(1.12); outline: 2px solid var(--text); outline-offset: 1px; z-index: 2; }
.up-pct { font-family: var(--font-num); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.up-pct.low { color: var(--down); font-weight: 600; }
.up-note { margin-top: 8px; }
.up-tip {
  position: absolute; z-index: 10; display: flex; flex-direction: column; gap: 2px; max-width: 320px;
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.up-tip b { display: inline-flex; align-items: center; gap: 6px; }
.up-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--k); margin-right: 6px; vertical-align: 0; }
@media (max-width: 720px) {
  .up-grid { --day: 64px; --pct: 48px; }
  .up-hours b:nth-child(2), .up-hours b:nth-child(4) { display: none; }
}

/* ---------- glossary ---------- */
.glossary { max-width: 860px; }
.gloss-tools { display: flex; gap: 6px; flex: none; }
.gloss-head { margin: 26px 0 10px; }
.gloss-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.gloss-list details + details { border-top: 1px solid var(--border-soft); }
.gloss-list summary {
  display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) auto 16px; align-items: center; gap: 14px;
  padding: 11px 16px; cursor: pointer; list-style: none;
}
.gloss-list summary::-webkit-details-marker { display: none; }
.gloss-list summary::after {
  content: ""; width: 8px; height: 8px; justify-self: end; margin-right: 3px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px);
}
.gloss-list details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.gloss-list summary:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.gloss-list summary:focus-visible { outline-offset: -3px; }
.gl-name { font-weight: 600; }
.gl-short { color: var(--muted); font-size: 13px; }
.gl-mode {
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap;
  padding: 1px 7px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-soft);
}
.gloss-list summary:not(:has(.gl-mode)) { grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) 16px; }
.gl-body { padding: 2px 16px 14px; max-width: 72ch; line-height: 1.55; }
.gl-body p { margin: 0 0 8px; }
.gl-body ul { margin: 0 0 8px; padding-left: 20px; }
.gl-body li { margin: 2px 0; }
.gloss-list details[open] { background: color-mix(in srgb, var(--surface-2) 40%, var(--surface)); }

/* ---------- dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: var(--overlay); }
.small-modal {
  width: min(380px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
.small-modal form { padding: 18px 20px 16px; }
.small-modal h2 { margin: 0 0 4px; }
.small-modal .hint { margin: 0 0 12px; }
.small-modal .editor-actions { justify-content: space-between; align-items: center; }
.columns-list { display: flex; flex-direction: column; gap: 2px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 6px; border-radius: 6px; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row input { margin-top: 3px; accent-color: var(--accent); }
.check-row small { display: block; font-size: 12px; }

/* symbol chart modal (scanner table): the chart page in an iframe */
.symbol-modal {
  width: min(1200px, calc(100vw - 32px)); height: calc(100vh - 32px); max-height: none; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  overflow: hidden; box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.symbol-modal[open] { display: flex; flex-direction: column; }
.modal-bar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.symbol-modal iframe { flex: 1; width: 100%; border: 0; display: block; background: var(--surface); }

/* alert chart modal (alert history): the chart itself is dark, like the Telegram picture */
.chart-modal {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto;
  border: 1px solid #2a2e39; border-radius: var(--radius); background: #131722; color: #d1d4dc;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.chart-modal .modal-bar { border-bottom: 0; padding-bottom: 0; }
.chart-modal .btn { background: transparent; color: #d1d4dc; border-color: #2a2e39; }
.chart-modal .btn:hover { background: #2a2e39; border-color: #363a45; }
.chart-modal .icon-btn { color: #9598a1; }
.chart-modal .icon-btn:hover { background: #2a2e39; color: #d1d4dc; }
.alert-chart { min-height: 120px; }
.chart-modal .hint { padding: 0 14px 14px; color: #9598a1; }

/* ---------- account menu (top right): who is logged in, change password, log out ---------- */
.account { position: relative; flex: none; }
.account-btn[aria-expanded="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px; max-width: calc(100vw - 24px);
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
.account-who { display: flex; flex-direction: column; gap: 1px; margin: 0 0 6px; padding: 6px 10px 10px; border-bottom: 1px solid var(--border-soft); overflow-wrap: anywhere; }
.account-who .muted { font-size: 12px; }
.account-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.account-menu button:hover { background: var(--surface-2); }
.pw-form { display: grid; gap: 12px; }
.pw-form .hint { margin: 0; }
.pw-form label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.pw-form label small { font-weight: 400; }
.pw-form .editor-actions { margin-top: 4px; }

/* what a user may not use: hidden (docs/user-access.md; core.js applyAccess) */
body.not-admin .admin-only { display: none !important; }
body.cannot-rules-edit #new-row, body.cannot-rules-edit .reset-row,
body.cannot-rules-edit #rows .actions { display: none; }

/* ---------- Settings: Users ---------- */
.user-form { margin-bottom: 14px; }
.user-form .settings-form input[type="email"], .user-form .settings-form input[type="text"] { width: 240px; }
.user-perms { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 24px; margin-top: 16px; }
.user-perms h3 { margin: 0 0 2px; font-size: 13px; color: var(--muted); }
.user-perms[aria-disabled="true"] { opacity: .5; }
.user-admin-note { margin: 12px 0 0; }
#user-table td { vertical-align: top; }
#user-table .who b { display: block; }
#user-table .who .muted, #user-table .time .muted { font-size: 12.5px; }
#user-table .can-use { max-width: 320px; color: var(--muted); font-size: 13px; }
#user-table .time { white-space: nowrap; }
#user-table tr.off td:not(.actions) { opacity: .55; }
#user-table td.actions { white-space: normal; min-width: 150px; }  /* the buttons may wrap (side menu) */
#user-table td.actions > * { margin: 2px 0 2px 4px; }
.you-tag { margin-left: 6px; font-size: 11.5px; font-weight: 600; color: var(--accent); }
.role-tag { font-size: 12.5px; font-weight: 600; }
.role-tag.admin { color: var(--accent); }
.link-box { margin-bottom: 14px; border-color: color-mix(in srgb, var(--up) 45%, var(--border)); }
.link-box > p { margin: 0 0 10px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1 1 auto; min-width: 0; font-family: var(--font-num); font-size: 13px; }
.link-box .hint { margin: 10px 0 0; }
.link-done { display: flex; justify-content: flex-end; margin-top: 10px; }
@media (max-width: 640px) {
  .user-form .settings-form .field, .user-form .settings-form input[type="email"], .user-form .settings-form input[type="text"] { flex: 1 1 100%; width: 100%; }
  .link-row { flex-direction: column; }
}

/* password boxes: the eye button inside (show_password.js) */
.pw-field { position: relative; display: block; }
span.pw-field > input { width: 100%; padding-right: 42px; }  /* beats .login-card input */
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: inline-grid; place-items: center; width: 32px; height: 30px; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.pw-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); }

/* Settings: the dropdown of sections (top right) */
.settings-wrap { position: relative; flex: none; }
.settings-btn .caret { width: 14px; height: 14px; margin-left: -2px; transition: transform .15s; }
.settings-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.settings-menu .menu-group {
  margin: 6px 0 2px; padding: 4px 10px 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.settings-menu .menu-group:first-child { margin-top: 0; }
.settings-menu button[aria-current="page"] { color: var(--accent); font-weight: 600; }
#settings-crumb { color: var(--muted); font-weight: 500; }
#view-settings .section-head.sub.first { margin-top: 8px; }
.account-card { max-width: 560px; margin-bottom: 16px; }
.account-card h2 { margin-bottom: 12px; }
.account-card .hint { margin: 10px 0 0; }
.me-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.me-list > div { display: contents; }
.me-list dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.me-list dd { margin: 0; overflow-wrap: anywhere; }
.account-card .pw-form { margin-top: 12px; max-width: 360px; }
.account-card .pw-form .hint { margin: 0; }
.pw-actions { display: flex; justify-content: flex-start; }
#pw-done { margin: 0; }
#tgme-body p { margin: 0 0 8px; }
#tgme-body .tgme-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#tgme-body .tgme-wait { margin-top: 12px; }
#tgme-message { margin: 8px 0 0; }
#tgme-message:empty { display: none; }
.tg-tag { display: block; margin-top: 3px; font-size: 11.5px; font-weight: 600; color: var(--up); }

/* Settings: login attempts */
.attempts-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
#attempts-table td.time { white-space: nowrap; color: var(--muted); font-size: 13px; }
#attempts-table td.from { white-space: nowrap; font-family: var(--font-num); font-size: 13px; }
#attempts-table td.from .muted { font-family: var(--font-ui); margin-left: 4px; }
.badge.bad { background: color-mix(in srgb, var(--down) 13%, transparent); color: var(--down); }

/* ---------- login page (login.html) ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: 28px 28px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 18px; }
.login-card h1 { margin-bottom: 14px; }
.login-card .theme-btn { position: absolute; top: 20px; right: 20px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; color: var(--muted); }
.login-card input {
  height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px; font-weight: 400; color: var(--text);
}
.login-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.login-card .btn.primary { min-height: 38px; justify-content: center; }
.login-card .hint { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.login-error { margin: 0; color: var(--down); font-size: 13px; }
.login-setup { display: none; }
.login-page[data-needs-admin="true"] .login-setup { display: block; margin: 0 0 16px; color: var(--text); }
.login-setup code { font-size: 12px; overflow-wrap: anywhere; }
.login-card .login-lead { margin: 0 0 16px; color: var(--text); overflow-wrap: anywhere; }
.login-card label small { font-weight: 400; }
/* set_password.html: invite or reset wording; a dead link shows only its notice */
.login-page[data-link="ok"] .link-invalid, .login-page[data-link="invalid"] .link-ok { display: none; }
.login-page[data-kind="invite"] .for-reset, .login-page[data-kind="reset"] .for-invite { display: none; }

/* ---------- medium widths: the top bar must still fit (eight menus) ---------- */
@media (max-width: 1100px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .tabs button { padding: 0 8px; }
  .status { min-width: 0; }
  #status-text { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 900px) { .brand span { display: none; } }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 12px; }
  .brand span { display: none; }
  .tabs button { padding: 0 8px; white-space: nowrap; }
  .status { font-size: 12px; }
  .view { padding: 14px 12px 32px; }
  h1 { font-size: 20px; }
  input[type="search"] { flex: 1 1 100%; width: auto; min-width: 0; }
  th, td { padding: 7px 9px; }
  .section-head { flex-direction: column; align-items: stretch; }
  .section-head .btn { align-self: flex-start; }
  .steps { grid-template-columns: 1fr; }
  .token-list { grid-template-columns: 1fr; }
  .columns-btn { margin-left: 0; }
  .vol-bar { width: 64px; }
  .gloss-list summary, .gloss-list summary:not(:has(.gl-mode)) { grid-template-columns: minmax(0, 1fr) 16px; gap: 2px 10px; padding: 10px 12px; }
  .gl-short, .gl-mode { grid-column: 1; justify-self: start; }
  .gloss-list summary::after { grid-column: 2; grid-row: 1; }
  .gl-body { padding: 2px 12px 12px; }
  .gloss-tools { display: none; }
  .mover-list { max-height: calc(5 * 29px + 8px); }
  .mover-list li { padding: 0 12px; grid-template-columns: 22px minmax(0, 1fr) auto 68px; }
  .symbol-modal { width: calc(100vw - 12px); height: calc(100vh - 12px); max-width: none; }
}
/* narrow phones: the status keeps its dot; the text is in its tooltip */
@media (max-width: 720px) {
  /* the menus scroll sideways on their own; status and the gear always fit */
  .tabs { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .status, .settings-wrap, .account, .brand { flex: none; }
  .settings-btn { padding: 0 8px; }
  .settings-btn span { display: none; }
  .tg-env-list > div { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 480px) {
  .status #status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
