/* HouselyPH OS design system. Tokens first; light and dark. No build step. */
:root {
  --navy: #1b2a4a; --navy-2: #24365c; --copper: #a8603a; --copper-2: #c47a50;
  --bg: #f6f4f0; --surface: #ffffff; --surface-2: #faf8f5; --line: #e6e1d8; --line-2: #d6cfc3;
  --text: #24211d; --text-2: #5e574e; --muted: #857c70;
  --ok: #2f7a54; --ok-bg: #e9f4ee; --warn: #9a6a12; --warn-bg: #fbf3e2; --err: #a33a2e; --err-bg: #fbecea; --info-bg: #edf1f7;
  --sidebar: #172238; --sidebar-text: #c9d1de; --sidebar-active: #24365c;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(23, 20, 15, .06), 0 1px 1px rgba(23, 20, 15, .04);
  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: 24px; --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --surface: #1a1d23; --surface-2: #1f232a; --line: #2b3039; --line-2: #3a404b;
    --text: #e8e6e1; --text-2: #bdb7ad; --muted: #8f8a82; --navy: #9fb6e0; --navy-2: #7f9ccf; --copper: #d9925f; --copper-2: #e6a77a;
    --ok: #6cc39a; --ok-bg: #16281f; --warn: #e2b55a; --warn-bg: #2a2416; --err: #ee8a7e; --err-bg: #2d1a18; --info-bg: #1c2433;
    --sidebar: #0f1218; --sidebar-active: #1f2a40; color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; font-size: 16px; }
.brand-dark { color: var(--text); padding: 0 0 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--copper); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-text b { color: var(--copper-2); font-weight: 700; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; margin-bottom: 2px; }
.nav-link:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--copper-2); }
.nav-link.is-soon { opacity: .55; cursor: default; }
.nav-link em { margin-left: auto; font-style: normal; font-size: 11px; opacity: .8; }
.nav-section { margin: 18px 12px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 14px 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { opacity: .7; font-size: 12px; }
.main-wrap { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 var(--gutter); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.page-title { font-size: 19px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today { color: var(--muted); font-size: 14px; }
.content { padding: var(--gutter); max-width: 1240px; width: 100%; }
.content > * + * { margin-top: 18px; }
.tabbar, .scrim, .icon-btn.only-mobile { display: none; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card-title { font-size: 15px; margin-bottom: 12px; }
a.card:hover { text-decoration: none; border-color: var(--line-2); }
.grid { display: grid; gap: 16px; }
.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.align-start { align-items: start; }
.stat { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-value small { font-size: 16px; color: var(--muted); font-weight: 500; }
.stat-note { font-size: 13px; color: var(--muted); }
.stat-muted { background: var(--surface-2); box-shadow: none; }
.hello h2 { font-size: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: var(--navy); color: #fff; }
:root .btn-primary { background: #1b2a4a; }
.btn-primary:hover { background: #24365c; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn-block { width: 100%; min-height: 44px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 127, 127, .12); }
.link { color: var(--navy); cursor: pointer; font-weight: 600; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--copper); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.badge, .chip { display: inline-block; white-space: nowrap; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.chip { background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-weight: 500; }
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-on_leave { background: var(--warn-bg); color: var(--warn); }
.badge-inactive { background: var(--surface-2); color: var(--muted); }

.alert, .flash { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 14px; }
.alert-error { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-ok, .flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 7px 10px; }
.table tr.is-past { opacity: .55; }
.table tr.group td { background: var(--surface-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.person { display: flex; align-items: center; gap: 10px; color: var(--text); }
.person span:last-child { display: flex; flex-direction: column; }
.person small { color: var(--muted); }
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; }
.perm-key { display: block; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.scope-select { font: inherit; font-size: 13px; padding: 3px 4px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
.scope-own { background: var(--info-bg); }
.scope-team { background: var(--warn-bg); }
.scope-all, .scope-select.scope-all { background: var(--ok-bg); }
.scope.scope-all { padding: 2px 8px; border-radius: 6px; color: var(--ok); font-size: 13px; font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); min-height: 38px; padding: 6px 10px; width: 100%; }
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--copper) 55%, transparent); border-color: var(--copper); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.field > span { font-weight: 600; color: var(--text-2); }
.field.narrow { max-width: 130px; }
.field-error { color: var(--err); font-size: 13px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.check input { width: auto; min-height: 0; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; margin: 2px 4px 2px 0; }
.role-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.form legend { font-weight: 700; margin-bottom: 12px; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; }
.form-row .field { flex: 1 1 160px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
details > summary { list-style: none; cursor: pointer; display: inline-flex; }
details > summary::-webkit-details-marker { display: none; }
.inline-form { margin-top: 14px; }
.row-edit[open] { position: relative; }
.row-edit[open] form { position: absolute; right: 0; z-index: 5; width: 260px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); margin-top: 6px; text-align: left; }

.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-id { flex: 1; min-width: 200px; }
.profile-id h2 { font-size: 20px; }
.profile-id p { margin: 3px 0 0; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.timeline { margin: 0; padding-left: 18px; font-size: 14px; }
.timeline li + li { margin-top: 6px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 6px 0 6px 26px; position: relative; }
.checklist li::before { content: ''; position: absolute; left: 2px; top: 11px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--warn); }
.checklist li.done::before { background: var(--ok); border-color: var(--ok); }
.empty { text-align: center; padding: 40px 20px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty p { margin: 4px 0; }

/* ---------- Attendance & DTR ---------- */
.h2 { font-size: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.card.flush { padding: 4px 8px; }
.warn { color: var(--warn); font-weight: 600; }
.action-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.form-row.inline { margin-top: 0; }
.punch-card { max-width: 560px; margin-left: auto; margin-right: auto; text-align: center; }
.punch-clock { display: flex; flex-direction: column; align-items: center; margin: 6px 0 4px; }
.punch-time { font-size: 52px; font-weight: 700; letter-spacing: -.02em; color: var(--navy); line-height: 1; }
.punch-date { color: var(--muted); }
.punch-state { font-weight: 600; margin: 10px 0 14px; }
.state-working { color: var(--ok); }
.state-on_break { color: var(--warn); }
.arrangements { border: 0; padding: 0; margin: 0 0 14px; }
.arrangements legend { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 0 auto 8px; }
.arrangements { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.arr-option { position: relative; }
.arr-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.arr-option span { display: flex; flex-direction: column; align-items: center; min-width: 120px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; }
.arr-option span small { font-weight: 400; color: var(--muted); font-size: 12px; }
.arr-option input:checked + span { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); background: var(--info-bg); }
.arr-option input:focus-visible + span { outline: 2px solid var(--copper); outline-offset: 2px; }
.punch-buttons { display: flex; gap: 10px; }
.punch-btn { flex: 1; min-height: 64px; font-size: 19px; border-radius: 12px; }
.punch-log { list-style: none; padding: 0; margin: 18px 0 0; text-align: left; border-top: 1px solid var(--line); }
.punch-log li { display: flex; gap: 10px; align-items: baseline; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.punch-log li b { margin-left: auto; }
.privacy-note { text-align: center; max-width: 560px; margin-left: auto; margin-right: auto; }
.badge.st-present, .badge.st-working, .badge.period-finalized { background: var(--ok-bg); color: var(--ok); }
.badge.st-absent, .badge.st-missing_out, .badge.st-missing_in { background: var(--err-bg); color: var(--err); }
.badge.st-on_break, .badge.st-rest_day_work, .badge.st-holiday_work, .badge.period-reviewed { background: var(--warn-bg); color: var(--warn); }
.badge.st-on_leave, .badge.st-holiday { background: var(--info-bg); color: var(--navy); }
.badge.st-rest_day, .badge.st-not_tracked, .badge.st-upcoming, .badge.st-not_yet, .badge.period-draft { background: var(--surface-2); color: var(--muted); }
.dtr-table tr.row-rest_day td, .dtr-table tr.row-not_tracked td, .dtr-table tr.row-upcoming td { color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; }
.cal-cell { position: relative; min-height: 76px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.cal-cell.is-empty { border: 0; background: none; }
.cal-day { font-weight: 700; font-size: 14px; }
.cal-status { color: var(--text-2); }
.cal-times { color: var(--muted); }
.cal-flag { position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.cal-cell.st-present, .cal-cell.st-working { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.cal-cell.st-absent, .cal-cell.st-missing_out, .cal-cell.st-missing_in { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); background: var(--err-bg); }
.cal-cell.st-rest_day, .cal-cell.st-not_tracked, .cal-cell.st-upcoming { background: var(--surface-2); }
.row-edit.wide[open] form { width: 420px; }

/* ---------- Sign-in ---------- */
.bare { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(23, 20, 15, .07); }
.auth-card > * + * { margin-top: 12px; }
.auth-title { font-size: 21px; }
.auth-foot { color: var(--muted); font-size: 12.5px; text-align: center; max-width: 400px; }
.code-input { font-size: 22px; letter-spacing: .3em; text-align: center; }
.secret { display: block; margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 15px; letter-spacing: .06em; word-break: break-all; }
.steps { padding-left: 20px; font-size: 14px; }
.steps li + li { margin-top: 8px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: none; }
  .main-wrap { margin-left: 0; padding-bottom: 72px; }
  .icon-btn.only-mobile { display: inline-grid; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar > * { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 11.5px; color: var(--muted); background: none; border: 0; padding: 4px 0; text-decoration: none !important; }
  .tabbar .is-active { color: var(--navy); font-weight: 600; }
  .tabbar .is-soon { opacity: .45; }
  .cards-2, .cards-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-cell { min-height: 58px; padding: 4px; font-size: 11px; }
  .cal-status, .cal-times { display: none; }
  .row-edit.wide[open] form { width: min(420px, calc(100vw - 48px)); }
  .punch-time { font-size: 44px; }
  .hide-sm { display: none; }
  .dl { grid-template-columns: 120px 1fr; }
  .filters, .filters input, .filters select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.small-value { font-size: 22px; }
.sub-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 4px 0; }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.danger-zone { border-color: color-mix(in srgb, var(--err) 30%, var(--line)); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.bell { position: relative; }
.bell-count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--copper); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
/* ---------- Requests ---------- */
.new-request { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.is-active { color: var(--navy); border-bottom-color: var(--copper); }
.tabs .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--copper); color: #fff; font-size: 12px; }
.badge.big { font-size: 14px; padding: 4px 12px; }
.badge.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-warn, .badge.tone-pending { background: var(--warn-bg); color: var(--warn); }
.badge.tone-err { background: var(--err-bg); color: var(--err); }
.badge.tone-muted { background: var(--surface-2); color: var(--muted); }
.narrow-form { max-width: 640px; }
.steps-list { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.steps-list li { position: relative; padding: 0 0 14px 18px; }
.steps-list li::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.steps-list li.done::before { background: var(--ok); border-color: var(--ok); }
.steps-list li.d-rejected::before, .steps-list li.d-not_recommended::before { background: var(--err); border-color: var(--err); }
.steps-list li.d-skipped::before { background: var(--line-2); border-color: var(--line-2); }
.steps-list li.current::before { border-color: var(--copper); background: var(--warn-bg); }
.note { color: var(--text-2); font-style: italic; }
.decide-form { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li.unread { background: var(--info-bg); }
.notif-list a { color: var(--text); text-decoration: none; }
.leave-pill { display: block; font-size: 11.5px; padding: 1px 6px; border-radius: 6px; background: var(--info-bg); color: var(--navy); border: 1px solid transparent; text-decoration: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leave-pill.is-pending { background: transparent; border: 1px dashed var(--navy); }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--copper); }
