@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --orange: #FF8A40;
  --orange-dark: #E8722A;
  --orange-light: #FFE4CC;
  --orange-pale: #FFF3E8;
  --ink: #2B2B2B;
  --ink-soft: #6B6560;
  --white: #FFFFFF;
  --green-ok: #2E4A2B;
  --red-err: #D9534F;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #FFFBF6;
  color: var(--ink);
}
h1, h2, h3 { font-family: 'Baloo 2', 'Nunito', sans-serif; }
a { color: var(--orange-dark); }

.screen { display: none; }
.screen.active { display: block; }

/* LOADING */
.loading-box { text-align: center; margin: 80px auto; }
.loading-logo { width: 120px; height: 120px; object-fit: contain; animation: bounce 1.4s ease-in-out infinite; }
.loading-box p { margin-top: 14px; color: var(--ink-soft); font-weight: 700; }
@keyframes bounce { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-10px);} }

/* LOGIN */
#screen-login.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #FFF9F3 0%, var(--orange-pale) 100%); padding: 20px; }
.login-card {
  background: #fff; border-radius: 26px; box-shadow: 0 10px 34px rgba(255,138,64,0.18);
  padding: 36px; width: 100%; max-width: 380px; text-align: center; border: 3px solid var(--orange-light);
}
.login-logo { width: 90px; height: 90px; object-fit: contain; margin-bottom: 10px; }
.login-card h1 { font-size: 24px; color: var(--orange-dark); margin-bottom: 4px; }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--ink-soft); margin-top: 14px; font-weight: 700; }
.small-note { font-size: 12px; margin-top: 18px; }

.muted { color: var(--ink-soft); font-size: 14px; }

.text-input {
  width: 100%; padding: 12px 14px; border: 2px solid var(--orange-light); border-radius: 12px;
  font-size: 15px; margin-top: 6px; background: #FFFBF6; color: var(--ink); font-family: inherit;
}
.text-input:focus { outline: none; border-color: var(--orange); }
.text-input.small { padding: 8px 10px; font-size: 13px; margin-top: 0; }

.btn {
  border: none; border-radius: 12px; padding: 11px 18px; font-size: 14px; font-weight: 800;
  font-family: 'Baloo 2', sans-serif; cursor: pointer;
}
.btn-block { width: 100%; margin-top: 16px; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--orange-pale); color: var(--orange-dark); }
.btn-secondary:hover { background: var(--orange-light); }
.btn-danger { background: #FBE4E1; color: #C0392B; }
.btn-danger:hover { background: #F6CFC9; }
.error-text { color: var(--red-err); font-size: 13px; min-height: 16px; font-weight: 700; margin-top: 8px; }
.saved-msg { color: var(--green-ok); font-size: 13px; font-weight: 700; margin-top: 8px; min-height: 16px; }

/* APP SHELL */
.app-shell.active { display: flex; min-height: 100vh; }
.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 300; width: 40px; height: 40px;
  border-radius: 10px; border: none; background: var(--orange); color: #fff; font-size: 18px; cursor: pointer;
}
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff; border-right: 2px solid var(--orange-pale);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; }
.sidebar-logo { width: 40px; height: 40px; object-fit: contain; }
.brand-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; color: var(--orange-dark); font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--ink-soft); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-btn {
  text-align: left; background: none; border: none; padding: 11px 12px; border-radius: 12px;
  font-size: 14px; font-weight: 700; color: var(--ink-soft); cursor: pointer;
}
.nav-btn:hover { background: var(--orange-pale); }
.nav-btn.active { background: var(--orange); color: #fff; }

.sidebar-footer { border-top: 2px solid var(--orange-pale); padding-top: 14px; }
.sidebar-user { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; word-break: break-all; }

.main-content { flex: 1; padding: 28px 34px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.view-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.view-header h1 { font-size: 22px; color: var(--orange-dark); }

.section-title { font-size: 16px; color: var(--orange-dark); margin: 18px 0 10px; }

.filter-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; }
.filter-row label { font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 2px; font-weight: 700; }

.table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: 0 2px 12px rgba(255,138,64,0.08); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--orange-pale); white-space: nowrap; }
th { background: var(--orange-pale); color: var(--orange-dark); font-weight: 800; position: sticky; top: 0; }
td.wrap { white-space: normal; min-width: 160px; }
td img.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; cursor: pointer; }
.emp-avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--orange-light); }
.emp-avatar-sm.placeholder { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--orange-dark); font-size: 12px; }

