/* Mindwave Attendance
   Dark top bar, icon rail, white cards on a soft grey canvas.
   One stylesheet, no build step, no web fonts (this runs on a LAN box). */

:root {
  /* canvas */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --rail: #ffffff;
  --topbar: #17191f;
  --topbar-2: #23262e;
  --topbar-line: #343843;

  /* ink */
  --text: #16181d;
  --text-dim: #667085;
  --text-faint: #98a2b3;
  --on-dark: #e7e9ee;
  --on-dark-dim: #9096a2;

  /* lines */
  --border: #e9ebef;
  --border-strong: #d7dbe2;

  /* accents */
  --brand: #0f9d74;
  --brand-ink: #ffffff;
  --brand-soft: #e6f6f1;
  --yellow: #ffd233;
  --blue: #2e6bea;
  --blue-soft: #e8f0fe;

  /* semantic */
  --ok: #0f9d74;
  --ok-soft: #e6f6f1;
  --warn: #d9850a;
  --warn-soft: #fdf3e2;
  --bad: #e5484d;
  --bad-soft: #fdeceb;
  --info: #2e6bea;
  --info-soft: #e8f0fe;
  --mute-soft: #f0f1f4;
  /* Weekly off. A clear red wash, distinct from the alarm red used for a
     problem - these rows are expected, just not working days. */
  --off-bg: #fdeaea;
  --off-bg-hover: #fadddd;

  --r-card: 14px;
  --r-ctl: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Urbanist carries the interface - geometric, even colour, legible in dense
     tables at 13px. Afacad is the display face: narrower and with more
     character, used for headings and the large figures. Both are self-hosted
     variable fonts, so intermediate weights render properly instead of
     snapping to the nearest static cut. */
  --font-ui: 'Urbanist', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Afacad', 'Urbanist', system-ui, "Segoe UI", sans-serif;
}

/* Theme.
   Three states: no attribute = follow the OS, data-theme="light"/"dark" =
   an explicit choice the viewer made. The dark palette is written twice on
   purpose - once for the OS preference and once for the explicit choice -
   because CSS has no way to reuse a declaration block. KEEP THEM IDENTICAL. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #181b21;
    --surface-2: #1e222a;
    --rail: #181b21;
    --topbar: #0b0d11;
    --topbar-2: #1b1f27;
    --topbar-line: #2a2f38;

    --text: #e7e9ee;
    --text-dim: #9aa3b2;
    --text-faint: #767e8c;

    --border: #262a33;
    --border-strong: #3a404b;

    --brand: #2bbf92;
    --brand-soft: #14312a;
    --blue: #6e9bf5;
    --blue-soft: #16233d;

    --ok: #2bbf92;
    --ok-soft: #14312a;
    --warn: #e0a64a;
    --warn-soft: #30260f;
    --bad: #f2777b;
    --bad-soft: #37191c;
    --info: #6e9bf5;
    --info-soft: #16233d;
    --mute-soft: #22262e;
    --off-bg: #2e1a1c;
    --off-bg-hover: #3a2022;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #181b21;
  --surface-2: #1e222a;
  --rail: #181b21;
  --topbar: #0b0d11;
  --topbar-2: #1b1f27;
  --topbar-line: #2a2f38;

  --text: #e7e9ee;
  --text-dim: #9aa3b2;
  --text-faint: #767e8c;

  --border: #262a33;
  --border-strong: #3a404b;

  --brand: #2bbf92;
  --brand-soft: #14312a;
  --blue: #6e9bf5;
  --blue-soft: #16233d;

  --ok: #2bbf92;
  --ok-soft: #14312a;
  --warn: #e0a64a;
  --warn-soft: #30260f;
  --bad: #f2777b;
  --bad-soft: #37191c;
  --info: #6e9bf5;
  --info-soft: #16233d;
  --mute-soft: #22262e;
  --off-bg: #2e1a1c;
  --off-bg-hover: #3a2022;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
  /* Urbanist runs a touch wide at default tracking in dense tables. */
  font-feature-settings: 'tnum' 1;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== top bar ========================================================== */

.topbar {
  background: var(--topbar);
  color: var(--on-dark);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 54px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--yellow);
  color: #17191f;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  flex: none;
}

.brand-sub {
  color: var(--on-dark-dim);
  font-weight: 500;
  padding-left: 11px;
  border-left: 1px solid var(--topbar-line);
  white-space: nowrap;
}

