:root {
  --bg: #0e1116; --bg2: #141922; --panel: #181e29; --panel2: #1e2533; --line: #273043; --line2: #323d54;
  --tx: #e6e9ef; --tx2: #a7b0c0; --tx3: #6f7a8f;
  --acc: #6aa9ff; --ok: #3ecf8e; --warn: #f5b942; --crit: #ff5d6c; --opp: #b48cff; --info: #6aa9ff;
  --k1: #f2a93b; --k2: #4cc3a8; --k3: #9d8cff;
  --r: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; color: var(--tx); }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--tx2); text-transform: uppercase; letter-spacing: .04em; }
small, .muted { color: var(--tx2); }
.dim { color: var(--tx3); }
code, .mono { font-family: var(--mono); font-size: 12px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; letter-spacing: -.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--k1), var(--k3)); display: grid; place-items: center; color: #10131a; font-weight: 800; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--tx2); margin-bottom: 2px; }
.nav a:hover { background: var(--panel); color: var(--tx); text-decoration: none; }
.nav a.on { background: var(--panel2); color: var(--tx); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--tx); font-weight: 600; }
.badge.crit { background: var(--crit); color: #1b0b0d; }
.badge.warn { background: var(--warn); color: #1d1503; }
.badge.opp { background: var(--opp); color: #150b25; }
.side-foot { padding: 14px 10px; color: var(--tx3); font-size: 12px; }
.side-foot button { margin-top: 8px; }

main { padding: 22px 28px 60px; max-width: 1600px; width: 100%; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.top .sub { color: var(--tx2); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

button, .btn, select, input[type=text], input[type=password], input[type=search] {
  background: var(--panel2); color: var(--tx); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer;
}
input[type=text], input[type=password], input[type=search] { cursor: text; }
button:hover, .btn:hover { border-color: var(--acc); text-decoration: none; }
button.primary { background: var(--acc); border-color: var(--acc); color: #08111f; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 11px; color: var(--tx2); }
.seg button.on { background: var(--panel2); color: var(--tx); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g2, .g4 { grid-template-columns: 1fr; } main { padding: 16px; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card.tight { padding: 12px 14px; }
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card .head h2 { margin: 0; }
.stack > * + * { margin-top: 14px; }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .lbl { color: var(--tx2); font-size: 12px; }
.kpi .val { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--tx2); }
.up { color: var(--ok); } .down { color: var(--crit); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px 18px; }

.chan { border-top: 3px solid var(--c, var(--acc)); }
.chan .name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--acc)); display: inline-block; flex: none; }
.k1 { --c: var(--k1); } .k2 { --c: var(--k2); } .k3 { --c: var(--k3); }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line2); color: var(--tx2); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #275e47; } .pill.failed, .pill.crit { color: var(--crit); border-color: #6e2a33; }
.pill.warn, .pill.planned, .pill.producing, .pill.pending { color: var(--warn); border-color: #6b5222; }
.pill.scheduled, .pill.running, .pill.in_progress { color: var(--acc); border-color: #2b4a73; }
.pill.published { color: var(--ok); border-color: #275e47; }
.pill.missed { color: var(--crit); border-color: #6e2a33; background: #2a1519; }
.pill.cancelled, .pill.idea { color: var(--tx3); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--tx3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--panel); cursor: default; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--tx); }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow: auto; max-height: 560px; }
.tbl-wrap { overflow-x: auto; }

.ins { display: grid; grid-template-columns: 4px 1fr; gap: 0 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ins:last-child { border-bottom: 0; }
.ins .bar { border-radius: 4px; background: var(--info); }
.ins.critical .bar { background: var(--crit); } .ins.warning .bar { background: var(--warn); } .ins.opportunity .bar { background: var(--opp); }
.ins .t { font-weight: 600; } .ins .d { color: var(--tx2); font-size: 13px; margin-top: 2px; }
.ins .meta { font-size: 11px; color: var(--tx3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .when { width: 92px; flex: none; color: var(--tx2); font-variant-numeric: tabular-nums; font-size: 12px; }
.list-item .what { flex: 1; min-width: 0; }
.list-item .what .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }

.cal { display: grid; grid-template-columns: 110px repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; min-height: 52px; }
.cal .hd { background: var(--bg2); font-size: 12px; color: var(--tx2); font-weight: 600; min-height: 0; }
.cal .day { background: var(--bg2); font-size: 12px; }
.cal .day.today { color: var(--acc); font-weight: 700; }
.cal .ev { display: block; background: var(--panel2); border-left: 3px solid var(--c); border-radius: 6px; padding: 4px 6px; margin-bottom: 5px; font-size: 12px; color: var(--tx); cursor: pointer; }
.cal .ev:hover { background: var(--line); text-decoration: none; }
.cal .ev .tm { color: var(--tx2); font-variant-numeric: tabular-nums; margin-right: 4px; }
.cal .ev.planned { border-style: dashed; opacity: .85; }
.cal .ev.gap { border-left-color: var(--crit); background: #2a1519; color: var(--crit); cursor: default; }

.timeline { position: relative; }
.tl-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; min-height: 26px; border-bottom: 1px dashed var(--line); }
.tl-row .lbl { font-size: 12px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.tl-track { position: relative; height: 26px; overflow: hidden; }
.tl-bar { position: absolute; top: 6px; height: 14px; border-radius: 4px; min-width: 4px; background: var(--ok); opacity: .9; cursor: pointer; }
.tl-bar.failed { background: var(--crit); } .tl-bar.running { background: var(--acc); }
.tl-bar.missed { background: transparent; border: 1.5px dashed var(--crit); }
.tl-bar.future { background: transparent; border: 1.5px dashed var(--line2); cursor: default; }
.tl-axis { display: grid; grid-template-columns: 150px 1fr; font-size: 11px; color: var(--tx3); }
.tl-axis .ticks { position: relative; height: 18px; }
.tl-axis .ticks span { position: absolute; transform: translateX(-50%); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); opacity: .7; pointer-events: none; }
.tl-day { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line2); pointer-events: none; }

.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--line2); display: inline-block; }
.dots i.ok { background: var(--ok); } .dots i.failed { background: var(--crit); } .dots i.missed { background: transparent; border: 1.5px solid var(--crit); }
.dots i.running { background: var(--acc); } .dots i.pending { background: transparent; border: 1.5px dashed var(--tx3); }

.progress { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--c, var(--acc)); border-radius: 99px; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.kanban .col { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 120px; }
.kanban .col h3 { display: flex; justify-content: space-between; }
.kanban .it { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; font-size: 12px; }
.kanban .it b { display: block; font-size: 13px; color: var(--tx); margin-bottom: 2px; }

pre.json { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 520px; font: 12px/1.5 var(--mono); color: var(--tx2); white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--tx3); }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 180px; }
.empty { color: var(--tx3); padding: 18px 0; text-align: center; }
.err { background: #2a1519; border: 1px solid #6e2a33; color: #ffb3bb; padding: 12px 14px; border-radius: 8px; }
.loading { color: var(--tx3); padding: 40px 0; text-align: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.note { font-size: 12px; color: var(--tx3); margin-top: 8px; }
.textblock { white-space: pre-wrap; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; color: var(--tx2); max-height: 360px; overflow: auto; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login .box h1 { margin-bottom: 6px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }
.login input { width: 100%; padding: 10px 12px; }
.login .msg { color: var(--crit); font-size: 13px; min-height: 18px; }
main { min-width: 0; }
.layout { background: linear-gradient(to right, var(--bg2) 220px, var(--bg) 220px); }
@media (max-width: 820px) { .layout { background: var(--bg); } }
button.mini, .mini { padding: 2px 8px; font-size: 11px; border-radius: 6px; text-transform: none; letter-spacing: 0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.modal { position: fixed; inset: 0; background: rgba(5,8,12,.7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal .box { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 20px; width: 100%; max-width: 620px; max-height: 90vh; overflow: auto; }
.modal .msg { margin-top: 10px; font-size: 13px; color: var(--crit); }
textarea { width: 100%; background: var(--bg2); color: var(--tx); border: 1px solid var(--line2); border-radius: 8px; padding: 10px; font: inherit; resize: vertical; margin-top: 4px; }
.okbox { background: #12281f; border: 1px solid #275e47; color: #9be7c4; padding: 12px 14px; border-radius: 8px; }
