/* Arah desain: DESIGN.md. Sidebar + isi; satu aksen hijau (bisa ditindak); status = pil bertitik; radius 6/8/12. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --sidebar: #ffffff;
  --hover: #f0f2f4;
  --text: #111827;
  --text-2: #374151;
  --muted: #5f6774;
  --line: #e4e7eb;
  --field: #8a93a3;
  --accent: #0f7a40;
  --accent-hover: #0b6334;
  --accent-weak: #e7f4ec;
  --accent-text: #ffffff;
  --ok: #0f7a40;
  --ok-bg: #e7f4ec;
  --warn: #8a5300;
  --warn-bg: #fff4dc;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --code: #f0f2f4;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-pop: 0 16px 40px rgb(16 24 40 / 0.2);
  accent-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #19202a;
    --sidebar: #11161d;
    --hover: #1e2631;
    --text: #e6eaf0;
    --text-2: #c3cad4;
    --muted: #8f9aa7;
    --line: #252d38;
    --field: #5f6a7a;
    --accent: #2fb36e;
    --accent-hover: #46c483;
    --accent-weak: #13291d;
    --accent-text: #04140b;
    --ok: #5fd896;
    --ok-bg: #12291c;
    --warn: #f2c063;
    --warn-bg: #2d2412;
    --bad: #ff958a;
    --bad-bg: #331717;
    --code: #1f2731;
    --shadow: none;
    --shadow-pop: 0 16px 40px rgb(0 0 0 / 0.55);
  }
}

/* ---------- dasar ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 0.9375rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1rem; line-height: 1.35; font-weight: 600; margin: 0; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--code); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; word-break: break-all; }
td code { word-break: normal; white-space: nowrap; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.bad-text { color: var(--bad); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a[href], button:not(:disabled), select, label.check, input[type=checkbox] { cursor: pointer; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow-pop); }
.skip:focus { left: 12px; }

/* ---------- kerangka: sidebar + isi ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 12px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 8px; }
.only-mobile { display: none !important; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none; min-height: 40px; white-space: nowrap; }
.brand:hover { color: var(--text); }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.mark .i { width: 19px; height: 19px; }
.nav-label { margin: 18px 10px 6px; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; margin-bottom: 2px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav-item .i { color: var(--muted); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item:active { background: var(--line); }
.nav-item[aria-current=page] { background: var(--accent-weak); color: var(--accent); font-weight: 650; }
.nav-item[aria-current=page] .i { color: var(--accent); }
.count { margin-left: auto; font-size: 0.75rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.bad, .count.warn { padding: 1px 8px; border-radius: 999px; }
.count.bad { color: var(--bad); background: var(--bad-bg); }
.count.warn { color: var(--warn); background: var(--warn-bg); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.health { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 500; color: var(--text-2); padding: 7px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.health.ok::before { background: var(--ok); }
.health.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.health.bad::before { background: var(--bad); }
.health.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.health.warn::before { background: var(--warn); }
.me { display: flex; align-items: center; gap: 10px; padding-left: 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--hover); color: var(--text-2); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex: none; text-transform: uppercase; }
.me-name { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
.me-name small { color: var(--muted); font-weight: 400; font-size: 0.78rem; }
.me form { margin-left: auto; }
.main { padding: 32px 40px 64px; max-width: 1200px; width: 100%; }
.backdrop { display: none; }

/* ---------- kepala halaman & bagian ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title { min-width: 0; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.crumb { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.875rem; font-weight: 500; min-height: 32px; margin: 0 0 4px -4px; padding-right: 6px; }
.crumb:hover { color: var(--text); }
.crumb .i { width: 16px; height: 16px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.section-head a { font-size: 0.875rem; font-weight: 500; }

/* ---------- kartu & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.card + .card, .split + .card, div + form.card { margin-top: 16px; }
.grid > .card + .card, .split > .card + .card { margin-top: 0; }
.card-pad { padding: 20px; }
.card-pad > h2 { margin-bottom: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-body { padding: 20px; }
.table-card { overflow: hidden; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }
.split { display: grid; gap: 16px 24px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.split.aside { grid-template-columns: minmax(0, 1fr) 320px; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.card-pad .stack { margin-top: 14px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; min-width: 0; }
.sub-line { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.empty { color: var(--muted); padding: 28px 20px; text-align: center; margin: 0; }

/* ---------- banner kesehatan & kartu nomor ---------- */
.banner { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; }
.banner > div { flex: 1; min-width: 0; }
.banner h2 { font-size: 1rem; }
.banner p { margin: 2px 0 0; color: var(--text-2); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner li { margin: 2px 0; }
.b-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--hover); color: var(--text-2); }
.banner.ok .b-icon { background: var(--ok-bg); color: var(--ok); }
.banner.warn .b-icon { background: var(--warn-bg); color: var(--warn); }
.banner.bad { border-color: var(--bad); background: var(--bad-bg); }
.banner.bad .b-icon { background: var(--surface); color: var(--bad); }
.banner.bad h2 { color: var(--bad); }
.banner.bad a { color: var(--text); font-weight: 600; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-bg); }
.banner.warn .b-icon { background: var(--surface); }
.banner.warn h2 { color: var(--warn); }
.banner.warn a { color: var(--text); font-weight: 600; }

