/* Quantos — мінімалістичний дашборд (редизайн 18.10). Важливе — крупно,
   другорядне — дрібно або згорнуто. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #262b35;
  --text: #e7e9ee;
  --muted: #8f97a5;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --bad: #f26d5b;
  --ok-bg: rgba(62, 207, 142, .12);
  --warn-bg: rgba(240, 180, 41, .12);
  --bad-bg: rgba(242, 109, 91, .12);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- вхід --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border-radius: 18px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* --- шапка --- */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(15, 17, 21, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--panel-2);
  font-size: 13px; font-weight: 600; color: var(--muted); }
.pill.running { background: var(--ok-bg); color: var(--ok); }
.pill.paused, .pill.starting { background: var(--warn-bg); color: var(--warn); }
.pill.stopped, .pill.halted { background: var(--bad-bg); color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.running { background: var(--ok); } .dot.starting, .dot.paused { background: var(--warn); }
.dot.stopped, .dot.halted { background: var(--bad); }
.dot.big { width: 16px; height: 16px; margin-top: 12px; }
.dot.big.running { box-shadow: 0 0 0 6px var(--ok-bg); }
.dot.big.paused, .dot.big.starting { box-shadow: 0 0 0 6px var(--warn-bg); }
.dot.big.stopped, .dot.big.halted { box-shadow: 0 0 0 6px var(--bad-bg); }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab { background: none; border: 0; padding: 9px 14px; border-radius: 10px; color: var(--muted); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel-2); font-weight: 600; }
.count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--accent); cursor: pointer; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

main { padding: 24px 20px 48px; max-width: 1180px; margin: 0 auto; }
.tab-page { display: flex; flex-direction: column; gap: 18px; }

