:root {
  --bg:        #0f1117;
  --surface:   #181c27;
  --surface2:  #1e2335;
  --border:    #2a2f45;
  --text:      #d6daf0;
  --muted:     #7a82a0;
  --accent:    #4f8ef7;
  --crit:      #ef4444;
  --high:      #f97316;
  --med:       #eab308;
  --low:       #3b82f6;
  --enh:       #8b5cf6;
  --vce:       #ec4899;
  --ux:        #06b6d4;
  --ok:        #22c55e;
  --radius:    6px;
  --font:      'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; min-height: 100vh; }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }
a { color: var(--accent); }

/* ── HEADER ── */
header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; gap: 16px; }
header .logo { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: -.3px; white-space: nowrap; }
header .sub  { color: var(--muted); font-size: 12px; }
header .spacer { flex: 1; }
header .user { color: var(--muted); font-size: 12px; text-align: right; line-height: 1.3; }
header .user strong { color: var(--text); font-weight: 600; }
header form { display: inline; }
.btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 6px 14px; cursor: pointer; font-size: 12px; font-family: var(--font); transition: border-color .15s, color .15s, background .15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3a7de0; color: #fff; }
.btn.danger:hover { border-color: var(--crit); color: var(--crit); }
.btn.sm { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 4px; cursor: pointer; padding: 2px 6px; font-size: 12px; line-height: 1.4; }
.icon-btn:hover { color: var(--accent); border-color: var(--border); background: var(--surface); }
.icon-btn.del:hover { color: var(--crit); }

/* ── KPI STRIP ── */
.kpi-strip { display: flex; gap: 10px; padding: 16px 24px; flex-wrap: wrap; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; flex: 1; min-width: 110px; text-align: center; }
.kpi .num  { font-size: 26px; font-weight: 700; line-height: 1; }
.kpi .lbl  { color: var(--muted); font-size: 11px; margin-top: 4px; text-transform: uppercase; letter-spacing: .6px; }
.kpi.crit  .num { color: var(--crit); }
.kpi.high  .num { color: var(--high); }
.kpi.med   .num { color: var(--med); }
.kpi.low   .num { color: var(--low); }
.kpi.enh   .num { color: var(--enh); }
.kpi.total .num { color: var(--accent); }
.kpi.sess  .num { color: var(--ok); }
.kpi.vce   .num { color: var(--vce); }
.kpi.ux    .num { color: var(--ux); }

/* ── LAYOUT ── */
.shell { display: flex; height: calc(100vh - 160px); min-height: 400px; }
nav { width: 180px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 0; }
nav a { display: flex; align-items: center; gap: 8px; padding: 9px 18px; cursor: pointer; color: var(--muted); border-left: 3px solid transparent; font-size: 13px; text-decoration: none; transition: color .15s, border-color .15s; }
nav a:hover, nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--surface2); }
nav a .ico { font-size: 15px; width: 18px; text-align: center; }
nav a .count:empty { display: none; }
nav a .count { margin-left: auto; font-size: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; color: var(--muted); }
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── PANELS ── */
.panel { display: none; }
.panel.active { display: block; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--text); }
h3 { font-size: 13px; font-weight: 600; margin: 20px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .spacer { flex: 1; }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 6px 10px; font-size: 12px; outline: none; font-family: var(--font); }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }
.filter-bar input { flex: 1; min-width: 160px; }
.filter-bar .result-count { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ── TABLES ── */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--surface2); padding: 9px 12px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--accent); }
thead th .sort-arrow { margin-left: 4px; opacity: .35; font-size: 9px; }
thead th.sorted { color: var(--text); }
thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 8px 12px; vertical-align: middle; }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
td.wrap { min-width: 220px; line-height: 1.45; }
.empty-row td { text-align: center; color: var(--muted); padding: 24px; font-style: italic; }
.id-code { font-size: 11px; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.CRIT { background: rgba(239,68,68,.15);  color: var(--crit); }
.badge.HIGH { background: rgba(249,115,22,.15); color: var(--high); }
.badge.MED  { background: rgba(234,179,8,.15);  color: var(--med); }
.badge.LOW  { background: rgba(59,130,246,.15); color: var(--low); }
.badge.ENH  { background: rgba(139,92,246,.15); color: var(--enh); }
.badge.VCE  { background: rgba(236,72,153,.15); color: var(--vce); }
.badge.UX   { background: rgba(6,182,212,.15);  color: var(--ux); }
.badge.open     { background: rgba(239,68,68,.1);   color: var(--crit); }
.badge.resolved { background: rgba(34,197,94,.1);   color: var(--ok); }
.badge.com  { background: rgba(79,142,247,.1);  color: var(--accent); }
.badge.local{ background: rgba(139,92,246,.1);  color: var(--enh); }
.badge.both { background: rgba(234,179,8,.1);   color: var(--med); }
.badge.clickable { cursor: pointer; }
.badge.clickable:hover { outline: 1px solid currentColor; }

/* ── PARITY TABLE ── */
.parity-cell { text-align: center; width: 150px; }
.parity-btn { background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 2px 10px; font-size: 15px; cursor: pointer; transition: border-color .15s, background .15s; }
.parity-btn:hover { border-color: var(--border); background: var(--surface); }
.parity-btn:disabled { cursor: default; }
.parity-group td { background: var(--surface2); font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 12px; }
.gap-action { color: var(--muted); font-size: 11px; cursor: text; min-height: 18px; border-radius: 4px; padding: 2px 4px; }
.gap-action:hover { background: var(--surface); }
.gap-input { width: 100%; background: var(--surface2); border: 1px solid var(--accent); color: var(--text); border-radius: 4px; padding: 4px 6px; font-size: 12px; font-family: var(--font); outline: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }

/* ── VOICE CAD ── */
.vc-status { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; display: flex; gap: 24px; flex-wrap: wrap; position: relative; }
.vc-stat { flex: 1; min-width: 140px; }
.vc-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.vc-val   { font-size: 14px; font-weight: 600; }
.vc-val.no  { color: var(--crit); }
.vc-val.yes { color: var(--ok); }
.vc-val.partial { color: var(--med); }
.vc-edit { position: absolute; top: 10px; right: 10px; }

/* ── SESSION HISTORY ── */
.session-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.session-row .s-num  { font-size: 20px; font-weight: 700; color: var(--accent); min-width: 36px; }
.session-row .s-date { color: var(--muted); font-size: 12px; }
.session-row .s-scope{ flex: 1; min-width: 200px; }
.session-row .s-stats{ display: flex; gap: 16px; }
.s-stat { text-align: center; min-width: 54px; }
.s-stat .n { font-weight: 700; }
.s-stat .l { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }

/* ── FORMS ── */
.add-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.add-form h3 { margin-top: 0; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; margin-bottom: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field label .req { color: var(--crit); margin-left: 2px; }
.field input, .field select, .field textarea, .form-row input, .form-row select, .form-row textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius);
  padding: 7px 10px; font-size: 12px; outline: none; font-family: var(--font); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 60px; line-height: 1.45; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; align-items: center; }
