/* =========================================================
   SecurityWatch — Design System
   Breakpoint: HP < 768 · Tablet 768–1099 (rail) · Laptop/Desktop ≥ 1100
   ========================================================= */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f4;
  --hover: #f3f5f8;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #6b7280;
  --border: #e5e8ec;
  --border-strong: #d3d8de;

  --primary: #2a78d6;
  --primary-strong: #1c5cab;
  --primary-soft: #eaf2fc;
  --on-primary: #ffffff;

  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: #e7f5e7;
  --warn: #fab219;
  --warn-text: #845600;
  --warn-soft: #fff4dc;
  --crit: #d03b3b;
  --crit-text: #b42323;
  --crit-soft: #fdeded;

  --grid: #eceef1;
  --axis: #c9cdd3;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);

  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
  --rail: 76px;
  --topbar: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12; --surface: #16191e; --surface-2: #1b1f25; --surface-3: #232830; --hover: #1e232a;
    --text: #eef0f3; --text-2: #c3c7cf; --muted: #969ca6; --border: #262b33; --border-strong: #353b45;
    --primary: #3987e5; --primary-strong: #86b6ef; --primary-soft: rgba(57, 135, 229, .16);
    --good-text: #3fc43f; --good-soft: rgba(12, 163, 12, .16);
    --warn-text: #fab219; --warn-soft: rgba(250, 178, 25, .14);
    --crit-text: #f07272; --crit-soft: rgba(208, 59, 59, .18);
    --grid: #242930; --axis: #3a404a;
    --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f12; --surface: #16191e; --surface-2: #1b1f25; --surface-3: #232830; --hover: #1e232a;
  --text: #eef0f3; --text-2: #c3c7cf; --muted: #969ca6; --border: #262b33; --border-strong: #353b45;
  --primary: #3987e5; --primary-strong: #86b6ef; --primary-soft: rgba(57, 135, 229, .16);
  --good-text: #3fc43f; --good-soft: rgba(12, 163, 12, .16);
  --warn-text: #fab219; --warn-soft: rgba(250, 178, 25, .14);
  --crit-text: #f07272; --crit-soft: rgba(208, 59, 59, .18);
  --grid: #242930; --axis: #3a404a;
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* ---------- Layout ---------- */
.layout { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sb-brand img { width: 36px; height: 36px; border-radius: 10px; }
.sb-brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.sb-brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.2; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; text-decoration: none;
}
.sb-nav a:hover { background: var(--hover); color: var(--text); }
.sb-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sb-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.sb-foot b { color: var(--text); font-size: 13px; }