/* --- кнопки --- */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: #3a4150; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.success { background: var(--ok-bg); border-color: rgba(62, 207, 142, .45); color: var(--ok); font-weight: 600; }
.btn.danger { background: var(--bad-bg); border-color: rgba(242, 109, 91, .45); color: #ffb4a8; font-weight: 600; }
.btn.ghost { background: none; }
.btn.small { padding: 5px 12px; font-size: 13px; min-height: 32px; }
.btn.lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn.wide { width: 100%; padding: 12px; }

/* --- огляд: головна картка стану --- */
.hero { background: var(--panel); border-radius: 18px; padding: 24px 28px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 18px 24px; border: 1px solid transparent; }
.hero.stopped, .hero.halted { border-color: rgba(242, 109, 91, .35); }
.hero.paused { border-color: rgba(240, 180, 41, .35); }
.hero-main { display: flex; gap: 18px; align-items: flex-start; min-width: 0; }
.hero h1 { font-size: 28px; line-height: 1.25; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-msg { flex-basis: 100%; }
.hero-msg:empty { display: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { border-radius: 999px; padding: 2px 10px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); background: var(--warn-bg); } .chip.bad { color: var(--bad); background: var(--bad-bg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border-radius: var(--radius); padding: 18px 22px; }
.kpi .k { color: var(--muted); font-size: 14px; }
.kpi .v { font-size: 32px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .s { color: var(--muted); font-size: 13px; }
.small-kpis .kpi { padding: 14px 18px; }
.small-kpis .v { font-size: 24px; }

.block { display: flex; flex-direction: column; gap: 10px; }
.block h2 { font-size: 17px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.list { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--panel-2); }
.row .main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row .title { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .badge, .row .btn { flex: none; }
.row .num { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.row .num.big { font-size: 22px; }
.row-empty { padding: 16px 20px; color: var(--muted); }
.attn .list { background: none; display: flex; flex-direction: column; gap: 8px; }
.attn .row { border: 0; border-radius: 12px; background: var(--warn-bg); }
.attn .row.bad { background: var(--bad-bg); }
.attn .row .sign { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; }
.attn .row.bad .sign { background: var(--bad); }
.all-ok { margin: -4px 0 0; color: var(--ok); font-size: 14px; }
.minor { margin: 0; }
.minor b { color: var(--text); font-weight: 600; }

details.fold { background: var(--panel); border-radius: var(--radius); }
details.fold > summary { cursor: pointer; padding: 12px 20px; color: var(--muted); list-style: none; font-size: 14px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸ "; }
details.fold[open] > summary::before { content: "▾ "; }
details.fold > :not(summary) { margin: 0 14px 14px; }

/* --- сегменти / фільтри --- */
.seg, .subtabs { display: inline-flex; gap: 4px; background: var(--panel); border-radius: 12px; padding: 4px; align-self: flex-start; }
.sub { background: none; border: 0; padding: 8px 16px; border-radius: 9px; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 36px; }
.sub:hover { color: var(--text); }
.sub.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .grow { flex: 1; min-width: 200px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label.inline { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* --- таблиці --- */
.table-wrap { overflow-x: auto; background: var(--panel); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--panel-2); }
td.r, th.r { text-align: right; }
td.wrap { white-space: normal; min-width: 260px; }
td.minor-col, th.minor-col { color: var(--muted); font-size: 13px; }
td.strong { font-weight: 700; }
.empty td { color: var(--muted); text-align: center; padding: 22px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: rgba(91, 140, 255, .14); color: #9db8ff; }

.log { background: #0b0d11; border-radius: 12px; padding: 12px; margin: 0;
  font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto; color: #c6cbd4; }
.log.small { max-height: 260px; }

.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 90px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { position: relative; height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bar-fill.pos { background: var(--ok); left: 50%; } .bar-fill.neg { background: var(--bad); right: 50%; }
.bar-row .r { text-align: right; }

/* --- перемикач торгівлі --- */
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; border: 0; background: #3a4150; cursor: pointer; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 21px; }
.switch:disabled { opacity: .5; cursor: wait; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  padding: 11px 18px; border-radius: 12px; z-index: 10; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }

/* --- акаунти --- */
.banner { background: var(--warn-bg); color: #f5d27a; border-radius: 12px; padding: 12px 16px; }
.ex-group { background: var(--panel); border-radius: var(--radius); margin-bottom: 14px; }
.ex-group > summary { list-style: none; cursor: pointer; padding: 14px 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-group > summary::-webkit-details-marker { display: none; }
.ex-group > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.ex-group[open] > summary::before { transform: rotate(90deg); }
.ex-title { font-weight: 700; font-size: 16px; }
.ex-group .grow { flex: 1; }
.ex-group .table-wrap { border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin: 0; background: none; }
tr.clickable { cursor: pointer; }
tr.off td { color: var(--muted); }
.wide-dlg { max-width: 860px; width: calc(100% - 24px); max-height: calc(100vh - 24px); padding: 0; margin: 12px auto auto; overflow-y: auto; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 8px; background: var(--panel); }
.dlg-title { font-weight: 700; font-size: 19px; }
.wide-dlg .subtabs { display: flex; margin: 0 16px 8px; overflow-x: auto; position: sticky; top: 0; z-index: 2; background: var(--panel-2); }
.ad-body { padding: 4px 20px 22px; min-height: 120px; }
.ad-msg { margin: 0 20px 8px; padding: 10px 14px; border-radius: 10px; background: var(--panel-2); white-space: pre-wrap; }
.ad-msg.bad { background: var(--bad-bg); } .ad-msg.ok { background: var(--ok-bg); }
.kv { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: 8px 14px; margin: 8px 0 16px; }
.kv .k { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; }
.field input[type=text], .field input[type=password], .field select, .field textarea, .ad-body input[type=text], .ad-body input[type=password], .ad-body textarea { width: 100%; }
.field textarea, .ad-body textarea { min-height: 70px; resize: vertical; font: 12px/1.4 var(--mono); }
.field .hint { color: var(--muted); font-size: 12px; line-height: 1.35; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.group-title { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: flex-end; }
.chiplist { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chiplist .chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text); padding: 4px 10px; font-size: 13px; }
.chiplist .chip button { background: none; border: 0; color: var(--bad); cursor: pointer; padding: 0 2px; }
.steps { margin: 6px 0 10px 18px; padding: 0; color: var(--muted); font-size: 13px; }
.steps li { margin: 3px 0; }
.dlg-head > div { min-width: 0; overflow-wrap: anywhere; }
.dlg-head > button { flex-shrink: 0; }

@media (max-width: 700px) {
  .topbar-in { gap: 8px 12px; padding: 8px 14px; }
  .tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding: 16px 14px 40px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .k { font-size: 12px; }
  .kpi .v { font-size: 19px; }
  .kpi .s { display: none; }
  .row { gap: 10px; }
  .row .num.big { font-size: 18px; }
  .row { padding: 12px 16px; }
  th, td { padding: 9px 10px; }
  .wide-dlg { width: 100%; max-width: none; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv .k { margin-top: 6px; }
}
#sub-active, #sub-history, #j-events, #j-log { display: flex; flex-direction: column; gap: 14px; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; min-width: 36px; min-height: 36px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--bad); background: var(--bad-bg); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
td.acc-name { white-space: normal; overflow-wrap: anywhere; min-width: 140px; max-width: 260px; }
