[hidden] { display: none !important; }
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --brand: #1e3a8a; --brand-2: #2563eb; --brand-soft: #e0e7ff; --side: #0b1736; --side-text: #cbd5e1;
  --low: #16a34a; --low-bg: #dcfce7; --med: #ca8a04; --med-bg: #fef9c3; --high: #ea580c; --high-bg: #ffedd5;
  --crit: #dc2626; --crit-bg: #fee2e2; --opp: #0891b2; --opp-bg: #cffafe; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #0f172a; --border: #1f2a44; --text: #e2e8f0; --muted: #94a3b8;
    --brand: #93c5fd; --brand-2: #60a5fa; --brand-soft: #1e293b; --side: #070d1c; --side-text: #94a3b8;
    --low-bg: #052e16; --med-bg: #3b2f04; --high-bg: #431407; --crit-bg: #450a0a; --opp-bg: #083344; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0 0 .5rem; letter-spacing: -.01em; }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand-2); }
.btn-primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--crit); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 22px; cursor: pointer; padding: 4px 8px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
label { display: block; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
label > input, label > select, label > textarea { margin-top: 4px; text-transform: none; font-weight: 400; letter-spacing: 0; font-size: 14px; }
.form-error { color: var(--crit); min-height: 1.2em; margin: 4px 0; }

/* login */
.login-body { background: radial-gradient(1200px 600px at 10% 10%, #1e3a8a 0%, #0b1736 55%, #050b1c 100%); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; max-width: 1080px; margin: 0 auto; padding: 32px 16px; }
.login-brand { color: #e2e8f0; }
.login-brand h1 { font-size: 40px; color: #fff; margin-top: 18px; }
.login-brand p { font-size: 16px; color: #cbd5e1; max-width: 460px; }
.login-points { padding-left: 18px; color: #cbd5e1; } .login-points li { margin: 6px 0; }
.login-card { background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: grid; gap: 14px; }
.logo-mark { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #3b82f6, #1e3a8a); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 26px; }
.logo-mark.sm { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; gap: 24px; } .login-brand h1 { font-size: 30px; } }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: #fff; }
.brand span { display: block; font-size: 11px; color: var(--side-text); }
nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 500; margin-bottom: 2px; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(59,130,246,.18); color: #fff; }
.sidebar-foot { margin-top: auto; } .sidebar-foot .btn { color: #fff; border-color: rgba(255,255,255,.2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.project-title { font-weight: 700; font-size: 15px; }
.project-title small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.user-chip { background: var(--brand-soft); color: var(--brand); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12px; }
#menuBtn { display: none; }
.mobile-only { display: none; }
.view { padding: 24px; max-width: 1500px; width: 100%; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  #menuBtn { display: block; }
  .mobile-only { display: inline-flex; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar-right .btn { display: none; }
}

/* cards & layout */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi .v { font-size: 28px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi.alert .v { color: var(--crit); }
.two { grid-template-columns: 1.2fr 1fr; } .three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .two, .three { grid-template-columns: 1fr; } }

/* heat map */
.heat { display: grid; grid-template-columns: 28px repeat(5, 1fr); grid-template-rows: repeat(5, 56px) 24px; gap: 4px; }
.heat .cell { border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; cursor: pointer; position: relative; border: 1px solid transparent; }
.heat .cell:hover { border-color: var(--text); }
.heat .axis { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.heat .opp { position: absolute; right: 4px; bottom: 2px; font-size: 10px; background: var(--opp); color: #fff; border-radius: 6px; padding: 0 4px; }
.z-low { background: var(--low-bg); color: var(--low); } .z-med { background: var(--med-bg); color: var(--med); }
.z-high { background: var(--high-bg); color: var(--high); } .z-crit { background: var(--crit-bg); color: var(--crit); }

/* bars */
.bar-row { display: grid; grid-template-columns: 140px 1fr 32px; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }

/* tables */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--surface-2); }
td.title { min-width: 240px; font-weight: 600; } td.title .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; white-space: nowrap; }

/* pills */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); }
.pill.Low, .pill.z-low { background: var(--low-bg); color: var(--low); border-color: transparent; }
.pill.Medium, .pill.z-med { background: var(--med-bg); color: var(--med); border-color: transparent; }
.pill.High, .pill.z-high { background: var(--high-bg); color: var(--high); border-color: transparent; }
.pill.Critical, .pill.z-crit { background: var(--crit-bg); color: var(--crit); border-color: transparent; }
.pill.Opportunity { background: var(--opp-bg); color: var(--opp); border-color: transparent; }
.pill.ai { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.dev { background: var(--crit-bg); color: var(--crit); border-color: transparent; }
.pill.ok { background: var(--low-bg); color: var(--low); border-color: transparent; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.45); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(760px, 100vw); background: var(--surface); z-index: 31; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.2); }
.drawer-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 18px; flex: 1; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 0 0 14px; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
fieldset legend { font-weight: 700; padding: 0 6px; color: var(--brand); }
fieldset .full { grid-column: 1 / -1; }
@media (max-width: 640px) { fieldset { grid-template-columns: 1fr; } }
.score-box { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--surface-2); border-radius: 8px; }
.score-box .big { font-size: 26px; font-weight: 800; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0; border-top: 1px solid var(--border); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--border); padding: 0 0 12px 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); }
.timeline .when { color: var(--muted); font-size: 12px; }
.chg { font-size: 12px; color: var(--muted); }
.cmp { width: 100%; font-size: 12px; margin-top: 8px; }
.cmp td, .cmp th { padding: 6px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); }
.chat-log { display: grid; gap: 10px; margin-bottom: 12px; }
.msg { padding: 10px 12px; border-radius: 10px; white-space: pre-wrap; }
.msg.me { background: var(--brand-soft); justify-self: end; max-width: 85%; }
.msg.bot { background: var(--surface-2); border: 1px solid var(--border); max-width: 95%; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; margin-top: 10px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.legend .l1::before { background: var(--low-bg); border: 1px solid var(--low); } .legend .l2::before { background: var(--med-bg); border: 1px solid var(--med); }
.legend .l3::before { background: var(--high-bg); border: 1px solid var(--high); } .legend .l4::before { background: var(--crit-bg); border: 1px solid var(--crit); }
.legend .l5::before { background: var(--opp); }
.src-card { margin-bottom: 12px; }
.src-card header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.src-card header strong { font-size: 15px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