.section-head + .grid { margin-bottom: 0; }
a.num-card { display: block; padding: 18px 20px; color: var(--text); text-decoration: none; transition: border-color 0.15s; }
a.num-card:hover { border-color: var(--field); }
a.num-card.bad { border-color: var(--bad); }
a.num-card.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.num-top { display: flex; gap: 12px; align-items: flex-start; }
.num-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-weak); color: var(--accent); display: grid; place-items: center; flex: none; }
.num-card.bad .num-icon { background: var(--bad-bg); color: var(--bad); }
.num-card.warn .num-icon { background: var(--warn-bg); color: var(--warn); }
.num-title { min-width: 0; flex: 1; }
.num-title b { display: block; font-weight: 600; }
.num-title > span { display: block; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.num-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.stat-v { display: block; font-size: 1.35rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-l { display: block; font-size: 0.8rem; color: var(--muted); }
.num-alert { margin: 14px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); font-size: 0.85rem; font-weight: 500; }

/* ---------- status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle; letter-spacing: 0; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.tag { display: inline-block; font-size: 0.78rem; color: var(--text-2); background: var(--hover); border-radius: 6px; padding: 1px 7px; margin: 2px 4px 2px 0; white-space: nowrap; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin: 0 0 20px; border: 1px solid transparent; font-weight: 500; }
.flash .i { margin-top: 2px; }
.flash a { color: inherit; font-weight: 650; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- tabel ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 10px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
table.compact td { padding: 9px 20px; font-size: 0.9rem; }
a.row-link { font-weight: 600; color: var(--text); text-decoration: none; }
a.row-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- kejadian ---------- */
.events { list-style: none; margin: 0; padding: 4px 0; }
.events li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 9px 20px; font-size: 0.875rem; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.events li > span { overflow-wrap: anywhere; }

/* ---------- form ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; font-weight: 500; color: var(--text-2); }
.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
label > .hint { margin-top: -4px; }
input, select { font: inherit; font-size: 0.9375rem; color: var(--text); background: var(--surface); border: 1px solid var(--field); border-radius: 8px; padding: 0 12px; min-height: 40px; width: 100%; min-width: 0; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; flex: none; }
::placeholder { color: var(--muted); opacity: 1; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; color: var(--text); min-height: 32px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: 0.875rem; font-weight: 500; color: var(--text-2); padding: 0; margin-bottom: 4px; }
.checks { display: flex; flex-direction: column; }
.checks.inline { flex-direction: row; flex-wrap: wrap; gap: 0 22px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: end; }
.fsec { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 16px 32px; padding: 24px; border-bottom: 1px solid var(--line); }
.fsec:last-child { border-bottom: 0; }
.fsec-desc h2 { font-size: 0.95rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fsec-desc p { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
.fsec-body { display: flex; flex-direction: column; gap: 14px; max-width: 580px; min-width: 0; }
.form-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.fsec + .form-foot { margin-top: -1px; }
.danger-zone .fsec-desc h2 { color: var(--bad); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 14px 20px; }
.filter-bar label:not(.check) { min-width: 180px; }
.filter-bar label.check { min-height: 40px; }
.filter-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* ---------- tombol ---------- */
button, .button { font: inherit; font-size: 0.9rem; font-weight: 600; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button .i, .button .i { width: 17px; height: 17px; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--field); }
button.secondary:hover, .button.secondary:hover { background: var(--hover); color: var(--text); border-color: var(--field); }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad-bg); color: var(--bad); }
button.icon-btn { width: 40px; height: 40px; min-height: 0; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); }
button.icon-btn:hover { background: var(--hover); color: var(--text); border-color: transparent; }
button.icon-btn .i { width: 20px; height: 20px; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.55; }

