/* ============================================================
   limabab — sistem antarmuka "Kertas & Tinta"
   Latar kertas hangat · tinta hitam-hangat · satu aksen hijau pinus.
   Datar (hairline, tanpa shadow dekoratif), editorial, dipimpin tipografi.
   ============================================================ */
:root {
  /* — Netral hangat — */
  --paper:      #F3EEE3;   /* latar aplikasi */
  --surface:    #FBF9F3;   /* kartu, sidebar, modal, permukaan terangkat */
  --surface-2:  #EDE7D9;   /* sumur: kepala tabel, isian input, hover, date-box */
  --ink:        #211E18;   /* teks utama (hitam-hangat) */
  --muted:      #645C4D;   /* teks sekunder (AA di atas surface) */
  --faint:      #8C8472;   /* teks tersier / label — bukan body */
  --hairline:   #E2DAC7;   /* garis batas utama */
  --hairline-2: #ECE5D6;   /* pembatas lebih lembut */

  /* — Aksen: hijau pinus, dipakai irit — */
  --accent:        #2E5A4B;
  --accent-strong: #244A3E;   /* hover / aktif / ditekan */
  --accent-tint:   #E2EBE4;   /* bg nav aktif, isian lembut, dasar fokus-ring */
  --on-accent:     #FBF9F3;   /* teks/ikon di atas isian aksen */

  /* — Status fungsional: tinta-di-atas-tint hangat (bukan warna permen) — */
  --ok-ink:   #2C6047;  --ok-bg:   #E3EFE4;   /* terlaksana · hadir  */
  --info-ink: #355C77;  --info-bg: #E5EDF2;   /* terjadwal  · izin   */
  --warn-ink: #8A5A12;  --warn-bg: #F2E8CF;   /* ditunda    · sakit  */
  --bad-ink:  #9E3B29;  --bad-bg:  #F3E1D9;   /* dibatalkan · alpa   */

  /* — Alias kompatibel (dipakai inline di JS lama) — */
  --bg: var(--paper);
  --text: var(--ink);
  --muted-2: var(--faint);
  --border: var(--hairline);
  --border-2: var(--hairline-2);
  --primary: var(--accent);
  --primary-d: var(--accent-strong);
  --primary-soft: var(--accent-tint);
  --green: var(--ok-ink);
  --amber: var(--warn-ink);
  --red: var(--bad-ink);
  --blue: var(--info-ink);

  /* — Bentuk & kedalaman — */
  --r-xs: 6px;    /* badge, chip, input kecil */
  --r-sm: 8px;    /* tombol, input */
  --r-md: 11px;   /* kartu, stat, baris */
  --r-lg: 16px;   /* modal, kartu masuk */
  --radius: var(--r-md);
  --radius-sm: var(--r-sm);
  /* hanya lapisan mengambang yang punya shadow */
  --shadow: none;
  --shadow-pop: 0 8px 30px rgba(33,30,24,.12), 0 2px 6px rgba(33,30,24,.06);
  --shadow-lg: var(--shadow-pop);

  --sidebar-w: 248px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: var(--font);
  font-family: var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--paper);
  /* butiran kertas yang sangat halus — hanya tampak pada area latar */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  background-blend-mode: multiply;
  color: var(--ink);
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  letter-spacing: -.01em; line-height: 1.18; text-wrap: balance;
}
h1 { letter-spacing: -.02em; }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--accent); text-underline-offset: 2px; }

/* Ikon SVG sebaris — mewarisi warna teks, tak menangkap klik. */
.icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; pointer-events: none; }

/* Fokus terlihat di semua kontrol interaktif. */
:where(.btn, .icon-btn, .input, .nav-item, .seg button, .ab-btn, .acct-btn, .menu-item, .row-item, .field-eye, a):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
  border-color: var(--accent);
}

