:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7785;
  --line: #e2e6eb;
  --primary: #1f4e79;
  --primary-soft: #e6eef6;
  --accent: #e08a1e;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1 { font-size: 1.3rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: .88rem; }
main { max-width: 860px; margin: 0 auto; padding: 14px 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--primary); color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { font-weight: 700; }
.who { font-size: .85rem; opacity: .9; text-align: right; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--card);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; text-align: center; padding: 10px 4px 8px; color: var(--muted);
  text-decoration: none; font-size: .78rem; font-weight: 600;
}
.bottomnav a .ic { display: block; font-size: 1.3rem; line-height: 1.2; }
.bottomnav a.active { color: var(--primary); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line); }

label { display: block; font-size: .85rem; font-weight: 600; margin: 0 0 4px; color: #3a4553; }
input, select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #cdd4dc; border-radius: 10px;
  background: #fff; color: var(--text); min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 > *, .grid3 > * { min-width: 0; }
input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 16px;
  min-height: 46px; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: #fbeaea; color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn:disabled { opacity: .6; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Form absensi */
.entry { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: #fbfcfd; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.entry-head strong { font-size: .9rem; color: var(--muted); }
.icon-btn { background: none; border: 0; color: var(--danger); font-size: .9rem; font-weight: 600; padding: 6px; cursor: pointer; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 44px; border: 1px solid #cdd4dc; background: #fff; font-size: 1.2rem; cursor: pointer; color: var(--primary); }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper input { border-radius: 0; text-align: center; border-left: 0; border-right: 0; min-width: 0; }
.note-input { margin-top: 8px; }

.sticky-save {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 6px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06); display: flex; gap: 12px; align-items: center;
}
.sticky-save .tot { flex: 1; font-size: .85rem; color: var(--muted); }
.sticky-save .tot b { color: var(--text); font-size: 1.1rem; }

/* Rekap */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .v { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat.accent .v { color: var(--accent); }
.stat .l { font-size: .8rem; color: var(--muted); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); background: #f8f9fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group td { background: var(--primary-soft); font-weight: 700; color: var(--primary); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); }
.badge.off { background: #eee; color: #888; }
.badge.warn { background: #fdf0de; color: var(--accent); }

.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-wrap .card { width: 100%; max-width: 380px; padding: 22px; }
.login-logo { font-size: 2.2rem; text-align: center; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; background: #1c2430; color: #fff; padding: 12px 16px;
  border-radius: 10px; z-index: 50; text-align: center; font-size: .95rem; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 22px; min-height: 22px; }

/* Lembur */
input[type="time"] { min-width: 0; -webkit-appearance: none; appearance: none; }
.ot-toggle { margin: 4px 0 2px; padding: 8px 0; }
.ot-box { background: #fff8ee; border: 1px solid #f2d9b3; border-radius: 10px; padding: 10px; margin: 6px 0 4px; }
.ot-row { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed #f2d9b3; }
.ot-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700;
  font-size: .85rem; color: var(--accent); margin-bottom: 6px; }
.ot-info { margin-top: 8px; font-size: .85rem; color: #6b4a1a; }

/* Laporan harian & navigasi */
.back { display: inline-block; margin: 0 0 6px; color: var(--primary); font-weight: 600; text-decoration: none; }
.notice p { margin: 6px 0 12px; }
.rule-note { margin: -2px 2px 12px; font-size: .8rem; }
.master-form { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.rep-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.rep-line { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.rep-line .muted { font-size: .82rem; margin-top: 2px; }
.rep-main { display: flex; justify-content: space-between; gap: 10px; }
.rep-foot { padding-top: 8px; font-size: .88rem; text-align: right; }

/* Jam 24 jam */
.timepick { display: flex; align-items: center; gap: 4px; }
.timepick select { flex: 1; min-width: 0; padding: 11px 6px; text-align: center; font-variant-numeric: tabular-nums; }
.timepick span { font-weight: 700; }

/* Beranda */
.hello { margin: 2px 0 14px; }
.hello h1 { margin-bottom: 2px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.menu-tile { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px; text-decoration: none; color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.05); min-height: 120px; }
.menu-tile:active { transform: scale(.98); }
.menu-tile .ic { font-size: 1.9rem; line-height: 1.1; }
.menu-tile b { font-size: 1rem; }
.menu-tile small { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.menu-tile.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.menu-tile.primary small { color: rgba(255,255,255,.85); }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.status-row:last-child { border-bottom: 0; }
.badge.ok { background: #e3f4ec; color: var(--ok); }

/* Password lihat / sembunyikan */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 50px; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 100%; width: 48px; border: 0; background: none;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--primary); }

/* Lembur melebihi total tenaga */
.ot-reason { margin-top: 10px; padding: 10px; border-radius: 8px; background: #fdecea; border: 1px solid #f5c2bd; }
.ot-reason label { color: var(--danger); font-size: .85rem; }
.ot-reason textarea { resize: vertical; min-height: 64px; }
.over-note { margin-top: 4px; font-size: .82rem; color: #8a3a1a; background: #fdf0de; border-radius: 6px; padding: 6px 8px; }
.ot-warn { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #fdf0de; border: 1px solid #f2d9b3;
  color: #8a3a1a; font-size: .85rem; font-weight: 600; }
