:root {
  --red: #F40008; --ink: #0c0c0f; --ink2: #1b1b22; --muted: #6b6f7b; --line: #e4e5ea;
  --bg: #f5f6f8; --card: #fff; --ok: #15803d; --warn: #b45309; --bad: #c81e1e; --blue: #1d4ed8;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue); text-decoration: none; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9cad1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; letter-spacing: .2px; }
.brand b { color: var(--red); }
.nav a { display: flex; justify-content: space-between; color: #c9cad1; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: var(--ink2); color: #fff; }
.nav a.on { background: var(--red); color: #fff; }
.nav .pill { background: rgba(255,255,255,.18); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.side .me { position: absolute; bottom: 16px; left: 12px; right: 12px; font-size: 12px; color: #8d8f99; }
.side .me button { margin-top: 6px; width: 100%; }
.main { padding: 22px 28px 60px; min-width: 0; }
h1 { font-size: 21px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; }
  .side .me { position: static; margin-top: 10px; } .grid2, .stats { grid-template-columns: 1fr; }
}

/* elements */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fff7f7; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd2da; border-radius: 7px; background: #fff; }
textarea { width: 100%; min-height: 70px; }
input[type=checkbox] { width: auto; }
label.f { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { display: block; width: 100%; margin-top: 4px; color: var(--ink); font-size: 14px; }
button { font: inherit; border: 1px solid #cfd2da; background: #fff; border-radius: 7px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #999; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #3b3f4a; white-space: nowrap; }
.b-new { background: #e8eefc; color: var(--blue); }
.b-confirmed, .b-ok { background: #e6f4ea; color: var(--ok); }
.b-dismissed, .b-closed { background: #eef0f4; color: var(--muted); }
.b-escalated, .b-bad { background: #fde8e8; color: var(--bad); }
.b-in_review, .b-warn { background: #fef3e2; color: var(--warn); }
.sev { display: inline-block; min-width: 26px; text-align: center; border-radius: 6px; padding: 1px 6px; font-weight: 700; color: #fff; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; }
.kv div:nth-child(odd) { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #f1f2f5; border-radius: 12px; padding: 3px 10px; font-size: 12px; }
.chip button { border: 0; background: none; padding: 0 0 0 6px; color: var(--muted); }
.chip.ai { background: #f2eefe; } .chip.system { background: #eef6ff; }
video, .media img { width: 100%; border-radius: 8px; background: #000; display: block; }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.strip img { width: 100%; border-radius: 6px; cursor: zoom-in; }
.scorebar { height: 8px; background: #eef0f4; border-radius: 4px; overflow: hidden; }
.scorebar div { height: 100%; background: var(--red); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #bbb; }
.dot.on { background: var(--ok); } .dot.off { background: var(--bad); }
.thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #ddd; display: block; }

/* modal + toast */
.backdrop { position: fixed; inset: 0; background: rgba(12,12,15,.55); display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: min(640px, 100%); padding: 20px; }
.modal.wide { width: min(1000px, 100%); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); }

/* auth */
.auth { max-width: 380px; margin: 9vh auto; background: #fff; border-radius: 14px; padding: 28px; border: 1px solid var(--line); }
.auth .brand { color: var(--ink); padding: 0 0 16px; font-size: 20px; }

/* editor */
.editor { position: relative; }
.editor canvas { width: 100%; border-radius: 8px; cursor: crosshair; display: block; background: #222; }
pre.json { background: #0c0c0f; color: #e6e6e6; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 320px; }
.task { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: #fff; }
.task .head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }
