/* ==========================================================================
   Fakhri HRMS — design system
   A dense, calm "business software" look: neutral greys, one maroon accent
   (#870808, from fakhriitservices.com), hairline borders instead of shadows,
   compact controls and tabular figures. Inter throughout.
   Mobile-first: one column by default, sidebar from 1024px, bottom tabs on
   phones, tables collapse into labelled cards under 720px.
   ========================================================================== */

:root {
  --primary: #870808;
  --primary-dark: #6f0606;
  --primary-light: #a90a0a;
  --primary-soft: #fbf3f3;
  --primary-soft-border: #efd3d3;

  --ink: #18181b;
  --ink-soft: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --surface: #f5f5f4;
  --card: #ffffff;
  --subtle: #fafaf9;
  --hover: #f4f4f3;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;

  --navy: #0a192f;
  --navy-soft: #1c3f60;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;

  --font-heading: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, .04);
  --shadow: 0 4px 12px -4px rgba(24, 24, 27, .12);
  --shadow-lg: 0 16px 40px -16px rgba(24, 24, 27, .25);

  --sidebar-w: 224px;
  --header-h: 48px;
  --bottom-nav-h: 56px;
  --gap: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .25rem;
  letter-spacing: -.011em;
  line-height: 1.25;
}
h1 { font-size: 1.25rem; }
h2 { font-size: .95rem; }
h3 { font-size: .9rem; }
h4 { font-size: .85rem; }
p  { margin: 0 0 .6rem; }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: .8rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: .86em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: .75rem; } .mt-3 { margin-top: var(--gap); }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: .75rem; } .mb-3 { margin-bottom: var(--gap); }
.gap-1 { gap: .5rem; } .gap-2 { gap: .75rem; }
.hidden { display: none !important; }
.num-cell, .tabular { font-variant-numeric: tabular-nums; }

svg.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* ---------------------------------------------------------------- app shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: .6rem;
  padding: 0 .75rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: .55rem; min-width: 0; color: var(--ink); }
.topbar-brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px; flex: none;
  background: var(--primary); color: #fff;
  font-weight: 700; font-size: .85rem;
  display: grid; place-items: center;
}
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: .86rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: .7rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.topbar-user { display: none; align-items: center; gap: .45rem; padding: 0 .5rem 0 .25rem; margin: 0 .2rem; border-left: 1px solid var(--border); }
.topbar-user .who { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-user .who strong { font-size: .8rem; }
.topbar-user .who small { font-size: .66rem; color: var(--muted); letter-spacing: .03em; }
.topbar-user .avatar { width: 28px; height: 28px; font-size: .7rem; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card); color: var(--ink-soft); display: grid; place-items: center;
  cursor: pointer; line-height: 1; padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

.body-wrap { display: flex; flex: 1; min-height: 0; }

.sidebar {
  display: none;
  width: var(--sidebar-w); flex: none;
  background: var(--card); border-right: 1px solid var(--border);
  padding: .5rem .5rem 0; position: sticky; top: var(--header-h);
  align-self: flex-start; height: calc(100vh - var(--header-h));
  overflow-y: auto; flex-direction: column;
}
.sidebar-foot { margin-top: auto; padding: .75rem .55rem; font-size: .68rem; color: var(--faint); }
.sidebar-user {
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem; border-radius: var(--radius);
  background: var(--subtle); border: 1px solid var(--border);
  margin-bottom: .5rem;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: .74rem;
}
.sidebar-user div { min-width: 0; }
.sidebar-user strong { display: block; font-size: .84rem; }
.sidebar-user span { font-size: .7rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; margin: .8rem .55rem .25rem; }
.nav-section:first-child { margin-top: .3rem; }
.nav a {
  display: flex; align-items: center; gap: .55rem;
  padding: .36rem .55rem; border-radius: var(--radius);
  color: var(--ink-soft); font-size: .84rem; font-weight: 500; text-decoration: none;
}
.nav a svg.i { color: var(--faint); }
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a:hover svg.i { color: var(--ink-soft); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active svg.i { color: var(--primary); }
.nav a span { flex: 1; min-width: 0; }
.badge-count {
  font-style: normal; font-size: .68rem; font-weight: 600; min-width: 18px; text-align: center;
  background: var(--primary); color: #fff; padding: 0 5px; border-radius: 999px; line-height: 17px;
}

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(24, 24, 27, .4);
  opacity: 0; pointer-events: none; transition: opacity .16s ease; z-index: 60;
}
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 82%; max-width: 300px;
  background: var(--card); z-index: 70; padding: .75rem .6rem;
  transform: translateX(-102%); transition: transform .2s ease;
  overflow-y: auto;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

.content {
  flex: 1; min-width: 0;
  padding: .85rem .75rem calc(var(--bottom-nav-h) + 1.25rem);
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .64rem; text-decoration: none; font-weight: 500;
}
.bottom-nav a svg.i { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--primary); }