.form-msg { font-size: 12px; color: var(--muted); }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--crit); }

/* ── NOTICE ── */
.notice { background: rgba(79,142,247,.08); border: 1px solid rgba(79,142,247,.25); border-radius: var(--radius); padding: 10px 14px; color: var(--muted); font-size: 12px; margin-bottom: 16px; line-height: 1.5; }
.notice strong { color: var(--accent); }

/* ── OVERVIEW CARDS ── */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.ov-card h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; font-weight: 600; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bar-label { width: 110px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.bar-fill   { height: 100%; border-radius: 3px; transition: width .4s ease; }
.bar-count  { width: 28px; text-align: right; font-size: 12px; font-weight: 600; }
.no-data { color: var(--muted); font-size: 12px; padding: 4px 0; }
.vc-ov-item { margin-bottom: 8px; }

/* ── MODAL ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,7,12,.7); display: none; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 14px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); align-items: center; }
.modal-foot .form-msg { margin-right: auto; }

/* ── TOAST ── */
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: var(--radius); font-size: 12px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 60; max-width: 360px; }
#toast.show { opacity: 1; transform: none; }
#toast.err { border-color: var(--crit); color: var(--crit); }
#toast.ok { border-color: var(--ok); }

/* ── AUTH PAGES ── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
  background: radial-gradient(ellipse at top, rgba(79,142,247,.08), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 32px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .logo { font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: -.3px; text-align: center; }
.auth-card .sub { color: var(--muted); font-size: 12px; text-align: center; margin: 4px 0 24px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .field input { padding: 10px 12px; font-size: 13px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px 14px; font-size: 13px; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn.google { background: #fff; color: #1f1f1f; border-color: #fff; font-weight: 600; }
.btn.google:hover { background: #f1f3f4; color: #1f1f1f; border-color: #f1f3f4; }
.btn.google svg { width: 18px; height: 18px; }
.auth-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: var(--crit); border-radius: var(--radius); padding: 9px 12px; font-size: 12px; margin-bottom: 16px; display: none; }
.auth-foot { color: var(--muted); font-size: 11px; text-align: center; margin-top: 22px; }

/* ── RESPONSIVE ── */
@media (max-width: 760px) {
  .shell { flex-direction: column; height: auto; }
  nav { width: 100%; display: flex; overflow-x: auto; padding: 0; border-right: none; border-bottom: 1px solid var(--border); }
  nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  nav a:hover, nav a.active { border-bottom-color: var(--accent); }
  nav a .count { display: none; }
  header { flex-wrap: wrap; }
  .form-grid .span-2 { grid-column: 1 / -1; }
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
