/* Video Klets admin. Layout: fixed sidebar + scrolling content; on phones the sidebar becomes a top tab strip. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --fg: #14202b;
  --muted: #5d6b78;
  --line: #d9e0e6;
  --accent: #0b7a6f;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --crit: #c2253c;
  --crit-soft: #fde8eb;
  --warn: #a35d00;
  --warn-soft: #fdf1dd;
  --ok: #1f7a3a;
  --ok-soft: #e3f4e8;
  --bar: #0b7a6f;
  --bar-2: #8aa4b8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1419;
    --surface: #161e25;
    --surface-2: #1d2730;
    --fg: #e3eaf0;
    --muted: #95a4b2;
    --line: #2a3640;
    --accent: #3cc4b2;
    --accent-ink: #062320;
    --accent-soft: #123430;
    --crit: #ff6b7f;
    --crit-soft: #3a1820;
    --warn: #f2b155;
    --warn-soft: #33260f;
    --ok: #5fd07f;
    --ok-soft: #12301c;
    --bar: #3cc4b2;
    --bar-2: #56697a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.tabular, td, .kpi-value { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.stack { display: grid; gap: 12px; }
.spacer { height: 14px; }
.spacer.small { height: 8px; }
#view { display: grid; gap: 18px; min-width: 0; }

/* ---------- Controls ---------- */
.btn {
  font: 600 13px/1 var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.link { background: none; border: 0; color: var(--accent); padding: 4px 0; }
input[type="text"], input[type="password"], input:not([type]), input[inputmode], select, textarea {
  font: 14px var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 10px; width: 100%; min-width: 0;
}
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-msg { margin: 0; min-height: 18px; font-size: 13px; color: var(--crit); }
.form-msg.ok { color: var(--ok); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 2px; gap: 2px; }
.seg button { font: 600 12.5px/1 var(--font); color: var(--muted); background: none; border: 0; border-radius: 5px; padding: 7px 11px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--line); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.dot.on { background: var(--ok); }

/* ---------- Sign-in ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 22px; }
.login-brand { display: flex; gap: 12px; align-items: center; }
.login-title { font-weight: 700; font-size: 18px; }
.login-sub { color: var(--muted); font-size: 13px; }
.approve-head { display: flex; gap: 12px; align-items: flex-start; }
.approve-title { font-weight: 650; font-size: 15px; margin-bottom: 2px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 4px; flex: none; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
.code-row { display: flex; gap: 8px; }
.code-row input { font: 600 18px var(--mono); letter-spacing: 0.25em; text-align: center; }
.approve-foot { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Panel layout ---------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; gap: 9px; align-items: center; font-weight: 700; padding: 4px 10px 16px; }
.sidebar a { display: flex; justify-content: space-between; align-items: center; color: var(--fg); text-decoration: none; padding: 8px 10px; border-radius: 6px; font-weight: 550; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.count:empty { display: none; }
.count { font-size: 11px; font-weight: 700; background: var(--crit); color: #fff; border-radius: 999px; padding: 1px 7px; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.who { font-size: 12.5px; color: var(--muted); }
.content { padding: 24px 28px 48px; min-width: 0; display: grid; gap: 18px; align-content: start; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flash { padding: 10px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.flash.err { background: var(--crit-soft); color: var(--crit); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.live .kpi-value { color: var(--accent); }
.kpi.crit { border-color: var(--crit); background: var(--crit-soft); }
.kpi.crit .kpi-value { color: var(--crit); }
.kpi.warn .kpi-value { color: var(--warn); }

/* ---------- Charts ---------- */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--muted); font: 10.5px var(--font); }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .bar.zero { fill: var(--line); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) minmax(0, 1fr) 52px; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--bar); border-radius: 5px; }
.hbar-fill.alt { background: var(--bar-2); }
.hbar-fill.crit { background: var(--crit); }
.hbar-fill.warn { background: var(--warn); }
.hbar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-2); margin: 6px 0 8px; }
.split > div { height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.member-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 3px 0; }

/* ---------- Report and case items ---------- */
.items { display: grid; gap: 12px; }
.item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.item.sev-3 { border-left-color: var(--crit); }
.item.sev-2 { border-left-color: var(--warn); }
.item.sev-1 { border-left-color: var(--bar-2); }
.item.report { border-left-color: var(--warn); }
.item.highlight { box-shadow: 0 0 0 2px var(--accent); }
.item-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.people { display: grid; gap: 6px; }
.person { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.person b { font-weight: 650; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chatlog { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; display: grid; gap: 4px; font-size: 13px; max-height: 320px; overflow-y: auto; }
.chatlog .line { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; }
.chatlog .line time { color: var(--muted); font-size: 11.5px; padding-top: 2px; }
.chatlog .line.flagged { background: var(--crit-soft); border-radius: 4px; margin: 0 -6px; padding: 2px 6px; }
.chatlog .line.flagged .text { color: var(--crit); font-weight: 600; }
.chatlog .who { font-weight: 650; margin-right: 6px; }
.chatlog .text { word-break: break-word; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
details[open] summary { margin-bottom: 8px; }

/* ---------- Settings ---------- */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting-row:last-child { border-bottom: 0; }
.setting-row .label { display: grid; gap: 2px; min-width: 0; }
.setting-row .label b { font-weight: 600; }
.setting-row .label span { font-size: 12.5px; color: var(--muted); }
.setting-row select { width: auto; min-width: 150px; }
.save-bar { display: flex; gap: 10px; align-items: center; }

/* ---------- Dialog ---------- */
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--fg); }
.dialog::backdrop { background: rgba(10, 16, 22, 0.55); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-brand { display: none; }
  .sidebar a { flex: none; padding: 7px 10px; }
  .side-foot { margin: 0 0 0 auto; padding: 0 0 0 10px; border-top: 0; border-left: 1px solid var(--line); display: flex; align-items: center; }
  .who { display: none; }
  .content { padding: 16px 16px 40px; }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .switch .track, .switch .track::after { transition: none; }
}
