:root {
  --bg: #f3f4f6; --card: #fff; --ink: #15171c; --muted: #5d6472; --faint: #8a909c;
  --line: #e2e4e9; --line2: #eef0f3; --head: #111214;
  --brand: #E8182A; --brand-deep: #C32B2B;
  --miss-bg: #b42318; --miss-fg: #fff;
  --exp-bg: #fdecea; --exp-fg: #a11a12; --exp-bd: #f4b8b2;
  --s30-bg: #fff1dc; --s30-fg: #8a4b00;
  --s90-bg: #fff9e0; --s90-fg: #6e5a00;
  --cur-bg: #e5f5eb; --cur-fg: #1b6a39;
  --nox-bg: #eff0f3; --nox-fg: #565d6b;
  --link: #1a56c4;
  --radius: 8px;
  font-family: 'Source Sans 3', system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.4; }
h1, h2, h3 { font-family: Poppins, system-ui, sans-serif; margin: 0; letter-spacing: -.01em; }
a { color: var(--link); }
button, select, input, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top { background: var(--head); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 18px; padding: 10px 20px; max-width: 1600px; margin: 0 auto; }
.brand img { display: block; height: 36px; width: auto; }
.title h1 { font-size: 18px; font-weight: 600; }
.syncline { font-size: 12.5px; color: #b9bdc6; }
.syncline b { color: #fff; font-weight: 600; }
.syncline .stale { color: #ffb347; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 2px; padding: 0 14px; max-width: 1600px; margin: 0 auto; overflow-x: auto; }
.tabs a { color: #c7cad1; text-decoration: none; padding: 9px 12px 10px; font-weight: 600; font-size: 13.5px;
          border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: #fff; }
.tabs a.on { color: #fff; border-bottom-color: var(--brand); }
.tabs a .n { display: inline-block; margin-left: 6px; background: var(--brand); color: #fff; border-radius: 9px;
             font-size: 11px; padding: 0 6px; line-height: 17px; }

.viewers { display: flex; }
.viewers .av { width: 28px; height: 28px; border-radius: 50%; background: #2c2f36; color: #fff; border: 2px solid var(--head);
               display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-left: -6px; cursor: default; }
.viewers .av.me { background: var(--brand); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ccf6e; margin-right: 5px;
            box-shadow: 0 0 0 3px rgba(60,207,110,.18); vertical-align: 1px; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer;
       font-weight: 600; font-size: 13px; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c4c8d0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); }
.btn.ghost-light { background: transparent; color: #e6e8ec; border-color: #3a3d45; }
.btn.ghost-light:hover { border-color: #6a6e78; color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; }

/* ---------- layout ---------- */
.main { max-width: 1600px; margin: 0 auto; padding: 18px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card, .section + .section { margin-top: 16px; }
.card-h { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px 10px; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 13px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.note { color: var(--muted); font-size: 13px; }
.warn { background: #fff6e5; border: 1px solid #f3d49b; color: #6b4600; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.err  { background: #fdecea; border: 1px solid #f4b8b2; color: #8a160f; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
       border-top: 4px solid var(--line); text-align: left; }
.kpi:hover { border-color: #c9ccd3; }
.kpi .v { font-family: Poppins, sans-serif; font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-weight: 600; font-size: 13px; margin-top: 2px; }
.kpi .s { color: var(--faint); font-size: 12.5px; margin-top: 4px; }
.kpi.k-nc { border-top-color: var(--ink); }
.kpi.k-miss { border-top-color: var(--miss-bg); }
.kpi.k-exp { border-top-color: #e2584e; }
.kpi.k-30 { border-top-color: #e5a63c; }

/* ---------- tables ---------- */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 250px); border-top: 1px solid var(--line); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line2); vertical-align: middle; }
th { position: sticky; top: 0; background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
     color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); z-index: 1; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--ink); }
th .ar { color: var(--brand); margin-left: 3px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: #fafbfd; }
tbody tr.click { cursor: pointer; }
td.cand { font-weight: 600; white-space: nowrap; }
td .sm { display: block; color: var(--faint); font-size: 12px; font-weight: 400; }
td.wrap { max-width: 240px; }
.neg { color: var(--exp-fg); font-weight: 700; }

/* breakdown table */
.bd th, .bd td { text-align: right; font-variant-numeric: tabular-nums; }
.bd th:first-child, .bd td:first-child { text-align: left; }
.bd td.c { cursor: pointer; }
.bd td.c:hover { background: #f1f4fb; text-decoration: underline; }
.bd tr.grp td { font-weight: 700; }
.bd .tot { background: #f7f8fa; font-weight: 700; }
.bd td.zero { color: #c3c7cf; }

/* ---------- chips / pills ---------- */
.res { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; font-size: 12px;
       font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.res.MISSING { background: var(--miss-bg); color: var(--miss-fg); }
.res.EXPIRED { background: var(--exp-bg); color: var(--exp-fg); border-color: var(--exp-bd); }
.res.s30 { background: var(--s30-bg); color: var(--s30-fg); }
.res.s90 { background: var(--s90-bg); color: var(--s90-fg); }
.res.cur { background: var(--cur-bg); color: var(--cur-fg); }
.res.nox { background: var(--nox-bg); color: var(--nox-fg); }
.yn { font-weight: 700; }
.yn.n { color: var(--exp-fg); }
.doc0 { color: var(--exp-fg); font-weight: 700; }
.act { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef2fb;
       color: #23408e; white-space: nowrap; }
.act.Resolved, .act.Updated { background: var(--cur-bg); color: var(--cur-fg); }
.act.none { background: transparent; color: var(--faint); font-weight: 400; padding: 0; }
.issues-n { display: inline-block; min-width: 22px; text-align: center; border-radius: 10px; padding: 0 6px; font-weight: 700; font-size: 12px; }
.issues-n.y { background: var(--miss-bg); color: #fff; }
.issues-n.z { color: #c3c7cf; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 16px 12px; }
.filters select, .filters input[type=search] { border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: #fff; min-width: 140px; }
.filters input[type=search] { min-width: 220px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .c { opacity: .7; margin-left: 4px; font-weight: 400; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.count { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- screenshot view ---------- */
.shot { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 20px; }
.shot h3 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.shot .asat { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.shot table { font-size: 13.5px; }
.shot th { position: static; }
.shot + .shot { margin-top: 16px; }
.shot .none { padding: 10px 0; color: var(--cur-fg); font-weight: 600; }

/* ---------- grid ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.callout { border-left: 4px solid var(--miss-bg); }
.list { list-style: none; margin: 0; padding: 0 16px 14px; }
.list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; }
.bar { height: 8px; background: #e9ebef; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: #8a909c; }
.spark { display: block; }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: #fff; z-index: 40;
          box-shadow: -10px 0 30px rgba(0,0,0,.12); transform: translateX(105%); transition: transform .18s ease; overflow-y: auto; }
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(17,18,20,.28); z-index: 35; display: none; }
.scrim.open { display: block; }
.drawer-in { padding: 18px 20px 30px; }
.drawer h2 { font-size: 17px; font-weight: 600; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 14px 0; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 600; }
.form { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; display: grid; gap: 8px; }
.form select, .form textarea { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
.form textarea { min-height: 70px; resize: vertical; }
.hist { list-style: none; padding: 0; margin: 14px 0 0; }
.hist li { border-left: 3px solid var(--line); padding: 4px 0 8px 10px; font-size: 13px; }
.hist .who { color: var(--muted); font-size: 12px; }
.x { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--head); color: #fff;
         padding: 10px 16px; border-radius: 8px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; }
.toast.on { opacity: 1; transform: translateX(-50%); }

.bookmarklet { display: inline-block; background: var(--brand); color: #fff !important; text-decoration: none; font-weight: 700;
               padding: 9px 16px; border-radius: 6px; cursor: grab; border: 2px dashed rgba(255,255,255,.5); }
ol.steps { margin: 6px 0 0; padding-left: 20px; }
ol.steps li { margin: 4px 0; }
code { background: #f1f2f5; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .top-in { flex-wrap: wrap; padding: 10px 16px; }
  .main { padding: 14px 16px 50px; }
  .viewers { display: none; }
}
@media print {
  .top, .filters, .no-print, .drawer, .scrim { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .shot { border: 0; padding: 0; page-break-inside: avoid; }
}
