/* Permintaan Meeting DRB — dipakai dari HP lebih sering daripada dari laptop,
   jadi tata letaknya satu kolom dulu dan melebar hanya kalau ada ruang.
   Warna diagram memakai palet data-viz yang sudah divalidasi (slot kategorikal
   1–4 untuk status, ramp biru ordinal untuk urgensi). */

:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --line: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --s1: #2a78d6;  /* baru */
  --s2: #eb6834;  /* dijadwalkan */
  --s3: #1baf7a;  /* selesai */
  --s4: #eda100;  /* ditolak */
  --u1: #86b6ef;  /* rendah  (ordinal, langkah paling terang yang lolos 2:1) */
  --u2: #3987e5;  /* sedang */
  --u3: #256abf;  /* tinggi */
  --u4: #104281;  /* mendesak */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 6px 20px rgba(11, 11, 11, .05);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --line: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --u1: #86b6ef; --u2: #3987e5; --u3: #256abf; --u4: #184f95;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --line: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --u1: #86b6ef; --u2: #3987e5; --u3: #256abf; --u4: #184f95;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* `display` dari sebuah kelas mengalahkan aturan [hidden] bawaan browser, dan
   .gate memang punya display:grid — tanpa baris ini gerbang kunci tetap
   terlihat di atas dashboard setelah berhasil masuk. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--accent); }
.dim { color: var(--muted); font-weight: 500; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.error { color: var(--critical); font-size: 13px; margin: 0; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ gerbang */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}
.gate-card h1 { font-size: 20px; }
.gate-card p { margin: 0; font-size: 14px; }

/* -------------------------------------------------------------------- rangka */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top)) 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-main { min-width: 0; flex: 1; }
.topbar-actions .btn { flex: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.conn { margin: 2px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.live .dot { background: var(--good); }
.conn.down .dot { background: var(--critical); }

main { padding: 16px; display: grid; gap: 16px; max-width: 1100px; margin: 0 auto; }
.foot { padding: 20px 16px 34px; text-align: center; color: var(--muted); font-size: 12px; }

/* -------------------------------------------------------------------- kontrol */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.danger { color: var(--critical); }
.btn.icon { width: 44px; padding: 0; font-size: 16px; }

.field { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); }
.field.inline { flex: 1; }
.field input, .field select, .field textarea, .search {
  font: inherit;
  font-size: 16px; /* < 16px membuat iOS auto-zoom saat fokus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
.field textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.filters { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--plane); border-color: transparent; }
.chip .swatch { width: 8px; height: 8px; border-radius: 3px; }

/* ---------------------------------------------------------------------- KPI */

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 2px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--ink-2); }
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 680; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* -------------------------------------------------------------------- grafik */

.charts { display: grid; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 0;
}
.chart figcaption { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }

.stackbar { display: flex; gap: 2px; height: 26px; border-radius: 6px; overflow: hidden; background: var(--grid); }
.stackbar span { display: block; height: 100%; }
.stackbar span:first-child { border-radius: 6px 0 0 6px; }
.stackbar span:last-child { border-radius: 0 6px 6px 0; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; padding: 0; font-size: 12px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend b { color: var(--ink); font-weight: 600; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-2); }
.bar-track { background: var(--grid); border-radius: 5px; height: 12px; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- daftar */

.list { display: grid; gap: 10px; }
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--u2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.item-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.item-code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item-title { font-size: 15px; font-weight: 620; line-height: 1.35; flex: 1 1 100%; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--ink-2); }
.item-meta span { display: inline-flex; gap: 4px; align-items: center; }
.item-detail { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.overdue { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }

.empty { text-align: center; color: var(--ink-2); font-size: 14px; padding: 24px 8px; }

/* --------------------------------------------------------------------- dialog */

.sheet {
  border: none;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(560px, 100%);
  max-height: 92dvh;
  border-radius: 16px 16px 0 0;
  margin: auto auto 0;
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet form { display: flex; flex-direction: column; max-height: 92dvh; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 16px; flex: 1; }
.sheet-body { padding: 14px 16px; display: grid; gap: 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }

.activity { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; font-size: 12px; color: var(--ink-2); }
.activity h3 { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.activity div { display: flex; gap: 8px; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* --------------------------------------------------------------------- toast */

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  background: var(--ink);
  color: var(--plane);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: rise .18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------------- lebar */

/* Di layar sempit judul tombol dilepas dan hanya ikonnya yang tinggal —
   nama tombol tetap ada untuk pembaca layar lewat aria-label. */
@media (max-width: 479px) {
  .btn-label { display: none; }
  .topbar-actions .btn { padding-inline: 11px; }
}

@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .charts { grid-template-columns: 1fr 1fr; }
  .sheet { border-radius: 16px; margin: auto; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}
@media (min-width: 900px) {
  .list { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
