:root {
  --bg: #f4f5f9; --panel: #ffffff; --text: #1a2033; --muted: #6a7389; --line: #e3e6ee;
  --brand: #d9481c; --brand-soft: #fdeee8; --ok: #15803d; --ok-soft: #e4f6ea;
  --bad: #c62828; --bad-soft: #fdeaea; --warn: #b45309;
  --sidebar: #131a2b; --sidebar-text: #c3c9de; --sidebar-active: rgba(255,255,255,.09);
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.06);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0d1220; --panel: #161c2f; --text: #e7eaf4; --muted: #8b94ae; --line: #252d46;
  --brand: #ff7a45; --brand-soft: #2a1d1a; --ok: #4ade80; --ok-soft: #12281c;
  --bad: #f87171; --bad-soft: #2d1818; --warn: #fbbf24;
  --sidebar: #0a0e1a; --sidebar-active: rgba(255,255,255,.07);
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220; --panel: #161c2f; --text: #e7eaf4; --muted: #8b94ae; --line: #252d46;
    --brand: #ff7a45; --brand-soft: #2a1d1a; --ok: #4ade80; --ok-soft: #12281c;
    --bad: #f87171; --bad-soft: #2d1818; --warn: #fbbf24;
    --sidebar: #0a0e1a; --sidebar-active: rgba(255,255,255,.07);
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em;
  background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ff8a4c, #d9481c); color: #fff; font-weight: 800; font-size: 20px; flex: none; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; font-size: 17px; line-height: 1.1; }
.brand-text small { font-weight: 500; font-size: 12px; color: var(--sidebar-text); opacity: .8; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .55; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; }
.nav-item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item em { margin-left: auto; font-style: normal; font-size: 10.5px; padding: 2px 7px; border-radius: 99px;
  background: rgba(255,255,255,.08); opacity: .8; }
a.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav-item.is-soon { opacity: .5; cursor: default; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 28px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { color: var(--muted); font-size: 12px; }
.content { padding: 26px 28px 48px; max-width: 1400px; width: 100%; }

/* ---------- Komponen ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Beranda ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi-label { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.kpi-value { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }
.kpi-ok { color: var(--ok); }
.kpi-bad { color: var(--bad); }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 30px 0 14px; }
.section-head h2 { font-size: 18px; }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.branch { padding: 18px 20px; }
.branch header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.branch h3 { font-size: 16.5px; margin-bottom: 4px; }
.branch dl { margin: 0; display: grid; gap: 8px; }
.branch dl div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px dashed var(--line); padding-top: 8px; }
.branch dt { color: var(--muted); font-size: 13.5px; }
.branch dd { margin: 0; font-weight: 700; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Login & error ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 15% -10%, rgba(217,72,28,.16), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 18px; }
.auth-brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; }
.field input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin: 18px 0 0; }
.error-code { font-size: 64px; font-weight: 800; color: var(--brand); line-height: 1; margin-bottom: 8px; }

/* ---------- Responsif ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 10px 12px; }
  .brand { padding-bottom: 8px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav-label, .nav-item.is-soon { display: none; }
  .nav-item { white-space: nowrap; }
  .topbar { padding: 12px 16px; position: static; }
  .user-meta { display: none; }
  .content { padding: 18px 16px 40px; }
}

/* ---------- Bagian 3: tabel, filter, tab, flash ---------- */
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: rgba(217,119,6,.12); color: var(--warn); }
.badge-warn { background: rgba(217,119,6,.14); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-danger:hover { background: var(--bad-soft); }
a.kpi-link { display: block; color: inherit; }
a.kpi-link:hover { border-color: var(--brand); }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; max-width: 640px; }
.head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; margin-bottom: 14px; }
.filters select, .filters input[type="search"] { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; min-width: 160px; }
.filters input[type="search"] { flex: 1; min-width: 200px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 14px; }
.tab span { margin-left: 6px; color: var(--muted); font-weight: 700; }
.tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab.is-active span { color: rgba(255,255,255,.85); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.chip strong { color: var(--text); }
.chip-warn { background: rgba(217,119,6,.12); color: var(--warn); border-color: transparent; }
.chip-warn strong { color: var(--warn); }

.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: rgba(127,127,127,.06); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty-cell { text-align: center; color: var(--muted); padding: 30px 14px !important; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline-block; margin-left: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; }
.pager-btns { display: flex; gap: 8px; }

/* ---------- Perbaikan tata letak tabel ---------- */
.nowrap { white-space: nowrap; }
.table th, .table td { padding-left: 12px; padding-right: 12px; }
.table td code { white-space: nowrap; }
/* kolom aksi tetap terlihat walau tabel harus digeser */
.table th:last-child.sticky-col, .table td.actions {
  position: sticky; right: 0; background: var(--panel); box-shadow: -10px 0 10px -10px rgba(0,0,0,.18);
}
.table tbody tr:hover td.actions { background: var(--panel); }

/* ---------- Bagian 4: bahasa, formulir, banner, kode ---------- */
.lang-switch { display: inline-flex; height: 38px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel); font-size: 12.5px; font-weight: 700; letter-spacing: .03em; }
.lang-switch span { display: grid; place-items: center; padding: 0 10px; color: var(--muted); }
.lang-switch span.on { background: var(--brand); color: #fff; }
.lang-switch:hover { border-color: var(--muted); }
.auth-lang { position: fixed; top: 16px; right: 16px; z-index: 10; }

.banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius);
  background: rgba(217,119,6,.12); border: 1px solid rgba(217,119,6,.35); color: var(--text); }
.banner strong { color: var(--warn); }

.form-grid { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 420px); gap: 20px; align-items: start; }
.side-forms { display: grid; gap: 20px; }
.form-card { padding: 22px 24px; }
.form-card.narrow { max-width: 640px; margin-top: 14px; }
.form-card h3 { font-size: 16px; margin-bottom: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.help { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; font-weight: 400; }
.field input[disabled] { opacity: .65; cursor: not-allowed; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; cursor: pointer; }
.ip-line { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.ip-hist { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line); }
.ip-hist:first-of-type { border-top: 0; }
pre.code { background: #0b1020; color: #d6e2ff; border-radius: var(--radius); padding: 18px 20px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; white-space: pre; margin: 0 0 14px; }
@media (max-width: 1000px) { .form-grid { grid-template-columns: 1fr; } }