/* Entri konten yang halus & bertahap (hormati prefers-reduced-motion). */
@media (prefers-reduced-motion: no-preference) {
  .view-root > * { animation: rise .30s cubic-bezier(.2,.7,.2,1) backwards; }
  .view-root > *:nth-child(2) { animation-delay: .04s; }
  .view-root > *:nth-child(3) { animation-delay: .08s; }
  .view-root > *:nth-child(4) { animation-delay: .12s; }
  .view-root > *:nth-child(5) { animation-delay: .16s; }
  .view-root > *:nth-child(n+6) { animation-delay: .18s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ============ Tata letak ============ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--hairline);
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 3px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; }
.brand-mark { color: var(--accent); flex: 0 0 auto; }
.brand-word { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -.025em; color: var(--ink); line-height: 1; }
.brand-refresh { margin-left: auto; }
/* Sisa gaya logo lama (tak lagi dirender, disimpan agar tak ada kejutan). */
.brand-logo, .brand-logo-sm, .auth-logo { display: grid; place-items: center; color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; }
.nav-item .ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-spacer { flex: 1; }
.nav-foot { font-size: 12px; color: var(--faint); padding: 12px 12px 2px; letter-spacing: .01em; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view-root { padding: 30px 40px 80px; flex: 1; max-width: 1240px; width: 100%; }
/* Header ringkas: judul kecil + tab/filter sebaris (tombol create pindah ke FAB). */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ Topbar + akun ============ */
.topbar { position: sticky; top: 0; z-index: 45; display: none; align-items: center; gap: 12px;
  padding: 11px 20px; min-height: 60px; border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.2) blur(8px); }
.topbar-spacer { flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 9px; }
.topbar-brand .brand-word { font-size: 19px; }

.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; letter-spacing: .01em; }
.avatar-sm { width: 32px; height: 32px; font-size: 12.5px; }

.acct { position: relative; }
.acct-btn { display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px; border: 1px solid var(--hairline);
  border-radius: 999px; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.acct-btn:hover { border-color: #d6cdb8; background: var(--surface-2); }
.acct.open .acct-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.acct-name { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.acct-name strong { font-size: 13.5px; font-weight: 600; }
.acct-name span { font-size: 11.5px; color: var(--muted); }
.acct-caret { color: var(--faint); transition: transform .18s; }
.acct.open .acct-caret { transform: rotate(180deg); }
.acct-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 246px; z-index: 60;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 7px; }
.acct.open .acct-menu { display: block; animation: acct-pop .14s ease; }
@keyframes acct-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.acct-menu-head { display: flex; align-items: center; gap: 11px; padding: 9px 10px 12px; margin-bottom: 5px; border-bottom: 1px solid var(--hairline-2); }
.acct-menu-id { min-width: 0; }
.acct-menu-id strong { display: block; font-size: 14px; font-weight: 600; }
.acct-menu-id span { font-size: 12px; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; cursor: pointer;
  padding: 9px 10px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500; color: var(--ink); text-align: left; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--bad-ink); }
.menu-item.danger:hover { background: var(--bad-bg); }

/* Akun di dasar sidebar (web): tombol selebar sidebar, menu membuka ke atas. */
.acct-sidebar { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--hairline-2); }
.acct-sidebar .acct-btn { width: 100%; border-radius: var(--r-md); padding: 7px 10px 7px 7px; }
.acct-sidebar .acct-name { flex: 1; min-width: 0; }
.acct-sidebar .acct-name strong, .acct-sidebar .acct-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-sidebar .acct-caret { margin-left: auto; }
.acct-sidebar .acct-menu { left: 0; right: 0; top: auto; bottom: calc(100% + 8px); min-width: 0; }
.acct-sidebar.open .acct-menu { animation: acct-pop-up .14s ease; }
@keyframes acct-pop-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ Tombol ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: var(--r-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .04s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surface); border-color: var(--hairline); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: #d6cdb8; }
.btn-danger { background: var(--surface); border-color: #e7c3b8; color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-xs); }
.btn-icon { padding-left: 8px; padding-right: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 18px; font-size: 15px; border-radius: var(--r-sm); }
.icon-btn { background: none; border: 1px solid transparent; color: var(--faint); cursor: pointer; width: 34px; height: 34px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

/* ============ Kartu ============ */
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); }
.card-pad { padding: 20px 22px; }
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin-bottom: 2px; letter-spacing: -.01em; }
.grid { display: grid; gap: 18px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 34px 0 14px; }

