/* MAZZIKA Monitor - dark observability UI. No external fonts or scripts (strict CSP). */
:root {
  --bg: #0b0a1a; --surface: #141127; --surface-2: #1b1733; --surface-3: #241f44; --line: #2a2550; --line-soft: #1f1b3d;
  --text: #ece9ff; --text-2: #a9a3cf; --text-3: #6f6a96;
  --violet: #9085e9; --blue: #3987e5; --magenta: #d55181;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --radius: 14px; --radius-s: 8px; --sidebar: 232px; --topbar: 60px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(1200px 600px at 80% -10%, rgba(144,133,233,.18), transparent 60%),
       radial-gradient(900px 500px at -10% 110%, rgba(57,135,229,.14), transparent 60%), var(--bg);
       color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--violet); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--topbar) 1fr; min-height: 100vh; }
.sidebar { grid-row: 1 / span 2; background: linear-gradient(180deg, #120f26, #0d0b1d); border-right: 1px solid var(--line-soft); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--violet), var(--blue) 60%, var(--magenta)); box-shadow: 0 0 24px rgba(144,133,233,.45); display: grid; place-items: center; font-weight: 800; color: #fff; }
.brand b { font-size: 15px; letter-spacing: .04em; } .brand span { display: block; font-size: 11px; color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(144,133,233,.22), rgba(57,135,229,.10)); color: #fff; box-shadow: inset 2px 0 0 var(--violet); }
.nav a .ic { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; }
.sidebar .foot { margin-top: auto; padding: 10px 12px; font-size: 11px; color: var(--text-3); }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--line-soft); background: rgba(11,10,26,.7); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.pill.good .dot { background: var(--good); box-shadow: 0 0 8px var(--good); } .pill.warn .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.pill.crit .dot { background: var(--crit); box-shadow: 0 0 8px var(--crit); }
.pill.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.iconbtn { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--text-2); }
.iconbtn:hover { color: #fff; border-color: var(--violet); }
.iconbtn .count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--magenta); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }
.profile { display: flex; align-items: center; gap: 8px; } .profile .avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--violet)); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.profile .role { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.main { padding: 22px 24px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.notif { position: absolute; right: 24px; top: calc(var(--topbar) + 6px); width: 360px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.5); z-index: 30; padding: 8px; }
.notif .item { padding: 10px; border-radius: 10px; display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: start; }
.notif .item:hover { background: var(--surface-2); }
.notif .item .sev { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.notif .empty { padding: 20px; text-align: center; color: var(--text-3); }

/* ---------- cards & grids ---------- */
.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)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 40%), var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card.glass { background: rgba(27,23,51,.55); backdrop-filter: blur(8px); }
.card > h2, .card > h3 { margin-bottom: 12px; }
.card .sub { color: var(--text-3); font-size: 12px; margin-top: -8px; margin-bottom: 12px; }
.section { margin-bottom: 22px; }
.section > h3 { margin-bottom: 10px; }
.tile { position: relative; padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 4px; line-height: 1.1; }
.tile .value.hero { font-size: 48px; }
.tile .delta { font-size: 12px; margin-top: 6px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.tile .delta.up { color: #4fc26b; } .tile .delta.down { color: #ec835a; }
.tile .spark { position: absolute; right: 12px; bottom: 10px; width: 90px; height: 28px; opacity: .9; }
.tile .state { position: absolute; top: 12px; right: 12px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; }
.state.good { color: #7fe07f; background: rgba(12,163,12,.14); border-color: rgba(12,163,12,.35); }
.state.warn { color: #ffd266; background: rgba(250,178,25,.14); border-color: rgba(250,178,25,.35); }
.state.serious { color: #ffb08f; background: rgba(236,131,90,.14); border-color: rgba(236,131,90,.35); }
.state.crit { color: #ff8a8a; background: rgba(208,59,59,.16); border-color: rgba(208,59,59,.4); }
.state.neutral { color: var(--text-2); background: var(--surface-2); border-color: var(--line); }
.state.info { color: #9cc4ff; background: rgba(57,135,229,.14); border-color: rgba(57,135,229,.35); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--surface-3); color: var(--text-2); }
.badge.crit { background: rgba(208,59,59,.25); color: #ff9a9a; } .badge.warn { background: rgba(250,178,25,.2); color: #ffd266; }
.badge.violet { background: rgba(144,133,233,.2); color: #c6bfff; } .badge.magenta { background: rgba(213,81,129,.2); color: #ff9cc0; }
.empty { padding: 28px 18px; text-align: center; color: var(--text-2); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 8px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.error-box { padding: 12px 14px; border-radius: 10px; background: rgba(208,59,59,.12); border: 1px solid rgba(208,59,59,.4); color: #ffb3b3; }
.ok-box { padding: 12px 14px; border-radius: 10px; background: rgba(12,163,12,.12); border: 1px solid rgba(12,163,12,.4); color: #b8f0b8; }
.note { padding: 10px 12px; border-radius: 10px; background: rgba(57,135,229,.1); border: 1px solid rgba(57,135,229,.3); color: #cfe2ff; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; }
.loading { opacity: .55; transition: opacity .2s; pointer-events: none; }

/* ---------- controls ---------- */
.btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 7px 12px; border-radius: 9px; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--violet); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--violet), var(--blue)); border: none; color: #fff; }
.btn.danger { border-color: rgba(208,59,59,.6); color: #ff9a9a; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.input, select.input, textarea.input { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; color: var(--text); min-width: 0; }
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(144,133,233,.2); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: transparent; border: none; color: var(--text-2); padding: 5px 10px; border-radius: 7px; font-size: 12.5px; }
.seg button.active { background: var(--surface-3); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; } .field label { font-size: 12px; color: var(--text-2); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.tbl th { color: var(--text-3); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); } .tbl th.sorted { color: var(--violet); }
.tbl tr.row:hover td { background: rgba(255,255,255,.025); } .tbl tr.click { cursor: pointer; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .ellip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.gicon { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3); object-fit: cover; vertical-align: middle; margin-right: 8px; display: inline-grid; place-items: center; font-size: 11px; color: var(--text-2); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 10px; font-size: 12.5px; color: var(--text-2); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.chart .bar { rx: 0; } .chart .bar:hover { filter: brightness(1.2); }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend .key.rect { height: 10px; border-radius: 2px; }
.tooltip { position: absolute; pointer-events: none; background: #0f0d22; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 10; min-width: 120px; white-space: nowrap; }
.tooltip .tt-title { color: var(--text-3); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; } .tooltip .tt-row b { font-weight: 600; } .tooltip .tt-row span { color: var(--text-2); }
.tooltip .tt-row i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.meter { height: 8px; border-radius: 4px; background: rgba(57,135,229,.18); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
.meter.warn > i { background: var(--warn); } .meter.crit > i { background: var(--crit); }
.hbar { display: grid; grid-template-columns: minmax(80px, 160px) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.hbar .track { height: 10px; background: var(--line-soft); border-radius: 3px; overflow: hidden; } .hbar .track i { display: block; height: 100%; background: var(--blue); border-radius: 0 3px 3px 0; }
.hbar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- live sessions ---------- */
.sess { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; }
.sess .art { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.sess .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .sess .a { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.progress { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 8px; overflow: hidden; } .progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--violet)); }
.sess-card { cursor: pointer; } .sess-card .details { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.feed { font-size: 12.5px; } .feed .ev { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); } .feed .ev time { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- logs ---------- */
.logs { background: #0a0917; border: 1px solid var(--line-soft); border-radius: var(--radius); font-family: var(--mono); font-size: 12.5px; height: calc(100vh - 290px); min-height: 360px; overflow: auto; padding: 6px 0; }
.log { display: grid; grid-template-columns: 150px 72px 80px 1fr auto; gap: 10px; padding: 3px 12px; border-left: 3px solid transparent; cursor: pointer; align-items: baseline; }
.log:hover { background: rgba(255,255,255,.03); }
.log .ts { color: var(--text-3); } .log .lv { font-weight: 700; } .log .cat { color: var(--text-3); } .log .msg { white-space: pre-wrap; word-break: break-word; } .log .ctx { color: var(--text-3); font-size: 11px; }
.log.DEBUG { border-left-color: #4a4670; } .log.DEBUG .lv { color: #8a86b0; }
.log.INFO .lv { color: var(--blue); } .log.SUCCESS .lv { color: var(--good); } .log.SUCCESS { border-left-color: rgba(12,163,12,.5); }
.log.WARNING .lv { color: var(--warn); } .log.WARNING { border-left-color: rgba(250,178,25,.5); }
.log.ERROR .lv { color: var(--serious); } .log.ERROR { border-left-color: var(--serious); background: rgba(236,131,90,.05); }
.log.CRITICAL .lv { color: #ff6b6b; } .log.CRITICAL { border-left-color: var(--crit); background: rgba(208,59,59,.1); }
.log-detail { margin: 0 12px 6px 15px; padding: 10px 12px; background: var(--surface); border-radius: 8px; border: 1px solid var(--line-soft); font-family: var(--font); font-size: 12.5px; }
.log-detail pre { margin: 8px 0 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: #ffb3a3; max-height: 320px; overflow: auto; }
pre.stack { background: #0a0917; border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: #ffb3a3; max-height: 400px; overflow: auto; margin: 0; }

/* ---------- misc ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 95vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -30px 0 60px rgba(0,0,0,.5); z-index: 40; overflow: auto; padding: 22px; }
.drawer .close { position: absolute; top: 14px; right: 14px; }
.toast-wrap { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--violet); padding: 10px 14px; border-radius: 10px; min-width: 260px; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slidein .2s ease-out; }
.toast.crit { border-left-color: var(--crit); } .toast.warn { border-left-color: var(--warn); } .toast.good { border-left-color: var(--good); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }
.map-empty { min-height: 260px; border-radius: var(--radius); background: radial-gradient(circle at 50% 50%, rgba(144,133,233,.12), transparent 60%), repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.03) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(255,255,255,.03) 39px 40px); border: 1px dashed var(--line); display: grid; place-items: center; text-align: center; padding: 24px; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heat i { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--blue); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); }
.login .brand { justify-content: center; padding-bottom: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .g4, .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .sidebar { display: none; } .sidebar.open { display: flex; position: fixed; inset: 0 30% 0 0; z-index: 60; }
  .main { padding: 16px; } .g2, .g3, .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar .clock, .topbar .profile .nm { display: none; } .menu-btn { display: grid; }
  .log { grid-template-columns: 80px 60px 1fr; } .log .cat, .log .ctx { display: none; }
}
@media (min-width: 901px) { .menu-btn { display: none; } }
@media (max-width: 560px) { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr; } .sess { grid-template-columns: 44px 1fr; } .sess .art { width: 44px; height: 44px; } .notif { right: 8px; left: 8px; width: auto; } }
