:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e6e8ef;
  --line-soft: #f0f1f6;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --side: #111521;
  --side-2: #1b2133;
  --side-text: #c9cede;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --new: #0d9488;
  --new-soft: #ccfbf1;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--side); color: var(--side-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 10px 8px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 2px 14px; border-bottom: 1px solid #232a3d; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 9px;
  background: linear-gradient(135deg, #5b5bf0, #7c3aed);
  color: #fff; font-weight: 700; font-size: 20px;
  display: grid; place-items: center;
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #aeb4c6; }
.school-box { margin: 12px 4px; padding: 10px; border: 1px solid #2a3147; border-radius: 10px; background: #161b2a; }
.school-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #8a91a6; margin-bottom: 6px; }
.school-select { background: #fff; color: #111; border-radius: 6px; padding: 8px 10px; font-size: 13px; display: flex; justify-content: space-between; white-space: nowrap; overflow: hidden; }
.nav-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #737a90; padding: 10px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  text-decoration: none; font-size: 13.5px;
}
.nav a:hover { background: var(--side-2); }
.nav a.active { background: #232a52; color: #a5b4fc; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; font-size: 14px; }
.build { margin-top: auto; font-size: 10.5px; color: #5c6378; text-align: center; padding: 10px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  position: sticky; top: 0; z-index: 20;
}
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 9px; }
.season-select { border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; font-size: 13px; display: flex; gap: 40px; }
.demo-pill { font-size: 11px; font-weight: 600; color: #92400e; background: var(--amber-soft); border-radius: 999px; padding: 4px 10px; }
.user { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

.content { padding: 20px 16px 60px; max-width: 1680px; width: 100%; }

/* Page header */
.page-title { font-size: 24px; font-weight: 500; margin: 6px 0 4px; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--muted); font-size: 13px; }
.page-desc { color: var(--muted); font-size: 13px; margin: 14px 0 18px; }
.back-btn { display: inline-block; border: 1px solid var(--text); border-radius: 4px; padding: 4px 10px; font-size: 13px; text-decoration: none; background: #fff; margin: 4px 0 12px; }

/* NEW badge */
.new {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--new); background: var(--new-soft);
  border-radius: 999px; padding: 2px 7px; vertical-align: middle;
  text-transform: uppercase; white-space: nowrap;
}
.new::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--new); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.panel.is-new { box-shadow: inset 3px 0 0 var(--new); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13.5px; flex-wrap: wrap; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; font-weight: 400; }
.panel-body { padding: 14px; }
.panel-note { font-size: 12px; color: var(--muted); font-weight: 400; }
.empty { text-align: center; color: var(--muted); padding: 14px; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2.6fr) minmax(0, 1fr); }
.grid-1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* Stat cards */
.stat {
  position: relative; overflow: hidden;
  border-radius: var(--radius); color: #fff;
  padding: 14px 16px; min-height: 92px;
}
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.12); }
.stat .lbl { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; opacity: .95; display: flex; gap: 6px; align-items: center; }
.stat .val { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .foot { font-size: 11px; opacity: .9; margin-top: 4px; }
.stat .foot a { color: #fff; }
.s-indigo { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.s-violet { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.s-blue { background: linear-gradient(135deg, #1d8fe0, #38bdf8); }
.s-green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.s-red { background: linear-gradient(135deg, #dc2626, #f43f5e); }
.s-orange { background: linear-gradient(135deg, #ea8a14, #f59e0b); }
.s-teal { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.stat .new { background: rgba(255,255,255,.22); color: #fff; }
.stat .new::before { background: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:nth-child(even) td { background: #fbfbfd; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft) !important; }
th.new-col { color: var(--new); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* Pills */
.pill { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.p-green { background: var(--green-soft); color: #166534; }
.p-solid-green { background: #22c55e; color: #fff; }
.p-amber { background: var(--amber-soft); color: #92400e; }
.p-red { background: var(--red-soft); color: #991b1b; }
.p-gray { background: #eef0f4; color: #4b5563; }
.p-indigo { background: var(--accent-soft); color: #3730a3; }

/* Progress */
.progress { height: 7px; background: #eceef4; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s; }
.summary-nums { display: flex; gap: 40px; margin-bottom: 14px; flex-wrap: wrap; }
.summary-nums .k { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.summary-nums .v { font-size: 20px; font-weight: 700; margin-top: 3px; }
.prog-label { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }

/* Live banner */
.live-banner { background: #c9e9d8; border: 1px solid #5bbf8a; color: #14532d; border-radius: 6px; padding: 12px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 0 rgba(22,163,74,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.6); } 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

.select { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 180px; }
.input { width: 100%; border: 1px solid var(--line); background: #fbfbfd; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Feed */
.feed { max-height: 430px; overflow-y: auto; }
.feed-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; cursor: pointer; }
.feed-row:hover { background: var(--accent-soft); }
.feed-row.fresh { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #d1fae5; } to { background: transparent; } }
.feed-row.blocked.fresh { animation: flashred 1.6s ease-out; }
@keyframes flashred { from { background: #fee2e2; } to { background: transparent; } }
.feed-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-main .t { font-weight: 600; }
.feed-main .s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* Room verification */
.verify-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.vbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.vbox .k { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.vbox .v { font-size: 18px; font-weight: 700; margin-top: 4px; }
.vbox.ok { border-color: #86efac; background: #f0fdf4; }
.vbox.bad { border-color: #fca5a5; background: #fef2f2; }

/* Floors */
.floors { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.floor { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.floor .fl { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.floor.closed { border-color: #86efac; background: #f0fdf4; }
.floor.in-progress { border-color: #fcd34d; background: #fffbeb; }
.floor .meta { color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* Scan dots (baseline P—W—D) */
.scans { display: inline-flex; align-items: center; gap: 0; }
.dot { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; background: #f0f1f5; color: #9ca3af; }
.dot.on { background: #22c55e; color: #fff; }
.dot.on.blk { background: #ef4444; }
.dash { width: 14px; height: 2px; background: #e5e7eb; }
.dash.on { background: #22c55e; }

/* Timeline */
.tl { padding: 6px 14px; }
.tl-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; padding: 12px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 36px; bottom: -12px; width: 2px; background: #e5e7eb; }
.tl-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; background: #166534; z-index: 1; }
.tl-ic.prog { background: var(--accent); }
.tl-ic.up { background: #d1d5db; }
.tl-name { font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.tl-date { font-size: 11.5px; color: var(--muted); margin: 3px 0; }
.tl-desc { font-size: 12.5px; }
.tl-status { font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; height: fit-content; background: #fafafa; }

/* Bars */
.bars { padding: 12px 14px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 8px; align-items: center; margin: 5px 0; font-size: 11.5px; }
.bar-row .nm { text-align: right; color: #4b5563; }
.bar-track { height: 10px; background: #f0f1f5; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: #6d4fe8; border-radius: 99px; }
.bar-row .n { font-size: 11px; font-weight: 600; }

/* Attention */
.att-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; text-decoration: none; }
.att-row:hover { background: var(--accent-soft); }
.att-row .go { margin-left: auto; color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Profile */
.profile-head { display: flex; gap: 14px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.big-av { width: 52px; height: 52px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 19px; font-weight: 700; display: grid; place-items: center; }
.profile-name { font-size: 24px; }
.profile-meta { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 13px; }
.idrow { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0 16px 14px; font-size: 12.5px; }
.idrow .k { color: var(--muted); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(17,21,33,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: #fff; z-index: 50; transform: translateX(100%); transition: transform .25s; overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-head .x { margin-left: auto; border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); }
.drawer-sec { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.drawer-sec h4 { margin: 0 0 10px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.evidence { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
.door { position: relative; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.door svg { display: block; width: 100%; height: auto; }
.door-tag { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(17,21,33,.78); color: #fff; font-size: 9px; padding: 4px 6px; letter-spacing: .03em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12.5px; }
.kv .k { color: var(--muted); }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 7px 0; position: relative; }
.events li:not(:last-child)::before { content: ""; position: absolute; left: 10px; top: 28px; bottom: -6px; width: 2px; background: #e5e7eb; }
.ev-ic { width: 22px; height: 22px; border-radius: 50%; background: #22c55e; color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; z-index: 1; }
.ev-ic.blk { background: #ef4444; }
.ev-ic.pend { background: #e5e7eb; color: #6b7280; }
.ev-t { font-weight: 600; font-size: 12.5px; }
.ev-s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.callout { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45; }
.callout.red { background: var(--red-soft); color: #7f1d1d; }
.callout.teal { background: #f0fdfa; color: #134e4a; border: 1px solid #99f6e4; }
.callout.gray { background: #f5f6f9; color: #374151; }

/* Pager */
.pager { display: flex; gap: 6px; justify-content: center; padding: 12px; flex-wrap: wrap; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 5px; font-size: 12px; }
.pager button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Modal-ish form inside drawer */
.form label { display: block; font-size: 12px; font-weight: 600; margin: 10px 0 4px; }
.form textarea { min-height: 80px; resize: vertical; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(30px); background: #111521; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: all .25s; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }

.chart svg { display: block; width: 100%; height: auto; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-1, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; z-index: 45; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .season-select { gap: 10px; }
  .user > div:last-child { display: none; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .verify-grid { grid-template-columns: 1fr; }
  .evidence { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 56px; }
  .demo-pill { display: none; }
}
.dot { font-size: 9.5px; }
.scan-key { display: block; font-size: 9px; font-weight: 500; letter-spacing: .02em; text-transform: none; color: var(--faint); margin-top: 2px; }
.dropzone { display: block; border: 2px dashed #c7cbe0; border-radius: 10px; padding: 22px 16px; text-align: center; cursor: pointer; background: #fafbff; transition: all .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.th-desc { display: block; font-size: 10px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--faint); margin-top: 2px; white-space: normal; }
