/* THE BRAIN operator app — mobile first, system fonts only, light and dark via prefers-color-scheme. */
:root {
  --bg: #f5f7fa; --panel: #ffffff; --text: #16202a; --muted: #67737f; --line: #dfe4ea;
  --accent: #1f6feb; --ok: #1a9c5b; --late: #d9931b; --stale: #d1383a; --never: #8a939c;
  --warn-bg: #fff4d6; --err-bg: #fde8e8; --chip: #eef2f6;
  --tabs-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1720; --panel: #172230; --text: #e6edf3; --muted: #8b98a5; --line: #26333f;
          --accent: #4c8dff; --warn-bg: #3a2f10; --err-bg: #3b1a1a; --chip: #223040; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tabs-h) + var(--safe-b)); }
h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 14px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  width: 36px; height: 36px; font-size: 18px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--never); flex: none; }
.dot.ok { background: var(--ok); } .dot.late { background: var(--late); } .dot.stale { background: var(--stale); } .dot.never { background: var(--never); }

main { padding: 12px 14px; max-width: 760px; margin: 0 auto; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.card .k { font-size: 12px; color: var(--muted); } .card .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.card.bad .v { color: var(--stale); } .card.warn .v { color: var(--late); } .card.good .v { color: var(--ok); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.list li .h { display: flex; align-items: center; gap: 8px; }
.list li .h .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.list li .msg { margin-top: 4px; word-break: break-word; }
.list li.click { cursor: pointer; }
.list li pre { margin: 8px 0 0; font-size: 11px; white-space: pre-wrap; word-break: break-word; background: var(--bg);
  padding: 8px; border-radius: 8px; max-height: 40vh; overflow: auto; }
.lvl { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--chip); font-weight: 600; }
.lvl.ERROR, .lvl.CRITICAL { background: var(--err-bg); color: var(--stale); } .lvl.WARNING { background: var(--warn-bg); color: var(--late); }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-weight: 600; text-transform: uppercase; }
.chip.done { background: var(--ok); color: #fff; } .chip.failed { background: var(--stale); color: #fff; }
.chip.running { background: var(--late); color: #fff; } .chip.queued { background: var(--chip); }

.row { display: flex; gap: 8px; align-items: center; margin: 6px 0 10px; }
.row.wrap { flex-wrap: wrap; }
label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 120px; }
label.chk { flex-direction: row; align-items: center; min-width: 0; flex: none; }
select, input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
.btn { font: inherit; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: 9px 14px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; }
.form { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; margin-bottom: 12px; }

.log { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 11px;
  line-height: 1.4; white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto; margin: 0; }
.log .WARNING { color: var(--late); } .log .ERROR, .log .CRITICAL { color: var(--stale); } .log .ts { color: var(--muted); }

.report { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; overflow-wrap: anywhere; }
.report h1 { font-size: 20px; margin: 4px 0 8px; } .report h2 { font-size: 16px; margin: 14px 0 6px; } .report h3 { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.report ul { padding-inline-start: 20px; } .report p { margin: 6px 0; }
.report .head { font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 8px; }
.report[dir="rtl"] { text-align: right; }
.banner { padding: 10px 12px; border-radius: 12px; margin-bottom: 10px; font-size: 13px; }
.banner.warn { background: var(--warn-bg); } .banner.err { background: var(--err-bg); }
.track { display: grid; gap: 8px; }
.track .card .v { font-size: 16px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--panel); border-top: 1px solid var(--line); z-index: 6; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; padding: 6px 0;
  position: relative; }
.tabs button.active { color: var(--accent); font-weight: 700; }
.badge { position: absolute; top: 4px; right: 12%; background: var(--stale); color: #fff; border-radius: 999px; font-size: 10px;
  padding: 0 5px; min-width: 16px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); width: min(92vw, 380px); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .form { margin: 0; border: 0; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 9; max-width: 90vw; }
[dir="rtl"] .list li .h { flex-direction: row-reverse; }