.status-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-ontime { background: #E3F3E3; color: #3C8C40; }
.status-late { background: #FBE4E1; color: #C0392B; }
.status-overtime { background: #FDEFD9; color: #B9770E; }
.status-early { background: #E6ECFA; color: #34558B; }
.status-inactive { background: #eee; color: #888; }
.status-eligible { background: #E3F3E3; color: #3C8C40; }
.status-not-eligible { background: #eee; color: #888; }
.status-note { display: block; margin-top: 4px; font-size: 11px; color: var(--ink-soft); font-style: italic; }
.small-link-btn { background: none; border: none; color: var(--orange-dark); font-size: 12px; text-decoration: underline; cursor: pointer; padding: 0; margin-right: 8px; }

.week-nav { display: flex; align-items: center; gap: 12px; }
.week-label { font-weight: 800; color: var(--ink); font-size: 14px; }
#scheduleTable select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--orange-light); font-size: 12px; background: #FFFBF6; }

.info-box {
  background: var(--orange-pale); border-left: 4px solid var(--orange); border-radius: 10px;
  padding: 14px 16px; font-size: 13px; color: var(--ink); margin-bottom: 16px; line-height: 1.5;
}
.info-box strong { color: var(--orange-dark); }

.settings-card {
  background: #fff; border-radius: 16px; padding: 20px; margin-bottom: 18px; max-width: 560px;
  box-shadow: 0 2px 12px rgba(255,138,64,0.08);
}
.settings-card label { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 700; margin-top: 12px; }
.settings-card .btn { margin-top: 14px; }

.shift-settings-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.shift-row {
  background: var(--orange-pale); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.shift-row .division-tag { font-weight: 800; color: var(--orange-dark); min-width: 66px; font-size: 12px; }
.shift-row input, .shift-row select { padding: 6px 8px; font-size: 12px; border-radius: 8px; border: 1px solid var(--orange-light); background: #FFFBF6; }
.shift-row input[type="text"] { width: 90px; }
.shift-row input[type="time"] { width: 100px; }
.shift-row input[type="number"] { width: 100px; }
.shift-row .btn { padding: 6px 10px; font-size: 12px; margin: 0; }

.sc-actions { display: flex; gap: 10px; margin-top: 14px; }

/* MODALS */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: 20px; padding: 26px; width: 100%; max-width: 420px; text-align: center;
  max-height: 90vh; overflow-y: auto;
}
.modal-box h2 { color: var(--orange-dark); font-size: 18px; margin-bottom: 6px; }
.modal-box label { display: block; text-align: left; font-size: 13px; color: var(--ink-soft); margin-top: 12px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; margin-top: 0; }
.photo-picker { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; }
.emp-photo-preview { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--orange-light); }
.photo-picker-buttons { display: flex; gap: 10px; }
.file-label { display: inline-flex; align-items: center; justify-content: center; }
.modal-photo-box img { width: 100%; border-radius: 12px; margin-bottom: 12px; }
.camera-wrap { width: 100%; max-width: 340px; aspect-ratio: 4/3; border-radius: 16px; overflow: hidden; background: #222; margin: 10px auto; }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* ===================== KEUANGAN ===================== */

.nav-divider {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); padding: 14px 12px 4px;
}

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

.kpi-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: #fff; border-radius: 14px; padding: 14px 18px; min-width: 170px; flex: 1;
  box-shadow: 0 2px 12px rgba(255,138,64,0.08); border: 2px solid var(--orange-pale);
}
.kpi-card .kpi-label { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.kpi-card .kpi-value { font-size: 20px; font-weight: 800; color: var(--orange-dark); margin-top: 4px; }
.kpi-card.kpi-warn { border-color: #F6CFC9; }
.kpi-card.kpi-warn .kpi-value { color: #C0392B; }
.kpi-card.kpi-good .kpi-value { color: var(--green-ok); }

.recon-status { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.recon-status.verified { background: #E3F3E3; color: #3C8C40; }
.recon-status.pending { background: #FDEFD9; color: #B9770E; }

.review-body { text-align: left; }
.review-section { margin-bottom: 14px; }
.review-section-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; color: var(--orange-dark); font-size: 13px; margin-bottom: 6px; }
.review-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--orange-pale); }
.review-row.total { font-weight: 800; border-bottom: none; padding-top: 6px; }
.review-empty { font-size: 12px; color: var(--ink-soft); }

.pnl-wrap { max-width: 560px; }
.pnl-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 12px rgba(255,138,64,0.08); }
.pnl-table td { padding: 10px 16px; border-bottom: 1px solid var(--orange-pale); font-size: 14px; }
.pnl-label { text-align: left; }
.pnl-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.pnl-sub .pnl-label { padding-left: 28px; color: var(--ink-soft); font-weight: 400; }
.pnl-sub .pnl-value { font-weight: 400; color: var(--ink-soft); }
.pnl-subtotal td { font-weight: 800; border-top: 2px solid var(--orange-light); }
.pnl-final td { font-weight: 800; font-size: 16px; color: var(--orange-dark); border-top: 3px double var(--orange); }
.pnl-note { font-size: 12px; color: var(--ink-soft); margin-top: 10px; line-height: 1.5; }

.dyn-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.dyn-item { display: flex; gap: 8px; align-items: center; background: var(--orange-pale); border-radius: 10px; padding: 8px 10px; }
.dyn-item input, .dyn-item select { flex: 1; padding: 6px 8px; font-size: 13px; margin-top: 0; }
.dyn-item-remove {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: none; background: #FBE4E1; color: #C0392B;
  font-size: 15px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

code { background: var(--orange-pale); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* RESPONSIVE */
@media (max-width: 880px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 250; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: 0 0 24px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 70px 16px 30px; }
  .view-header h1 { font-size: 19px; }
}