/* ---------- QR, 2FA, salin ---------- */
.qr { display: block; background: #fff; padding: 10px; border-radius: 10px; margin: 12px 0 0; max-width: 100%; height: auto; border: 1px solid var(--line); }
.twofa { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.twofa img { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.secret { letter-spacing: 1px; }
.copy { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.copy code { padding: 9px 12px; font-size: 0.95rem; }
.key-card { max-width: 720px; }

/* ---------- login & setup ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: stretch; }
.auth > .brand { align-self: center; margin-bottom: 20px; font-size: 1.1rem; }
.auth-card { padding: 28px; }
.auth-card h1 { font-size: 1.3rem; }
.auth-card .sub { color: var(--muted); margin: 6px 0 20px; }
.auth-card button { width: 100%; min-height: 44px; margin-top: 4px; }

/* ---------- layar sedang ---------- */
@media (max-width: 1180px) {
  .split, .split.aside { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- HP & tablet kecil: bar atas + laci menu ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; min-height: 56px; background: var(--sidebar); border-bottom: 1px solid var(--line); }
  .topbar .health { margin-left: auto; padding: 4px 10px; font-size: 0.78rem; white-space: nowrap; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw); height: 100%; transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; box-shadow: var(--shadow-pop); }
  body.menu-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; }
  body.menu-open { overflow: hidden; }
  .only-mobile { display: inline-grid !important; }
  .backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.45); }
  .main { padding: 20px 16px 56px; }
  h1 { font-size: 1.3rem; }
  .page-head { align-items: flex-start; margin-bottom: 18px; }
  .split.even { grid-template-columns: minmax(0, 1fr); }
  .fsec { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 18px 16px; }
  .form-foot { padding: 12px 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dd { margin-bottom: 8px; }
  .filter-bar { padding: 14px 16px; }
  .filter-bar label:not(.check) { min-width: 0; flex: 1 1 140px; }
  .filter-actions { margin-left: 0; }
  .events li { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px 16px; }
  /* Tabel jadi baris berlabel: tidak ada geser ke samping. */
  table.reflow, table.reflow tbody, table.reflow tr, table.reflow td { display: block; }
  table.reflow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.reflow tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.reflow tr:last-child { border-bottom: 0; }
  table.reflow td, table.compact.reflow td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; font-size: 0.9rem; }
  table.reflow td::before { content: attr(data-label); color: var(--muted); font-size: 0.8rem; padding-top: 1px; }
  table.reflow td .cv { min-width: 0; }
  table.reflow td:not([data-label]) { display: block; }
  table.reflow td.empty { text-align: left; padding: 8px 0; }
  table.reflow tbody tr:hover td { background: none; }
  table.reflow td code { white-space: normal; word-break: break-all; }
}

@media (pointer: coarse) {
  .nav-item, button, .button, input:not([type=checkbox]), select { min-height: 44px; }
  button.icon-btn { width: 44px; height: 44px; }
  label.check { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, body.menu-open .sidebar { transition: none; }
  a.num-card { transition: none; }
}