@media (min-width: 640px) { .topbar-user { display: flex; } }
@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .content { padding: 1.1rem 1.5rem 2rem; max-width: 1680px; }
  .bottom-nav { display: none; }
  #menuToggle { display: none; }
}

/* ------------------------------------------------------------------ layout */
.page-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin-bottom: var(--gap); min-height: 34px;
}
.page-head .titles { flex: 1; min-width: 200px; }
.page-head h1 { margin-bottom: 0; }
.page-head .sub { color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

.grid { display: grid; gap: var(--gap); }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
}
.grid-sidebar > div > .card:last-child, .grid-sidebar > div > .card.flush:last-child { margin-bottom: 0; }

/* Cards. A card that has a head/body/table is "sectioned" and carries no
   padding of its own — that is what kept the old layout from double-padding. */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem;
}
.card.flush,
.card:has(> .card-head), .card:has(> .card-body), .card:has(> .table-wrap) { padding: 0; overflow: hidden; }
.card:has(> .card-head) > :not(.card-head):not(.card-body):not(.table-wrap):not(.card-foot):not(.pager):not(details):not(.alert) { margin: .85rem; }
.card:has(> .card-head) > details { margin: .75rem .85rem; }
.card:has(> .card-head) > form:has(> .table-wrap), .card:has(> .card-head) > form:has(> .card-body) { margin: 0; }
.card-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  min-height: 42px; padding: .45rem .85rem; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; font-size: .88rem; font-weight: 600; }
.card-head .spacer { margin-left: auto; }
.card-head .filters { padding: .2rem 0; }
.card-body { padding: .85rem; }
.card-body > :last-child { margin-bottom: 0; }
.card-foot { padding: .6rem .85rem; border-top: 1px solid var(--border); background: var(--subtle); }
.card .card { border-radius: var(--radius); }

