:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1b1f24; --muted: #66707a; --line: #e2e5e9;
  --accent: #0a6cff; --ok: #1a7f37; --ok-bg: #e6f4ea; --warn: #9a6700; --warn-bg: #fff4d6;
  --review: #6f42c1; --review-bg: #f0e9fb; --real: #0a6cff; --real-bg: #e7f0ff; --error: #c62828;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1e24; --text: #e8eaed; --muted: #9aa3ad; --line: #2b3138;
    --accent: #5b9dff; --ok: #6fd28a; --ok-bg: #173a22; --warn: #f0c35a; --warn-bg: #3a2f12;
    --review: #b794f6; --review-bg: #2d2140; --real: #7fb0ff; --real-bg: #172a45; --error: #ff7b72;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 8px; }
button { font: inherit; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); margin-top: 4px; }
label { display: block; margin-bottom: 10px; }
a { color: var(--accent); }
pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; font: inherit; }
[hidden] { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--error); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.review { background: var(--review-bg); color: var(--review); } .badge.real { background: var(--real-bg); color: var(--real); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); } .login h1 { margin-bottom: 16px; }

#app-view { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; } .topbar #tick-status { flex: 1; min-width: 0; font-size: 13px; }
.switches { display: grid; gap: 8px; } .switch { display: flex; gap: 10px; align-items: center; margin: 0; font-weight: 600; }
.switch input { width: 20px; height: 20px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; padding: 12px 16px; } .stat strong { font-size: 24px; font-variant-numeric: tabular-nums; } .stat span { color: var(--muted); font-size: 13px; }
.layout { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px; align-items: start; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .list-head h2 { margin: 0; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; font-size: 13px; }
.filters button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.chat { width: 100%; text-align: left; display: grid; gap: 4px; background: transparent; color: var(--text); border: 1px solid var(--line); padding: 10px; }
.chat.active { border-color: var(--accent); background: var(--real-bg); }
.chat .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { display: grid; gap: 10px; min-width: 0; } .detail h2 { margin: 0; }
.tasks { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; } .tasks p { margin: 4px 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--bg); } .timeline li p { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.timeline li.out { justify-self: end; background: var(--real-bg); }
.connections { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; } .result { min-height: 1.4em; font-size: 13px; color: var(--muted); }
.notifications { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 320px; overflow-y: auto; }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } #chats { max-height: 40vh; } .timeline li { max-width: 100%; } }

.table-wrap { overflow-x: auto; }
table.demand { width: 100%; border-collapse: collapse; font-size: 14px; }
table.demand th, table.demand td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.demand th { color: var(--muted); font-weight: 600; font-size: 13px; }
table.demand .num { text-align: right; font-variant-numeric: tabular-nums; }
.switch.small { font-weight: 400; font-size: 13px; }