.main-col { margin-left: var(--sidebar); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar); padding: 0 28px;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.tb-logo { display: none; width: 30px; height: 30px; border-radius: 8px; }
.tb-title h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; line-height: 1.2; }
.tb-title p { margin: 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title { min-width: 0; }
main { padding: 8px 28px 40px; max-width: 1480px; }

.status-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.status-chip:hover { background: var(--hover); }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-chip.offline .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-chip.error .dot { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.status-chip.syncing .dot { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #fff;
  font-weight: 700; font-size: 14px;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

.bottomnav, .fab { display: none; }

/* Tablet: sidebar menjadi rail ikon */
@media (max-width: 1099px) and (min-width: 768px) {
  .sidebar { width: var(--rail); padding: 16px 10px; align-items: center; }
  .sb-brand { padding: 4px 0 18px; }
  .sb-brand div, .sb-label, .sb-nav a span, .sb-foot { display: none; }
  .sb-nav a { justify-content: center; padding: 12px; }
  .sb-nav a svg.i { width: 22px; height: 22px; }
  .main-col { margin-left: var(--rail); }
  .topbar, main { padding-left: 24px; padding-right: 24px; }
}

/* HP: top bar + bottom nav */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .main-col { margin-left: 0; }
  .topbar { padding: 0 16px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .tb-logo { display: block; }
  .tb-title h1 { font-size: 17px; }
  .tb-title p { display: none; }
  .status-chip { padding: 0; width: 36px; justify-content: center; }
  .status-chip .txt { display: none; }
  main { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; border-radius: 12px; text-decoration: none;
    color: var(--muted); font-size: 11px; font-weight: 600;
  }
  .bottomnav a svg.i { width: 22px; height: 22px; }
  .bottomnav a.active { color: var(--primary); }
  .bottomnav a.active svg.i { background: var(--primary-soft); border-radius: 999px; padding: 3px 14px; width: 52px; height: 28px; }
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 26;
    right: 18px; bottom: calc(80px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 18px;
    background: var(--primary); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 45%, transparent);
  }
  .fab svg.i { width: 26px; height: 26px; }
  .fab:hover { text-decoration: none; filter: brightness(1.06); }
}

/* ---------- Komponen umum ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 15px; font-weight: 650; }
.section-title span { color: var(--muted); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.07); background: var(--primary); }
.btn.danger { color: var(--crit-text); }
.btn.danger:hover { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 35%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; }
.btn .count { background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }

input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.field { display: block; min-width: 0; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.field .req { color: var(--crit-text); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint.warn { color: var(--warn-text); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.hint.warn:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }

.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge svg.i { width: 13px; height: 13px; stroke-width: 2.5; }
.badge.good { background: var(--good-soft); color: var(--good-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn-text); }
.badge.crit { background: var(--crit-soft); color: var(--crit-text); }
.badge.tag { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); font-weight: 500; }

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
  background: var(--warn-soft); color: var(--warn-text); font-weight: 500;
}
.banner.info { background: var(--primary-soft); color: var(--primary); }
.banner.crit { background: var(--crit-soft); color: var(--crit-text); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty svg.i { width: 40px; height: 40px; stroke-width: 1.5; margin-bottom: 8px; opacity: .7; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* Toolbar & filter */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-row select { width: auto; flex: 1 1 150px; max-width: 220px; height: 40px; background-color: var(--surface); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 12px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.chip:hover { background: var(--hover); }
.chip svg.i { width: 14px; height: 14px; }
.btn-filter { display: none; }
@media (max-width: 767px) {
  .filter-row { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px; scrollbar-width: none; }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-row select { flex: 0 0 auto; width: auto; max-width: none; height: 36px; border-radius: 999px; font-size: 13px; padding-left: 14px; }
  .btn-filter { display: inline-flex; }
  .filter-row.panel { display: none; }
  .filter-row.panel.open { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow: visible; margin: 0 0 14px; padding: 0; }
  .filter-row.panel.open select { max-width: none; width: 100%; border-radius: 10px; height: 40px; }
  .toolbar .btn .lbl { display: none; }
  .toolbar .btn.add { display: none; }
}

/* ---------- Dashboard ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
  background: linear-gradient(120deg, var(--primary-strong), var(--primary));
  color: #fff;
}
:root[data-theme="dark"] .hero { background: linear-gradient(120deg, #123764, #1c5cab); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(120deg, #123764, #1c5cab); } }
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 70%);
}
.hero small { opacity: .85; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 11.5px; }
.hero h2 { margin: 4px 0 2px; font-size: 20px; letter-spacing: -.01em; line-height: 1.3; max-width: 760px; }
.hero p { margin: 0; opacity: .9; font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 10px; padding: 18px 18px 16px;
  color: inherit; text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s;
}
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.kpi-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.kpi-ico.warn { background: var(--warn-soft); color: var(--warn-text); }
.kpi-ico.good { background: var(--good-soft); color: var(--good-text); }
.kpi-ico.neutral { background: var(--surface-3); color: var(--text-2); }
.kpi-val { font-size: 30px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-sub b { color: var(--text-2); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--good); }

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.cat {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px;
  color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.cat:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow-lg); }
.cat .lbl { font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat .val { font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.cat .pct { font-size: 12px; color: var(--muted); font-weight: 600; }
.cat .meter i { background: var(--primary); }
.cat.zero .val { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.chart-box { position: relative; height: 300px; padding: 8px 16px 16px; }

.rank { list-style: none; margin: 0; padding: 8px 20px 18px; display: grid; gap: 4px; }
.rank li a { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 8px; margin: 0 -8px; border-radius: 10px; color: inherit; text-decoration: none; }
.rank li a:hover { background: var(--hover); }
.rank .pos { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.rank .name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .cnt { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank .meter { grid-column: 2 / 4; height: 4px; }
.rank .meter i { background: var(--primary); }
.rank .none { color: var(--muted); padding: 14px 0; }

@media (max-width: 1279px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 > :last-child { grid-column: 1 / -1; } }
@media (max-width: 1099px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 899px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (max-width: 767px) {
  .hero { padding: 18px; margin-bottom: 14px; }
  .hero h2 { font-size: 16px; }
  .kpi { padding: 14px; gap: 8px; }
  .kpi-top { font-size: 12px; }
  .kpi-ico { width: 30px; height: 30px; border-radius: 9px; }
  .kpi-ico svg.i { width: 16px; height: 16px; }
  .kpi-val { font-size: 26px; }
  .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cat { padding: 12px 14px; }
  .cat .val { font-size: 22px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .chart-box { height: 250px; padding: 4px 8px 12px; }
}

/* ---------- Tabel ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 250px); }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
table.tbl th[data-sort] { cursor: pointer; }
table.tbl th[data-sort]:hover { color: var(--text); }
table.tbl th .arr { display: inline-block; width: 12px; color: var(--primary); }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr { cursor: pointer; transition: background .1s; }
table.tbl tbody tr:hover td { background: var(--hover); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
table.tbl td.strong { font-weight: 600; }
table.tbl td.wrap { min-width: 200px; max-width: 320px; }
table.tbl td.nowrap { white-space: nowrap; }
table.tbl td.sub { color: var(--text-2); }
tr.inactive td { opacity: .5; }
.pend { display: inline-flex; vertical-align: middle; margin-left: 4px; color: var(--warn-text); }
.pend.err { color: var(--crit-text); }
.pend svg.i { width: 14px; height: 14px; }

.list-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.list-meta select { width: auto; height: 34px; font-size: 13px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.pager .muted { font-size: 13px; }

/* Kartu data (HP) */
.cards { display: none; }
.dcard { padding: 14px 16px; display: grid; gap: 8px; cursor: pointer; }
.dcard + .dcard { margin-top: 10px; }
.dcard:active { background: var(--hover); }
.dcard .top { display: flex; align-items: flex-start; gap: 10px; }
.dcard .who { flex: 1; min-width: 0; }
.dcard .who b { display: block; font-size: 15px; line-height: 1.3; }
.dcard .who span { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.dcard .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.dcard .meta span { display: inline-flex; align-items: center; gap: 5px; }
.dcard .meta svg.i { width: 14px; height: 14px; }
.dcard .foot { display: flex; align-items: center; gap: 8px; }
.dcard .no { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 767px) {
  .table-card.data { display: none; }
  .cards { display: block; }
  .pager.data { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; }
}

/* Tabel responsif generik (master, user) */
@media (max-width: 767px) {
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  table.rtable tbody tr:last-child { border-bottom: 0; }
  table.rtable td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  table.rtable td::before { content: attr(data-label); flex: 0 0 110px; color: var(--muted); font-size: 12.5px; }
  table.rtable td:first-child::before { display: none; }
  table.rtable td:first-child { font-size: 15px; }
  table.rtable td.blank { display: none; }
  .table-scroll { max-height: none; }
}

/* ---------- Form ---------- */
.form-wrap { max-width: 920px; }
.form-sec { margin-bottom: 16px; }
.sec-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px 20px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { position: relative; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 500; font-size: 13.5px; cursor: pointer; user-select: none; transition: all .12s;
}
.toggle span svg.i { width: 15px; height: 15px; display: none; }
.toggle span:hover { background: var(--hover); }
.toggle input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.toggle input:checked + span svg.i { display: inline; }
.toggle input:focus-visible + span { box-shadow: var(--ring); }
.toggle.st-good input:checked + span { background: var(--good-soft); border-color: var(--good); color: var(--good-text); }
.toggle.st-warn input:checked + span { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-text); }
.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 14px 0; margin-top: 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
@media (max-width: 767px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 18px; gap: 14px; }
  .actionbar { bottom: calc(64px + env(safe-area-inset-bottom)); margin: 0 -16px; padding: 12px 16px; }
  .actionbar .btn { flex: 1; }
  .actionbar .btn.ghost { flex: 0 0 auto; }
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px;
}
.tabs button:hover { background: var(--hover); }
.tabs button.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.tabs button .n { font-size: 11.5px; opacity: .7; }
@media (max-width: 767px) { .tabs { margin: 0 -16px 14px; padding: 0 16px 2px; } }

/* ---------- Modal / sheet ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
.modal header { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal header .t { flex: 1; min-width: 0; }
.modal header .t b { display: block; font-size: 17px; letter-spacing: -.01em; }
.modal header .t span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal header .x { border: 0; background: var(--surface-3); color: var(--text-2); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.modal .body { padding: 18px 20px; overflow: auto; display: grid; gap: 14px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@media (max-width: 767px) {
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; animation: up .22s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  .modal::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .modal footer .btn { flex: 1; }
}

dl.detail { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 14px; margin: 0; }
dl.detail dt { color: var(--muted); font-size: 13px; }
dl.detail dd { margin: 0; font-weight: 500; word-break: break-word; }
dl.detail .sep { grid-column: 1 / -1; height: 1px; background: var(--border); margin: 2px 0; }
@media (max-width: 420px) { dl.detail { grid-template-columns: 105px minmax(0, 1fr); } }

/* Menu */
.menu {
  position: fixed; z-index: 40; right: 16px; top: 60px; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out;
}
.menu .who { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .who b { display: block; }
.menu .who > div span { display: block; font-size: 12.5px; color: var(--muted); }
.menu button.mi {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 500;
}
.menu button.mi:hover { background: var(--hover); }
.menu button.mi.danger { color: var(--crit-text); }
.menu .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 6px 8px; padding: 4px; background: var(--surface-3); border-radius: 10px; }
.menu .seg button { border: 0; background: none; border-radius: 7px; padding: 6px 0; font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.menu .seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.menu .seg button svg.i { width: 16px; height: 16px; }
.menu .ver { padding: 8px 10px 4px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 6px; }

/* Toast */
#toasts { position: fixed; z-index: 60; right: 24px; bottom: 24px; display: grid; gap: 8px; width: min(92vw, 380px); }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #111827; color: #fff; padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease-out;
}
.toast svg.i { flex: none; }
.toast.ok svg.i { color: #4ade80; }
.toast.error { background: #7f1d1d; }
.toast button { margin-left: auto; background: rgba(255, 255, 255, .16); color: #fff; border: 0; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
@media (max-width: 767px) { #toasts { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-side {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #0f2f57 0%, #1c5cab 55%, #2a78d6 100%);
}
.login-side::before, .login-side::after { content: ""; position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 70%); }
.login-side::before { width: 520px; height: 520px; right: -180px; top: -160px; }
.login-side::after { width: 420px; height: 420px; left: -140px; bottom: -180px; }
.login-side .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; position: relative; }
.login-side .brand img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.login-side h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; margin: 0 0 14px; max-width: 460px; position: relative; }
.login-side p { opacity: .85; max-width: 420px; margin: 0 0 26px; position: relative; font-size: 15px; }
.login-side ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; position: relative; }
.login-side li { display: flex; gap: 12px; align-items: center; font-weight: 500; }
.login-side li .ic { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; }
.login-side small { opacity: .7; position: relative; }
.login-main { display: grid; place-items: center; padding: 32px 24px; background: var(--surface); }
.login { width: 100%; max-width: 380px; }
.login .logo-m { display: none; }
.login h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
.login p.sub { margin: 0 0 26px; color: var(--muted); }
.login form { display: grid; gap: 16px; }
.login .btn { height: 46px; font-size: 15px; }
.login .err { color: var(--crit-text); font-weight: 600; font-size: 13px; }
.login .err:empty { display: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 38px; height: 34px; border-radius: 8px; display: grid; place-items: center; }
.pw-wrap button:hover { background: var(--hover); }
@media (max-width: 899px) {
  .login-wrap { grid-template-columns: minmax(0, 1fr); }
  .login-side { display: none; }
  .login-main { background: var(--bg); align-items: start; padding-top: max(64px, 10vh); }
  .login .logo-m { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; font-weight: 700; font-size: 17px; }
  .login .logo-m img { width: 44px; height: 44px; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Penyesuaian responsif ---------- */
.chips:empty { display: none; }
table.tbl td { white-space: nowrap; }
table.tbl td.wrap { white-space: normal; }
@media (max-width: 1499px) { table.tbl .opt { display: none; } }
.cats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 767px) {
  .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { flex-wrap: nowrap; }
  .toolbar .search { flex: 1 1 0; }
}
.order { display: inline-flex; align-items: center; gap: 6px; }
.order .num { min-width: 20px; text-align: center; color: var(--muted); font-weight: 600; }
.order .btn.icon { width: 30px; height: 30px; }
.order .btn svg.i { width: 16px; height: 16px; }
@media (max-width: 767px) {
  #btnAdd { width: 40px; padding: 0; flex: none; }
  #btnAdd span { display: none; }
}

/* Tabel: kolom pendukung disembunyikan bertahap agar tidak perlu geser ke samping */
table.tbl td { white-space: normal; }
table.tbl td.nowrap, table.tbl td.num { white-space: nowrap; }
table.tbl td.strong { min-width: 120px; }
@media (max-width: 1399px) { table.tbl .opt2 { display: none; } }
@media (max-width: 1099px) { table.tbl .opt3 { display: none; } }

/* Perangkat mouse/touchpad: menu & filter turun baris, bukan geser ke samping */
@media (min-width: 768px), (hover: hover) and (pointer: fine) {
  .tabs { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .filter-row { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .filter-row select { flex: 1 1 150px; }
}

/* Tombol tambah cepat di form */
.toggle-add {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px dashed var(--primary); background: transparent;
  color: var(--primary); font-weight: 600; font-size: 13.5px;
}
.toggle-add:hover { background: var(--primary-soft); }
.toggle-add svg.i { width: 15px; height: 15px; }
table.tbl .badge.tag { white-space: normal; height: auto; min-height: 24px; padding: 3px 9px; line-height: 1.3; }
@media (max-width: 1399px) { table.tbl th, table.tbl td { padding-left: 10px; padding-right: 10px; } }
