/* Control panel — «Графит».
 *
 * The design handoff writes every rule as an inline `style` attribute. That
 * cannot be used here: the panel serves
 *   Content-Security-Policy: default-src 'none'; style-src 'self'
 * and `style-src 'self'` blocks inline style attributes just as it blocks
 * inline scripts. The same policy is why there is no Google Fonts link — a
 * `font-src` would have to be opened to a third party, and the container may
 * have no egress at all. Manrope / Azeret Mono are therefore replaced by the
 * closest system stacks; every other token is the handoff's exact value.
 *
 * The two themes in the handoff collapse to one — «Графит», as it instructs.
 */

:root {
  --bg:          oklch(0.152 0.005 285);
  --bg2:         oklch(0.194 0.006 285);   /* cards */
  --bg3:         oklch(0.238 0.008 285);   /* hover, raised surfaces */
  --line:        oklch(0.275 0.008 285);   /* hairlines */
  --line2:       oklch(0.345 0.01 285);    /* field borders, dividers */
  --text:        oklch(0.955 0.004 285);
  --dim:         oklch(0.715 0.008 285);
  --dim2:        oklch(0.555 0.01 285);
  --accent:      oklch(0.665 0.175 292);
  --accent-soft: oklch(0.665 0.175 292 / 0.16);
  --accent-line: oklch(0.665 0.175 292 / 0.42);
  --up:          oklch(0.755 0.155 152);
  --up-soft:     oklch(0.755 0.155 152 / 0.13);
  --down:        oklch(0.665 0.195 22);
  --down-soft:   oklch(0.665 0.195 22 / 0.14);
  --warn:        oklch(0.79 0.14 76);
  --warn-soft:   oklch(0.79 0.14 76 / 0.13);

  /* Manrope and Azeret Mono cannot be fetched under this CSP; these are the
     nearest stacks already present on the machine that runs the panel. */
  --sans: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --pill: 999px;
  --pad: 14px;
  --pad2: 20px;
  --rowpy: 9px;
  --gap: 18px;
  --shell: 1720px;
}

* { box-sizing: border-box; }

html { margin: 0; padding: 0; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* An author-origin `display` beats the user-agent `[hidden] { display: none }`
   rule, so any element with its own `display` would stay on screen after being
   hidden. This one line keeps `hidden` meaning hidden, everywhere. */
[hidden] { display: none !important; }

h1, h2, h3, p, dl, dd, ul { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
th { font-weight: 500; }
code { font-family: var(--mono); color: var(--dim); }

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

@keyframes blip { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }
@keyframes pop  { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-card h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
}
.login-card button[type="submit"] {
  font-size: 12.5px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.login-card button[type="submit"]:hover { border-color: var(--accent); }

/* ----------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 16px var(--pad2) 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim2);
  flex: none;
  animation: blip 2.4s ease-in-out infinite;
}
.dot.live { background: var(--up); }
.dot.paused { background: var(--warn); }
/* Stale data must not pulse: a blinking dot reads as "alive". */
.dot.stale { background: var(--dim2); animation: none; }

.badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  padding: 4px 8px;
  border-radius: var(--pill);
  border: 1px solid var(--line2);
  color: var(--dim);
  white-space: nowrap;
}
.badge.live-mode { border-color: var(--down); color: var(--down); background: var(--down-soft); }
.badge-state.running { background: var(--up-soft); color: var(--up); border-color: transparent; }
.badge-state.paused { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.uptime {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--dim2);
  white-space: nowrap;
}

.spacer { flex: 1 1 40px; }

.conn {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--warn);
  white-space: nowrap;
}

.viewbar {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 14px var(--pad2) 0;
  display: flex;
  gap: 22px;
  overflow-x: auto;
}

.viewbar button {
  font-size: 13.5px;
  font-weight: 500;
  padding: 0 1px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--dim2);
  white-space: nowrap;
  transition: color .12s;
}
.viewbar button:hover { color: var(--text); }
.viewbar button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.ghost {
  font-size: 12px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--dim);
  transition: color .12s, border-color .12s;
}
.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--dim2); }
.ghost:disabled { opacity: .45; }
.ghost.danger:hover:not(:disabled) { color: var(--down); border-color: var(--down); }
.ghost.small { font-size: 11.5px; padding: 5px 10px; }

