:root {
  --bg: #f1f5f9; --panel: #ffffff; --ink: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --head: #0b1220; --head-ink: #e2e8f0;
  --green: #16a34a; --amber: #d97706; --orange: #ea580c; --red: #dc2626;
  --blue: #2563eb;
  --green-bg: #dcfce7; --amber-bg: #fef3c7; --orange-bg: #ffedd5;
  --red-bg: #fee2e2; --gray-bg: #e2e8f0; --blue-bg: #dbeafe;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; font-size: 13px; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--blue); }
.hidden { display: none !important; }

.app-header { background: var(--head); color: var(--head-ink); display: flex; align-items: center;
  gap: 16px; padding: 10px 18px; position: sticky; top: 0; z-index: 20; }
.app-header .brand { font-weight: 700; letter-spacing: .3px; font-size: 15px; }
.app-header .brand small { color: #94a3b8; font-weight: 400; margin-left: 8px; }
.app-header .tabs { display: flex; gap: 4px; margin-left: 12px; }
.app-header .tab { background: transparent; border: 0; color: #94a3b8; padding: 6px 12px; border-radius: 6px; font-weight: 600; }
.app-header .tab.active { background: #1e293b; color: #fff; }
.app-header .spacer { flex: 1; }
.app-header .who { display: flex; align-items: center; gap: 8px; color: #cbd5e1; }
.app-header .who img { width: 26px; height: 26px; border-radius: 50%; }
.app-header .updated { color: #64748b; font-size: 11px; margin-right: 8px; }
.app-header .logout { background: #1e293b; color: #cbd5e1; border: 1px solid #334155; border-radius: 6px; padding: 5px 10px; }

.wrap { padding: 14px 18px; max-width: 1500px; margin: 0 auto; }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.metric .n { font-size: 22px; font-weight: 700; }
.metric .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.badges .label { color: var(--muted); font-size: 11px; margin-right: 4px; }
.badge { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px;
  font-weight: 600; font-size: 11px; display: inline-flex; gap: 6px; align-items: center; }
.badge.active { outline: 2px solid var(--blue); }
.badge .c { color: var(--muted); }

.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; background: #fff; }
.filters input[type=search] { min-width: 240px; }
.filters .clear { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; color: var(--muted); }
.filters .grow { flex: 1; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tbl-scroll { overflow-x: auto; }
table.q { width: 100%; border-collapse: collapse; }
table.q th { text-align: left; background: #f8fafc; color: #475569; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.q td { padding: 8px 10px; border-bottom: 1px solid #eef2f7; white-space: nowrap; }
table.q tr { cursor: pointer; }
table.q tr:hover td { background: #f8fafc; }
table.q tr.crit td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.uid, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #334155; }
.name-cell { display: flex; align-items: center; gap: 8px; }

.chip { border-radius: 999px; padding: 2px 8px; font-weight: 700; font-size: 10.5px; letter-spacing: .3px; }
.chip.LOW { background: var(--green-bg); color: #166534; }
.chip.MEDIUM { background: var(--amber-bg); color: #92400e; }
.chip.HIGH { background: var(--orange-bg); color: #9a3412; }
.chip.CRITICAL { background: var(--red-bg); color: #991b1b; }
.chip.UNSCORED { background: var(--gray-bg); color: #475569; }
.status-chip { border-radius: 6px; padding: 2px 8px; font-weight: 600; font-size: 11px; text-transform: capitalize; }
.status-chip.pending { background: #e2e8f0; color: #334155; }
.status-chip.under_review { background: var(--blue-bg); color: #1e40af; }
.status-chip.blocked { background: var(--red-bg); color: #991b1b; }
.status-chip.cleared { background: var(--green-bg); color: #166534; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; font-weight: 600; font-size: 12px; color: var(--ink); text-decoration: none; display: inline-block; }
.btn.sm { padding: 3px 8px; font-size: 11px; }
.btn.block { background: var(--red); color: #fff; border-color: var(--red); }
.btn.clear { background: var(--green); color: #fff; border-color: var(--green); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: 6px; }

.drawer-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw; background: #fff;
  z-index: 41; box-shadow: -8px 0 30px rgba(0,0,0,.15); display: flex; flex-direction: column; }
.drawer header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer .body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.drawer .x { border: 0; background: transparent; font-size: 20px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 8px 0; }
.kv .k { color: var(--muted); }
.namebox { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; background: #fafafa; }
.namebox .big { font-size: 26px; font-weight: 800; }
.timeline { list-style: none; padding: 0; margin: 8px 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 12px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.timeline .t { color: var(--muted); font-size: 11px; }
.drawer .actions { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 10px; width: 440px; max-width: 92vw; padding: 18px; }
.modal h3 { margin: 0 0 6px; }
.modal textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-family: inherit; font-size: 13px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.warn { color: var(--red); font-size: 12px; }
.pending-tag { color: var(--amber); font-size: 11px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--head); }
.login .card { background: #fff; border-radius: 14px; padding: 34px; width: 380px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login h1 { margin: 6px 0; font-size: 20px; }
.login p { color: var(--muted); margin: 0 0 20px; }
.login .dev { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; text-align: left; }
.login .dev input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 6px 0; }
.login .err { color: var(--red); margin-top: 12px; font-size: 12px; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.spin { color: var(--muted); padding: 20px; text-align: center; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0b1220; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 80; }
