:root {
  --bg: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #F1ECE1;
  --border: #E4DDCD;
  --text: #201C15;
  --text-muted: #756C5C;
  --text-faint: #A39A88;
  --primary: #0B6B57;
  --primary-dark: #084F40;
  --primary-tint: #E3F0EB;
  --gold: #A6780F;
  --gold-tint: #F6EDD8;
  --hadir: #1E8E5A;
  --hadir-tint: #E4F5EC;
  --terlambat: #C98A1A;
  --terlambat-tint: #FBF0DC;
  --sakit: #3E6FA8;
  --sakit-tint: #E7EFF8;
  --izin: #7A5AC2;
  --izin-tint: #EFEAFA;
  --alpa: #C1402F;
  --alpa-tint: #FBE9E6;
  --netral: #8A8272;
  --netral-tint: #EFEBE1;
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 76px; /* ruang untuk bottom nav fixed */
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-size: 15px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }

/* Topbar */
.topbar { padding: 22px 20px 6px; }
.topbar-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.topbar-back { padding: 16px 16px 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--text); flex-shrink: 0; border: none; }
.greeting-sub { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.greeting-name { font-size: 21px; font-weight: 800; margin-top: 2px; }
.greeting-date { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; font-weight: 600; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-tint); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.avatar-sm { width: 40px; height: 40px; border-radius: 11px; font-size: 13px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 15px; }
.card-primary { background: var(--primary); color: #fff; border-radius: 20px; padding: 20px; }
.badge { font-size: 11px; font-weight: 800; display: inline-block; padding: 3px 8px; border-radius: 6px; letter-spacing: 0.03em; }
.badge-primary { color: var(--primary); background: var(--primary-tint); }
.badge-gold { color: var(--gold); background: var(--gold-tint); }
.pill { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 7px; display: inline-flex; align-items: center; gap: 4px; }
.pill-primary { color: var(--primary); background: var(--primary-tint); }
.pill-gold { color: var(--gold); background: var(--gold-tint); }
.pill-hadir { color: var(--hadir); background: var(--hadir-tint); }
.pill-terlambat { color: var(--terlambat); background: var(--terlambat-tint); }
.pill-muted { color: var(--text-faint); background: transparent; }

.section-title { padding: 20px 20px 8px; font-size: 12.5px; font-weight: 800; color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.list-px { padding: 0 20px; }
.row-link { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.row-link .chev { color: var(--text-faint); flex-shrink: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 14px 18px; border-radius: 12px; font-weight: 800; font-size: 13.5px; border: 1.5px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #fff; color: var(--text-muted); border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); display: block; margin-bottom: 7px; }
.field input[type=text], .field input[type=number], .field input[type=time], .field input[type=email],
.field input[type=password], .field select, .field textarea {
  width: 100%; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
}
.field textarea { resize: vertical; }
.chip-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 11px 13px; border-radius: 11px; font-weight: 700; font-size: 12.5px; white-space: nowrap; background: #fff; color: var(--text-muted); border: 1.5px solid var(--border); }
.chip.selected { color: #fff; background: var(--primary); border-color: var(--primary); }
.chip-code.selected-hadir { background: var(--hadir-tint); border-color: var(--hadir); color: var(--hadir); }
.chip-code.selected-terlambat { background: var(--terlambat-tint); border-color: var(--terlambat); color: var(--terlambat); }
.chip-code.selected-sakit { background: var(--sakit-tint); border-color: var(--sakit); color: var(--sakit); }
.chip-code.selected-izin { background: var(--izin-tint); border-color: var(--izin); color: var(--izin); }
.chip-code.selected-alpa { background: var(--alpa-tint); border-color: var(--alpa); color: var(--alpa); }
.chip-code.selected-netral { background: var(--netral-tint); border-color: var(--netral); color: var(--netral); }

/* Chip berbasis radio/checkbox asli (tanpa JS) */
.chip-radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip-radio + label.chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.chip-radio:focus-visible + label.chip { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip-radio:checked + label.chip.code-V { background: var(--hadir-tint); border-color: var(--hadir); color: var(--hadir); }
.chip-radio:checked + label.chip.code-T { background: var(--terlambat-tint); border-color: var(--terlambat); color: var(--terlambat); }
.chip-radio:checked + label.chip.code-S { background: var(--sakit-tint); border-color: var(--sakit); color: var(--sakit); }
.chip-radio:checked + label.chip.code-I { background: var(--izin-tint); border-color: var(--izin); color: var(--izin); }
.chip-radio:checked + label.chip.code-A { background: var(--alpa-tint); border-color: var(--alpa); color: var(--alpa); }
.chip-radio:checked + label.chip.code-G,
.chip-radio:checked + label.chip.code-D { background: var(--netral-tint); border-color: var(--netral); color: var(--netral); }

/* Bottom nav */
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; display: flex; justify-content: space-around; align-items: center; height: 68px; border-top: 1px solid var(--border); background: var(--surface); z-index: 20; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-faint); }
.nav-item.active { color: var(--primary); }
.nav-item span { font-size: 10.5px; font-weight: 700; }

/* Footer aksi sticky (form) */
.footer-actions { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); position: sticky; bottom: 0; }

/* Tabel scroll horizontal */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table.recap { border-collapse: collapse; font-size: 11.5px; white-space: nowrap; width: 100%; }
table.recap th { text-align: left; padding: 10px 8px; font-weight: 800; background: var(--surface-2); }
table.recap td { padding: 8px; border-top: 1px solid var(--border); }
table.recap th:first-child, table.recap td:first-child { position: sticky; left: 0; background: inherit; padding-left: 12px; }
table.recap td:first-child { background: var(--surface); font-weight: 700; }
.code-pill { display: inline-block; min-width: 20px; text-align: center; padding: 3px 6px; border-radius: 6px; font-weight: 800; }

.wa-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.wa-preview pre { margin: 0; white-space: pre-wrap; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; line-height: 1.6; color: var(--text); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.muted-box { background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 12px; color: var(--text-muted); font-weight: 700; text-align: center; }
.hint-box { background: var(--primary-tint); border-radius: 12px; padding: 12px 14px; font-size: 12px; color: var(--primary-dark); font-weight: 600; line-height: 1.5; }
.flash { padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 700; margin: 16px 20px 0; }
.flash-success { background: var(--hadir-tint); color: var(--hadir); }
.flash-error { background: var(--alpa-tint); color: var(--alpa); }

/* --- Panel admin (layout lebar, tabel biasa) --- */
.admin-shell { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-nav a { padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); }
.admin-nav a.active { color: #fff; background: var(--primary); border-color: var(--primary); }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
table.admin-table th { text-align: left; padding: 12px 14px; background: var(--surface-2); font-size: 12.5px; font-weight: 800; }
table.admin-table td { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.admin-actions { display: flex; gap: 8px; }
.admin-form { max-width: 560px; }

@media (max-width: 480px) {
  .admin-shell { padding: 0 16px 60px; }
}