.link {
  font-size: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}
.link:hover:not(:disabled) { color: var(--text); }
.link:disabled { color: var(--dim2); cursor: default; }

.primary {
  font-size: 12.5px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  justify-self: start;
}
.primary:hover:not(:disabled) { border-color: var(--accent); }

/* Segmented control: chart ranges, activity tabs, anything with 2–4 choices. */
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  overflow-x: auto;
}
.seg button {
  font-size: 11px;
  letter-spacing: .04em;
  padding: 5px 11px;
  border-radius: var(--pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim2);
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.seg button:hover { color: var(--text); background: var(--bg3); }
.seg button.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }

/* ------------------------------------------------------------------ shell */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--pad2);
}

/* Hairlines live on the cells, not on the container background: when the grid
   wraps on a narrow screen the leftover area stays cell-coloured instead of
   glowing in the border colour. */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--gap);
}

.metric {
  background: var(--bg2);
  padding: 16px var(--pad2);
  box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line);
}
.metric .label {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--dim2);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.metric .value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(21px, 1.9vw, 26px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
.metric .value .unit { font-size: 13px; color: var(--dim); margin-left: 6px; }
.metric .value .pct { font-size: 15px; }
.metric .value .of { color: var(--dim2); }

.stale-values .value { opacity: .45; }

.pos { color: var(--up); }
.neg { color: var(--down); }

/* ------------------------------------------------------------------- grid */

.cols { display: grid; gap: var(--gap); align-items: start; }
.cols-overview { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.cols-traders { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.cols-settings { grid-template-columns: 236px minmax(0, 1fr); }
.stack-col { display: grid; gap: var(--gap); min-width: 0; }

/* ------------------------------------------------------------------ cards */

.panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--pad) var(--pad2);
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.panel-head .meta { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }
.panel-head .title-group { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.panel-head .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.panel-body { padding: var(--pad2); }
.panel-body.grid { display: grid; gap: 14px; }

.muted { color: var(--dim2); }
.small { font-size: 11.5px; line-height: 1.55; text-wrap: pretty; }

.empty-state { padding: 44px var(--pad2); text-align: center; }
.empty-state .head { font-size: 13px; color: var(--dim); }
.empty-state .hint { font-family: var(--mono); font-size: 11px; color: var(--dim2); margin-top: 7px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table { font-family: var(--mono); font-size: 11.5px; }

th {
  text-align: left;
  padding: 10px 8px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: bottom;
}
td {
  padding: var(--rowpy) 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
th:first-child, td:first-child { padding-left: var(--pad2); }
th:last-child, td:last-child { padding-right: var(--pad2); }
th.num, td.num { text-align: right; }
td.dim { color: var(--dim); }
td.dim2 { color: var(--dim2); }
/* Prose is set in the body font, not mono: these are sentences, not numbers.
   The max-width goes on a block inside the cell — on the `td` itself an
   auto-layout table ignores it and the paragraph spans the whole row. */
td.prose { white-space: normal; }
td.prose > span {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.6;
  max-width: 560px;
}

tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg3); }
td.empty { text-align: center; color: var(--dim2); padding: 22px; white-space: normal; }

.tag {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: .06em;
  padding: 3px 7px;
  border-radius: var(--pill);
  background: var(--bg3);
  color: var(--dim);
  white-space: nowrap;
}
.tag.long, .tag.up { background: var(--up-soft); color: var(--up); }
.tag.short, .tag.down { background: var(--down-soft); color: var(--down); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

.chip-cell {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: var(--pill);
  background: var(--bg3);
}

/* Bias bar in the smart-money table. */
.bias { display: flex; align-items: center; gap: 8px; width: 110px; }
.bias-track { flex: 1; height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; }
.bias-fill { height: 100%; border-radius: 2px; background: var(--dim2); }
.bias-fill.pos { background: var(--up); }
.bias-fill.neg { background: var(--down); }
.bias-value { font-size: 10.5px; color: var(--dim2); min-width: 34px; text-align: right; }

/* ------------------------------------------------------------------ chart */

.chart-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; }

.chart-labels {
  position: relative;
  width: 72px;
  height: 280px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim2);
}
.chart-labels span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}

.chart-plot { position: relative; height: 280px; cursor: crosshair; }
.chart-plot .rule { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart-plot .rule.r0 { top: 0; }
.chart-plot .rule.r1 { top: 25%; }
.chart-plot .rule.r2 { top: 50%; }
.chart-plot .rule.r3 { top: 75%; }
.chart-plot .rule.base { bottom: 0; background: var(--line2); }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.crosshair-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line2);
  pointer-events: none;
}
.crosshair-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg2);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.crosshair-tip {
  position: absolute;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg3);
  box-shadow: 0 8px 20px oklch(0.1 0 0 / .35);
  pointer-events: none;
  white-space: nowrap;
  transform: translateY(-50%);
}
.crosshair-tip .v { font-family: var(--mono); font-size: 11px; display: block; }
.crosshair-tip .t { font-family: var(--mono); font-size: 10px; color: var(--dim2); display: block; }

