/* =====================================================================
   Dashboard Layer 2 Gateway
   Palet grafik memakai slot kategorikal yang sudah divalidasi untuk
   keterbacaan pada gangguan penglihatan warna (deutan/protan/tritan),
   di mode terang maupun gelap.
   ===================================================================== */

:root {
  color-scheme: light dark;

  --surface-1:      #fcfcfb;
  --plane:          #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);

  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;

  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
  --success-text:   #006300;

  --radius:   10px;
  --radius-s: 6px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --surface-1:      #1a1a19;
    --plane:          #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255, 255, 255, 0.10);

    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --success-text:   #0ca30c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Tata letak ----------------------------------------------------- */

.shell { max-width: 1160px; margin: 0 auto; padding: 0 20px 64px; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  max-width: 1160px; margin: 0 auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 650; letter-spacing: -0.01em; font-size: 16px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-secondary); font-size: 13.5px; }

h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 620; letter-spacing: -0.01em; margin: 0 0 14px; }
.sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 26px; }

/* --- Kartu ----------------------------------------------------------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; align-items: start; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
}

/* --- Kartu angka ----------------------------------------------------- */

.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.tile .label {
  font-size: 12.5px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 560;
  margin-bottom: 6px;
}
.tile .value { font-size: 27px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.tile .foot { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* --- Grafik ---------------------------------------------------------- */

.chart-wrap { position: relative; height: 260px; }

/* Batang horizontal dengan label langsung — memenuhi syarat "relief"
   sehingga nilai tidak pernah bergantung pada warna semata. */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; }
.bar-row .nama {
  font-size: 13.5px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-track { background: var(--grid); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 4px; }
.bar-row .nilai {
  font-size: 13px; color: var(--text-primary);
  font-variant-numeric: tabular-nums; min-width: 68px; text-align: right;
}

/* --- Tabel ------------------------------------------------------------ */

.tabel { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabel th {
  text-align: left; font-weight: 560; font-size: 12.5px;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tabel td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabel tr:last-child td { border-bottom: none; }
.tabel .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabel .nama-buyer { font-weight: 560; }
.tabel .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--text-muted);
}

.tabel-scroll { overflow-x: auto; }

/* --- Lencana ---------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 560; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--border); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.aktif  .dot { background: var(--good); }
.badge.blokir .dot { background: var(--critical); }
.badge.sepi   .dot { background: var(--text-muted); }
.badge.perhatian .dot { background: var(--warning); }

/* --- Tombol & form ----------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 560;
  padding: 8px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--plane); text-decoration: none; }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); border-color: var(--critical); }
.btn.danger:hover { background: color-mix(in srgb, var(--critical) 8%, transparent); }
.btn.kecil { padding: 5px 10px; font-size: 12.5px; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13.5px; font-weight: 560;
  margin-bottom: 6px; color: var(--text-secondary);
}
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], textarea, select {
  width: 100%; font: inherit; font-size: 14px;
  padding: 9px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent;
}

.rentang { display: flex; gap: 6px; flex-wrap: wrap; }
.rentang a {
  font-size: 13px; padding: 5px 11px; border-radius: var(--radius-s);
  border: 1px solid var(--border); color: var(--text-secondary); text-decoration: none;
}
.rentang a.aktif {
  background: var(--series-1); border-color: var(--series-1);
  color: #fff; font-weight: 560;
}
.rentang a:hover { text-decoration: none; }

/* --- Pesan ------------------------------------------------------------- */

.notif {
  padding: 11px 15px; border-radius: var(--radius-s);
  font-size: 14px; margin-bottom: 18px;
  border: 1px solid var(--border);
}
.notif.ok    { border-left: 3px solid var(--good);     color: var(--success-text); }
.notif.galat { border-left: 3px solid var(--critical); color: var(--critical); }

.peringatan-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.peringatan-item:last-child { border-bottom: none; }
.peringatan-item .ikon { font-size: 16px; line-height: 1.4; }
.peringatan-item .waktu { color: var(--text-muted); font-size: 12.5px; }
.peringatan-item .isi { flex: 1; }
.peringatan-item .isi b { font-weight: 600; }

.kosong { color: var(--text-muted); font-size: 14px; padding: 22px 0; text-align: center; }

/* --- Kredensial -------------------------------------------------------- */

.kredensial {
  background: var(--plane); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 16px; margin-top: 8px;
}
.kredensial .baris { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; flex-wrap: wrap; }
.kredensial .k { font-size: 12.5px; color: var(--text-secondary); min-width: 84px; font-weight: 560; }
.kredensial .v {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; word-break: break-all; flex: 1;
}

/* --- Login ------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.login-box { width: 100%; max-width: 380px; }
.login-box .card { padding: 28px; margin-bottom: 14px; }
.login-box h1 { font-size: 21px; margin-bottom: 6px; }
.tab-row { display: flex; gap: 4px; margin-bottom: 22px; }
.tab-row a {
  flex: 1; text-align: center; font-size: 13.5px; font-weight: 560;
  padding: 8px; border-radius: var(--radius-s);
  border: 1px solid var(--border); color: var(--text-secondary); text-decoration: none;
}
.tab-row a.aktif { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.tab-row a:hover { text-decoration: none; }