nav.main { display: flex; gap: 3px; flex: 1; flex-wrap: wrap; }

nav.main a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--on-dark-dim);
  font-weight: 540;
  font-size: 13.5px;
  white-space: nowrap;
}
nav.main a:hover { background: var(--topbar-2); color: #fff; text-decoration: none; }
nav.main a.on { background: var(--topbar-2); color: #fff; }

.count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--topbar-2);
  color: var(--on-dark-dim);
  line-height: 1.6;
}
.count.warn { background: #f7a23b; color: #2a1a04; }
.count.bad  { background: #e5484d; color: #fff; }
.count.info { background: #2e6bea; color: #fff; }
.count.ok   { background: #0f9d74; color: #fff; }

.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-user { color: var(--on-dark); font-size: 13px; white-space: nowrap; }
.top-user b { font-weight: 620; }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--topbar-line);
  background: var(--topbar-2);
  color: var(--on-dark);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: #2e323c; color: #fff; text-decoration: none; }
.icon-btn.accent { background: var(--yellow); border-color: var(--yellow); color: #17191f; }
.icon-btn.accent:hover { filter: brightness(1.06); }

/* ===== mobile nav drawer ================================================ */
/* Below the nav breakpoint the text bar wraps into four rows and the icon
   rail disappears, so both are replaced by one drawer behind a hamburger.
   Hidden - and so out of the accessibility tree - at every other width. */

.nav-toggle { display: none; flex: none; }

/* The bar itself has to sit above both the backdrop and the drawer, all three
   being children of the sticky header's stacking context. */
.topbar-inner { position: relative; z-index: 2; background: var(--topbar); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, .45);
}

.nav-drawer {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1;
  background: var(--topbar);
  border-top: 1px solid var(--topbar-line);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .35);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-drawer a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--on-dark-dim);
  font-size: 15px;
  font-weight: 560;
}
.nav-drawer a:hover { background: var(--topbar-2); color: #fff; text-decoration: none; }
.nav-drawer a.on { background: var(--topbar-2); color: #fff; }
.nav-drawer a svg { flex: none; }
.nav-drawer a .count { margin-left: auto; }

.nav-drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--topbar-line);
}
.nav-drawer-user .nm { color: #fff; font-weight: 620; line-height: 1.25; }
.nav-drawer-user .id { color: var(--on-dark-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.nav-drawer-extra {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--topbar-line);
}

/* ===== shell ============================================================ */

.shell { display: flex; align-items: flex-start; }

.rail {
  width: 60px;
  flex: none;
  background: var(--rail);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 54px);
  position: sticky;
  top: 54px;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rail .avatar { margin-bottom: 10px; }

.rail a {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: var(--text-faint);
  position: relative;
}
.rail a:hover { background: var(--mute-soft); color: var(--text); text-decoration: none; }
.rail a.on { background: var(--brand-soft); color: var(--brand); }

/* Tooltip for the collapsed rail. */
.rail a::after {
  content: attr(data-label);
  position: absolute;
  left: 46px;
  background: var(--topbar);
  color: #fff;
  font-size: 12px;
  font-weight: 560;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  z-index: 50;
}
.rail a:hover::after { opacity: 1; }

.content { flex: 1; min-width: 0; padding: 20px 22px 60px; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  flex: none;
  letter-spacing: 0;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

/* ===== page head ======================================================== */

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h1 {
  font-family: var(--font-display);
  font-size: 27px; margin: 0; font-weight: 700; letter-spacing: -0.01em;
  line-height: 1.2;
}
h2 {
  font-family: var(--font-display);
  font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -0.005em;
}
.sub { color: var(--text-dim); font-size: 13px; margin: 3px 0 0; }
.head-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stepper a, .stepper span {
  padding: 7px 11px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
}
.stepper a:hover { background: var(--mute-soft); color: var(--text); text-decoration: none; }
.stepper .label {
  font-weight: 620;
  color: var(--text);
  min-width: 170px;
  justify-content: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 13.5px;
}

/* ===== cards ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body > :last-child { margin-bottom: 0; }

.chip-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex: none;
}
.chip-icon.ok   { background: var(--ok-soft);   color: var(--ok); }
.chip-icon.bad  { background: var(--bad-soft);  color: var(--bad); }
.chip-icon.warn { background: var(--warn-soft); color: var(--warn); }
.chip-icon.info { background: var(--info-soft); color: var(--info); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metrics { display: flex; gap: 8px; padding: 15px 16px; flex-wrap: wrap; }
.metric { flex: 1; min-width: 86px; }
.metric .k {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 540;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric .n {
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.metric .d {
  font-size: 11.5px;
  font-weight: 560;
  margin-top: 3px;
  color: var(--text-faint);
  white-space: nowrap;
}
.metric .d.up   { color: var(--ok); }
.metric .d.down { color: var(--bad); }
.metric.is-bad  .n { color: var(--bad); }
.metric.is-warn .n { color: var(--warn); }
.metric.is-ok   .n { color: var(--ok); }

/* ===== filter bar ======================================================= */

.filters {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters form { display: contents; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  box-shadow: var(--shadow);
  min-width: 210px;
}
.search input {
  border: 0; background: none; outline: none;
  padding: 8px 0; font: inherit; font-size: 13.5px;
  color: var(--text); width: 100%;
}
.search svg { color: var(--text-faint); flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 7px 11px;
  font-size: 13.5px;
  font-weight: 540;
  color: var(--text-dim);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.chip select {
  border: 0; background: none; outline: none; font: inherit;
  font-weight: 540; color: var(--text); cursor: pointer; padding: 0; width: auto;
}

/* ===== tables =========================================================== */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* A swipe that runs off the end of the table stops there instead of
     handing the gesture to the page or triggering a back navigation. */
  overscroll-behavior-x: contain;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 620;
  color: var(--text-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th .th { display: inline-flex; align-items: center; gap: 6px; }
thead th svg { color: var(--text-faint); }

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td {
  font-weight: 640;
  background: var(--surface-2);
  border-top: 1px solid var(--border-strong);
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.dim, .dim { color: var(--text-faint); }
.nowrap { white-space: nowrap; }

tr.is-off td { background: var(--off-bg); }
/* After the generic row hover, or that would win and the day would lose
   its colour exactly when someone points at it. */
tbody tr.is-off:hover td { background: var(--off-bg-hover); }
tr.is-today td { box-shadow: inset 2px 0 0 var(--brand); }

.person { display: flex; align-items: center; gap: 10px; }
.person .nm { font-weight: 620; color: var(--text); line-height: 1.25; }
.person .id { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.person a:hover { text-decoration: none; }
.person a:hover .nm { color: var(--blue); }

/* clock-in --- duration --- clock-out */
.punchline {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 190px;
}
.punchline .t { font-weight: 640; font-size: 13px; letter-spacing: -0.01em; }
.punchline .t.late { color: var(--bad); }
.punchline .t.none { color: var(--text-faint); font-weight: 500; }
.punchline .span {
  flex: 1;
  min-width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.punchline .span .mins {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 560;
  line-height: 1;
}
.punchline .rule {
  width: 100%;
  border-top: 1.5px dashed var(--border-strong);
  position: relative;
  height: 1px;
}
.punchline .rule::before,
.punchline .rule::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}
.punchline .rule::before { left: -1px; }
.punchline .rule::after  { right: -1px; }
.punchline.running .rule { border-color: var(--brand); }
.punchline.running .rule::before,
.punchline.running .rule::after { background: var(--brand); }

/* ===== pills ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
}
.pill.present      { background: var(--ok-soft);    color: var(--ok); }
.pill.late         { background: var(--warn-soft);  color: var(--warn); }
.pill.half_day     { background: var(--info-soft);  color: var(--info); }
.pill.absent       { background: var(--bad-soft);   color: var(--bad); }
.pill.leave        { background: var(--blue-soft);  color: var(--blue); }
.pill.holiday      { background: var(--blue-soft);  color: var(--blue); }
.pill.weekly_off   { background: var(--bad-soft);  color: var(--bad); }
.pill.not_employed { background: var(--mute-soft);  color: var(--text-faint); }
.pill.upcoming     { background: var(--mute-soft);  color: var(--text-faint); }
.pill.not_required { background: var(--mute-soft);  color: var(--text-faint); }
/* Entered by the employee after the fact. Its own class, not a borrowed
   one - this is a normal record, so it must never pick up a colour that
   says something is wrong. */
.pill.self-entered { background: var(--ok-soft);    color: var(--ok); }
.pill.in_progress  { background: var(--brand-soft); color: var(--brand); }
.pill.live         { background: var(--brand-soft); color: var(--brand); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot.beat { animation: beat 1.8s ease-in-out infinite; }
@keyframes beat { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.badge-role {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: var(--mute-soft); color: var(--text-dim); font-weight: 620;
}
.badge-role.admin   { background: var(--brand-soft); color: var(--brand); }
.badge-role.manager { background: var(--info-soft);  color: var(--info); }

/* ===== forms ============================================================ */

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
input[type=checkbox] { width: auto; margin-right: 6px; accent-color: var(--brand); }

.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; }

fieldset { border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 12px; font-weight: 650; color: var(--text-dim); padding: 0 6px; }

.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; font-weight: 500; color: var(--text); margin: 0; font-size: 13px; }

/* ===== buttons ========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 580;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); background: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ===== messages ========================================================= */

.flash {
  padding: 11px 14px;
  border-radius: var(--r-ctl);
  margin-bottom: 16px;
  font-weight: 540;
  border: 1px solid transparent;
  display: flex; align-items: center; gap: 9px;
}
.flash.ok  { background: var(--ok-soft);  color: var(--ok);  border-color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

.empty { padding: 40px 18px; text-align: center; color: var(--text-faint); }
.empty p { margin: 0 0 6px; }

.warn-text { color: var(--warn); font-size: 12.5px; }
.bad-text  { color: var(--bad);  font-size: 12.5px; }
.problems { margin: 3px 0 0; padding-left: 16px; font-size: 12px; color: var(--warn); }

/* ===== punch panel ====================================================== */

.punch-panel { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.punch-clock {
  font-family: var(--font-display);
  font-size: 46px; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.punch-meta { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ===== login / kiosk ==================================================== */

.centered {
  min-height: 100vh;
  min-height: 100dvh;      /* 100vh is taller than the visible area on phones */
  display: grid; place-items: center; padding: 24px; background: var(--bg);
}
.panel {
  width: 100%; max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .10);
  padding: 28px;
}
.panel .brand-mark { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; margin-bottom: 14px; }
.panel h1 { margin-bottom: 4px; }
.panel .sub { margin-bottom: 20px; }

.kiosk-panel { max-width: 450px; text-align: center; }
.kiosk-panel .brand-mark { margin: 0 auto 14px; }
.kiosk-panel input { font-size: 22px; text-align: center; padding: 13px; letter-spacing: .1em; }
.kiosk-panel .btn { width: 100%; }
.kiosk-result .big {
  font-family: var(--font-display);
  font-size: 40px; font-weight: 700; margin: 12px 0 2px; letter-spacing: -0.01em;
}
.kiosk-result .who-name { font-size: 17px; color: var(--text-dim); }
.kiosk-clock { font-size: 15px; color: var(--text-faint); margin-bottom: 20px; }

/* ===== misc ============================================================= */

.inline-form { display: inline; }

/* The CSV paste box. Small and monospaced so a row fits on one line - but see
   the narrow-screen rules, where anything under 16px makes Safari zoom in. */
.mono-input { font-family: var(--mono); font-size: 12.5px; }

details.row-edit summary {
  cursor: pointer; font-size: 12.5px; color: var(--blue); font-weight: 580; list-style: none;
}
details.row-edit summary::-webkit-details-marker { display: none; }
/* Correcting a punch already on the record. One line per punch: its time as an
   editable field, which end of the session it is, save, delete. The time input
   drops its 100% width here so all four fit inside the 260px panel. */
.punch-note { font-size: 12px; color: var(--text-faint); font-weight: 400; margin: 4px 0 8px; }
.punch-edit { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.punch-edit .inline-form { display: flex; align-items: center; gap: 6px; }
.punch-edit input[type=time] { width: auto; padding: 4px 7px; font-size: 12.5px; }
.punch-edit .dim { font-size: 12px; }

details.row-edit .panel-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 12px;
  margin-top: 8px;
  /* Fixed rather than a minimum: the panel lives in the last column of an
     already-wide table, so a panel that grows with its contents pushes itself
     off the right edge and the admin has to scroll sideways to reach Save. */
  width: 268px;
  /* The panel lives in a td.num, which is nowrap so that figures never break
     mid-number. Prose inside the panel does need to wrap. */
  white-space: normal;
}
/* The two-up field grid is for full-width forms; inside the panel it is what
   forced the width past 400px. Stack instead. */
details.row-edit .panel-inline .field-row { grid-template-columns: 1fr; gap: 0; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); margin-top: 12px; }

/* ===== narrow screens =================================================== */

/* The text bar starts wrapping well before this, but two rows still read as a
   bar. Below 900px it becomes four, so hand navigation to the drawer - and
   drop the rail with it, so there is exactly one way to navigate, not two. */
@media (max-width: 900px) {
  .nav-toggle { display: grid; }
  nav.main { display: none; }
  .rail { display: none; }
  .top-user { display: none; }
  .brand-sub { display: none; }
  /* Four icon buttons plus the brand and the hamburger wrap onto a second
     row on a phone. These two move into the drawer instead. */
  .top-wide { display: none; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .top-right { gap: 8px; }
  .topbar.nav-open .nav-drawer,
  .topbar.nav-open .nav-backdrop { display: block; }
  .content { padding: 18px 16px calc(48px + env(safe-area-inset-bottom)); }
}

@media (max-width: 600px) {
  .content { padding: 14px 13px calc(40px + env(safe-area-inset-bottom)); }

  h1 { font-size: 23px; }
  .page-head { gap: 10px; margin-bottom: 14px; }
  /* Actions sit under the title rather than being squeezed beside it. */
  .head-actions { margin-left: 0; width: 100%; }

  /* Safari zooms the whole page when a field smaller than 16px takes focus,
     and never zooms back out. Every control the thumb can reach is 16px. */
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=time], input[type=number], select, textarea,
  .search input, .chip select, .mono-input { font-size: 16px; }

  .icon-btn { width: 36px; height: 36px; }
  .btn { padding: 10px 14px; }
  .btn.small { padding: 7px 11px; }
  .chip { padding: 9px 12px; }

  /* Controls that were sized for a toolbar take the full row instead. */
  .filters .search { flex: 1 1 100%; min-width: 0; }
  .toolbar form { width: 100%; }
  .toolbar .field { min-width: 0; flex: 1 1 140px; }
  .stepper, .monthnav { width: 100%; }
  .stepper .label, .monthnav .label { flex: 1; min-width: 0; }

  .grid.two { grid-template-columns: 1fr; }
  /* Two columns of a date or time field at this width is narrower than the
     text inside them. */
  .field-row { grid-template-columns: 1fr; }

  /* Flex wrapping leaves the last row of figures stretched across the card;
     a grid keeps every tile the same size. */
  .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 12px 8px; }
  .metric { min-width: 0; }
  .metric .n { font-size: 26px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .n { font-size: 25px; }

  .card-head { padding: 12px 13px; }
  .card-body { padding: 13px; }
  thead th { padding: 9px 11px; }
  td { padding: 10px 11px; }
  /* A table set to 100% is squeezed into the viewport rather than being left
     to scroll, which breaks a two-word name across three lines. Pinning the
     name keeps rows one line tall and pushes the overflow into the wrap,
     which is what .table-wrap is there to scroll. */
  .person .nm { white-space: nowrap; }

  .punch-panel { gap: 14px; }
  .punch-clock { font-size: 32px; }
  .punch-panel form { width: 100%; }
  .punch-panel form .btn { width: 100%; }

  .centered { padding: 16px; }
  .panel { padding: 22px 20px; }
  .kiosk-panel input { font-size: 20px; }
}

@media print {
  .topbar, .rail, .filters, .btn, .no-print, .stepper { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .content { padding: 0; }
}

/* ===== stat tiles ======================================================= */
/* Standalone metric cards, used where a page shows headline numbers outside
   a summary card (employee month, exceptions, import preview). */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.stat .n {
  font-family: var(--font-display);
  font-size: 29px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat .k {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 540;
  margin-top: 4px;
}
.stat.good .n { color: var(--ok); }
.stat.warn .n { color: var(--warn); }
.stat.bad  .n { color: var(--bad); }
.stat.info .n { color: var(--info); }

/* ===== toolbar + month nav ============================================== */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.toolbar .field { margin: 0; min-width: 150px; }

.monthnav {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.monthnav .btn {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  padding: 7px 12px;
  color: var(--text-dim);
}
.monthnav .btn:hover { background: var(--mute-soft); color: var(--text); }
.monthnav .label {
  font-weight: 620;
  font-size: 13.5px;
  padding: 7px 14px;
  min-width: 150px;
  text-align: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ===== utilities ======================================================== */

.time {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--text-dim);
}

/* Theme toggle: only the active mode's icon is shown. */
#theme-toggle [data-mode] { display: inline-flex; }
#theme-toggle [data-mode][hidden] { display: none !important; }