/* stat tiles */
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .65rem .8rem; position: relative; min-width: 0;
}
.stat .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 650; line-height: 1.2; margin-top: .1rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .foot { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.accent { border-color: var(--primary-soft-border); background: var(--primary-soft); }
.stat.accent::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; border-radius: var(--radius-lg) 0 0 var(--radius-lg); background: var(--primary); }
.stat.accent .value { color: var(--primary); }
.stat.ok .value { color: var(--success); }
.stat.warn .value { color: var(--warning); }
.stat.danger .value { color: var(--danger); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 32px; padding: 0 .7rem; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--ink); font-family: var(--font-body);
  font-size: .82rem; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  white-space: nowrap; box-shadow: var(--shadow-sm); vertical-align: middle;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-danger { background: var(--card); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-sm { height: 26px; padding: 0 .5rem; font-size: .76rem; }
.btn-sm svg.i { width: 14px; height: 14px; }
.btn-lg { height: 40px; padding: 0 1rem; font-size: .9rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; gap: .3rem; flex-wrap: wrap; }

/* -------------------------------------------------------------------- forms */
.field { margin-bottom: .65rem; }
.field label, .label {
  display: block; font-size: .76rem; font-weight: 500; color: var(--ink-soft); margin-bottom: .22rem;
}
.hint, .field .hint { font-size: .72rem; color: var(--muted); margin-top: .2rem; line-height: 1.35; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=time], input[type=month], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; height: 32px; padding: 0 .6rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: #fff; font-family: var(--font-body); font-size: .84rem; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
select { padding-right: 1.6rem; }
textarea { height: auto; min-height: 72px; padding: .45rem .6rem; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(135, 8, 8, .1);
}
input[type=file] { width: 100%; font-size: .8rem; padding: .3rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--subtle); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; }
.form-row { display: grid; gap: 0 .65rem; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-row.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) { .form-row.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.checkline { display: flex; align-items: center; gap: .45rem; font-size: .84rem; }
.checkline input { width: auto; }
.inline-form { display: inline-flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .45rem; align-items: end; }
.filters .field { margin-bottom: 0; min-width: 140px; }
.filters .field label { font-size: .7rem; color: var(--muted); }
.form-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .3rem; }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data th, table.data td { padding: .42rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  color: var(--muted); font-weight: 600; background: var(--subtle); position: sticky; top: 0; z-index: 1;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; }
table.data tbody tr:hover { background: var(--hover); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total-row td { font-weight: 600; background: var(--subtle); }
table.data td .sub { display: block; font-size: .72rem; color: var(--muted); }
table.data td strong { font-weight: 600; }
table.data td a strong { color: var(--ink); }
table.data td a:hover strong { color: var(--primary); }
table.data td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
table.data td.actions-cell form { display: inline-flex; margin: 0; }
table.data td.actions-cell > * + * { margin-left: .25rem; }
table.data td.check-cell, table.data th.check-cell { width: 28px; padding-right: 0; }
table.data tr.is-selected { background: var(--primary-soft); }
table.data tr.detail-row td { background: var(--subtle); padding: .7rem .85rem; }
table.data tr.detail-row:hover { background: var(--subtle); }

@media (max-width: 720px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td {
    position: relative; border: none; text-align: right; min-height: 1.5rem;
    padding: .2rem .85rem .2rem 40%; overflow-wrap: anywhere;
  }
  table.stack td.num { text-align: right; }
  table.stack td::before {
    content: attr(data-label); position: absolute; left: .85rem; top: .3rem; width: 36%;
    font-size: .68rem; text-transform: uppercase; text-align: left;
    letter-spacing: .04em; color: var(--muted); font-weight: 600;
  }
  /* the first cell (usually the person) reads as the card title */
  table.stack td:first-child, table.stack td.check-cell + td { padding-left: .85rem; text-align: left; font-size: .86rem; }
  table.stack td:first-child::before, table.stack td.check-cell + td::before { content: none; }
  table.stack td:not([data-label])::before { content: none; }
  table.stack td:not([data-label]) { padding-left: .85rem; }
  table.stack td.actions-cell { width: 100%; text-align: right; padding-top: .35rem; }
  table.stack td.check-cell { display: none; }
  table.stack tr.detail-row td { text-align: left; padding: .6rem .85rem; }
  table.stack tr.detail-row td::before { content: none; }
}

/* -------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: 0 .45rem; height: 20px; border-radius: 4px;
  font-size: .7rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; line-height: 1;
}
.chip-ok      { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.chip-warn    { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.chip-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.chip-info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.chip-muted   { background: var(--hover); color: var(--muted); border-color: var(--border); }
.chip-ghost   { background: transparent; color: var(--muted); border-color: var(--border-strong); border-style: dashed; }
.chip-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft-border); }

.alert {
  display: flex; gap: .55rem; align-items: flex-start;
  padding: .55rem .75rem; border-radius: var(--radius); margin-bottom: var(--gap);
  font-size: .82rem; border: 1px solid transparent;
}
.alert > svg.i { margin-top: 1px; }
.alert > .ico { display: none; }
.alert > div { min-width: 0; flex: 1; }
.alert-ok    { background: var(--success-soft); border-color: var(--success-border); color: #14532d; }
.alert-err   { background: var(--danger-soft);  border-color: var(--danger-border);  color: #7f1d1d; }
.alert-warn  { background: var(--warning-soft); border-color: var(--warning-border); color: #78350f; }
.alert-info  { background: var(--info-soft);    border-color: var(--info-border);    color: #1e3a8a; }
.card .alert:last-child { margin-bottom: 0; }

/* --------------------------------------------------------- attendance board */
.trend { display: flex; align-items: stretch; gap: .5rem; height: 130px; padding-top: .25rem; }
.trend .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0; }
.trend .bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.trend .bar { width: 100%; max-width: 30px; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; }
.trend .bar.off { background: var(--border-strong); }
.trend .bar-label { font-size: .68rem; color: var(--muted); }
.trend .bar-value { font-size: .7rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1em; }