.chart-note {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim2);
}

/* --------------------------------------------------------------- controls */

.controls { display: grid; gap: 10px; }

.controls button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border: 1px solid transparent;
}
.controls button .hint { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--dim2); }
.controls button:disabled { opacity: .45; color: var(--dim2); }
.controls-hint { margin-top: 12px; }

#btn-pause { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn); }
#btn-pause:hover:not(:disabled) { border-color: var(--warn); }
#btn-resume { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
#btn-resume:hover:not(:disabled) { border-color: var(--accent); }
#btn-flatten { background: var(--down-soft); border-color: var(--down-soft); color: var(--down); }
#btn-flatten:hover:not(:disabled) { border-color: var(--down); }

/* -------------------------------------------------------- watched pairs */

.group-label {
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--dim2);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.pair-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pair-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--pill);
  border: 1px solid var(--line2);
  color: var(--text);
}
.pair-chip.ai { border-color: var(--accent-line); background: var(--accent-soft); }
.pair-conf { font-family: var(--mono); font-size: 11px; color: var(--accent); padding: 5px 2px; }

/* Compact "last trades" list on the overview. */
.feed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 11px var(--pad2);
  border-bottom: 1px solid var(--line);
}
.feed-row .a { font-family: var(--mono); font-size: 12px; }
.feed-row .b { font-family: var(--mono); font-size: 12px; text-align: right; }
.feed-row .c { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }
.feed-row .d { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); text-align: right; }

/* Runtime summary rows. */
.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px var(--pad2);
  border-bottom: 1px solid var(--line);
}
.kv-row .k { font-size: 12px; color: var(--dim); }
.kv-row .v { font-family: var(--mono); font-size: 11.5px; text-align: right; }

.errors { list-style: none; padding: 0 var(--pad2) var(--pad2); display: grid; gap: 6px; }
.errors li { font-family: var(--mono); font-size: 11px; color: var(--down); }

/* --------------------------------------------------------------- settings */

.secnav { position: sticky; top: 118px; display: grid; gap: 2px; min-width: 0; align-content: start; }
.secnav-label { font-size: 10px; letter-spacing: .1em; color: var(--dim2); padding: 2px 10px 8px; }

.secnav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-size: 12.5px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--dim);
  transition: background .1s, color .1s;
}
.secnav button:hover { background: var(--bg2); color: var(--text); }
.secnav button.active { background: var(--accent-soft); color: var(--text); }
.secnav button .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secnav button .count {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--dim2);
  flex: none;
}
.secnav button .count.dirty { background: var(--accent-soft); color: var(--accent); }

.settings-head { padding: var(--pad2); display: grid; gap: 16px; }
.settings-head .row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.settings-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px; }
.settings-head .lead { max-width: 640px; margin-bottom: 12px; }

.keychips { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.keychips .caption { font-size: 11px; color: var(--dim2); margin-right: 2px; }
.keychip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--pill);
  border: 1px solid transparent;
  color: var(--dim);
  white-space: nowrap;
}
.keychip i { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.keychip.on { background: var(--up-soft); }
.keychip.on i { background: var(--up); }
.keychip.on .state { color: var(--up); }
.keychip.off { background: var(--warn-soft); }
.keychip.off i { background: var(--warn); }
.keychip.off .state { color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { position: relative; flex: 1 1 280px; min-width: 0; }
.search input {
  width: 100%;
  padding: 10px 12px 10px 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-size: 12.5px;
  transition: border-color .12s;
}
.search .glyph {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim2);
  pointer-events: none;
}

.toggle-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--dim);
  flex: none;
}
.toggle-filter.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.toggle-filter .count { font-family: var(--mono); font-size: 10px; color: var(--dim2); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: var(--pad2);
  border-bottom: 1px solid var(--line);
}
.section-head h3 { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; margin-bottom: 5px; }
.section-head .hint { max-width: 560px; font-size: 11.5px; line-height: 1.5; color: var(--dim2); text-wrap: pretty; }
.section-head .side { display: flex; align-items: center; gap: 14px; flex: none; }