/* ============ Ringkasan (stat) ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(166px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 18px 20px; display: flex; flex-direction: column; }
.stat-ic { color: var(--accent); margin-bottom: 16px; height: 22px; display: inline-flex; align-items: center; }
.stat .v { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

/* ============ Kartu kategori ============ */
.kat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(256px, 1fr)); gap: 18px; }
.kat-card h3 { font-size: 18px; display: inline; }
.kat-head { display: flex; align-items: center; gap: 9px; }
.kat-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--c, var(--accent)); }
.kat-stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pill { font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--hairline-2); color: var(--muted); }
.pill b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pill-btn { cursor: pointer; font-family: inherit; transition: background .12s, border-color .12s, color .12s; }
.pill-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--ink); }
.pill-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.ring-wrap { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.ring { --p: 0; --c: var(--ok-ink); width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--hairline) 0); display: grid; place-items: center; position: relative; }
.ring::before { content: ''; position: absolute; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============ Chip / badge ============ */
/* Chip kategori diwarnai sesuai warna kategorinya (var --c). */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--faint)) 14%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--faint)) 60%, var(--ink));
  border: 1px solid color-mix(in srgb, var(--c, var(--faint)) 30%, transparent); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-xs); }
.s-terjadwal  { background: var(--info-bg); color: var(--info-ink); }
.s-terlaksana { background: var(--ok-bg);   color: var(--ok-ink); }
.s-ditunda    { background: var(--warn-bg); color: var(--warn-ink); }
.s-dibatalkan { background: var(--bad-bg);  color: var(--bad-ink); }

/* ============ Daftar sambung ============ */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-item { display: flex; align-items: center; gap: 15px; padding: 13px 16px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-md); cursor: pointer; transition: border-color .15s, background .15s; }
.row-item:hover { border-color: #d6cdb8; background: var(--surface-2); }
.date-box { flex: 0 0 56px; text-align: center; background: var(--surface-2); border: 1px solid var(--hairline-2); border-radius: var(--r-sm); padding: 6px 4px; }
.date-box .d { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.date-box .m { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: .03em; }
.date-box .w { font-size: 10.5px; color: var(--faint); }
.row-main { flex: 1; min-width: 0; }
.row-main .t { font-weight: 600; font-size: 15px; }
.row-main .meta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.row-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.resched-tag { font-size: 11.5px; color: var(--warn-ink); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* ============ Tabel ============ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--hairline); min-width: 640px; }
.tbl th, .tbl td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--hairline-2); font-size: 14px; }
.tbl th { background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.tbl td { color: var(--ink); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--surface-2); }

/* ============ Filter / toolbar ============ */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; padding: 6px 13px; border-radius: var(--r-xs); font-weight: 500; font-size: 13.5px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; }
.spacer { flex: 1; }

/* ============ Form / field ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field-hint { font-size: 12px; color: var(--muted); }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: var(--r-sm); font-size: 15px; font-family: inherit; background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea.input { resize: vertical; }
.input-color { padding: 4px; height: 42px; cursor: pointer; }
.input-color::-webkit-color-swatch-wrapper { padding: 0; }
.input-color::-webkit-color-swatch { border: none; border-radius: var(--r-xs); }

/* Sub-teks dalam sel tabel + pembatas seksi form. */
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.form-divider { font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin: 8px 0 -2px; }

/* Pohon scope (admin → pengaturan). */
.wilayah-tree { display: flex; flex-direction: column; gap: 5px; }
.wil-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface); }
.wil-row[data-level="2"] { margin-left: 22px; }
.wil-row[data-level="3"] { margin-left: 44px; background: var(--surface-2); }
.wil-name { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; min-width: 0; }
.wil-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wil-ic { color: var(--faint); flex: 0 0 auto; }
.wil-row[data-level="1"] .wil-ic { color: var(--accent); }
.wil-acts { display: flex; gap: 6px; flex: 0 0 auto; }
@media (max-width: 860px) {
  .wil-row[data-level="2"] { margin-left: 12px; }
  .wil-row[data-level="3"] { margin-left: 24px; }
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Grup checkbox pil (pilih > 1: hari / kategori) */
.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface); font-size: 13.5px;
  font-weight: 500; color: var(--muted); cursor: pointer; user-select: none; transition: background .12s, border-color .12s, color .12s; }
.check-pill:hover { border-color: #d6cdb8; color: var(--ink); }
.check-pill .check-input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-pill:has(.check-input:checked) { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.check-pill:has(.check-input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-tint); }

/* Foto jamaah: preview di form + thumbnail di tabel */
.foto-prev { width: 76px; height: 76px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  border: 1px solid var(--hairline); background: var(--surface-2); display: grid; place-items: center; }
.foto-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-empty { color: var(--faint); display: grid; place-items: center; }
.ava-img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  border: 1px solid var(--hairline); background: var(--surface-2); }