.register-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
table.register { border-collapse: separate; border-spacing: 0; font-size: .76rem; }
table.register th, table.register td { padding: .3rem .28rem; text-align: center; border-bottom: 1px solid var(--border); border-right: 1px solid #f1f0ef; font-variant-numeric: tabular-nums; }
table.register thead th { position: sticky; top: 0; background: var(--subtle); z-index: 3; font-size: .68rem; color: var(--muted); }
table.register .sticky-col {
  position: sticky; left: 0; background: var(--card); z-index: 2; text-align: left;
  min-width: 160px; border-right: 1px solid var(--border);
}
table.register thead .sticky-col { z-index: 4; background: var(--subtle); }
table.register td.cell { font-weight: 600; cursor: help; }
table.register td.cell.P { background: var(--success-soft); color: var(--success); }
table.register td.cell.A { background: var(--danger-soft); color: var(--danger); }
table.register td.cell.pending { color: var(--faint); }
table.register td.cell.ne { color: var(--faint); background: repeating-linear-gradient(135deg, #fafaf9 0 4px, #f1f0ef 4px 8px); }
table.register td.cell.H, table.register td.cell.W { background: #f5f5f4; color: var(--faint); }
table.register td.cell.leave { background: var(--info-soft); color: var(--info); }
table.register td.cell.half { background: var(--warning-soft); color: var(--warning); }
table.register td.weekend { background: #fafaf9; }
table.register td.today-col { box-shadow: inset 0 0 0 2px var(--primary-soft-border); }
table.register tfoot td { font-weight: 600; background: var(--subtle); }

.timeline { display: flex; flex-direction: column; gap: .35rem; }
.timeline-item { display: flex; gap: .55rem; align-items: center; padding: .4rem .55rem; border-radius: var(--radius); background: var(--subtle); border: 1px solid var(--border); }
.timeline-item .t { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 46px; }

/* list rows used in side panels */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .85rem; border-bottom: 1px solid var(--border); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow strong { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .grow span { display: block; font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .avatar { width: 28px; height: 28px; font-size: .68rem; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .85rem; border-top: 1px solid var(--border); font-size: .78rem; background: var(--subtle); }
.pager .pager-links { display: flex; gap: .35rem; align-items: center; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .3rem;
  background: var(--faint); vertical-align: 1px; }
.live-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.live-dot.off { background: var(--danger); }
.status-strip { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .76rem; color: var(--muted); margin-top: .25rem; }

/* rating stars / score pills */
.score { display: inline-flex; gap: 2px; }
.score input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.score label { margin: 0; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-size: .76rem; font-weight: 600; cursor: pointer; color: var(--ink-soft); background: #fff; }
.score input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.score input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 1px; }
.rating-big { font-size: 1.6rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* bulk-action bar */
.bulk-bar { display: none; align-items: center; gap: .5rem; padding: .45rem .85rem; background: var(--ink); color: #fff; font-size: .8rem; }
.bulk-bar.is-visible { display: flex; }
.bulk-bar .btn { height: 26px; font-size: .76rem; }

/* ------------------------------------------------------------------ steps */
.steps { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; font-size: .76rem; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: .35rem; color: var(--faint); padding-right: .9rem; }
.steps li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; }
.steps li.done { color: var(--ink-soft); }
.steps li.done::before { background: var(--success); border-color: var(--success); }
.steps li.current { color: var(--primary); font-weight: 600; }
.steps li.current::before { border-color: var(--primary); background: var(--primary); }
/* ------------------------------------------------------------------- kiosk */
/* Full-screen gate scanner, Fakhri-branded: maroon bar, black camera, two
   controls. Deliberately shows nothing about anybody else. */

.kiosk-body {
  margin: 0;
  min-height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0b0709;
  color: #fff;
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* the overlays below set their own display, which would otherwise beat [hidden] */
.kiosk-body [hidden] { display: none !important; }

/* -- top bar ---------------------------------------------------------------- */
.kiosk-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: calc(.55rem + env(safe-area-inset-top)) .8rem .55rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 6px 20px -12px rgba(0, 0, 0, .9);
  z-index: 5;
}
.kiosk-logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  font-family: var(--font-heading);
  font-weight: 700; font-size: 1.02rem;
  color: #fff;
}
.kiosk-brand { min-width: 0; line-height: 1.15; }
.kiosk-brand strong {
  display: block;
  font-family: var(--font-heading);
  font-size: .92rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kiosk-brand small { display: block; font-size: .68rem; color: rgba(255, 255, 255, .78); }

.kiosk-state {
  width: 9px; height: 9px; border-radius: 50%;
  margin-left: auto; flex: none;
  background: rgba(255, 255, 255, .45);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .12);
}
.kiosk-state[data-state="ok"]  { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .22); }
.kiosk-state[data-state="bad"] { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .22); }

.kiosk-clock {
  font-family: var(--font-heading);
  font-size: 1.02rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.kiosk-quit { margin: 0; }
.kiosk-quit button {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 1rem; line-height: 1;
}
.kiosk-quit button:active { background: rgba(255, 255, 255, .26); }

/* -- camera stage ----------------------------------------------------------- */
.kiosk-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.kiosk-cam {
  position: relative;
  flex: 1; min-height: 0;
  background: #000;
  overflow: hidden;
  transition: box-shadow .18s ease;
}
.kiosk-cam video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.kiosk-cam.mirror video { transform: scaleX(-1); }   /* selfie view feels natural */

.kiosk-cam.ok   { box-shadow: inset 0 0 0 5px var(--success); }
.kiosk-cam.warn { box-shadow: inset 0 0 0 5px #f59e0b; }
.kiosk-cam.bad  { box-shadow: inset 0 0 0 5px #ef4444; }

/* the oval the person lines up with */
.kiosk-guide {
  position: absolute; top: 46%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(66%, 340px);
  aspect-ratio: 3 / 4;
  border: 3px dashed rgba(255, 255, 255, .5);
  border-radius: 50% / 42%;
  transition: border-color .18s ease, border-style .18s ease, width .18s ease;
  pointer-events: none;
}
.kiosk-guide.ok   { border-color: #34d399; border-style: solid; }
.kiosk-guide.warn { border-color: #fbbf24; border-style: solid; }
.kiosk-guide.bad  { border-color: #f87171; border-style: solid; }

/* -- anonymous result flash ------------------------------------------------- */
.kiosk-flash {
  position: absolute; inset: auto 0 0 0;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: 2.2rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(4, 4, 6, .92) 12%, rgba(4, 4, 6, .55) 60%, transparent);
  text-align: center;
  animation: kiosk-pop .16s ease-out;
}
@keyframes kiosk-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.kiosk-flash .flash-ico {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2.5rem; font-weight: 700; line-height: 1;
  background: rgba(255, 255, 255, .14);
  border: 3px solid rgba(255, 255, 255, .3);
}
.kiosk-flash .flash-txt {
  font-family: var(--font-heading);
  font-size: 2.4rem; font-weight: 700; letter-spacing: .01em;
  margin-top: .45rem;
}
.kiosk-flash .flash-time {
  font-size: 1.05rem; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .8);
}

.kiosk-flash.ok   .flash-ico { background: rgba(16, 185, 129, .25); border-color: #34d399; color: #6ee7b7; }
.kiosk-flash.ok   .flash-txt { color: #6ee7b7; }
.kiosk-flash.warn .flash-ico { background: rgba(245, 158, 11, .25); border-color: #fbbf24; color: #fcd34d; }
.kiosk-flash.warn .flash-txt { color: #fcd34d; }
.kiosk-flash.bad  .flash-ico { background: rgba(239, 68, 68, .25); border-color: #f87171; color: #fca5a5; }
.kiosk-flash.bad  .flash-txt { color: #fca5a5; }

/* -- confirmation card (full mode) ----------------------------------------- */
.kiosk-card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .35rem;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 30%, #0f3d2e 0%, #06140f 70%);
  text-align: center;
  z-index: 4;
  animation: kiosk-pop .18s ease-out;
}
.kiosk-card .card-tick {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2.1rem; font-weight: 700; line-height: 1;
  background: rgba(16, 185, 129, .22); border: 3px solid #34d399; color: #6ee7b7;
}
.kiosk-card .card-punch {
  font-family: var(--font-heading);
  font-size: 3rem; font-weight: 700; line-height: 1.05; letter-spacing: .04em;
  color: #6ee7b7;
}
.kiosk-card.out .card-punch { color: #93c5fd; }
.kiosk-card .card-avatar {
  width: 92px; height: 92px; border-radius: 50%;
  margin-top: .6rem;
  display: grid; place-items: center;
  font-family: var(--font-heading); font-size: 2.1rem; font-weight: 600;
  background: var(--primary); border: 3px solid rgba(255, 255, 255, .35); color: #fff;
}
.kiosk-card .card-name {
  font-family: var(--font-heading);
  font-size: 1.6rem; font-weight: 600; margin-top: .25rem;
}
.kiosk-card .card-meta { font-size: .95rem; color: rgba(255, 255, 255, .75); }
.kiosk-card .card-when {
  margin-top: .5rem;
  font-size: 1.1rem; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .9);
}
.kiosk-card .card-late {
  margin-top: .45rem;
  padding: .3rem .85rem; border-radius: 999px;
  background: rgba(245, 158, 11, .2); border: 1px solid #fbbf24; color: #fcd34d;
  font-size: .9rem; font-weight: 600;
}

/* -- "verifying" HUD (tap mode) --------------------------------------------- */
.kiosk-hud {
  position: absolute; left: 50%; bottom: 1.2rem;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  font-size: .95rem; white-space: nowrap;
  z-index: 3;
}
.kiosk-hud i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff;
  animation: kiosk-spin .8s linear infinite;
}
@keyframes kiosk-spin { to { transform: rotate(360deg); } }

/* -- tap-to-start ---------------------------------------------------------- */
.kiosk-start {
  position: absolute; inset: 0;
  margin: auto;
  width: min(78%, 330px); height: fit-content;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: 1.5rem 1.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(12, 8, 10, .72);
  backdrop-filter: blur(6px);
  color: #fff; cursor: pointer;
  font-family: var(--font-body);
}
.kiosk-start .ico { font-size: 2.2rem; }
.kiosk-start strong { font-family: var(--font-heading); font-size: 1.12rem; font-weight: 600; }
.kiosk-start small { font-size: .82rem; color: rgba(255, 255, 255, .72); }
.kiosk-start:active { transform: scale(.985); }

.kiosk-live {
  position: absolute; top: .7rem; left: .7rem;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 999px;
  background: rgba(0, 0, 0, .5);
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
}
.kiosk-live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399; animation: kiosk-pulse 1.6s ease-in-out infinite;
}
@keyframes kiosk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* -- bottom dock: exactly two controls ------------------------------------- */
.kiosk-dock {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.6rem;
  padding: .85rem 1rem calc(.85rem + env(safe-area-inset-bottom));
  background: #0b0709;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  width: 68px; padding: 0;
  background: none; border: 0; cursor: pointer;
  color: rgba(255, 255, 255, .8);
  font-family: var(--font-body);
}
.dock-btn .ico {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 1.35rem;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .14);
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.dock-btn .lbl { font-size: .7rem; letter-spacing: .02em; }
.dock-btn:active .ico { transform: scale(.94); }
.dock-btn.is-on .ico {
  background: var(--primary);
  border-color: var(--primary-light);
  color: #fff;
}
.dock-btn.is-active .ico { background: rgba(255, 255, 255, .22); }

@media (min-width: 720px) {
  /* Tablet on a stand: keep the camera centred and the dock compact. */
  .kiosk-cam { max-height: none; }
  .kiosk-guide { width: min(46%, 340px); top: 44%; }
  .kiosk-flash .flash-ico { width: 88px; height: 88px; font-size: 2.9rem; }
  .kiosk-flash .flash-txt { font-size: 2.8rem; }
}

/* -------------------------------------------------------------------- login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-head { padding: 1.4rem 1.4rem .4rem; }
.auth-head .brand-mark { width: 36px; height: 36px; border-radius: 8px; font-size: 1rem; margin-bottom: .8rem; }
.auth-head h1 { font-size: 1.15rem; margin-bottom: .15rem; }
.auth-head p { color: var(--muted); font-size: .82rem; margin: 0; }
.auth-body { padding: 1rem 1.4rem 1.4rem; }
.auth-body .btn { height: 36px; }

/* --------------------------------------------------------------------- misc */
.empty-state { text-align: center; padding: 1.6rem 1rem; color: var(--muted); font-size: .82rem; }
.empty-state .ico { display: none; }
.empty-state h3 { margin-top: .2rem; }
td.empty-state { padding: 1.4rem 1rem !important; }
.kv { display: grid; grid-template-columns: 1fr; gap: 0 .9rem; font-size: .82rem; }
.kv div { display: flex; justify-content: space-between; gap: 1rem; padding: .32rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.kv div:last-child { border-bottom: none; }
.kv dt, .kv .k { color: var(--muted); flex: none; }
.kv .v { font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 640px) { .kv.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.section-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: .9rem 0 .4rem; }
.section-title:first-child { margin-top: 0; }
.divider { height: 1px; background: var(--border); margin: .75rem 0; border: 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: .3rem; }
details.disclosure { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: .6rem; }
details.disclosure > summary { cursor: pointer; padding: .5rem .75rem; font-weight: 500; font-size: .82rem; list-style: none; display: flex; align-items: center; gap: .4rem; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "›"; font-size: 1rem; color: var(--muted); transition: transform .12s ease; display: inline-block; width: .6rem; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }
details.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
details.disclosure .card-body { padding: .75rem; }
details.disclosure > form, details.disclosure > div:not(.card-body) { padding: .75rem; }
.progress { height: 6px; border-radius: 999px; background: #ecebea; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.camera-box { border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--border); }
.camera-box video { width: 100%; display: block; }
.face-thumb { width: 96px; height: 96px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); background: #f1efee; }
.statement td:first-child { width: 70%; }

/* ------------------------------------------------------------------- print */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .page-actions, .drawer, .drawer-backdrop { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
  .payslip-print { max-width: 100%; }
  table.data th { position: static; }
}