.applies {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--up-soft);
  color: var(--up);
  white-space: nowrap;
}
.applies.restart { background: var(--bg3); color: var(--dim2); }

.section-note {
  padding: var(--pad) var(--pad2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--dim);
  background: var(--bg);
  text-wrap: pretty;
}

.setrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 6px 20px;
  align-items: center;
  padding: 13px var(--pad2) 13px calc(var(--pad2) - 2px);
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
}
.setrow.dirty { border-left-color: var(--accent); background: var(--bg3); }
.setrow .left { min-width: 0; }
.setrow .caption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.setrow .label { font-size: 12.5px; color: var(--text); }
.setrow .hint { font-size: 11px; line-height: 1.5; color: var(--dim2); margin-top: 5px; text-wrap: pretty; }
.setrow .key { font-family: var(--mono); font-size: 10px; color: var(--dim2); opacity: .7; margin-top: 5px; }
.setrow .badge-dirty {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.setrow .reset { font-size: 10.5px; padding: 0; border: 0; background: transparent; color: var(--accent); }
.setrow .ctl { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.setrow .unit { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); min-width: 34px; flex: none; }

/* The model picker: a catalogue select with a text field behind «своя модель…». */
.setrow .choice { display: grid; gap: 6px; width: 100%; max-width: 196px; }
.setrow .choice select,
.setrow .choice input {
  width: 100%;
  max-width: 196px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  text-align: left;
}

.setrow input[type="text"],
.setrow input[type="number"] {
  width: 100%;
  max-width: 150px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  transition: border-color .12s;
}
.setrow textarea {
  width: 100%;
  max-width: 196px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  resize: vertical;
}

.select-wrap { position: relative; width: 100%; max-width: 196px; }
.select-wrap select {
  width: 100%;
  padding: 8px 26px 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .12s;
}
.select-wrap .caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--dim2);
  pointer-events: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent-line); outline: none; }

/* Toggle switch — booleans are drawn, never native. */
.switch {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--bg3);
  padding: 0;
  position: relative;
  flex: none;
}
.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dim2);
  transition: left .14s;
}
.switch.on { background: var(--accent-soft); border-color: var(--accent-line); }
.switch.on i { left: 20px; background: var(--accent); }

/* Key entry: a wide field plus its buttons, in the control column of a row. */
.setrow .ctl.keyctl { gap: 6px; flex-wrap: wrap; }
.setrow .ctl.keyctl input {
  flex: 1 1 150px;
  min-width: 0;
  max-width: 236px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
}
.setrow .ctl.keyctl .primary { padding: 8px 12px; font-size: 12px; }
.keybar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px var(--pad2);
  border-bottom: 1px solid var(--line);
}

.section-empty { padding: 36px var(--pad2); text-align: center; }
.section-empty .head { font-size: 12.5px; color: var(--dim); }
.section-empty .hint { font-size: 11.5px; color: var(--dim2); margin-top: 6px; }

/* Apply bar — floats above everything while there are unsaved edits. */
.applybar-holder {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 0 20px 20px;
  pointer-events: none;
}
.applybar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line2);
  background: var(--bg3);
  box-shadow: 0 18px 44px oklch(0.1 0 0 / .45);
  pointer-events: auto;
  animation: pop .18s ease-out;
}
.applybar .count { font-size: 12.5px; }
.applybar .keys {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim2);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.applybar .actions { display: flex; gap: 8px; margin-left: auto; }
.applybar .apply {
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.applybar .apply:hover:not(:disabled) { border-color: var(--accent); }

/* -------------------------------------------------------- account section */

.acc-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
}
.acc-block {
  padding: var(--pad2);
  display: grid;
  gap: 10px;
  align-content: start;
  box-shadow: -1px 0 0 var(--line);
}
.acc-block .group-label { margin-bottom: 0; }
.acc-block input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
}
.acc-block input.mismatch { border-color: var(--down); }
.acc-error { font-size: 11px; color: var(--down); }
.acc-who { font-family: var(--mono); font-size: 11px; color: var(--accent); }