/* Field dengan ikon di dalam (login & form). */
.field-ico { position: relative; display: flex; align-items: center; }
.field-ico-lead { position: absolute; left: 12px; color: var(--faint); }
.field-ico .input { padding-left: 38px; }
.field-ico:has(.field-eye) .input { padding-right: 42px; }
.field-eye { position: absolute; right: 7px; width: 30px; height: 30px; border: none; background: none; cursor: pointer;
  color: var(--faint); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-xs); }
.field-eye:hover { color: var(--ink); background: var(--surface-2); }

/* ============ Layar masuk (login) ============ */
#app.app-auth { display: block; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1100px 540px at 50% -10%, var(--accent-tint), transparent 60%); }
.auth-card { width: 100%; max-width: 408px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 34px 30px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-brand .brand-word { font-size: 26px; }
.auth-title { font-size: 27px; }
.auth-sub { color: var(--muted); font-size: 15px; margin: 6px 0 24px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form .btn-lg { margin-top: 10px; }
.auth-error { display: flex; align-items: center; gap: 8px; background: var(--bad-bg); border: 1px solid #e7c3b8; color: var(--bad-ink);
  font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: var(--r-sm); margin: 2px 0 6px; }
.auth-foot { display: flex; align-items: center; gap: 7px; justify-content: center; margin-top: 20px; font-size: 12px; color: var(--faint); }

/* ============ Panel admin: badge peran ============ */
.badge[class*="role-"] { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hairline-2); }
.badge[class*="role-admin_"] { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
.role-superadmin, .role-admin { background: var(--accent-tint); color: var(--accent-strong); border-color: transparent; }
.role-petugas { background: var(--surface-2); color: var(--muted); }
.user-cell { display: flex; align-items: center; gap: 11px; }
.you-tag { display: inline-block; margin-left: 7px; font-size: 10.5px; font-weight: 700; color: var(--accent-strong);
  background: var(--accent-tint); padding: 1px 7px; border-radius: 999px; vertical-align: middle; }

/* ============ Modal ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(33,30,24,.45); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; z-index: 100; opacity: 0; transition: opacity .18s; }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-pop); transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal-backdrop.show .modal { transform: none; }
.modal-wide { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--hairline-2); }
.modal-head h3 { font-size: 19px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--hairline-2); flex-wrap: wrap; }
.confirm-text { color: var(--muted); }

/* ============ Absensi ============ */
.absen-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.absen-sum { display: flex; gap: 8px; flex-wrap: wrap; }
.absen-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--hairline-2); }
.absen-row .nm { flex: 1; font-weight: 600; font-size: 14px; }
.absen-row .nm small { display: block; color: var(--faint); font-weight: 500; font-size: 11.5px; }
.absen-seg { display: inline-flex; gap: 4px; }
.ab-btn { border: 1px solid var(--hairline); background: var(--surface); color: var(--muted); border-radius: var(--r-xs); padding: 5px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.ab-btn:hover { border-color: #d6cdb8; color: var(--ink); }
.ab-btn.on.h-hadir { background: var(--ok-bg);   color: var(--ok-ink);   border-color: #b6dcc2; }
.ab-btn.on.h-izin  { background: var(--info-bg); color: var(--info-ink); border-color: #bcd2e0; }
.ab-btn.on.h-sakit { background: var(--warn-bg); color: var(--warn-ink); border-color: #e6d3a3; }
.ab-btn.on.h-alpa  { background: var(--bad-bg);  color: var(--bad-ink);  border-color: #e7bfb2; }

/* ============ Kalender ============ */
.cal { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--hairline-2); }
.cal-head h3 { font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 9px 0; background: var(--surface-2); text-transform: uppercase; letter-spacing: .04em; }
.cal-cell { height: 110px; overflow: hidden; border-right: 1px solid var(--hairline-2); border-top: 1px solid var(--hairline-2); padding: 6px; cursor: pointer; transition: background .12s; position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.muted { background: color-mix(in srgb, var(--paper) 60%, var(--surface)); }
.cal-cell.muted .cal-num { color: var(--faint); }
.cal-cell.today .cal-num { background: var(--accent); color: var(--on-accent); border-radius: 50%; width: 23px; height: 23px; display: grid; place-items: center; }
.cal-num { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-ev { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: var(--r-xs); margin-top: 4px; color: var(--on-accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--c, var(--accent)); }
.cal-ev.done { opacity: .5; }
.cal-ev.cancel { text-decoration: line-through; opacity: .5; }
.cal-more { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ============ Tren chart (SVG) ============ */
.trend { width: 100%; height: 180px; }
.trend .area { fill: url(#g); }
.trend .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.trend .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.trend .lbl { font-size: 10px; fill: var(--faint); }
.trend .val { font-size: 10.5px; font-weight: 700; fill: var(--accent-strong); font-variant-numeric: tabular-nums; }

/* ============ Aneka ============ */
.loader { display: grid; place-items: center; padding: 60px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--hairline); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-ikon { width: 58px; height: 58px; border-radius: var(--r-md); margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--hairline-2); }
.empty-ikon[data-tone="danger"] { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
.kebab { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 5px; z-index: 30; min-width: 168px; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: var(--r-xs); font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--bad-ink); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 600; }
.note { background: var(--surface-2); border: 1px solid var(--hairline-2); border-radius: var(--r-sm); padding: 11px 13px; font-size: 13.5px; color: var(--muted); }

/* ============ Toast ============ */
#toast-root { position: fixed; left: 0; right: 0; bottom: 22px; z-index: 200; display: flex; flex-direction: column;
  align-items: center; gap: 10px; padding: 0 16px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(440px, 100%);
  background: #2A2620; color: #FBF9F3; padding: 11px 16px 11px 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s, transform .22s; }
.toast.show { opacity: 1; transform: none; }
.toast .toast-ic { flex: 0 0 auto; }
.toast-sukses .toast-ic { color: #6FBF92; }
.toast-galat .toast-ic { color: #E59585; }

/* ============ Tombol aksi mengambang (FAB) ============ */
#fab-root { position: fixed; z-index: 60; right: 28px; bottom: 28px; }
.fab { width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 10px 26px rgba(33,30,24,.20), 0 3px 8px rgba(33,30,24,.12);
  transition: background .15s, transform .08s, box-shadow .15s; }
.fab:hover { background: var(--accent-strong); box-shadow: 0 14px 32px rgba(33,30,24,.26); }
.fab:active { transform: translateY(1px) scale(.97); }
.fab:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-tint), 0 10px 26px rgba(33,30,24,.2); }

/* ============ Responsif ============ */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  /* FAB di atas bilah navigasi bawah */
  #fab-root { right: 16px; bottom: calc(74px + env(safe-area-inset-bottom) + 10px); }
  .fab { width: 52px; height: 52px; }

  /* Sidebar menjadi bilah navigasi bawah. */
  .sidebar {
    width: 100%; height: auto; flex: none; gap: 2px;
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50;
    flex-direction: row; justify-content: space-around; align-items: stretch;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px);
  }
  .brand, .nav-spacer, .nav-foot, .acct-sidebar { display: none; }
  .nav-item { flex: 1 1 0; flex-direction: column; gap: 3px; width: auto; padding: 7px 4px; min-height: 48px;
    border-radius: var(--r-sm); font-size: 11px; text-align: center; justify-content: center; }
  .nav-item:hover { background: none; }
  .nav-item .lbl { display: block; font-size: 10.5px; line-height: 1; font-weight: 600; }
  .nav-item .ic { width: 100%; max-width: 60px; height: 26px; border-radius: 999px; transition: background .15s; }
  .nav-item.active { background: none; color: var(--accent-strong); }
  .nav-item.active .ic { background: var(--accent-tint); }

  /* Topbar: merek di kiri, akun di kanan. */
  .topbar { display: flex; padding: 10px 16px; min-height: 56px; }
  .topbar-brand { display: flex; }
  .acct-name { display: none; }
  .acct-btn { padding: 4px; }

  .view-root { padding: 20px 16px 96px; }
  .page-head h1 { font-size: 19px; }
  .form-row { grid-template-columns: 1fr; }
  .cal-cell { height: 76px; }

  #toast-root { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .modal-backdrop { padding-bottom: 84px; }
}
