:root {
  --bg-top: #fdf8f0;
  --bg-bottom: #f2e3cf;
  --ink: #33200f;
  --ink-soft: #7d6149;
  --line: #eddfcc;
  --card: #fffdf9;
  --accent: #8a4b2a;
  --accent-dark: #6c3719;
  --gold: #c08a45;
  --green: #5a7434;
  --green-soft: #eef2e1;
  --amber: #a8721f;
  --amber-soft: #fbf0da;
  --red: #a83a25;
  --red-soft: #fbe9e3;
  --slate-soft: #f8f0e3;
  --radius: 18px;
  --shadow: 0 20px 45px -26px rgba(74, 42, 18, 0.45), 0 2px 6px rgba(74, 42, 18, 0.05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  padding: 28px 16px 40px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -10%, #fff8ec 0%, transparent 60%), linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fade 0.3s ease;
}

.hidden { display: none !important; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- typography ---------- */
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 2px 0 0; letter-spacing: -0.01em; }
h3 { font-size: 18px; margin: 0 0 4px; }
p { margin: 0; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.muted { color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.small { font-size: 12.5px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- brand / topbar ---------- */
.brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 6px 2px 2px;
}

.logo {
  display: block;
  height: 118px;
  width: auto;
  mix-blend-mode: multiply; /* drops the logo's white plate onto the cream bg */
}

.brand-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 4px 2px;
}

.topbar-id { display: flex; align-items: center; gap: 14px; }
.topbar-id .logo { height: 52px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(16, 24, 40, 0.06);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-card { padding: 30px 26px; }

/* ---------- passcode input ---------- */
.passcode {
  width: 100%;
  margin: 18px 0 2px;
  padding: 16px 18px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.55em;
  text-align: center;
  color: var(--ink);
  background: var(--slate-soft);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.passcode::placeholder { color: #b6becb; letter-spacing: 0.4em; }
.passcode:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(138, 75, 42, 0.12);
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.block { width: 100%; margin-top: 14px; }

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn.success { background: var(--green-soft); color: var(--green); border-color: #bfe5d5; }
.btn.success:hover:not(:disabled) { background: #d6efe5; }

.btn.danger { background: var(--red-soft); color: var(--red); border-color: #f6d0cb; }
.btn.danger:hover:not(:disabled) { background: #fbdcd8; }

.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: var(--slate-soft); color: var(--ink); }

.link {
  background: none; border: 0; padding: 0;
  font: inherit; font-size: 13px; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--accent); }

.page-footer {
  text-align: center;
  padding: 6px 0 2px;
}

.hint {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  color: #667085;
}

/* ---------- clock card ---------- */
.clock-card {
  padding: 24px;
  background: linear-gradient(155deg, #fffdf9 0%, #fbf1e0 100%);
  border-color: #f0e0c9;
}
.clock {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.clock-sub { font-size: 13px; color: var(--ink-soft); }

/* ---------- staff status ---------- */
.row-between {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.row-between.wrap { flex-wrap: wrap; }

.big-status {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--slate-soft);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge.full { background: var(--green-soft); color: var(--green); }
.badge.half { background: var(--amber-soft); color: var(--amber); }
.badge.open { background: #eee9f7; color: #5b468f; }
.badge.absent { background: var(--red-soft); color: var(--red); }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 22px;
  padding: 16px;
  border-radius: 14px;
  background: var(--slate-soft);
}
.facts dt {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px;
}
.facts dd {
  margin: 0; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums;
}

.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; }

/* ---------- admin ---------- */
.date-field {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 650; color: var(--ink-soft);
}
.date-field input {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--slate-soft);
  outline: none;
}
.date-field input:focus { border-color: var(--accent); background: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--slate-soft);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.chip b { color: var(--ink); font-weight: 700; }

.table-card { padding: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
tbody td:nth-child(2) { font-weight: 600; white-space: normal; }

.codes-card { padding: 18px 22px; }
.codes-card summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}
.codes-card summary::marker { color: var(--gold); }
.codes-card .muted { margin: 10px 0 14px; }
.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.code-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--slate-soft);
  font-size: 12.5px;
}
.code-item span:first-child { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.code-item code { font-weight: 700; letter-spacing: 0.08em; color: var(--ink); }
.file-links { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 2px; }
.file-links a {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 1px;
}
.file-links a:hover { color: var(--accent-dark); }

/* ---------- admin header actions / salary toggle ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
}
.icon-btn .eye {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn .eye-shut { display: none; }
#money-toggle[aria-pressed="true"] .eye-open { display: none; }
#money-toggle[aria-pressed="true"] .eye-shut { display: block; }
#money-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--gold); }

/* ---------- admin tabs / monthly ---------- */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f3e7d5;
}
.seg-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 8px 20px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  background: transparent;
}
.seg-btn.active {
  background: #fffdf9;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(88, 50, 22, 0.16);
}
.monthly-note {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.monthly-note b { color: var(--ink); }
#view-monthly table th:nth-child(n + 3),
#view-monthly table td:nth-child(n + 3) { text-align: right; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(3px);
  z-index: 20;
}
.modal-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 30px 70px -20px rgba(16, 24, 40, 0.5);
  animation: fade 0.18s ease;
}
.modal-card .muted { margin-top: 4px; }
.modal-card .actions { margin-top: 18px; display: flex; gap: 8px; justify-content: flex-end; }
.modal-card .actions .btn { flex: 1; }

/* ---------- payslip image download ---------- */
@media (pointer: fine) {
  #payslip-download { margin-left: 8px; }
}

/* ---------- payslip ---------- */
.payslip-card { max-width: 460px; }
.payslip-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.payslip-logo { height: 58px; width: auto; }
.payslip-head h3 { margin: 2px 0 0; }
.payslip-grid { margin: 0; display: grid; gap: 8px; }
.payslip-grid > div {
  display: flex; justify-content: space-between; gap: 16px;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.payslip-grid dt { color: var(--ink-soft); }
.payslip-grid dd { margin: 0; font-weight: 600; text-align: right; }
.payslip-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 16px; padding: 12px 14px;
  border-radius: 12px;
  background: var(--slate-soft);
  font-size: 14px; color: var(--ink-soft);
}
.payslip-total b { font-size: 20px; color: var(--accent-dark); }
.payslip-note { margin-top: 10px; line-height: 1.5; }
.small-btn { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.payslip-cell { text-align: right; }

/* ---------- clean payslip image (off-screen render) ---------- */
.payslip-sheet-wrap {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 520px;
  padding: 28px;
  box-sizing: border-box;
  background: transparent;
}
.payslip-sheet {
  background: #fffdf9;
  border: 1px solid #e3d3bd;
  border-radius: 22px;
  padding: 30px 32px 24px;
  overflow: hidden;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: #33200f;
}
.ps-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 2px solid #e3d3bd;
}
.ps-logo { height: 64px; width: auto; display: block; }
.ps-head-text { display: flex; flex-direction: column; gap: 2px; }
.ps-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a4b2a;
  font-weight: 700;
}
.ps-month { margin: 0; font-size: 14px; color: #7a6350; }
.ps-staff { padding: 20px 0 16px; }
.ps-name {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #33200f;
  letter-spacing: 0.01em;
}
.ps-meta { margin: 4px 0 0; font-size: 13px; color: #7a6350; }
.ps-rows { margin: 0; padding: 0; }
.ps-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px dashed #e3d3bd;
  font-size: 14px;
}
.ps-row dt { margin: 0; color: #7a6350; }
.ps-row dd { margin: 0; font-weight: 600; text-align: right; }
.ps-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.ps-col {
  border: 1px solid #e3d3bd;
  border-radius: 12px;
  padding: 12px 14px 10px;
  background: #fffaf3;
}
.ps-col-title {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: #8a4b2a;
}
.ps-col-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  font-size: 11.5px;
  border-bottom: 1px dashed #ecdfcc;
  color: #7a6350;
}
.ps-col-row b { color: #33200f; font-weight: 600; white-space: nowrap; }
.ps-col-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #33200f;
}
.ps-status {
  margin: 12px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: #a08d78;
}
.ps-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 18px;
  padding: 14px 18px;
  background: #f7efe2;
  border-radius: 16px;
  font-size: 14px;
  color: #7a6350;
}
.ps-total b { font-size: 22px; color: #6c3719; }
.ps-footer {
  margin: 18px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b09a80;
}

@media print {
  body.print-payslip { padding: 0; background: #fff; }
  body.print-payslip .screen,
  body.print-payslip #admin-modal { display: none !important; }
  body.print-payslip .modal {
    position: static; inset: auto; display: block;
    padding: 0; background: none; backdrop-filter: none;
  }
  body.print-payslip .modal-card {
    max-width: none; padding: 0; border-radius: 0; box-shadow: none;
  }
  body.print-payslip #payslip-modal .actions { display: none; }
}

@media (max-width: 560px) {
  body { padding: 20px 12px 32px; }
  .card { padding: 18px; }
  .login-card { padding: 24px 20px; }
  .clock { font-size: 38px; }
  .btn { padding: 12px 14px; font-size: 14px; }
  .logo { height: 96px; }
  .topbar-id .logo { height: 42px; }
}
