:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface-1: #15181d;
  --surface-2: #1c2027;
  --border: #2a2f38;
  --grid: #262a31;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c85;
  --accent: #3987e5;
  --sev-kritis: #d03b3b;
  --sev-tinggi: #ec835a;
  --sev-sedang: #fab219;
  --sev-rendah: #6da7ec;
  --sev-info: #8d8c85;
  --good: #0ca30c;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
h2 { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); margin: 16px 0 8px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.mono { font-family: var(--mono); }
button, .button, select, input {
  font: inherit; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.ghost, .button.ghost { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-1); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); display: inline-block; }
.brand-dot.on { background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.6);} 70% { box-shadow: 0 0 0 8px rgba(12,163,12,0);} 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0);} }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { background: transparent; border-color: transparent; color: var(--text-secondary); }
.tabs button[aria-selected="true"] { background: var(--surface-2); border-color: var(--border); color: var(--text-primary); }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.badge { background: var(--sev-kritis); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
.badge:empty { display: none; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.kpi { background: var(--surface-1); padding: 10px 16px; display: flex; flex-direction: column; }
.kpi-label { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.kpi-val { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }

.sev-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.sev-dot.kritis { background: var(--sev-kritis); } .sev-dot.tinggi { background: var(--sev-tinggi); }
.sev-dot.sedang { background: var(--sev-sedang); } .sev-dot.rendah { background: var(--sev-rendah); } .sev-dot.info { background: var(--sev-info); }
.sev { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.sev.kritis { color: var(--sev-kritis); } .sev.tinggi { color: var(--sev-tinggi); } .sev.sedang { color: var(--sev-sedang); }
.sev.rendah { color: var(--sev-rendah); } .sev.info { color: var(--sev-info); }

main { flex: 1; display: flex; min-height: 0; }
.tab-panel { flex: 1; min-width: 0; padding: 16px; }
#tab-live { padding: 0; }

/* live */
.live-grid { display: grid; grid-template-columns: 320px 1fr 340px; height: calc(100vh - 128px); min-height: 560px; }
.panel { background: var(--surface-1); padding: 16px; overflow-y: auto; }
.feed-panel { border-right: 1px solid var(--border); }
.side-panel { border-left: 1px solid var(--border); }
.globe-wrap { position: relative; overflow: hidden; background: #000; }
#globe { position: absolute; inset: 0; }
.globe-legend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 14px; background: rgba(13,15,18,.8); padding: 6px 12px; border-radius: var(--radius); font-size: 12px; flex-wrap: wrap; }
.globe-legend span { display: flex; align-items: center; gap: 6px; }
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.globe-toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(208,59,59,.92); color: #fff; padding: 8px 16px; border-radius: var(--radius); font-weight: 600; max-width: 90%; text-align: center; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 10px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; margin-bottom: 4px; background: var(--surface-2); }
.feed li:hover { border-color: var(--accent); }
.feed li.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #3a2a1a; } to { background: var(--surface-2); } }
.feed .row1 { display: flex; justify-content: space-between; gap: 8px; }
.feed .row2 { font-size: 13px; margin-top: 2px; }
.feed .row3 { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* bars (horizontal, single series) */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12px; cursor: default; }
.bar-row .lbl { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .val { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }
.bar-row.clickable { cursor: pointer; } .bar-row.clickable:hover .lbl { color: var(--text-primary); }

.chart { height: 150px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis { fill: var(--text-muted); font-size: 10px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-legend { display: flex; gap: 10px; font-size: 11px; color: var(--text-secondary); margin-top: 4px; flex-wrap: wrap; }
.chart-legend span { display: flex; align-items: center; gap: 4px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #23272f; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12px; max-width: 320px; box-shadow: 0 4px 16px rgba(0,0,0,.5); }

/* log */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { min-width: 220px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-secondary); background: var(--surface-1); position: sticky; top: 0; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr { cursor: pointer; } .tbl tbody tr:hover { background: var(--surface-2); }
.tbl .path { font-family: var(--mono); font-size: 12px; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; }

/* vuln */
.vuln-summary { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.vuln-summary .chip { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; display: flex; gap: 8px; align-items: center; }
.vuln-summary .chip b { font-size: 18px; }
.vuln-list { display: flex; flex-direction: column; gap: 8px; }
.vuln { background: var(--surface-1); border: 1px solid var(--border); border-left: 4px solid var(--sev-info); border-radius: var(--radius); padding: 10px 14px; }
.vuln.kritis { border-left-color: var(--sev-kritis); } .vuln.tinggi { border-left-color: var(--sev-tinggi); }
.vuln.sedang { border-left-color: var(--sev-sedang); } .vuln.rendah { border-left-color: var(--sev-rendah); }
.vuln summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none; }
.vuln summary::-webkit-details-marker { display: none; }
.vuln .title { font-weight: 600; }
.vuln .target { color: var(--text-muted); font-size: 12px; }
.vuln .cat { font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; }
.vuln pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--text-secondary); margin: 8px 0; }
.vuln .rec { background: var(--surface-2); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.vuln .rec::before { content: "Rekomendasi: "; font-weight: 600; color: var(--good); }

/* kb */
.kb-intro { max-width: 900px; }
.kb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.kb { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kb h3 { margin: 0 0 6px; font-size: 15px; }
.kb p { margin: 4px 0; color: var(--text-secondary); font-size: 13px; }
.kb ol { margin: 8px 0 0; padding-left: 20px; font-size: 13px; }
.kb li { margin-bottom: 4px; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-inner { width: min(560px, 100%); height: 100%; background: var(--surface-1); border-left: 1px solid var(--border); overflow-y: auto; padding: 20px; position: relative; }
.drawer .close { position: absolute; top: 12px; right: 12px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; margin: 12px 0; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; word-break: break-all; }
.code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 6px; word-break: break-all; white-space: pre-wrap; }
.warnbox { background: rgba(208,59,59,.15); border: 1px solid var(--sev-kritis); border-radius: 6px; padding: 8px 10px; margin: 10px 0; font-size: 13px; }
.howto { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-top: 12px; }
.howto code { font-family: var(--mono); font-size: 12px; background: #0d0f12; padding: 1px 4px; border-radius: 3px; }

/* login */
.login-page { align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #16202e, var(--bg)); }
.login-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: min(380px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.login-card button { background: var(--accent); border-color: var(--accent); font-weight: 600; padding: 9px; }
.err { color: var(--sev-kritis); min-height: 1em; margin: 0; }

@media (max-width: 1200px) {
  .live-grid { grid-template-columns: 1fr; height: auto; }
  .globe-wrap { height: 60vh; order: -1; }
  .feed-panel, .side-panel { border: 0; border-top: 1px solid var(--border); max-height: 520px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-val { font-size: 20px; }
  .who { margin-left: 0; }
  .kb-list { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
