/* ===== Buku Upah Kru - style (responsif HP & PC) ===== */
:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-deep: #134e4a;
  --amber: #d97706;
  --bg: #eef2f1;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --masuk: #16a34a;
  --izin: #d97706;
  --absen: #ef4444;
  --libur: #94a3b8;
  --danger: #dc2626;
  --nav-h: 62px;
  --side-w: 236px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 8px 30px rgba(15,23,42,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 20px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 16px; }

/* ---------- Sidebar (PC) ---------- */
.sidebar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 20px 18px 16px; color: #fff; letter-spacing: .01em; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 18px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 6px 12px; }
.side-nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; color: rgba(255,255,255,.82); border: none; cursor: pointer;
  padding: 12px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 500;
}
.side-nav button .ni { font-size: 18px; width: 22px; text-align: center; }
.side-nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.side-nav button.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

/* ---------- Main ---------- */
.app { padding-bottom: var(--nav-h); }
.screen { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Header */
.app-head {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff; padding: 18px 16px 16px; position: sticky; top: 0; z-index: 5;
}
.app-head .sub { margin: 4px 0 0; font-size: 13px; opacity: .9; }
.app-head.row { display: flex; align-items: center; gap: 10px; }
.app-head.row h1 { flex: 1; text-align: center; }
.icon-btn {
  background: rgba(255,255,255,.2); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.icon-btn.solid { background: var(--teal); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { border-radius: 16px; padding: 16px; color: #fff; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow); }
.stat-card.teal { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.stat-card.amber { background: linear-gradient(135deg, #b45309, #f59e0b); }
.stat-label { font-size: 12px; opacity: .92; }
.stat-val { font-size: 22px; font-weight: 800; }
.stat-foot { font-size: 11px; opacity: .85; }

/* Quick actions */
.quick-row { display: flex; gap: 12px; margin: 18px 0; }
.quick-btn {
  flex: 1; background: var(--teal); color: #fff; border: none; padding: 15px;
  border-radius: 14px; font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--shadow);
  transition: transform .08s;
}
.quick-btn:active { transform: scale(.97); }
.quick-btn.alt { background: var(--amber); }
.quick-btn .qi { font-size: 18px; font-weight: 700; }

.sec-title { margin: 20px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 11.5px; font-weight: 600; }

/* Lists & cards */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 14px; padding: 14px; border: 1px solid var(--line); cursor: pointer; box-shadow: var(--shadow); transition: transform .08s, box-shadow .15s; }
.card:not(.flat):hover { box-shadow: var(--shadow-lg); }
.card:not(.flat):active { transform: scale(.995); }
.card.flat { cursor: default; box-shadow: none; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-name { font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-amt { font-weight: 700; white-space: nowrap; }
.card-amt.neg { color: var(--danger); }

/* Avatar */
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; font-weight: 700; font-size: 13px; vertical-align: middle; margin-right: 6px; }
.avatar.supir { background: #0284c7; }
.avatar.kernet { background: #d97706; }
.avatar.lg { width: 48px; height: 48px; font-size: 20px; border-radius: 12px; margin-right: 12px; }

/* Badges / pills */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.supir { background: #e0f2fe; color: #0369a1; }
.badge.kernet { background: #fef3c7; color: #92400e; }
.badge.lunas { background: #dcfce7; color: #15803d; }
.pill { font-size: 10px; padding: 2px 7px; border-radius: 6px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.pill.masuk { background: var(--masuk); }
.pill.izin { background: var(--izin); }
.pill.absen { background: var(--absen); }
.pill.libur { background: var(--libur); }
.pill.bon { background: var(--amber); }

/* Chips */
.chips { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 15px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.chip.ghost { margin-left: auto; color: var(--teal); border-color: transparent; background: transparent; }

/* Week / month nav */
.week-nav, .month-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.week-label { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.month-row input[type=month] { flex: 1; padding: 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; color: var(--ink); }

/* Summary */
.sum-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.sum-card h2 { margin-bottom: 10px; }
.sum-card.hero { background: linear-gradient(135deg, #f0fdfa, #ffffff); border-color: #99f6e4; }
.sum-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; gap: 10px; }
.sum-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 11px; font-weight: 800; font-size: 17px; }
.sum-row.penuh { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 10px; color: var(--teal-dark); font-weight: 600; }
.detail-head { display: flex; align-items: center; }
.dh-name { font-weight: 700; font-size: 16px; }

/* Day grid */
.quickfill { display: flex; gap: 8px; margin: 6px 0 14px; align-items: center; flex-wrap: wrap; }
.quickfill .lbl { font-size: 12px; color: var(--muted); }
.qf-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--teal); background: #fff; color: var(--teal); font-weight: 700; cursor: pointer; }
.qf-btn:hover { background: var(--teal); color: #fff; }
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 16px; }
.day-cell { border: 1px solid var(--line); border-radius: 12px; padding: 7px 2px; text-align: center; cursor: pointer; background: #fff; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-family: inherit; }
.day-cell .dn { font-size: 10px; color: var(--muted); }
.day-cell .dnum { font-size: 14px; font-weight: 700; }
.day-cell .ds { font-size: 9px; font-weight: 700; }
.day-cell .dp { font-size: 8px; color: var(--muted); line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-cell.masuk { background: #dcfce7; border-color: #86efac; } .day-cell.masuk .ds { color: var(--masuk); }
.day-cell.izin { background: #fef3c7; border-color: #fcd34d; } .day-cell.izin .ds { color: var(--izin); }
.day-cell.absen { background: #fee2e2; border-color: #fca5a5; } .day-cell.absen .ds { color: var(--absen); }
.day-cell.libur { background: #f1f5f9; border-color: #cbd5e1; } .day-cell.libur .ds { color: var(--libur); }
.day-cell.weekend { background: #f8fafc; } .day-cell.weekend .ds { color: var(--libur); }
.day-cell.empty .ds { color: #cbd5e1; }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
table.rep { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 560px; }
table.rep th, table.rep td { padding: 9px 11px; text-align: right; white-space: nowrap; }
table.rep th:first-child, table.rep td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
table.rep thead th { background: #f0fdfa; color: var(--teal-deep); border-bottom: 1px solid var(--line); }
table.rep tbody tr { border-top: 1px solid var(--line); }
table.rep tbody tr:hover td { background: #f8fafc; }
table.rep tfoot td { border-top: 2px solid var(--teal); font-weight: 700; background: #f0fdfa; }

/* Buttons */
.btn-primary { background: var(--teal); color: #fff; border: none; padding: 12px 16px; border-radius: 11px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary.sm { padding: 11px 14px; flex: 0 0 auto; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 12px 16px; border-radius: 11px; font-size: 14px; cursor: pointer; }
.btn-ghost.full { width: 100%; margin-top: 8px; }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 12px 16px; border-radius: 11px; font-size: 14px; cursor: pointer; }
.btn-lunas { background: var(--amber); color: #fff; border: none; padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.wide { width: 100%; margin-top: 12px; }

/* Bottom nav (HP) */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; color: var(--muted); padding: 6px 0; }
.nav-btn .ni { font-size: 19px; }
.nav-btn.active { color: var(--teal); font-weight: 600; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: #fff; width: 100%; max-width: 460px; border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.modal-card input, .modal-card select { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 11px; font-size: 15px; background: #fff; color: var(--ink); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.modal-actions.between { align-items: center; }
.modal-actions .spacer { flex: 1; }
.status-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st-opt { padding: 15px; border-radius: 12px; border: none; color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.st-opt.masuk { background: var(--masuk); } .st-opt.izin { background: var(--izin); }
.st-opt.absen { background: var(--absen); } .st-opt.libur { background: var(--libur); }

/* Quick upah list */
.quick-upah-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.qu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px; }
.qu-item .qu-name { font-weight: 600; font-size: 14px; }
.qu-item .qu-sub { font-size: 11px; color: var(--muted); }
.qu-opts { display: flex; gap: 4px; }
.qu-opts button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.qu-opts button.sel-masuk { background: var(--masuk); color: #fff; border-color: var(--masuk); }
.qu-opts button.sel-izin { background: var(--izin); color: #fff; border-color: var(--izin); }
.qu-opts button.sel-absen { background: var(--absen); color: #fff; border-color: var(--absen); }
.qu-opts button.sel-libur { background: var(--libur); color: #fff; border-color: var(--libur); }

/* Empty + toast + sync */
.empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 14px; }
.toast { position: fixed; bottom: calc(var(--nav-h) + 14px); left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 11px; font-size: 13px; z-index: 100; max-width: 90%; text-align: center; box-shadow: var(--shadow-lg); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--teal); }
.sync-bar { position: fixed; top: 0; left: 0; right: 0; background: var(--amber); color: #fff; font-size: 12px; text-align: center; padding: 6px; z-index: 60; }

/* ---------- RESPONSIF ---------- */
/* Tablet: pusatkan konten */
@media (min-width: 560px) and (max-width: 899px) {
  .app { max-width: 540px; margin: 0 auto; }
  .bottom-nav { max-width: 540px; margin: 0 auto; }
}

/* Desktop: sidebar kiri, bottom-nav sembunyi, header rata & lebih lebar */
@media (min-width: 900px) {
  body { display: flex; min-height: 100vh; }
  .sidebar { display: block; position: fixed; top: 0; left: 0; bottom: 0; width: var(--side-w); background: linear-gradient(180deg, var(--teal-deep), var(--teal-dark)); overflow-y: auto; }
  .app { margin-left: var(--side-w); flex: 1; min-width: 0; max-width: none; padding-bottom: 32px; }
  .bottom-nav { display: none; }
  .app-head { border-radius: 0; }
  .pad { padding: 22px 28px 40px; }
  .app-head { padding: 22px 28px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 620px; }
  #karyawanList { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
  .quick-row { max-width: 620px; }
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; max-width: 440px; }
}
