:root {
  --brand: #ED1B24;
  --brand-dark: #C4141B;
  --brand-soft: #FDECEC;
  --ink: #1F2A37;
  --ink-2: #475467;
  --muted: #8A94A6;
  --border: #E4E7EC;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --ok: #12805C;
  --warn: #B54708;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }

/* ---------- Header & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 800; color: var(--brand); font-size: 18px; letter-spacing: -.01em; white-space: nowrap; }
.brand small { color: var(--ink); font-weight: 700; }
.spacer { flex: 1; }
.who { text-align: right; line-height: 1.2; min-width: 0; }
.who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.who span { font-size: 12px; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 10px;
  width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); }
.tabs {
  max-width: 880px; margin: 0 auto; padding: 0 12px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 12px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

main { max-width: 880px; margin: 0 auto; padding: 16px 16px 80px; }

/* ---------- Umum ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 16px; }
h1.page { font-size: 22px; margin: 4px 0 4px; letter-spacing: -.01em; line-height: 1.25; }
.sub { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.red { background: var(--brand-soft); color: var(--brand-dark); border-color: #F9C9CB; }
.badge.green { background: #E7F6EF; color: var(--ok); border-color: #BDE5D3; }
.badge.gray { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--card); border-radius: 10px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--brand-dark); border-color: #F9C9CB; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: #fff; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(237, 27, 36, .12); }
textarea.input { min-height: 380px; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; line-height: 1.6; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 13px; cursor: pointer; background: #fff; user-select: none;
}
.check input { accent-color: var(--brand); margin: 0; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: var(--brand-soft); color: var(--brand-dark); }
.alert-info { background: #EEF4FF; color: #3538CD; }
.alert-ok { background: #E7F6EF; color: var(--ok); }
.alert-warn { background: #FEF6EE; color: var(--warn); }

/* ---------- Beranda ---------- */
.search {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search input { flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.theme { margin-bottom: 12px; overflow: hidden; }
.theme > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.theme > summary::-webkit-details-marker { display: none; }
.theme-no {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.theme-name { font-weight: 700; flex: 1; min-width: 0; }
.theme-count { font-size: 12px; color: var(--muted); }
.chev { transition: transform .15s; color: var(--muted); flex-shrink: 0; }
.theme[open] .chev { transform: rotate(90deg); }
.sop-list { border-top: 1px solid var(--border); }
.sop-link {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 12px 56px;
  border-bottom: 1px solid var(--border); font-size: 14.5px;
}
.sop-link:last-child { border-bottom: 0; }
.sop-link:hover { background: var(--bg); }
.sop-link .t { flex: 1; min-width: 0; }

/* ---------- Tampilan SOP ---------- */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.crumb a:hover { color: var(--brand); }
.sop-head { margin-bottom: 14px; }
.sec-tabs { position: sticky; top: 58px; z-index: 5; background: var(--bg); padding: 6px 0 10px; margin-bottom: 4px; }
.sop-body { padding: 18px 16px; }
.sop-body > :first-child { margin-top: 0; }
.blk-h1 {
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand);
  margin: 22px 0 8px; display: flex; align-items: center; gap: 10px;
}
.blk-h1::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.blk-h2 { font-size: 15px; font-weight: 700; margin: 16px 0 6px; }
.blk-p { margin: 0 0 8px; white-space: pre-line; }
.blk-list { margin: 0 0 10px; }
.li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.li:last-child { border-bottom: 0; }
.li .n {
  flex-shrink: 0; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; background: var(--bg);
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: var(--ink-2);
}
.li.lv0 .n { background: var(--ink); color: #fff; }
.li .x { padding-top: 2px; }
.blk-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0 12px; display: block; }

.tbl-tools { margin: 4px 0 10px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; background: #fff; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.sect td { background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.tbl img.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block; border: 1px solid var(--border); }
.tbl td.merged-top { border-bottom: 0; }

@media (max-width: 640px) {
  .stackable { border: 0; background: transparent; overflow: visible; }
  .stackable .tbl thead { display: none; }
  .stackable .tbl, .stackable .tbl tbody { display: block; }
  .stackable .tbl tr[data-row] {
    display: grid; grid-template-columns: 1fr auto; column-gap: 12px;
    border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 10px 12px; margin-bottom: 8px;
  }
  .stackable .tbl tr[data-row][hidden] { display: none; }
  .stackable .tbl tr.sect { display: block; margin: 14px 0 8px; }
  .stackable .tbl tr.sect td { display: block; border-radius: 8px; }
  .stackable .tbl td {
    grid-column: 1; display: flex; gap: 8px; border: 0; padding: 2px 0; text-align: left; white-space: normal;
  }
  .stackable .tbl td::before {
    content: attr(data-label); flex: 0 0 42%; color: var(--muted); font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em; padding-top: 2px;
  }
  .stackable .tbl td[data-empty] { display: none; }
  .stackable .tbl td[data-key] { order: -1; font-weight: 700; font-size: 15px; padding-bottom: 4px; }
  .stackable .tbl td[data-key]::before, .stackable .tbl td[data-photo]::before { display: none; }
  .stackable .tbl td[data-photo] { grid-column: 2; grid-row: 1 / span 20; align-self: start; }
  .stackable .tbl td[data-photo] img.thumb { width: 84px; height: 84px; }
}

.rgroup-title { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); margin: 18px 0 8px; }
.rcards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 12px; }
.rcard { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; background: #fff; }
.rcard-title { padding: 10px 12px; font-weight: 700; background: var(--bg); border-bottom: 1px solid var(--border); }
.rcard table.tbl th { background: #fff; white-space: normal; }
.rcard .tbl th, .rcard .tbl td { padding: 7px 8px; }
@media (max-width: 640px) {
  .rcards { grid-template-columns: 1fr; }
  .sop-body { padding: 16px 12px; }
}

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 100; display: grid; place-items: center; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 10px; }

/* ---------- Admin ---------- */
.admin-theme { margin-bottom: 12px; }
.admin-theme-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.admin-theme-head .theme-name { min-width: 140px; }
.admin-sop { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.admin-sop:last-child { border-bottom: 0; }
.admin-sop .t { flex: 1; min-width: 160px; font-size: 14.5px; }
.admin-sop .t a:hover { color: var(--brand); }
.act { display: flex; gap: 4px; }
.act .btn { padding: 4px 9px; }

.list-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .main { flex: 1; min-width: 180px; }

.report td, .report th { font-size: 13px; }

.help { font-size: 13px; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.help code { background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; font-size: 12.5px; }
.help summary { cursor: pointer; font-weight: 700; }

.modal-back {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px 20px;
}
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
@media (min-width: 600px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 16px; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}

/* ---------- Absensi ---------- */
.badge.warn { background: #FEF6EE; color: var(--warn); border-color: #F9DBAF; }
.chip .count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 800;
}
.abs-hero { text-align: center; padding: 20px 16px; background: var(--ink); color: #fff; border-color: var(--ink); }
.abs-date { font-size: 14px; opacity: .8; }
.abs-clock { font-size: 46px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 4px 0; }
.abs-who { font-size: 13px; opacity: .7; }
.abs-status { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; margin-bottom: 14px; }
.abs-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.abs-status.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px #E7F6EF; }
.abs-status.done .dot { background: var(--ink); }
.abs-kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.abs-kv > div { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.abs-kv span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.abs-kv b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abs-kv small { font-size: 12px; color: var(--ink-2); }
.btn.big { padding: 14px; font-size: 16px; border-radius: 12px; }
.abs-hint { text-align: center; margin: 8px 0 0; }
.abs-title { font-size: 16px; margin: 20px 0 8px; }
.abs-note { font-size: 13.5px; margin-top: 4px; white-space: pre-line; }
.abs-preview { display: block; width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; background: var(--bg); margin-bottom: 12px; }
.abs-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
textarea.input.short { min-height: 90px; font-family: inherit; font-size: inherit; }

.abs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.abs-stats .card { padding: 12px; text-align: center; }
.abs-stats b { display: block; font-size: 26px; line-height: 1.1; }
.abs-stats b.red, .abs-tbl td.red { color: var(--brand-dark); }
.abs-stats span { font-size: 12px; color: var(--muted); font-weight: 600; }
.abs-user { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.abs-user:last-child { border-bottom: 0; }
.abs-rec { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0 0; flex-wrap: wrap; }
.card > .abs-rec { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.card > .abs-rec:last-child { border-bottom: 0; }
.abs-rec .main { flex: 1; min-width: 180px; font-size: 14px; }
.abs-photos { display: flex; gap: 4px; }
.abs-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.abs-leave { display: flex; gap: 8px; align-items: center; padding-top: 8px; flex-wrap: wrap; }
.abs-tbl td.num, .abs-tbl th { text-align: center; }
.abs-tbl td:first-child { white-space: nowrap; }
.abs-link { font-weight: 700; color: var(--brand-dark); }
.abs-total td { font-weight: 800; background: var(--bg); }
.abs-status.warn .dot { background: var(--warn); box-shadow: 0 0 0 4px #FEF6EE; }
.abs-decide { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 8px; }
.abs-review { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px; background: #FEF6EE; border-radius: 8px; }
.abs-subtitle { font-size: 14px; color: var(--ink-2); margin: 14px 0 6px; }
.abs-next { background: #EEF4FF; color: #3538CD; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; line-height: 1.6; }
.abs-rules summary { cursor: pointer; font-weight: 700; }
.abs-sublabel { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 3px; }

/* Indikator status lokasi (live) */
.gps-stat { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; font-size: 13px; font-weight: 600; }
.gps-stat .gps-dot { width: 10px; height: 10px; border-radius: 50%; background: #6b7280; flex-shrink: 0; }
.gps-stat .gps-text { color: var(--muted); }
.gps-stat[data-state="on"] .gps-dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); animation: gpsPulse 1.6s ease-in-out infinite; }
.gps-stat[data-state="on"] .gps-text { color: #12805C; }
.gps-stat[data-state="wait"] .gps-dot { background: #f59e0b; }
.gps-stat[data-state="wait"] .gps-text { color: var(--warn); }
.gps-stat[data-state="off"] .gps-dot { background: #4b5563; }
.gps-stat[data-state="denied"] .gps-dot { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
.gps-stat[data-state="denied"] .gps-text { color: var(--brand-dark); }
@keyframes gpsPulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); } 50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); } }

/* Kamera selfie live */
.cam-back { position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.cam { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px; }
.cam-wrap { position: relative; width: 100%; aspect-ratio: 3/4; max-height: 70vh; border-radius: 14px; overflow: hidden; background: #000; }
.cam-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-oval {
  position: absolute; left: 17%; top: 5%; width: 66%; height: 80%;
  border: 3px dashed rgba(255,255,255,.85); border-radius: 50%;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45); pointer-events: none; transition: border-color .15s;
}
.cam-oval.ok { border-color: #22c55e; border-style: solid; }
.cam-status { text-align: center; color: #fff; font-weight: 600; font-size: 14px; min-height: 20px; }
.cam-status.ok { color: #4ade80; }
.cam-actions { display: flex; gap: 10px; }
.cam-actions .btn { flex: 1; padding: 13px; }
.abs-shift {
  padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.abs-shift .row { align-items: flex-end; margin-bottom: 8px; }
.abs-shift label > span { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 3px; }
.abs-shift-name { flex: 1; min-width: 160px; }
.abs-seg { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.abs-seg-no { font-size: 12px; font-weight: 800; color: var(--brand-dark); min-width: 44px; padding-bottom: 12px; }
.abs-seg-no:empty { display: none; }
.abs-shift [type=time] { width: 112px; padding: 10px 6px; }
.abs-rules { font-size: 13px; background: var(--bg); border-radius: 10px; padding: 8px 12px; margin-top: 10px; line-height: 1.7; }
@media (max-width: 640px) {
  .abs-stats { grid-template-columns: repeat(2, 1fr); }
  .abs-kv b { font-size: 15px; }
  .abs-shift-name { flex-basis: 100%; }
}

/* ---------- Perlindungan konten (karyawan) ---------- */
html.guard body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.guard input, html.guard textarea { -webkit-user-select: text; user-select: text; }
html.guard img { -webkit-user-drag: none; pointer-events: auto; }
#watermark {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; background-repeat: repeat;
}
#shield {
  position: fixed; inset: 0; z-index: 200; background: var(--bg); display: none;
  place-items: center; text-align: center; padding: 24px; color: var(--ink-2); font-weight: 600;
}
html.guard-hidden #shield { display: grid; }
@media print {
  html.guard body { display: none !important; }
}