.tfa-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tfa-chip {
  font-size: 10px;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: var(--pill);
  text-transform: uppercase;
}
.tfa-chip.on { background: var(--up-soft); color: var(--up); }
.tfa-chip.off { background: var(--warn-soft); color: var(--warn); }

.qr {
  width: 190px;
  padding: 8px;
  background: #fff;
  border-radius: var(--radius-sm);
}
.qr svg { width: 100%; height: auto; display: block; }

.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; letter-spacing: .04em; }

.newuser { border-top: 1px solid var(--line); padding: var(--pad2); max-width: 720px; display: grid; gap: 14px; }
.newuser .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.newuser input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
}
.newuser .foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.perms { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2px 20px; }

/* Drawn checkbox: the native one cannot be themed to match. */
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text);
  border: 0;
  background: transparent;
  padding: 6px 0;
  text-align: left;
}
.check i {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  flex: none;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: transparent;
  line-height: 1;
}
.check.on i { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.check:disabled { opacity: .55; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* -------------------------------------------------------- modal and toast */

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: none;
  max-height: none;
}
dialog::backdrop { background: oklch(0.1 0 0 / .62); backdrop-filter: blur(3px); }

.dialog-card {
  width: min(440px, calc(100vw - 48px));
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px oklch(0.1 0 0 / .5);
  animation: pop .16s ease-out;
}
.dialog-card .head {
  padding: var(--pad2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-card .head i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.dialog-card h3 { font-size: 14px; font-weight: 600; }
.dialog-card .body { padding: var(--pad2); display: grid; gap: 14px; }
.dialog-card .body p { font-size: 12.5px; line-height: 1.6; color: var(--dim); text-wrap: pretty; }
.dialog-card label { display: grid; gap: 7px; }
.dialog-card label span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--dim2);
  text-transform: uppercase;
}
.dialog-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .06em;
}
.dialog-card input.mismatch { border-color: var(--down); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions .confirm {
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.dialog-actions .confirm:disabled { opacity: .4; }
.dialog-card.tone-down .head i { background: var(--down); }
.dialog-card.tone-down .dialog-actions .confirm {
  background: var(--down-soft);
  color: var(--down);
  border-color: var(--down);
}
.dialog-card.tone-warn .head i { background: var(--warn); }
.dialog-card.tone-warn .dialog-actions .confirm {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--bg3);
  box-shadow: 0 14px 34px oklch(0.1 0 0 / .42);
  animation: pop .18s ease-out;
}
.toast i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex: none; }
.toast.bad i { background: var(--down); }
.toast.good i { background: var(--up); }
.toast span { font-size: 12.5px; line-height: 1.5; }

.result { font-size: 12px; line-height: 1.5; }
.result.good { color: var(--up); }
.result.bad { color: var(--down); }
.error { color: var(--down); font-size: 12px; }

footer {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad2) 28px;
  font-size: 11.5px;
  color: var(--dim2);
}

/* --------------------------------------------------------------- adaptive */

@media (max-width: 1180px) {
  .cols-overview, .cols-traders, .cols-settings { grid-template-columns: minmax(0, 1fr); }

  /* Otherwise a column of 15 buttons grows above the content on a phone and
     has to be scrolled past in full. */
  .secnav {
    position: static;
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .secnav-label { display: none; }
  .secnav button {
    width: auto;
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--pill);
    padding: 7px 12px;
  }
}

@media (max-width: 760px) {
  /* A fixed 236px control column left ~100px for the label on a 375px screen. */
  .setrow { grid-template-columns: minmax(0, 1fr); gap: 10px 0; }
  .setrow .ctl { justify-content: flex-start; }
  .setrow input, .setrow textarea, .setrow .select-wrap { max-width: 100%; }
  .chart-labels { width: 52px; font-size: 9.5px; }
  .applybar .keys { display: none; }
  .applybar { width: 100%; }
}

@media (max-width: 700px) {
  :root { --pad2: 14px; --gap: 12px; }
}
