:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #faf9f6; --line: #e4e1d8; --line-strong: #cfcabd;
  --text: #1d1f1e; --muted: #6a6d68; --faint: #9a9c96;
  --brand: #0f5c4d; --brand-ink: #ffffff; --brand-soft: #e3efe9;
  --ok: #1d7a4f; --ok-soft: #e1f2e8; --warn: #9a6200; --warn-soft: #fbefd6; --bad: #b3261e; --bad-soft: #fbe4e1; --info: #2f5aa8; --info-soft: #e5ecf8;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,20,10,.05), 0 4px 16px rgba(20,20,10,.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615; --surface: #1c1f1e; --surface-2: #222625; --line: #2f3432; --line-strong: #3d4340;
    --text: #e9ebe8; --muted: #a2a8a4; --faint: #737a76;
    --brand: #5cc3a6; --brand-ink: #0c1f1a; --brand-soft: #1d3530;
    --ok: #6fd39c; --ok-soft: #1b3326; --warn: #f0b85a; --warn-soft: #3a2e17; --bad: #ff8a80; --bad-soft: #3d1f1d; --info: #8fb3f5; --info-soft: #1f2a3f;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.boot { padding: 40px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .badge { margin-left: auto; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.topbar { display: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Controls */
button, .btn { font: inherit; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; }
button.sm, .btn.sm { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }
button.big { padding: 12px 22px; font-size: 15px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: auto; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.f > span { font-weight: 500; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.inline-input { width: 90px; padding: 4px 6px; text-align: right; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; }
tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line-strong); }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

/* Attendance register */
.reg { font-size: 12px; }
.reg th, .reg td { padding: 5px 4px; text-align: center; border-right: 1px solid var(--line); }
.reg th.name, .reg td.name { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 150px; padding-left: 10px; }
.reg th.off { color: var(--faint); }
.reg td.c { cursor: pointer; min-width: 30px; font-weight: 600; }
.reg td.c:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.c-P { color: var(--ok); } .c-HD { color: var(--warn); background: var(--warn-soft); } .c-A { color: var(--bad); background: var(--bad-soft); }
.c-L, .c-L½ { color: var(--info); background: var(--info-soft); } .c-LWP, .c-LWP½ { color: var(--bad); background: var(--info-soft); }
.c-WO, .c-H { color: var(--faint); background: var(--surface-2); } .c-NA, .c-F, .c-- { color: var(--faint); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend b { padding: 0 5px; border-radius: 4px; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dh { font-size: 11px; color: var(--faint); text-align: center; text-transform: uppercase; }
.cal .d { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 64px; background: var(--surface); font-size: 12px; }
.cal .d .n { font-weight: 600; color: var(--muted); }
.cal .d .s { font-weight: 700; margin-top: 2px; display: inline-block; padding: 0 5px; border-radius: 4px; }
.cal .d.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal .d.blank { visibility: hidden; }

/* Check-in widget */
.clock { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.clock .time { font-size: 34px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,12,11,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
#toast div.err { background: var(--bad); color: #fff; }

.notice { padding: 12px 14px; border-radius: 8px; background: var(--info-soft); color: var(--text); margin-bottom: 14px; border: 1px solid transparent; }
.notice.warn { background: var(--warn-soft); }
.notice.ok { background: var(--ok-soft); }
.secret { font-family: var(--mono); font-size: 18px; padding: 10px 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 8px; user-select: all; letter-spacing: .04em; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.policy-body { white-space: pre-wrap; line-height: 1.65; max-width: 75ch; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); }
.login .card { padding: 26px; }
.login h1 { margin-bottom: 4px; }

/* Payslip */
.slip { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 32px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.slip .hd { display: flex; justify-content: space-between; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 14px; gap: 16px; }
.slip .hd h1 { font-size: 20px; }
.slip .meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 24px; margin-bottom: 14px; }
.slip .meta div { display: flex; justify-content: space-between; border-bottom: 1px dotted #ccc; padding: 3px 0; }
.slip .meta span:first-child { color: #555; }
.slip table { border: 1px solid #999; }
.slip th, .slip td { border: 1px solid #bbb; padding: 6px 10px; color: #111; background: #fff; }
.slip th { background: #f1f1ee; color: #111; }
.slip tbody tr:hover td { background: #fff; }
.slip .net { margin-top: 14px; padding: 12px 14px; background: #f1f1ee; border: 1px solid #999; display: flex; justify-content: space-between; align-items: center; font-size: 15px; flex-wrap: wrap; gap: 8px; }
.slip .foot { margin-top: 18px; color: #666; font-size: 11.5px; }
.slip-actions { max-width: 820px; margin: 0 auto 14px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.menu-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.stats { grid-template-columns: repeat(2, 1fr); }
  .slip { padding: 16px; } .slip .meta { grid-template-columns: 1fr; }
  .cal .d { min-height: 48px; padding: 4px; }
}
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, #toast, .slip-actions { display: none !important; }
  .shell { display: block; } .main { padding: 0; }
  .slip { border: 0; padding: 0; max-width: none; }
}
