/* ==========================================================================
   Fablorin Services — Attendance
   Brand: navy #08284E + gold #C9973A (from the logo). Type: Inter (UI) + Cormorant Garamond (titles).
   ========================================================================== */

@font-face { font-family: "Inter"; src: url("fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url("fonts/cormorant-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url("fonts/cormorant-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  /* brand */
  --navy-950: #041429;
  --navy-900: #061C38;
  --navy: #08284E;
  --navy-700: #16406F;
  --gold: #C9973A;
  --gold-soft: #F6ECD8;
  --gold-ink: #8A6417;

  /* surfaces & ink */
  --canvas: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --border: #E3E8EF;
  --border-strong: #CFD7E2;
  --ink: #0E1A2B;
  --ink-2: #334155;
  --muted: #5A6B80;
  --subtle: #8796AA;
  --focus: #2F62B0;

  /* status (always paired with a text label) */
  --ok: #127A45;   --ok-bg: #E4F4EA;
  --warn: #8A6417; --warn-bg: #FBF1DC;
  --info: #24569F; --info-bg: #E7EEF9;
  --bad: #B42318;  --bad-bg: #FDEBE9;
  --neutral: #475467; --neutral-bg: #EEF1F5;

  /* chart series (validated: lightness band, CVD, contrast) */
  --series-1: #2F62B0;
  --series-2: #B07E24;
  --grid: #E8ECF2;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(8, 40, 78, .06);
  --shadow-md: 0 1px 2px rgba(8, 40, 78, .05), 0 8px 24px -8px rgba(8, 40, 78, .12);
  --shadow-lg: 0 24px 48px -12px rgba(4, 20, 41, .28);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  --serif: "Cormorant", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sidebar-w: 264px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0B1320; --surface: #131C2B; --surface-2: #182335; --border: #243247; --border-strong: #31425B;
    --ink: #E8EDF4; --ink-2: #C3CDDA; --muted: #97A6BA; --subtle: #6E7F96; --focus: #7FA6E6;
    --gold-soft: #3A2D14; --gold-ink: #E0B45C;
    --ok: #5CCB8F; --ok-bg: #11301F; --warn: #E6B660; --warn-bg: #3A2C12; --info: #8AB0EE; --info-bg: #182B48;
    --bad: #FF8F85; --bad-bg: #3D1B1A; --neutral: #B5C0CF; --neutral-bg: #1F2A3B;
    --series-1: #5F8BD2; --series-2: #B98A3C; --grid: #223047;
    --shadow-sm: none; --shadow-md: 0 0 0 1px rgba(255, 255, 255, .02); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14.5px/1.55 var(--sans); color: var(--ink); background: var(--canvas); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
img { display: block; max-width: 100%; }
small { font-size: .82em; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); font-weight: 600; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- app shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-900) 55%, var(--navy-950) 100%);
  color: #C9D5E6;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar::after { /* thin gold rule, echoing the arc in the logo */
  content: ""; position: absolute; top: 0; right: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, rgba(201, 151, 58, .55) 30%, rgba(201, 151, 58, .15) 70%, transparent);
}
.sidebar-brand { display: block; padding: 26px 24px 4px; }
.sidebar-brand img { width: 176px; height: auto; }
.sidebar-product { padding: 0 24px 18px; margin-left: 2px; font-size: 12px; color: rgba(201, 151, 58, .9); letter-spacing: .02em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 14px; }
.nav-group { display: grid; gap: 2px; margin-bottom: 18px; }
.nav-group-label { padding: 0 12px 6px; font-size: 12px; font-weight: 500; color: #7F93B0; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; color: #C9D5E6; font-weight: 500; font-size: 14px;
}
.nav-link .ic { color: #8FA3C0; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link:hover .ic { color: #fff; }
.nav-link.is-active { background: rgba(255, 255, 255, .09); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.nav-link.is-active .ic { color: var(--gold); }
.nav-link.is-active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }

.sidebar-user { display: flex; align-items: center; gap: 10px; margin: 12px; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.sidebar-user-text { min-width: 0; flex: 1; display: grid; }
.sidebar-user-text strong { color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text span { font-size: 12px; color: #8FA3C0; }
.sidebar-user-actions { display: flex; gap: 2px; }
.sidebar-user-actions form { margin: 0; }
.sidebar .icon-btn { color: #A9B8CE; border-color: transparent; background: transparent; }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 12px 32px; min-height: 64px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar .appbar-menu, .appbar .appbar-mark { display: none; }
.appbar-clock { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.clock-time { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock-date { color: var(--muted); font-size: 13.5px; }
.content { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 32px 40px; }
.footer { padding: 16px 32px 24px; color: var(--subtle); font-size: 12.5px; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(4, 20, 41, .5); }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .shell { margin-left: 0; }
  .appbar { padding: 10px 16px; }
  .appbar .appbar-menu { display: inline-grid; }
  .appbar .appbar-mark { display: block; width: 30px; height: auto; }
  .content { padding: 20px 16px 32px; }
  .footer { padding: 12px 16px 20px; }
}
@media (max-width: 640px) {
  .clock-date { display: none; }
  .appbar .btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-family: var(--serif); font-weight: 600; font-size: 36px; line-height: 1.1; letter-spacing: -.005em; color: var(--navy); }
@media (prefers-color-scheme: dark) { .page-title { color: #F1F4F9; } }
.page-sub { margin-top: 6px; color: var(--muted); max-width: 70ch; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back-link .ic { width: 16px; height: 16px; }
@media (max-width: 640px) { .page-title { font-size: 30px; } }

/* ---------- panels & grids ---------- */
.panel { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 20px; min-width: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-narrow { max-width: 520px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-flush > .panel-head { padding: 18px 20px 0; margin-bottom: 14px; }
.panel-head h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; }
.panel-sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.panel-toolbar { padding: 14px; }
.grid { display: grid; gap: 20px; }
.grid > .panel { margin-bottom: 0; }
.grid + .grid, .grid + .panel, .kpi-strip + .grid { margin-top: 20px; }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); align-items: start; margin-bottom: 20px; }
@media (max-width: 1200px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .grid-main, .grid-2, .grid-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- KPI strip: one connected surface, the lead tile in brand navy ---------- */
.kpi-strip {
  display: grid; grid-template-columns: minmax(240px, 1.35fr) repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 20px;
}
.kpi { position: relative; display: grid; align-content: start; gap: 4px; padding: 20px 22px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-value small { font-size: .55em; font-weight: 500; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.kpi-value-sm { font-size: 22px; padding-top: 6px; }
.kpi-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; margin-bottom: 8px; }
.kpi-icon .ic { width: 18px; height: 18px; }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral); }

.kpi-lead {
  color: #fff; gap: 6px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(201, 151, 58, .22) 0%, transparent 45%), linear-gradient(135deg, var(--navy-700), var(--navy) 55%, var(--navy-900));
}
.kpi-lead .kpi-label { color: #B8C7DC; }
.kpi-lead .kpi-value { font-weight: 600; font-size: 46px; letter-spacing: -.03em; line-height: 1; margin: 6px 0 10px; }
.kpi-lead .kpi-value small { color: #8FA3C0; font-size: .45em; letter-spacing: 0; }
.kpi-foot { font-size: 12.5px; color: #B8C7DC; }
.kpi-lead .meter::-webkit-progress-bar { background: rgba(255, 255, 255, .14); }
.kpi-lead .meter::-webkit-progress-value { background: linear-gradient(90deg, #B07E24, #E2B660); }
.kpi-lead .meter::-moz-progress-bar { background: linear-gradient(90deg, #B07E24, #E2B660); }
.kpi-lead .meter { background: rgba(255, 255, 255, .14); }

@media (max-width: 1200px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-lead { grid-column: 1 / -1; }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(n+2) { border-top: 1px solid var(--border); }
  .kpi:nth-child(odd):not(.kpi-lead) { border-left: 1px solid var(--border); }
}
@media (min-width: 720px) and (max-width: 1200px) {
  .kpi-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi:nth-child(n+2) { border-left: 1px solid var(--border); }
  .kpi:nth-child(2) { border-left: 0; }
}

/* progress meter */
.meter { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--neutral-bg); color: var(--series-1); }
.meter::-webkit-progress-bar { background: var(--neutral-bg); border-radius: 99px; }
.meter::-webkit-progress-value { background: var(--series-1); border-radius: 99px; }
.meter::-moz-progress-bar { background: var(--series-1); border-radius: 99px; }
.meter-sm { height: 6px; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.grid-line.baseline { stroke: var(--border-strong); }
.axis-label { fill: var(--subtle); font: 500 11px var(--sans); font-variant-numeric: tabular-nums; }
.axis-today { fill: var(--ink); font-weight: 650; }
.s-ontime { fill: var(--series-1); }
.s-late { fill: var(--series-2); }
.bar-group .hit { fill: transparent; }
.bar-group:hover .hit, .bar-group:focus-visible .hit { fill: var(--surface-2); }
.bar-group:focus { outline: none; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; white-space: pre-line;
  min-width: 140px; padding: 10px 12px; border-radius: 10px;
  background: var(--navy-900); color: #E8EEF6; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip::first-line { font-weight: 600; color: #fff; }
.legend { display: flex; gap: 14px; margin: 2px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.s-ontime { background: var(--series-1); }
.swatch.s-late { background: var(--series-2); }

/* ---------- lists ---------- */
.people-list { list-style: none; margin: 0; padding: 0; display: grid; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.people-list li:first-child { border-top: 0; padding-top: 0; }
.people-list li.is-overdue .people-main strong { color: var(--bad); }
.people-main { flex: 1; min-width: 0; display: grid; }
.people-main strong { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-main > span { color: var(--muted); font-size: 12.5px; }
.people-meta { display: grid; justify-items: end; gap: 3px; font-size: 12.5px; color: var(--ink-2); text-align: right; }
.time-chip { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; }

.dept-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.dept-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; margin-bottom: 6px; }
.dept-row strong { font-variant-numeric: tabular-nums; }
.dept-foot { display: flex; gap: 12px; margin-top: 5px; font-size: 12px; color: var(--muted); }

.empty-inline { display: flex; align-items: center; gap: 10px; padding: 14px 0; color: var(--muted); font-size: 13.5px; }
.table .empty-inline { justify-content: center; padding: 28px 0; }
.empty-inline .ic { color: var(--subtle); }
.empty-state { max-width: 460px; margin: 10vh auto; text-align: center; display: grid; justify-items: center; gap: 12px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--warn-bg); color: var(--warn); }
.empty-icon .ic { width: 26px; height: 26px; }

/* ---------- avatars, pills, status ---------- */
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; font-size: 12.5px; font-weight: 650; letter-spacing: .02em; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.tone-1 { background: #E6EDF8; color: #16406F; }
.tone-2 { background: #F6ECD8; color: #7A5613; }
.tone-3 { background: #E4F1EE; color: #1D5E52; }
.tone-4 { background: #EDE8F5; color: #4B3A78; }
.tone-5 { background: #F3E6E3; color: #7E3A2E; }
.sidebar .avatar { background: linear-gradient(135deg, #E2B660, #B07E24); color: var(--navy-900); }
@media (prefers-color-scheme: dark) {
  .tone-1 { background: #1B2E4B; color: #A9C3EC; } .tone-2 { background: #3A2D14; color: #E7C27B; }
  .tone-3 { background: #16332D; color: #8FD1C1; } .tone-4 { background: #2A2340; color: #C2B3EA; }
  .tone-5 { background: #3A221D; color: #EDB0A2; }
}

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--neutral); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.status::before, .dot { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot { display: inline-block; }
.status-in, .status-present { color: var(--ok); }
.status-outside { color: var(--info); }
.status-out, .status-weekend, .status-not_joined { color: var(--neutral); }
.status-late { color: var(--warn); }
.status-absent { color: var(--bad); }
.dot-in { color: var(--ok); } .dot-outside { color: var(--info); } .dot-out { color: var(--neutral); } .dot-absent { color: var(--bad); }
.status-outside::before { box-shadow: 0 0 0 3px var(--info-bg); }
.cell-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); font-weight: 400; }
.done-mark { position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.done-mark .ic { width: 16px; height: 16px; color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 220px; }
.table-wrap.scroll-y { max-height: 520px; overflow: auto; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; border-bottom-color: var(--border); }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tr.is-muted td { opacity: .55; }
.table tr.is-alert td { background: var(--bad-bg); }
.col-actions { width: 1%; white-space: nowrap; text-align: right !important; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-actions form { margin: 0; }
.person { display: flex; align-items: center; gap: 12px; min-width: 200px; color: inherit; }
.person strong { display: block; font-weight: 600; white-space: nowrap; }
.person-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
a.person-link:hover { text-decoration: none; }
a.person-link:hover strong { color: var(--info); }
.rate { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.rate .meter { flex: 1; }
.rate span { font-size: 12.5px; font-weight: 600; min-width: 44px; text-align: right; }

.mv-list { margin-top: 3px; }
.mv-list summary { cursor: pointer; color: var(--info); font-size: 12px; font-weight: 500; list-style: none; }
.mv-list summary::-webkit-details-marker { display: none; }
.mv-list ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; min-width: 230px; }
.mv-list li { white-space: normal; display: grid; font-size: 12px; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--info-bg); }
.mv-list li .tabular { color: var(--ink-2); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  font: 600 13.5px/1 var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { color: #fff; background: var(--navy); border-color: var(--navy); box-shadow: 0 1px 2px rgba(8, 40, 78, .25), inset 0 1px 0 rgba(255, 255, 255, .08); }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
@media (prefers-color-scheme: dark) {
  .btn-primary { background: #2F62B0; border-color: #2F62B0; }
  .btn-primary:hover { background: #3A70C2; border-color: #3A70C2; }
}
.btn-accent { color: #3B2A06; background: linear-gradient(180deg, #E2B660, #C9973A); border-color: #B8872E; }
.btn-accent:hover { background: linear-gradient(180deg, #E8BF6E, #CF9E42); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--neutral-bg); color: var(--ink); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { min-height: 46px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.icon-btn .ic { width: 17px; height: 17px; }
.icon-btn-danger:hover { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.icon-btn.is-disabled { opacity: .4; cursor: default; }
.pager { display: flex; gap: 6px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field label, fieldset legend { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.optional { font-weight: 400; color: var(--subtle); margin-left: 4px; }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--bad); font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  font: 400 14px/1.3 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color .12s, box-shadow .12s;
}
select { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6B80' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input:hover, select:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--navy); }
.input-sm, .select-sm { min-height: 32px; font-size: 13px; padding-top: 4px; padding-bottom: 4px; border-radius: 8px; }
.input-sm { max-width: 150px; }
.input-icon { position: relative; display: block; }
.input-icon > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; width: 17px; height: 17px; }
.input-icon > input { padding-left: 38px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar > select { width: auto; min-width: 180px; }
.toolbar .grow { flex: 1 1 260px; min-width: 200px; }
.toolbar > select.grow { flex: 1 1 220px; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.inline-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.inline-form input { width: 150px; flex: none; }
.select-sm { width: auto; min-width: 150px; }
.timeline.scroll-y { max-height: 640px; overflow-y: auto; }
.stack { display: grid; gap: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.date-jump { display: flex; align-items: center; gap: 8px; }
.date-jump input { width: auto; }

.entry-time { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--gold-soft); }
.entry-time label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--gold-ink); }
.entry-time input { width: 124px; min-height: 34px; }
.entry-time .hint { color: var(--gold-ink); opacity: .85; }
@media (max-width: 640px) { .entry-time .hint { display: none; } }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted); }
.tab:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tab.is-active { background: var(--navy); color: #fff; }
.tab.is-active .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.tab .count { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: 6px; background: var(--neutral-bg); color: var(--ink-2); }
.tab.is-active .count { background: rgba(255, 255, 255, .16); color: #fff; }
@media (prefers-color-scheme: dark) { .tab.is-active { background: #2F62B0; } }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--neutral-bg); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-md); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.role-picker { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.role-picker legend { margin-bottom: 6px; }
.role-picker label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.role-picker label:has(input:checked) { border-color: var(--navy); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--navy); }
.role-picker input { margin-top: 3px; }
.role-picker span { display: grid; font-size: 12.5px; color: var(--muted); }
.role-picker strong { font-size: 13.5px; color: var(--ink); }

/* employee form */
.form-layout { display: grid; gap: 20px; max-width: 1040px; }
.form-layout .panel { margin: 0; }
.form-section { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; padding: 24px; }
.form-section-intro h2 { font-size: 15.5px; font-weight: 600; }
.form-section-intro p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 860px) { .form-section { grid-template-columns: 1fr; gap: 16px; } }
@media (max-width: 560px) { .form-grid, .field-row { grid-template-columns: 1fr; } }

/* ---------- popover (Going out form) ---------- */
details.popover { position: relative; }
details.popover > summary { list-style: none; }
details.popover > summary::-webkit-details-marker { display: none; }
details.popover[open] > summary { background: var(--surface-2); border-color: var(--focus); }
.popover-body {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 320px;
  display: grid; gap: 12px; padding: 16px; text-align: left; white-space: normal;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.popover-title { font-weight: 600; font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* ---------- departments ---------- */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.dept-card { margin: 0; display: grid; gap: 14px; }
.dept-name { display: flex; gap: 6px; margin: 0; }
.dept-name input { font-weight: 600; font-size: 15px; border-color: transparent; background: transparent; padding-left: 6px; margin-left: -6px; }
.dept-name input:hover { border-color: var(--border); }
.dept-name input:focus { background: var(--surface); }
.dept-stats { display: flex; gap: 28px; }
.dept-stats div { display: grid; }
.dept-stats strong { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1; color: var(--navy); font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .dept-stats strong { color: var(--ink); } }
.dept-stats span { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.dept-actions { display: flex; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--border); }
.dept-actions form { margin: 0 0 0 auto; }

/* ---------- activity timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 20px 16px; }
.timeline li { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline li:first-child::before { top: 18px; }
.timeline li:last-child::before { bottom: calc(100% - 18px); }
.timeline-dot { position: relative; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--subtle); }
.timeline li.is-alert .timeline-dot { border-color: var(--bad); background: var(--bad-bg); }
.timeline-body p { font-size: 13.5px; }
.timeline-detail { margin-top: 2px; font-size: 12.5px !important; color: var(--muted); word-break: break-word; }
.timeline-time { display: grid; justify-items: end; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline-time span { font-size: 11.5px; color: var(--subtle); }

/* ---------- toasts & alerts ---------- */
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 18px; border-radius: 12px; font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.toast .ic { flex: none; }
.toast span { flex: 1; }
.toast-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.toast-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.toast-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.toast-close { display: grid; place-items: center; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; opacity: .7; border-radius: 6px; }
.toast-close:hover { opacity: 1; }
.toast-close .ic { width: 16px; height: 16px; }
.inline-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 13.5px; font-weight: 500; }
.inline-alert ul { margin: 0; padding-left: 16px; }
.panel-narrow .inline-alert { margin-bottom: 16px; }

/* ---------- auth (login / setup) ---------- */
.auth-page { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px; color: #fff;
  background: radial-gradient(90% 70% at 85% 10%, rgba(201, 151, 58, .20), transparent 60%), linear-gradient(160deg, var(--navy-700) 0%, var(--navy) 40%, var(--navy-950) 100%);
}
.auth-hero-logo { width: 230px; height: auto; position: relative; z-index: 1; }
.auth-hero-copy { position: relative; z-index: 1; max-width: 460px; }
.auth-hero-title { font-family: var(--serif); font-weight: 600; font-size: 46px; line-height: 1.06; letter-spacing: -.01em; }
.auth-hero-text { margin-top: 18px; color: #B8C7DC; font-size: 15.5px; line-height: 1.6; max-width: 44ch; }
.auth-hero-foot { position: relative; z-index: 1; color: #7F93B0; font-size: 12.5px; }
.auth-hero-arc { position: absolute; right: -60px; bottom: -40px; width: 620px; height: 620px; }
.auth-hero-arc path { fill: none; stroke: rgba(201, 151, 58, .35); stroke-width: 1.5; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px 24px; }
.auth-main-logo { display: none; width: 190px; height: auto; margin-bottom: 36px; }
.auth-main > .toast { width: 100%; max-width: 380px; }
.auth-form-wrap { width: 100%; max-width: 380px; }
.auth-title { font-family: var(--serif); font-weight: 600; font-size: 38px; color: var(--navy); line-height: 1.1; }
@media (prefers-color-scheme: dark) { .auth-title { color: var(--ink); } }
.auth-sub { margin-top: 8px; color: var(--muted); }
.auth-form { display: grid; gap: 18px; margin-top: 28px; }
.auth-form input { min-height: 46px; font-size: 15px; }
.auth-note { margin-top: 22px; font-size: 13px; color: var(--muted); text-align: center; }
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-main-logo { display: block; }
}
@media (max-width: 900px) and (prefers-color-scheme: dark) { .auth-main-logo { content: url("img/logo-white.svg"); } }

/* ---------- print ---------- */
@media print {
  .sidebar, .appbar, .footer, .no-print, .col-actions, .scrim { display: none !important; }
  .shell { margin: 0; }
  body { background: #fff; color: #000; font-size: 11px; }
  .content { padding: 0; max-width: none; }
  .panel, .kpi-strip { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .kpi-lead { background: #fff !important; color: #000; }
  .kpi-lead .kpi-label, .kpi-foot { color: #444; }
  .table-wrap { overflow: visible; }
  .table thead th { position: static; }
  .page-title { color: #000; }
}

/* ---------- density tweaks for wide tables on laptop screens ---------- */
@media (max-width: 1560px) {
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .board .row-actions .btn:not(.btn-primary):not(.btn-accent) { width: 32px; padding: 0; }
  .board .row-actions .btn:not(.btn-primary):not(.btn-accent) span,
  .board .done-mark span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .board details.popover > summary.btn { width: 32px; padding: 0; }
}
.rate { min-width: 96px; }
.rate .meter { width: 44px; flex: none; }

/* ---------- phones: attendance board rows become cards ---------- */
@media (max-width: 720px) {
  .board thead { display: none; }
  .board, .board tbody { display: block; }
  .board tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 16px; border-bottom: 1px solid var(--border); }
  .board tbody tr:hover { background: transparent; }
  .board td { display: block; padding: 0 !important; border: 0; white-space: normal; }
  .board td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--subtle); font-weight: 500; margin-bottom: 1px; }
  .board td.cell-person, .board td.cell-status, .board td.col-actions { grid-column: 1 / -1; }
  .board td.cell-status { display: flex; align-items: center; gap: 10px; }
  .board td.cell-status .cell-sub { margin: 0; }
  .board td.col-actions { width: auto; text-align: left !important; padding-top: 4px !important; }
  .board .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .board .row-actions .btn:not(.btn-primary):not(.btn-accent) { width: auto; padding: 0 11px; }
  .board .row-actions .btn span, .board .done-mark span { position: static !important; width: auto !important; height: auto !important; clip: auto !important; overflow: visible !important; }
  .board details.popover > summary.btn { width: auto; padding: 0 11px; }
  .board .row-actions > form:first-child .btn, .board .row-actions > details { flex: 1; }
  .board .row-actions > details > summary { width: 100%; }
  .popover-body { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; }
  .board tr:has(td[colspan]) { display: block; }
}
@media (max-width: 720px) {
  .chart { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
  .chart-svg { min-width: 600px; }
  .panel-head { flex-wrap: wrap; }
}

/* popovers opened from a panel that clips overflow need to escape it */
.panel-flush:has(details.popover[open]) { overflow: visible; }
.panel-flush:has(details.popover[open]) .table-wrap { overflow: visible; }
