/* Nirjai Attendance — dashboard stylesheet.
 *
 * This replaces the inline <style> block that used to live in
 * templates/attendance_hr/base.html, plus ~76 style="..." attributes scattered
 * across the 17 templates. A real file is not cosmetic housekeeping:
 *   - the inline block was re-sent on every single page load, uncached;
 *   - inline style="" attributes cannot be overridden by a media query, which
 *     is why this app had zero responsive behaviour and scrolled sideways on a
 *     phone;
 *   - and a palette expressed as custom properties can be re-pointed for dark
 *     mode in one place instead of being retyped per rule.
 *
 * Nginx serves /static/ with `expires 7d` (deploy/nginx/nginx.conf). That cache
 * header is only safe because config/settings.py hashes these filenames via
 * ManifestStaticFilesStorage — see the comment there.
 */

/* ===========================================================================
 * Brand
 * ---------------------------------------------------------------------------
 * Values taken from nirjai.com's live CSS, not guessed.
 *
 * THE ONE RULE THAT MATTERS: amber #ffa807 on white is 1.93:1. That fails every
 * WCAG threshold there is, including the 3:1 floor for non-text. So amber is a
 * FILL (dark text sits on it: #25140d on #ffa807 = 9.16:1) and an INK ON DARK
 * (#ffa807 on #25140d = 9.16:1). It is never text or a border on a light
 * surface. Where a brand-coloured link is wanted on a light background, use
 * --brand-ink (#9a5600, 5.67:1 on white) — a darkened amber, not the brand one.
 * ======================================================================== */

:root {
  color-scheme: light;

  /* Brand constants — identical in both themes; only their ROLES change. */
  --amber: #ffa807;
  --amber-hover: #ffa500;
  --espresso: #25140d;
  --brown: #4c271f;
  /* Darkened amber: the only brand-ish colour allowed as text on light. */
  --brand-ink: #9a5600;
  /* Focus ring. 3.59:1 against white — above the 3:1 non-text floor, and warm
   * enough to read as ours rather than as the browser default. */
  --focus: #c47400;

  /* Surfaces and text (light) */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-sunken: #f0f2f4;
  --row-hover: #fafbfc;
  --text: #1a1a1a;
  --text-muted: #6b7280;      /* 4.7:1 on --bg */
  --border: #e5e7eb;
  --border-strong: #cccccc;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  /* The header is espresso in BOTH themes: the logo is amber on transparent,
   * so it needs a dark ground to exist on at all. */
  --header-bg: var(--espresso);
  --header-fg: #ffffff;
  --header-rule: rgba(255, 255, 255, 0.5);

  --danger: #b91c1c;
  --danger-bg: #fef2f2;

  --radius: 6px;
  --gutter: 1rem;             /* the 16px side gutter, used at every width */
}

/* Dark palette, declared twice on purpose.
 *
 * The first block is the system preference, but guarded so an explicit
 * data-theme="light" wins over it. The second is an explicit data-theme="dark".
 * Declaring only the media query would make a manual light choice impossible;
 * declaring only the attribute would ignore the OS. Nothing below is a colour's
 * ONLY definition — every token already has a light value on bare :root above. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a0e08;
    --surface: #2b1710;
    --surface-sunken: #35201a;
    --row-hover: #33201a;
    --text: #f5ece6;
    --text-muted: #c3ab9d;    /* 7.8:1 on --surface; #6b7280 would be ~4.0 */
    --border: #4c271f;
    --border-strong: #5e352b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --header-bg: #130a05;
    /* On a dark ground amber finally gets to be ink: 8.8:1 on --surface. */
    --brand-ink: var(--amber);
    --focus: var(--amber);
    --danger: #f87171;
    --danger-bg: #3b1413;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a0e08;
  --surface: #2b1710;
  --surface-sunken: #35201a;
  --row-hover: #33201a;
  --text: #f5ece6;
  --text-muted: #c3ab9d;
  --border: #4c271f;
  --border-strong: #5e352b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --header-bg: #130a05;
  --brand-ink: var(--amber);
  --focus: var(--amber);
  --danger: #f87171;
  --danger-bg: #3b1413;
}

/* ===========================================================================
 * Base
 * ======================================================================== */

/* Poppins first, then a system stack. Deliberately NOT a Google Fonts @import:
 * this is an on-prem deployment that may have no outbound internet (the webfont
 * would simply never arrive and every page would flash unstyled text), and even
 * where it does, fetching from fonts.googleapis.com leaks a request per page
 * load to a third party. If Poppins is installed on the machine it is used; if
 * not, the system UI font is a clean fallback. */
body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--brand-ink); }

/* One visible focus style everywhere, including for mouse users: this is an
 * internal tool people drive with the keyboard all day, and the default ring is
 * invisible on the espresso header. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Visually hidden but still announced. Used for the actions column's empty
 * <th> and for the skip link when it is not focused. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* First tab stop on every page: the sidebar is a dozen links long and nobody
 * using a screen reader should have to walk it to reach the table. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--amber);
  color: var(--espresso);     /* 9.16:1 */
  padding: 0.6rem 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

/* ===========================================================================
 * Header (signed out: login, password reset, onboarding)
 * ======================================================================== */

header {
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 0.6rem var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header a {
  color: var(--header-fg);
  text-decoration: none;
  font-size: 0.95rem;
}
header a:hover { text-decoration: underline; }

.header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

/* The lockup is amber on transparent, which is exactly why the header is
 * espresso — on the old white chrome it would have been invisible. */
.brand { display: inline-flex; align-items: center; }
.brand img {
  height: 1.6rem;
  width: auto;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* --- Light / Dark / Auto ----------------------------------------------------
 *
 * Three submit buttons sharing one form, drawn as a single segmented control so
 * they read as one three-way choice rather than three unrelated actions.
 *
 * Deliberately quiet. This is a preference somebody sets once: Settings ->
 * Appearance when signed in, the espresso header when not.
 *
 * Only the layout lives here. The segments' own appearance is further down with
 * the other .btn variants, and it HAS to be: these buttons carry .btn as well,
 * `.btn-theme` and `.btn` are both one class, and the later rule wins a tie --
 * so anything written up here that .btn also sets (padding, radius, font-size)
 * would be silently overridden. */
.theme-switch { display: inline-flex; align-items: center; }
.theme-options { display: inline-flex; }

main {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 var(--gutter);
}

/* ===========================================================================
 * Sidebar (signed in)
 * ---------------------------------------------------------------------------
 * A fixed column on the left, the page beside it. The column is espresso in
 * both themes, as the header was: the logo is amber on transparent and needs a
 * dark ground.
 *
 * minmax(0, 1fr) is what keeps a wide table inside its own .table-wrap scroll:
 * a plain 1fr track grows to its widest child and the whole page would scroll
 * sideways. main takes the full track (width: 100%) and keeps its 1100px cap,
 * centred, on a very wide screen.
 *
 * The sidebar is the viewport's height and scrolls on its own, so every link
 * stays reachable when the list is longer than the window.
 * ======================================================================== */
.app {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
}
.app > main {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  background: var(--header-bg);
  color: var(--header-fg);
}
.sidebar .brand { padding: 0 0.5rem 0.75rem; }
.sidebar .brand img { height: 2rem; }

/* The phone's Menu control; nothing on a desktop, where the list is always
 * shown. See the 760px block below. */
.sidebar-toggle,
.sidebar-toggle-label { display: none; }

.sidebar-body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.side-group-title {
  margin: 1rem 0.5rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--header-rule);
}
.side-list,
.side-sections { list-style: none; margin: 0; padding: 0; }

.side-nav a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--header-fg);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.3;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.08); }

/* The visible half of aria-current="page": a fill, an amber rule and weight,
 * so it is not carried by colour alone. Amber on espresso is 9.16:1. */
.side-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}
/* Analytics or Settings while you are in one of its sections: marked, but
 * quieter than the section itself, which is the page you are on. */
.side-nav a[aria-current="true"] { color: var(--amber); font-weight: 600; }

/* A page's sections, indented under it, with a rule tying them to it. */
.side-sections {
  margin: 0.15rem 0 0.4rem 0.9rem;
  padding-left: 0.35rem;
  border-left: 1px solid var(--header-rule);
}
.side-sections a { font-size: 0.82rem; padding: 0.3rem 0.5rem; }

/* Who is signed in -- name and role -- pinned to the bottom of the column by
 * margin-top: auto. The theme switch, Change password and Log out are
 * sections of Settings. */
.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}
.sidebar-user { margin: 0 0.5rem; font-size: 0.85rem; line-height: 1.35; }
.sidebar-user-name { display: block; font-weight: 600; }
.sidebar-user-role { color: var(--header-rule); }

/* Phones: the column becomes a bar across the top -- logo on the left, Menu on
 * the right -- and the list opens below it when Menu is ticked. No JavaScript:
 * the checkbox is visually hidden (still focusable, so the keyboard reaches
 * it) and its label is the control. */
@media (max-width: 760px) {
  .app { display: block; min-height: 0; }
  .sidebar {
    position: relative;
    height: auto;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem var(--gutter);
  }
  .sidebar .brand { padding: 0; }
  .sidebar .brand img { height: 1.6rem; }
  .sidebar-toggle {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .sidebar-toggle-label {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    min-height: 2.1rem;
    box-sizing: border-box;
    border: 1px solid var(--header-rule);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
  }
  .sidebar-toggle:focus-visible + .sidebar-toggle-label {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
  .sidebar-toggle:checked + .sidebar-toggle-label {
    background: var(--amber);
    border-color: var(--amber);
    color: var(--espresso);
    font-weight: 600;
  }
  .sidebar-body { display: none; flex-basis: 100%; min-width: 0; }
  .sidebar-toggle:checked ~ .sidebar-body { display: flex; }
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; }

/* ===========================================================================
 * Tables
 * ======================================================================== */

/* The horizontal scroll lives HERE, not on <body>. The attendance table has ten
 * columns of nowrap times; without this wrapper the whole page scrolls sideways
 * on a phone and the nav/header drift off screen with it. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Makes this the containing block for the absolutely positioned boxes inside
   * it -- which today means exactly one thing: the `.sr-only` label in the
   * actions column's otherwise empty <th>.
   *
   * Without it that 1px box has the INITIAL containing block instead, so it is
   * laid out at its static position inside a table wider than the phone and
   * contributes that position to the DOCUMENT's scrollable overflow. The table
   * still scrolled inside this wrapper exactly as intended; the whole page
   * scrolled sideways as well, carrying the header and nav off screen -- which
   * is precisely the failure the comment above says this wrapper exists to
   * prevent, reintroduced by a span nobody can see.
   *
   * Measured at 390px on the all-timesheets page: document scrollWidth was 528
   * against a 390 viewport, and the only element past the edge was that label.
   * It was latent on every wide table in this app (attendance, corrections) and
   * showed up here first because this table is the widest one an employee-free
   * page draws.
   *
   * Safe for the one other absolutely positioned thing that used to live in
   * here: .punch-popover stopped being position:absolute some time ago and now
   * flows in its cell (see its comment below), so there is nothing left that
   * WANTS to escape this box. */
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
th {
  background: var(--surface-sunken);
  font-weight: 600;
}
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }

/* Times, dates and durations. tabular-nums keeps a column of 09:15 / 17:40 on a
 * shared grid instead of letting proportional digits ripple; nowrap stops a
 * duration breaking across two lines in a narrow column. */
.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.nowrap { white-space: nowrap; }

.empty-row {
  text-align: center;
  padding: 2rem;
}

/* A flagged day has to be findable by scanning the table, not only by filtering. */
tr.row-suspected { background: var(--danger-bg); box-shadow: inset 3px 0 0 var(--danger); }
tr.row-suspected:hover { background: var(--danger-bg); filter: brightness(0.97); }

.frame-thumb {
  height: 2.2rem;
  width: auto;
  border-radius: 3px;
  border: 1px solid var(--danger);
  vertical-align: middle;
  margin-left: 0.3rem;
}

/* ===========================================================================
 * Cards, forms, buttons
 * ======================================================================== */

.card {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
/* Saves a style="margin-top:0" on the heading of nearly every card, and a
 * style="margin:0" on the trailing paragraph of several more. */
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* The two card widths this app actually uses: a narrow auth/credential panel
 * and a wider data-entry form. */
.card-narrow { max-width: 360px; margin-left: auto; margin-right: auto; margin-top: 2rem; }
.card-form { max-width: 480px; }

/* Login: the brand panel above the form. Espresso in both themes for the same
 * reason the header is — the lockup is amber on transparent and needs a dark
 * ground to be legible at all. Negative margins pull it out to the card's edges
 * so it reads as a banner rather than a floating box. */
/* Selector is `.card > .login-hero`, not `.login-hero`: `.card > :first-child`
 * above zeroes margin-top on whatever leads a card, which would eat the
 * negative pull. Same specificity, declared later, so this wins. */
.card > .login-hero {
  background: var(--espresso);
  margin: -1.25rem -1.25rem 1.25rem;
  padding: 1.5rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  text-align: center;
}
.login-hero img {
  height: 2.6rem;
  width: auto;
  display: inline-block;
}
.login-tagline {
  margin: 0.6rem 0 0;
  color: var(--amber);        /* 9.16:1 on espresso */
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

form.inline { display: inline; }

.btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
}
.btn:hover { background: var(--surface-sunken); }

/* Amber fill, espresso text: 9.16:1, and the one place the brand colour carries
 * real weight. An amber *border* or amber *text* on white would be 1.93:1. */
.btn-primary {
  background: var(--amber);
  color: var(--espresso);
  border-color: var(--amber);
  font-weight: 600;
}
.btn-primary:hover { background: var(--amber-hover); border-color: var(--amber-hover); }

.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-bg); }

/* The theme switch on the signed-out espresso header. */
.btn-ghost {
  background: transparent;
  color: var(--header-fg);
  border-color: var(--header-rule);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn-theme {
  /* Smaller than a real action and tighter than .btn's default padding, but not
   * below the ~44px tap target a thumb needs -- hence the min-height rather than
   * padding alone. A control nobody can hit on a phone is not unobtrusive, it is
   * broken. */
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  min-height: 2.1rem;
  border-radius: 0;
}
.btn-theme + .btn-theme { margin-left: -1px; }
.theme-options .btn-theme:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.theme-options .btn-theme:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* The visible half of aria-pressed="true". Amber as a FILL with espresso text on
 * it (9.16:1), never amber text -- the one rule at the top of this file. */
.btn-theme.is-current {
  background: var(--amber);
  color: var(--espresso);
  border-color: var(--amber);
  font-weight: 600;
  /* Lifts the selected segment's border over its neighbour's, which the -1px
   * overlap would otherwise let win on one side. */
  position: relative;
  z-index: 1;
}
.btn-theme.is-current:hover { background: var(--amber-hover); border-color: var(--amber-hover); }

/* The same switch on a card (Settings -> Appearance): the ghost's white text
 * and white rule are for the espresso bar and would vanish on a light card, so
 * the unchosen segments are drawn as ordinary buttons here, in either theme.
 * :not(.is-current) keeps the amber fill of the chosen one. */
.card .btn-theme:not(.is-current) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.card .btn-theme:not(.is-current):hover { background: var(--surface-sunken); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 420px;
  padding: 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
}
.field .errorlist { color: var(--danger); font-size: 0.85rem; margin: 0.25rem 0 0; padding: 0; list-style: none; }

/* A checkbox and its wording on one line. The checkbox must not inherit the
 * width:100% above or it stretches across the whole field. */
.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.check-label input[type="checkbox"] { width: auto; margin: 0; }

/* Help text under a field: `margin: 0.25rem 0 0` repeated five times inline. */
.help { margin: 0.25rem 0 0; }

/* The filter bar. align-items:end keeps the buttons on the baseline of the
 * inputs rather than their labels. */
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
}
.toolbar .field { margin: 0; }

/* ===========================================================================
 * Page furniture
 * ======================================================================== */

/* Title on the left, backend-health or record-count on the right. */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }
.page-head-tight { margin-bottom: 0.5rem; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-row-end { justify-content: flex-end; }

/* Buttons inside a table cell. This is on an inner <div>, never on the <td>
 * itself: display:flex on a td destroys its table-cell layout and the column
 * stops aligning with its header. */
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.section-head { margin: 1.5rem 0 0.5rem; }
.section-note { margin-top: 0; }
.footnote { margin-top: 1rem; }
.table-note { margin-top: 0.75rem; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; }
.status-ok { background: #22c55e; }
.status-down { background: #ef4444; }

.muted { color: var(--text-muted); font-size: 0.85rem; }
/* Match-confidence and liveness annotations riding alongside a time. */
.annot { font-size: 0.78rem; }
.annot-sm { font-size: 0.74rem; }

.pagination { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.messages .success { background: #dcfce7; color: #166534; }
.messages .error { background: #fee2e2; color: #991b1b; }
/* "That request had already been decided. Nothing was changed." is not a success
 * and not a failure — it is the double-submit guard reporting that it worked.
 * Without this rule such a message rendered with no background at all, which on
 * a dark card read as stray body text rather than as a notice. */
.messages .info { background: #dbeafe; color: #1e40af; }

/* The "All N punches" disclosure inside the actions column.
 *
 * This popover used to be position:absolute. It cannot be any more: .table-wrap
 * sets overflow-x:auto, and per spec a non-visible overflow on one axis forces
 * the other to `auto` too — so an absolutely positioned child is clipped by the
 * wrapper and spawns a scrollbar inside it instead of floating over the page.
 * Letting it flow in the cell also behaves far better on a phone, where an
 * absolutely positioned 16rem card would have hung off the screen edge. */
.punch-list { display: inline-block; vertical-align: middle; margin-left: 0.35rem; }
.btn-summary { display: inline-block; list-style: none; cursor: pointer; }
.btn-summary::-webkit-details-marker { display: none; }
.punch-popover { margin-top: 0.35rem; margin-bottom: 0; min-width: 14rem; }
.punch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.2rem 0;
}

/* ===========================================================================
 * Badges
 * ---------------------------------------------------------------------------
 * Each badge is a self-contained background/foreground pair (all ≥ 4.5:1), so
 * they are intentionally NOT re-themed for dark mode: a pale chip on a dark
 * card still reads correctly, and re-tinting nine state colours per theme is
 * where a palette starts drifting out of sync with itself.
 * ======================================================================== */

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-in { background: #dcfce7; color: #166534; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-pending_enrollment { background: #fef9c3; color: #854d0e; }
.badge-inactive { background: #e5e7eb; color: #4b5563; }
.badge-camera { background: #dbeafe; color: #1e40af; }
.badge-manual { background: #fce7f3; color: #9d174d; }
.badge-system { background: #ede9fe; color: #5b21b6; }
.badge-suspected { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-break_start { background: #fef3c7; color: #92400e; }
.badge-break_end { background: #e0f2fe; color: #075985; }
.badge-short { background: #ffedd5; color: #9a3412; }
/* Work schedule marks (attendance table, admin and leadership only) and the
 * schedule history's statuses (Settings -> Office hours). Self-contained pairs,
 * like every badge here, so not re-themed for dark. */
.badge-late { background: #fef3c7; color: #92400e; }
.badge-early { background: #ffedd5; color: #9a3412; }
.badge-overbreak { background: #fce7f3; color: #9d174d; }
.badge-holiday { background: #e0f2fe; color: #075985; }
.badge-schedule-current { background: #dcfce7; color: #166534; }
.badge-schedule-scheduled { background: #e0f2fe; color: #075985; }
.badge-schedule-past,
.badge-schedule-replaced { background: #e5e7eb; color: #4b5563; }
/* Correction requests. The two kinds share the in/out palette they describe --
 * a missed break is an out followed by an in, a missed punch out is an out --
 * so that the chip on a queue row and the chips on that day's punches below it
 * are speaking the same visual language rather than two unrelated ones.
 *
 * The four outcomes are deliberately NOT four new hues. 'approved' reuses the
 * same green every positive state in this app uses and 'rejected' the same red;
 * 'pending' is the amber already used for pending_enrollment, which is the same
 * idea (waiting on somebody) in a different table; and 'cancelled' borrows the
 * grey of 'inactive', because a withdrawn request and a deactivated employee are
 * both "this is here but no longer live". Introducing a tenth and eleventh
 * colour for states that mean things the palette can already say is how a set of
 * status chips stops being readable at a glance. */
/* Two kinds since migration 0014, which replaced missed_break,
 * missed_punch_out and missed_punch_in. Both reuse hues already in this
 * palette, for the reason stated above, and the pairing is apt rather than
 * merely thrifty: 'break' keeps the amber the old missed_break wore, so a
 * queue somebody has been reading for a month still looks the same for the
 * kind that did not change; 'full_day' takes break_end's sky blue, which
 * already marks arriving, and is deliberately not the badge-in green, which
 * sits two columns away from 'approved' in the same green on the same row of
 * the same table. */
.badge-full_day { background: #e0f2fe; color: #075985; }
.badge-break { background: #fef3c7; color: #92400e; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #e5e7eb; color: #4b5563; }

/* ===========================================================================
 * Correction review: the day's punch photos
 * ---------------------------------------------------------------------------
 * The admin's whole method is to walk the day in order and check a claim
 * against the frames, so these are laid out as a row of labelled cells rather
 * than as thumbnails in a table cell (which is what .frame-thumb is for, on the
 * attendance table, where the photo is an aside rather than the subject).
 *
 * auto-fill + minmax rather than a fixed column count: a day has anywhere from
 * two to eight punches, and at 390px exactly one cell fits per row. No media
 * query is needed for that — the grid resolves it at every width on its own,
 * which is also why the cells never force the page to scroll sideways.
 * ======================================================================== */

.frame-grid {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 0.75rem;
}

/* A flex column, with the image or the placeholder as the growing child.
 *
 * Without this the cells still line up (the grid stretches them to the tallest
 * row) but a placeholder keeps its own small height and leaves a block of empty
 * card below it — which, next to three full-height photographs, reads as a
 * frame that failed to load rather than as a punch that never kept one. Letting
 * the placeholder grow makes "nothing here" fill exactly the space a photo
 * would have. Verified by looking, in both themes: it was the one thing the
 * rendered page got visibly wrong. */
.frame-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.frame-cell > .frame-full,
.frame-cell > .frame-placeholder { flex: 1 1 auto; }

.frame-caption {
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.frame-full {
  display: block;
  width: 100%;
  height: auto;
  /* contain, with a min-height, so a frame grown by the flex rule above is
   * letterboxed rather than stretched. The kiosk's aspect ratio is whatever its
   * camera preset produced, not a fixed shape — the photo export scales by the
   * longer side for the same reason. */
  object-fit: contain;
  border-radius: 4px;
  /* A face photo on a dark card with no ground of its own floats; the sunken
   * surface gives it an edge while the image loads, and a visible frame for a
   * portrait whose own background happens to match the card. */
  background: var(--surface-sunken);
}

/* A sentence, never a broken image. Sized to roughly the height a frame would
 * occupy so a day with some photos and some without does not jump about. */
.frame-placeholder {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 7rem;
  padding: 0.75rem;
  border-radius: 4px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===========================================================================
 * "If you approve the times above" — what the button is actually going to do
 * ---------------------------------------------------------------------------
 * Since migration 0014 an approval inserts only the punches that are MISSING,
 * so the admin has to be able to see, before pressing Approve, that a request
 * for 10:00 to 19:00 may add nothing but the 19:00. This is that list.
 *
 * A sunken panel inside the decide card rather than a card of its own: it is
 * not a separate thing to read, it is a caption on the two time boxes directly
 * above it, and giving it the same surface as the card would let it drift away
 * from them. Same treatment as .frame-placeholder, and the same tokens, so it
 * follows both themes without a second set of colours.
 *
 * Each row wraps rather than truncating. A sentence that says what will happen
 * to somebody's attendance is not a thing to hide behind an ellipsis at 390px.
 * =========================================================================== */
.plan {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border-radius: 4px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-sunken);
}

.plan-head {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.plan-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Flex with wrap, not a table row: the badge and the clock time stay together
 * on one line and the explanation flows underneath them on a narrow screen,
 * instead of three columns squeezing into nothing. */
.plan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

/* The two footnotes under the list -- "edit it on the attendance page" and
 * "worked out against this day's punches as they are now" -- are separate
 * thoughts and have to read as two paragraphs. .help zeroes its own margins
 * (it is normally the last line of a form field), so without this they butt
 * straight up against the list and against each other and the block reads as
 * one run-on sentence. */
.plan > .help,
.plan > .plan-list + .help { margin-top: 0.6rem; }

/* The refusal takes the danger colour because it is the one case where
 * pressing the button will not work, and an admin skimming the page should not
 * have to read the sentence to find that out. */
.plan-refusal {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--danger);
}

/* ===========================================================================
 * Definition lists, for "what was asked" beside "what was decided"
 * ---------------------------------------------------------------------------
 * A two-column grid rather than a table: these are field/value pairs about one
 * record, which is what a <dl> is, and a table here would announce column
 * headers that do not exist. Collapses to one column on a phone so a long note
 * is never squeezed into half the screen.
 * ======================================================================== */

.kv {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.35rem 1rem;
}
.kv dt { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }
.kv dd { margin: 0; }

@media (max-width: 420px) {
  .kv { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .kv dd { margin-bottom: 0.5rem; }
}

/* Radios for the two correction kinds. Django renders RadioSelect as a <ul>,
 * which inherits the bullets and padding of an ordinary list; .field's input
 * rule also sets width:100% on every input, which would stretch each radio
 * across the form. Both are undone here rather than by giving the widget inline
 * attributes, so the fix lives with the rest of the form styling. */
.field ul { list-style: none; margin: 0; padding: 0; }
.field ul li { margin-bottom: 0.2rem; }
.field ul label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; }
.field input[type="radio"] { width: auto; margin: 0; }

/* ===========================================================================
 * Responsive
 * ---------------------------------------------------------------------------
 * There was not one media query in this codebase before. Target is ~400px —
 * an HR phone checking who is in. The 16px gutter (--gutter) holds at every
 * width; only .table-wrap is allowed to scroll sideways, never the body.
 * ======================================================================== */

@media (max-width: 760px) {
  header {
    /* Brand+nav above, identity+logout below, rather than squeezing both onto
     * one line and wrapping mid-nav. */
    flex-direction: column;
    align-items: flex-start;
  }
  /* The header stacks at this width, so the second row carries the theme switch,
   * the account name and Log out. space-between spreads them; wrap lets the
   * switch drop to a line of its own on a narrow phone rather than squeezing the
   * three segments down to a few pixels each. */
  .header-right { width: 100%; justify-content: space-between; }

  main { margin: 1rem auto; }

  /* Title and the backend-health line stack: side by side they each get about
   * 180px and the health sentence wraps to four lines. */
  .page-head { flex-direction: column; align-items: flex-start; }

  /* Every filter control full width. A flex row of three date inputs at 400px
   * gives each ~110px, which is narrower than a date picker renders. */
  .toolbar { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .toolbar .field input, .toolbar .field select { max-width: none; }
  .toolbar .btn { text-align: center; }

  .btn-row, .btn-row-end { justify-content: flex-start; }
  .card-narrow { margin-top: 1rem; }
}

@media (max-width: 420px) {
  /* The lockup is 521x161; below this it is wider than the usable line, so drop
   * to a slightly smaller mark-plus-wordmark rather than letting it wrap the
   * nav onto five lines. */
  .brand img { height: 1.3rem; }
  .card { padding: 1rem; }
  .card > .login-hero { margin: -1rem -1rem 1rem; padding: 1.25rem 1rem; }
  th, td { padding: 0.45rem 0.55rem; }
  .btn-row .btn { flex: 1 1 auto; text-align: center; }
}

/* Tables and the kiosk-frame thumbnails are the only things allowed to be wider
 * than the screen, and both are already inside a scroll container. */
img { max-width: 100%; }

@media print {
  header, .sidebar, .toolbar, .btn, .pagination, .skip-link, .theme-switch { display: none !important; }
  .app { display: block; }
  .table-wrap { overflow: visible; box-shadow: none; }
}

/* --- The day strip ---------------------------------------------------------
 *
 * One line: first punch in, last punch out (or "on site"), and a count when the
 * day was more than one sitting. An earlier version drew every stretch as its own
 * pill, which was honest but wrapped to three lines on a five-punch day and
 * pushed every other column off the screen. The per-stretch detail is one click
 * away in the punch list, which is where you would go to change one anyway.
 */
.daystrip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.daystrip .t { font-weight: 600; }
.daystrip .arr { color: var(--text-muted); }
.daystrip .unknown { color: var(--text-muted); font-weight: 400; }

/* Still inside. Amber is unreadable as text on white (1.93:1), so the state is
 * carried by the word plus a filled dot -- never by colour alone. */
.daystrip .now {
  font-weight: 600;
  color: var(--brand-ink);
}
.daystrip .now::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 0.35rem;
}

/* Deliberately quiet. That somebody stepped out and came back is a fact about
 * the shape of their day, not a finding about them. */
.stretches {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.stretches::before { content: "·"; margin-right: 0.3rem; }

/* Hours so far on an open day. The figure a person checks to decide whether they
 * have done their nine hours -- so it is the same size and weight as a finished
 * total, with the qualifier carrying the difference rather than shrinking it. */
.running { color: var(--brand-ink); }
.sofar {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.2rem;
}

/* ===========================================================================
 * Analytics charts
 * ---------------------------------------------------------------------------
 * The charts are server-rendered inline <svg> (see templates/.../analytics.html
 * and attendance_hr/charts.py). No charting library ships with this app, so the
 * "chart furniture" -- axes, labels, legends, direct labels -- is ordinary CSS
 * on ordinary SVG elements, and it inherits the same tokens everything else on
 * the dashboard uses. That is the point: dark mode needs no second stylesheet
 * and no JavaScript, because the axes and labels are already var(--text-muted).
 *
 * THE SERIES COLOURS ARE NOT TOKENS AND ARE NOT DECLARED HERE. They are
 * #1f6feb / #c47400 / #b3261e, set as `fill`/`stroke` attributes in the
 * template, in that fixed order, checked as an ordered set for colourblind
 * separation. Green/amber/red is unusable: green and amber separate by only
 * dE 2.6 under deuteranopia. Brand amber #ffa807 appears nowhere as a mark --
 * it is 1.93:1 on white, which is why it exists only as a fill behind dark text
 * and as ink on the espresso header.
 *
 * Text here never wears a series colour. Values, axis labels and legend text
 * are var(--text) / var(--text-muted); the coloured mark beside them is what
 * carries identity, and every mark is also directly labelled, so identity never
 * rests on colour alone.
 * ======================================================================== */

.week-picker { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.week-label { display: inline-flex; gap: 0.4rem; align-items: baseline; }

.chart-card { margin-bottom: 1.25rem; }
.chart-card h2 { margin-top: 0; }

/* The denominator line. Not a footnote and deliberately not .muted-small: every
 * chart on this page has to state what it counted and what it threw away, and a
 * statement nobody reads is the same as no statement. Sits directly under the
 * heading, above the chart it describes. */
.chart-denominator {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-sunken);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
}

/* One chip per working day, so "this week expects 45h" is checkable: the reader
 * can see which dates were counted and how many people were in on each. */
.daychip {
  display: inline-block;
  margin: 0.15rem 0.3rem 0.15rem 0;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.78rem;
  white-space: nowrap;
}
.daychip-sat { border-color: var(--border-strong); font-weight: 600; }

.chart-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.chart-row-wrap { align-items: flex-start; }
.chart-figure { margin: 0; min-width: 0; }
.chart-figure figcaption {
  font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--text);
}
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-pie { max-width: 360px; }
.chart-wide { width: 100%; }

/* A 2px gap in the surface colour between neighbouring fills, not a border: it
 * separates the slices without adding a colour, and it is what keeps two fills
 * from reading as one shape against the dark surface. */
.pie-slice { stroke: var(--surface); stroke-width: 2; }
.pie-slice-on { stroke: var(--text); stroke-width: 2.5; }
a:hover .pie-slice { filter: brightness(1.08); }

/* White on the three series fills is 4.6:1, 3.5:1 and 6.0:1. The middle one is
 * only legal because this glyph is 20px bold -- WCAG's large-text 3:1 floor --
 * so do not shrink it without re-checking. */
.pie-count { fill: #ffffff; font-size: 20px; font-weight: 700; }
/* The name sits OUTSIDE the pie in ordinary text ink, so it is readable in both
 * themes and does not depend on the fill behind it. */
.pie-name { fill: var(--text); font-size: 13px; font-weight: 600; }

.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.chart-legend-inline { flex-direction: row; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.5rem; }
.chart-legend-inline li { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }
.legend-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text); background: var(--surface);
}
.legend-link:hover { background: var(--surface-sunken); }
.legend-link-on { border-color: var(--text); font-weight: 600; }
.legend-swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none;
  /* A hairline in the text colour so a swatch is still a distinct shape in
   * forced-colours mode, where backgrounds are discarded. */
  outline: 1px solid var(--border-strong); outline-offset: -1px;
}
.legend-text { font-size: 0.85rem; }
.legend-value { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Recessive by design: the data is the mark, not the frame around it. */
.axis-line { stroke: var(--border-strong); stroke-width: 1; }
.axis-label { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--text-muted); font-size: 10px; }
.bar-value { fill: var(--text); font-size: 11px; font-variant-numeric: tabular-nums; }
.series-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.bar:hover, .marker:hover { filter: brightness(1.12); }
/* A surface-coloured ring so an overlapping marker stays a separate dot. */
.marker { stroke: var(--surface); stroke-width: 1.5; }

/* The selected state of a drill-down, on a bar and on a point. Same idea as
 * .pie-slice-on: a ring in the TEXT colour rather than a different fill, so the
 * validated three-colour palette is never extended to say "this one is chosen"
 * -- and so the mark stays distinguishable for a reader who cannot separate the
 * fills at all. */
.bar-on { stroke: var(--text); stroke-width: 2; }
/* Work-schedule reference marks on the arrivals chart. Amber at low opacity reads
   on both the light and the dark surface; the label's surface-coloured halo keeps
   it legible where it crosses a bar. */
.grace-band { fill: rgba(245, 158, 11, 0.16); }
.start-line { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.marker-label {
  fill: var(--text); font-size: 10px; font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.marker-on { stroke: var(--text); stroke-width: 3; }

/* The way back out of a filter, beside the "showing X of Y" count. Deliberately
 * a plain link rather than a button: it undoes a navigation, and it sits in a
 * heading where a button would read as the section's main action. */
.drill-clear { margin-left: 0.6rem; font-size: 0.8rem; font-weight: 400; }

/* One break, start to finish, inside a table cell. Several of these ride in one
 * cell for a person-day with three breaks. */
.brk-chip {
  display: inline-block;
  margin: 0.1rem 0.25rem 0.1rem 0;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-sunken);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Two charts side by side in EQUAL tracks, which is the whole fix for the
 * unreadable break-duration axis. Font size inside an SVG is in user units, so
 * two charts with the same viewBox render their labels at the same size only if
 * the browser scales them by the same factor. The old pair sat in a flex row
 * where the wider viewBox was squeezed harder than its neighbour, so identical
 * CSS produced visibly smaller text on one of them. Equal viewBox + equal track
 * = equal text, and nothing has to be measured by hand. */
.chart-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: start;
}

/* The selected day in the heartbeat's small multiples. An outline rather than a
 * background, so the panel beneath it is unchanged and the twelve panels stay
 * comparable by eye. */
.beat-link { font-weight: 600; }
.beat-panel-on {
  outline: 2px solid var(--focus);
  outline-offset: 5px;
  border-radius: var(--radius);
}

.small-multiples {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

@media (max-width: 760px) {
  .chart-row { gap: 1rem; }
  .chart-pie { max-width: 100%; }
  .chart-grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* --- Sortable column headers ------------------------------------------------
 *
 * The header IS the control, so it gets the whole cell as a hit target rather
 * than a small arrow somebody has to aim at. The arrow only appears on the
 * column actually in use; a row of idle arrows reads as decoration and makes it
 * harder to see which one is live.
 */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.th-sort:hover { color: var(--brand-ink); text-decoration: underline; }
.th-sort.is-sorted { color: var(--brand-ink); font-weight: 700; }
.th-arrow { font-size: 0.8em; }

/* --- Weekly leaderboard -------------------------------------------------------
 *
 * Four lists, five names each. Every colour here is an existing token, so there
 * is no second palette to keep in step with the first and both themes work
 * without a single extra declaration -- the cards sit on --surface and the text
 * is --text/--text-muted, exactly like every other card in the app.
 *
 * Nothing on this page carries meaning in colour alone: the rank is a number,
 * the figure is a number, and the day a break fell on is written out. That is
 * the same rule the analytics charts follow, and it is what keeps the board
 * readable for a colourblind reader and in print.
 *
 * Two across, then two more, rather than all four in a row. Four columns fit on
 * a 1280px laptop only by squeezing each card to ~260px, and at that width real
 * names truncate -- "Sandesh Jaikrishan" became "Sandesh Jaikri..." next to its
 * own number, which is the one thing a board of names must not do. A 2x2 grid
 * gives each card about twice the room and costs nothing but a little height on
 * a page that has plenty.
 *
 * The auto-fit rule underneath handles everything narrower on its own: two
 * columns while they fit, one below ~700px, no further media query needed.
 */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  align-items: start;
}
@media (min-width: 900px) {
  .board-grid { grid-template-columns: repeat(2, 1fr); }
}

.board-title { margin: 0 0 0.15rem; font-size: 1.05rem; }
.board-blurb { margin: 0 0 0.75rem; font-size: 0.85rem; }

/* list-style:none, with the rank drawn as its own element instead. The <ol> is
 * kept because the ORDER is the content -- a screen reader should hear "list of
 * 5 items" and a position -- but a default marker cannot be given the fixed
 * width that keeps two-digit and one-digit ranks from shifting the names. */
.board-list { list-style: none; margin: 0; padding: 0; }

.board-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}
.board-row:first-child { border-top: 0; }

.board-rank {
  flex: 0 0 1.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--brand-ink);
}

/* The name takes the slack so the figures stay right-aligned against each
 * other down the list; min-width:0 lets a long name ellipsis rather than
 * pushing the figure off the card. */
.board-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-figure { flex: 0 0 auto; text-align: right; }
/* tabular-nums so "8h 20m" and "10h 05m" line up their digits down the column;
 * without it a proportional font makes a sorted list look unsorted. */
.board-value { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.board-detail { display: block; font-size: 0.78rem; color: var(--text-muted); }

/* A configuration fault, not a data point: the left rule is the same idiom a
 * flagged attendance row uses, so the two read as the same kind of "look at
 * this" without inventing a new one. */
.board-warning {
  background: var(--danger-bg);
  box-shadow: inset 3px 0 0 var(--danger), var(--shadow);
}

@media (max-width: 420px) {
  /* A safety net, not a layout. At 390px the grid is already one column and a
   * card is wide enough that name and figure share a line comfortably -- this
   * only drops the figure onto its own line for a name long enough that it
   * would otherwise be ellipsised, which on a leaderboard of real names is the
   * one thing worth spending a line on. The indent keeps it under the name
   * rather than under the rank when that happens. */
  .board-row { flex-wrap: wrap; }
  .board-figure { text-align: left; padding-left: 2rem; }
}

/* ========================================================================
 * Timesheets
 * ======================================================================== */

/* Archived projects. Grey, borrowed from badge-inactive and badge-cancelled
 * rather than given a colour of its own, because it means the same thing those
 * two do: this is here, and it is no longer live. A new hue for a state the
 * palette can already say is how a set of status chips stops being readable at
 * a glance -- the same reasoning the correction badges above are built on.
 *
 * Deliberately not amber or red. An archived project is not a warning and not
 * a fault; it is a project nobody is logging against any more, and the badge
 * exists only so that a name absent from the dropdown does not read as a bug
 * when it turns up on an old entry. */
.badge-archived { background: #e5e7eb; color: #4b5563; }

/* The day heading inside a week on the employee's own timesheet. An <h3> so
 * the document outline is week -> day -> rows and a screen reader can jump
 * between days, but sized down to the body text: three levels of heading each
 * visibly larger than the last would make a fortnight of entries read as an
 * essay rather than a list. */
.day-head {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* "not known", where a number would otherwise be. Muted like the text around
 * it, because this is not a warning -- it is the honest answer for a day whose
 * attendance cannot be measured, and this codebase says that rather than 0
 * everywhere (see _group_by_day on withholding net_delta).
 *
 * Weighted, though, and that is the point of having a class at all: inside a
 * muted sentence the one phrase carrying the actual answer has to be findable
 * without being alarming. Colour is left alone deliberately -- making it amber
 * would turn a missing punch into an accusation against somebody who worked
 * from home. */
.muted-strong { font-weight: 600; }

/* Nothing is needed for the hours columns themselves: .num above already
 * carries font-variant-numeric: tabular-nums, which is exactly what a column
 * of 3, 1.5 and 10.25 needs so that its decimal points line up with the total
 * underneath. Noted rather than restated, because a second .num rule further
 * down this file would be two places to change one decision. */

/* ========================================================================
 * Analytics: timesheets
 * ======================================================================== */

/* "missed" is a word in the cell, not only a colour -- colour never carries
 * meaning on its own on this page. The tint is the existing danger pair, which
 * is already defined for both themes, so dark mode needs nothing extra. */
.ts-missed { background: var(--danger-bg); color: var(--danger); font-weight: 600; font-size: 0.8rem; }
/* Amber tint for "short", using the brand amber at low alpha so it works on
 * both surfaces; the number keeps brand ink, which is 5:1+ on the tint. */
.ts-short { background: rgba(255, 168, 7, 0.16); }
.ts-short a, .ts-flag.ts-short { color: var(--brand-ink); font-weight: 600; }
.ts-flag { display: inline-block; padding: 0 0.4rem; border-radius: 4px; font-size: 0.8rem; }

.ts-summary { margin: 0 0 0.25rem; }
.ts-key { margin: 0 0 0.5rem; color: var(--text-muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: center; }
.ts-sort { margin-left: auto; display: inline-flex; gap: 0.6rem; }
.ts-sort a[aria-current] { color: var(--text); font-weight: 600; text-decoration: none; }

.ts-table th, .ts-table td { padding-left: 0.5rem; padding-right: 0.5rem; }
.ts-table tfoot th, .ts-table tfoot td { border-top: 2px solid var(--border-strong); font-weight: 600; }

/* The admin timesheet report: each person's rows are one <tbody>, their total
 * row closes it, the grand total is the <tfoot>. Theme variables only, so dark
 * mode needs nothing of its own. The name is a row header for screen readers,
 * not a heading to the eye, so it keeps the cells' weight. */
.report-table th[scope="row"] { font-weight: normal; background: transparent; }
.report-table .report-subtotal th, .report-table .report-subtotal td { font-weight: 600; }
.report-table tbody + tbody tr:first-child th,
.report-table tbody + tbody tr:first-child td { border-top: 2px solid var(--border); }
.report-table tfoot th[scope="row"], .report-table tfoot td { border-top: 2px solid var(--border-strong); font-weight: 600; }

/* Leadership and supporting staff: shown, kept below everyone else, and quieter,
 * because the table's job is to say who needs a conversation. */
.ts-tagged th, .ts-tagged td { opacity: 0.65; }
.ts-tag { margin-left: 0.4rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
          color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 999px;
          padding: 0 0.4rem; font-weight: 500; }

.ts-back { margin: 0 0 0.5rem; }
.ts-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.ts-stat { background: var(--surface-sunken); border-radius: var(--radius); padding: 0.6rem 0.75rem; }
.ts-stat-value { display: block; font-size: 1.4rem; font-weight: 600; }
.ts-stat-label { font-size: 0.8rem; color: var(--text-muted); }
.ts-stat-alert .ts-stat-value { color: var(--danger); }
.ts-stat-warn .ts-stat-value { color: var(--brand-ink); }

/* ========================================================================
 * Requests: leave, work from home, client site
 * ======================================================================== */

/* The three kinds. Existing pairs from the palette above, for the reason the
 * correction badges give -- a new hue for a state the palette can already say
 * is how a set of chips stops being readable at a glance. Leave takes the
 * violet 'system' pair (not working: nothing here is green, which already
 * means approved two columns along); WFH takes the sky blue of arriving; a
 * client site the pink of 'manual' -- somewhere other than the kiosk. All
 * self-contained bg/fg pairs >= 4.5:1, so like every badge they are not
 * re-themed for dark mode. */
.badge-leave { background: #ede9fe; color: #5b21b6; }
.badge-wfh { background: #e0f2fe; color: #075985; }
.badge-client_site { background: #fce7f3; color: #9d174d; }

/* How many requests are waiting, beside "Requests" in the nav. Amber fill with
 * espresso text (9.16:1), the one way amber is allowed to carry text. */
.nav-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.15rem;
  border-radius: 999px;
  background: var(--amber);
  color: var(--espresso);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  text-decoration: none;
}

/* "New request" in front of the kind buttons. */
.btn-row-label { align-self: center; font-size: 0.85rem; color: var(--text-muted); }

/* The Requests page's type and status filters: two wrapping rows of links,
 * the chosen one in text colour and weight rather than link colour -- the
 * .ts-sort treatment, so both themes are covered by the variables. */
.req-filters { margin: 0 0 1rem; }
.req-filter { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; margin: 0 0 0.35rem; }
.req-filter-label { font-size: 0.85rem; color: var(--text-muted); min-width: 3.25rem; }
.req-filter a[aria-current] { color: var(--text); font-weight: 600; text-decoration: none; }

/* The queue: one card per pending request, each with its own decide form.
 * Cards rather than table rows because a row of inline forms cannot narrow to
 * 390px without scrolling sideways; a card simply gets taller. */
.req-list { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(22rem, 100%), 1fr)); }
.req-card { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.req-card > * { margin: 0; }
.req-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.req-name { margin: 0; font-size: 1rem; }
.req-meta { font-size: 0.9rem; }
/* The employee's own words, which can be long and contain line breaks. */
.req-note { white-space: pre-line; overflow-wrap: anywhere; }
.req-decide label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.25rem; }
.req-decide textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.5rem;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

/* The decided list. The button under an outcome badge sits on its own line. */
.req-inline-form { margin: 0.35rem 0 0; }
.req-table td { vertical-align: top; }

/* Who is away: a short list of name, kind and dates that wraps on a phone. */
.away-week { list-style: none; padding: 0.5rem 1rem; }
.away-week li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}
.away-week li:first-child { border-top: 0; }

/* The leave-type radios, as a fieldset whose legend looks like every other
 * field label on the form. */
.field-radios { border: 0; margin: 0; padding: 0; min-width: 0; }
.field-radios legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; padding: 0; }
.field-radios > div { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.field-radios label { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; }
.field-radios input[type="radio"] { width: auto; margin: 0; }
.form-errors .errorlist { color: var(--danger); list-style: none; padding: 0; margin: 0 0 1rem; font-size: 0.9rem; }

/* Analytics: a day somebody was away, marked in the timesheet cell beside the
 * hours or "missed". Muted and outlined rather than coloured: being on leave
 * or at a client is not a finding, it is context for one. */
.ts-away {
  display: inline-block;
  margin-left: 0.2rem;
  padding: 0 0.3rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Inside the week table the marker goes UNDER the hours or "missed", not
 * beside them. Beside, it widened every day column with one in it, and at
 * 1280px that pushed the Hours column off the card into the table's own
 * scroll -- the one total on the row people read first. Stacked, a column is
 * only as wide as its widest word. */
.ts-table .ts-away { display: block; width: max-content; margin: 0.15rem 0 0; }

/* Average hours: the two-row header groups "this week" apart from history. */
.av-group { text-align: center; border-bottom: 1px solid var(--border); }

/* ===========================================================================
 * Timesheets: a row opened IN PLACE, and the per-category totals
 * ======================================================================== */

/* A timesheet row opened IN PLACE, with no request and no motion.
 *
 * Every editable row already holds two hidden full-width cells after its own:
 * its prefilled edit form (td.row-panel-edit) and its "Delete this entry?"
 * (td.row-panel-delete). Edit and Delete are <label>s for two checkboxes in
 * the row's last cell. Ticking one hides the row's own cells and shows that
 * panel in their place; Cancel, a label for the same box, unticks it. No
 * JavaScript (the house rule), no navigation, no scroll, and no transition or
 * animation anywhere in it -- the owner asked for exactly that.
 *
 * `tr:has(> td .row-toggle-…:checked)` reaches only this row's own boxes, so
 * opening one row never touches another. Hidden cells are display:none, which
 * takes them out of the table's layout entirely: a closed form adds nothing
 * to any column's width.
 *
 * The checkbox is clipped rather than display:none so it stays focusable and
 * Space toggles it; its focus ring is drawn on the label beside it, as the
 * sidebar's Menu toggle does. Positioned inside .table-wrap, which is its
 * containing block -- see the note there on why that matters at 390px. */
.row-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.row-toggle:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
label.btn { user-select: none; }

td.row-panel { display: none; }
tr:has(> td .row-toggle:checked) > td { display: none; }
tr:has(> td .row-toggle-edit:checked) > td.row-panel-edit,
tr:has(> td .row-toggle-delete:checked) > td.row-panel-delete { display: table-cell; }

/* The open panel: the inset bar on the left is the row-suspected device, in
 * the brand ink for an edit and in the danger colour for a delete, so the open
 * row is findable by scanning and the two kinds are told apart before anything
 * is read. Tokens only, so both themes come for free. The cell's own
 * background also covers the row's hover tint: a form you are typing into
 * should not change colour under the pointer. */
td.row-panel-edit {
  background: var(--surface-sunken);
  box-shadow: inset 3px 0 0 var(--brand-ink);
}
td.row-panel-delete {
  background: var(--danger-bg);
  box-shadow: inset 3px 0 0 var(--danger);
}

/* Free time asks for nothing else. With the free-time category selected in a
 * timesheet form, its Project and What you did fields are not shown -- the
 * owner: "there is no point of keeping it there." The <option> carries its
 * kind (forms.CategorySelect); the rule is scoped to the one <form> whose
 * selected option that is, so one row's choice never hides another row's
 * fields. Neither field carries the HTML `required` attribute, or the browser
 * would refuse the submit over a control nobody can see; the server enforces
 * both for every other category, and ignores both under Free time -- which is
 * also all a browser without :has() needs. */
.ts-entry-form:has(option[data-kind="free_time"]:checked) :is(.field-project, .field-task) {
  display: none;
}

/* The open row's content: as wide as its cell, capped to the screen, and
 * contributing NOTHING to how the table sizes its columns.
 *
 * The cap: the cell is as wide as the TABLE, and on a phone the table is
 * wider than the screen -- it scrolls sideways inside .table-wrap, which is
 * the accepted shape for these tables. Content left to fill the cell would lay
 * its fields out across that whole width and put Save off to the right of the
 * visible area. Capped at the viewport (less the page gutters and this cell's
 * own padding), its fields stack and Save is on screen.
 *
 * The sticky: Edit and Delete sit in the LAST column, so on a phone they are
 * reached by scrolling the table sideways -- and opening a row no longer
 * reloads the page, so nothing puts that scroll back to zero. A form drawn at
 * the cell's left edge would open off screen, behind the reader's back.
 * Sticky at the scrollport's left edge (.table-wrap is the scroll container,
 * and the cell spans the whole table, so there is room to slide), it is drawn
 * wherever the reader is looking. A no-op wherever the table fits.
 *
 * The zero: this sits in a colspan cell of an auto-layout table, which sizes
 * its columns from every cell's min- AND max-content. An open form's
 * max-content is all its fields side by side, and the table shared that out
 * across the columns it spans -- squeezing the actions column until Edit and
 * Delete wrapped onto two lines on every OTHER row, the moment one row was
 * opened. `width: 0` takes the form out of that sum; the min-width then sizes
 * it after layout. A percentage min-width counts as zero while the table is
 * measuring (it would be circular), and resolves against the finished cell
 * afterwards -- which is exactly the order wanted. */
.row-form {
  width: 0;
  min-width: min(100%, calc(100vw - 2 * var(--gutter) - 1.5rem));
  position: sticky;
  left: 0.75rem;
}
.row-form .btn-row { margin-top: 0.25rem; }
.row-question { margin: 0 0 0.5rem; }

/* The fields of the open row: as many to a line as fit, each at least 11rem,
 * so Day / Category / Project sit on one line at 1280px and stack one per line
 * at 390px. The task box takes a line of its own at every width
 * -- it is the one field people type sentences into.
 *
 * A wrapping FLEX row, not a grid, and the difference is the table around it.
 * This sits in a colspan cell, and an auto-layout table sizes its columns from
 * each cell's min-content width. A grid with repeat(auto-fill, ...) under the
 * max-width above counts its columns from that max-width -- six of them at
 * 1280px -- and reports all six as its min-content, ~1100px; the table then
 * squeezed every other column to make room, and the Edit/Delete buttons on
 * every other row wrapped onto two lines. A wrapping flex row's min-content
 * is only its widest single field, so the open row no longer moves the
 * table's columns at all. */
.row-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
}
.row-form-grid > .field { flex: 1 1 11rem; min-width: 0; margin-bottom: 0.75rem; }
.row-form-grid > .field-wide { flex-basis: 100%; }
/* .field caps inputs at 420px for the standalone forms; in the grid each cell
 * is already the right width, and the task box should span its line. */
.row-form-grid .field input,
.row-form-grid .field select,
.row-form-grid .field textarea { max-width: none; }

/* By project and By category, side by side where there is room and stacked on
 * a phone. min() so a column never asks for more than the screen has, which
 * is what would otherwise put a sideways scroll on the whole page at 390px. */
.totals-pair {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  align-items: start;
}
.totals-pair > section { min-width: 0; }

/* Projects page: the task-categories section under the projects, with a rule
 * above it so the two lists read as two lists, and its In use / Archived
 * headings a step smaller than the section's own. */
.page-section {
  margin-top: 2rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.sub-head { margin: 1.25rem 0 0.5rem; font-size: 1rem; }

/* Time spent: [ 7 ] h [ 30 ] min on one line. A fieldset reset to look like
 * every other .field, its legend styled as the field labels are. The selects
 * are as wide as their longest option rather than the 100% every other
 * .field control takes -- two full-width selects would put "min" on a line of
 * its own and read as two separate questions. */
fieldset.field-duration { border: 0; margin: 0 0 1rem; padding: 0; min-width: 0; }
.row-form-grid fieldset.field-duration { margin-bottom: 0.75rem; min-width: max-content; }
.field-duration legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; padding: 0; }
.duration { display: flex; align-items: center; gap: 0.35rem; flex-wrap: nowrap; }
.field-duration .duration select { width: auto; min-width: 4.25rem; }
.field-duration .duration label {
  display: inline;
  margin: 0 0.5rem 0 0;
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Average tables: a full-height divider before each column group -- this week,
 * previous weeks, last four weeks -- so the eye never reads a previous week's
 * average as part of this week's figures. border-strong is defined for both
 * themes. */
.ts-table .av-sep { border-left: 2px solid var(--border-strong); }
.av-sortrow { justify-content: flex-end; }

/* Edit and Delete side by side on the timesheet tables at desktop widths.
 * These tables have one free-text column ("What you did"), and an auto-layout
 * table short of room shrinks every column to its min-content -- for a
 * wrapping .actions that is ONE button wide, so a single long task description
 * stacked Edit over Delete on every row and doubled the table's height. Not
 * wrapping hands the squeeze to the task text, the column that can take it.
 *
 * Only above the phone breakpoint. At 390px the table already scrolls
 * sideways, and side by side would push Delete wholly out of view on every
 * row; stacked, both stay within reach at the right edge, as before. */
@media (min-width: 761px) {
  .actions-inline { flex-wrap: nowrap; }
}

/* ===========================================================================
 * Settings (admin only)
 * ---------------------------------------------------------------------------
 * The section list and panel reuse the analytics layout classes as they are,
 * so the two pages read as one design and fold onto a phone the same way.
 * Only what is new to this page is here.
 * ======================================================================== */

/* The office-hours derived values: three short facts on a line, wrapping as
 * whole facts on a phone rather than mid-phrase. */
.settings-summary { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0 0 1rem; }

/* Mon-Fri and Saturday as two labelled groups; start and end side by side.
 * A fieldset reset to look like every other .field, its legend styled as the
 * field labels are. */
.settings-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.settings-group legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; padding: 0; }
.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
  max-width: 420px;
}
.field-pair .field input { max-width: none; }

/* The EMP ID & manager table: a control in every cell. Widths set so the three
 * columns fit a desktop card without wrapping a name; on a phone the table
 * scrolls inside .table-wrap, never the page. */
.settings-people { box-shadow: none; margin-bottom: 1rem; }
.settings-people input,
.settings-people select {
  width: 100%;
  min-width: 7rem;
  padding: 0.35rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
}
.settings-people select { min-width: 9rem; }
.settings-people .errorlist {
  color: var(--danger);
  font-size: 0.8rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  white-space: normal;
}
.settings-people th[scope="row"] { font-weight: 600; background: transparent; white-space: nowrap; }
.settings-people tbody tr:last-child th { border-bottom: 0; }
.settings-people .cell-label { display: none; }

/* An address or a holiday name with no spaces in it is still allowed to break,
 * rather than widening the table past a phone. */
.wrap-anywhere { overflow-wrap: anywhere; }
tr.row-past td { color: var(--text-muted); }

/* ===========================================================================
 * Calendar
 * ---------------------------------------------------------------------------
 * Seven equal columns, fixed at 100% of the card: table-layout: fixed is what
 * stops a long holiday name or a column of names from widening a day past its
 * seventh of the screen, and so what keeps the page from scrolling sideways at
 * 390px. Every tag in a cell is one line, clipped with an ellipsis -- the full
 * words are in its title and in the list under the grid.
 *
 * Tag colours reuse the palette: leave the break amber, work from home the sky
 * blue, a client the green, a holiday the "system" violet. Pending is the same
 * chip with a dashed border, never a colour of its own, and says "pending" in
 * words wherever there is room for the word.
 * ======================================================================== */
.cal-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.cal { table-layout: fixed; width: 100%; }
.cal th { text-align: center; padding: 0.45rem 0.2rem; font-size: 0.8rem; }
.cal td {
  vertical-align: top;
  height: 6rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  overflow: hidden;
}
.cal tbody tr:hover { background: transparent; }
.cal tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.cal-off { background: var(--surface-sunken); }
.cal-out .cal-num { color: var(--text-muted); font-weight: 400; }
.cal-num {
  display: inline-block;
  font-weight: 600;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  min-width: 1.5rem;
  text-align: center;
  line-height: 1.5rem;
}
.cal-today .cal-num { background: var(--brand-ink); color: var(--surface); border-radius: 999px; }
.cal-tag {
  display: block;
  margin-top: 0.2rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
}
.cal-tag-inline { display: inline-block; margin-top: 0; vertical-align: baseline; }
.cal-tag-holiday { background: #ede9fe; color: #5b21b6; }
.cal-tag-leave { background: #fef3c7; color: #92400e; }
.cal-tag-wfh { background: #e0f2fe; color: #075985; }
.cal-tag-client_site { background: #dcfce7; color: #166534; }
.cal-tag-pending { border: 1px dashed currentColor; }
.cal-count { display: none; margin-top: 0.2rem; font-size: 0.72rem; font-weight: 600; }
.cal-apply {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The month as a list: a date, then everything on it. */
.cal-agenda { list-style: none; margin: 0 0 1rem; padding: 0; }
.cal-agenda li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.cal-agenda-date { font-weight: 600; font-size: 0.9rem; }
.cal-agenda-items { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .field-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  /* EMP ID & manager: one block per person -- the name, then the two
   * controls side by side, each under its own small heading -- instead of a
   * table of inputs scrolling sideways inside the card. */
  .settings-people { overflow: visible; background: transparent; }
  .settings-people table,
  .settings-people tbody { display: block; background: transparent; }
  .settings-people thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .settings-people tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 0.2rem 0.6rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
  }
  .settings-people tbody tr:last-child { border-bottom: 0; }
  .settings-people th[scope="row"] { grid-column: 1 / -1; padding: 0; border: 0; }
  .settings-people td { display: block; padding: 0; border: 0; }
  .settings-people input,
  .settings-people select { min-width: 0; }
  .settings-people .cell-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
  }
  .cal th { font-size: 0.7rem; padding: 0.35rem 0; }
  .cal td { height: 4.5rem; padding: 0.15rem; }
  .cal-tag { font-size: 0.62rem; padding: 0 0.15rem; margin-top: 0.15rem; }
  .cal-apply { font-size: 0.65rem; }
  /* The long words fold away; the list under the grid has them. */
  .cal-wide { display: none; }
  /* An admin's names become "3 away" -- one name per line would make a day as
   * tall as the office is big, and still clip every name to four letters. */
  .cal-everyone .cal-tag-person { display: none; }
  .cal-everyone .cal-count { display: block; }
  .cal-agenda li { grid-template-columns: minmax(0, 1fr); }
}

/* ===========================================================================
 * Settings: Notifications and Reminders (the backend's reminders migration)
 * ---------------------------------------------------------------------------
 * Built from what the other sections use -- .card, .field, .check-label,
 * .settings-summary, .table-wrap -- with only the new arrangements here.
 * ======================================================================== */

/* The four placeholders, as values on one wrapping line. */
.placeholder-list { align-items: baseline; gap: 0.35rem 0.6rem; }
.placeholder-list code {
  font-size: 0.85rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: var(--surface-sunken);
  color: var(--text);
}

/* A template's form beside its preview; stacked on a phone (below). */
.template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem 1.5rem;
  align-items: start;
}
.template-form .field input,
.template-form .field textarea { max-width: none; }
.template-form .field textarea { resize: vertical; min-height: 9rem; }
.template-preview h3 { font-size: 0.9rem; margin: 0 0 0.35rem; }
.preview-subject { font-weight: 600; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
/* The body exactly as it will be sent: line breaks kept, long words broken
 * rather than widening the card. */
.preview-body {
  margin: 0;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The master switch: its state and the one button that changes it. */
.switch-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #e5e7eb; color: #4b5563; }

/* A card's heading with something on the same line -- the reminder's On box,
 * or an Off badge -- wrapping under it on a narrow screen. */
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
}
.card-title-row h2, .card-title-row h3 { margin: 0; }
.preview-card h3 { font-size: 1rem; }

/* Several checkboxes on a line, and a grid of them for the people list. */
.check-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin-bottom: 0.5rem; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.3rem 1rem;
  margin-bottom: 0.5rem;
}
.check-plain { font-weight: 400; font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; }
.settings-group + .settings-group,
.field + .settings-group,
.settings-summary + .settings-group { margin-top: 0.75rem; }
.field-short input { max-width: 8rem; }
.form-end { margin-bottom: 1.5rem; }
.preview-card { margin-bottom: 0.5rem; }

/* "Nobody has punched in": a fact about today, in the brand's amber ink --
 * which the palette already re-themes for dark, both ways it can be chosen. */
.status-line { margin: 0.25rem 0 0; font-size: 0.9rem; font-weight: 600; }
.status-warn { color: var(--brand-ink); }

/* Delivery states. Self-contained pale pairs, like every badge above. */
.badge-note-sent { background: #dcfce7; color: #166534; }
.badge-note-failed { background: #fee2e2; color: #991b1b; }
.badge-note-sending { background: #fef9c3; color: #854d0e; }
.badge-note-skipped,
.badge-note-skip { background: #e5e7eb; color: #4b5563; }
.badge-note-would { background: #e0f2fe; color: #075985; }
.badge-note-hr { background: #ede9fe; color: #5b21b6; margin-top: 0.2rem; }
.detail-cell { min-width: 12rem; font-size: 0.85rem; }
.stack-table th[scope="row"] { font-weight: 600; background: transparent; }
.stack-table tbody tr:last-child th { border-bottom: 0; }

/* One email's recipients: To, then CC, then the HR badge, each on its own
 * line, so three columns of addresses become one. */
.recipients { min-width: 11rem; overflow-wrap: anywhere; font-size: 0.85rem; }
.recipients span { display: block; width: fit-content; }
.recipients-cc { color: var(--text-muted); }
/* A second, quieter line in a cell: which date(s) a reminder was about. */
.cell-sub { display: block; color: var(--text-muted); font-size: 0.8rem; }

@media (max-width: 760px) {
  .template-layout { grid-template-columns: minmax(0, 1fr); }
  .check-grid { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }

  /* The two reminder tables stack on a phone: one block per row, the row's
   * heading cell on top and each other cell under a small label taken from
   * its data-label -- the EMP ID table's approach, in CSS alone -- rather than
   * a seven-column table of which a phone shows two. */
  .table-wrap:has(> .stack-table) { overflow: visible; }
  .stack-table,
  .stack-table tbody { display: block; }
  .stack-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .stack-table tbody tr {
    display: block;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
  }
  .stack-table tbody tr:last-child { border-bottom: 0; }
  .stack-table th[scope="row"] { display: block; padding: 0 0 0.3rem; border: 0; white-space: normal; }
  .stack-table td {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 0 0.5rem;
    padding: 0.15rem 0;
    border: 0;
    min-width: 0;
    white-space: normal;
  }
  .stack-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding-top: 0.1rem;
  }
  /* Each cell's content is one wrapper, so it all lands in the value column. */
  .stack-table td > div { min-width: 0; }
  .stack-table td.is-empty,
  .stack-table td.empty-row::before { display: none; }
  .stack-table td.empty-row { display: block; }
  .stack-table .recipients,
  .stack-table .detail-cell { min-width: 0; }
}

/* ===========================================================================
 * Offline punches
 * ---------------------------------------------------------------------------
 * A punch the kiosk saved while the server was down. On the attendance page it
 * is an ordinary punch with one chip beside it, saying its time came from the
 * phone rather than from the server at the moment of punching. Indigo, which
 * nothing else in this palette uses: it is not a warning (amber/red) and not a
 * state of the employee (green/grey), it is a fact about where the time came
 * from -- the same family of statement as the camera/manual/system source chips,
 * so it sits in the cool half of the palette beside them.
 *
 * The review statuses reuse the corrections' meanings, for the reason given
 * above that block: needs_review is the amber of 'pending', recorded/approved
 * the green of 'approved', and the two that produced nothing -- discarded and
 * duplicate -- the grey of 'cancelled'. The reason chip on a queued punch is the
 * orange of 'short', "look at this", rather than the red of a suspected spoof,
 * because most reasons (nobody recognised, phone clock) are not accusations.
 * ======================================================================== */
.badge-offline { background: #e0e7ff; color: #3730a3; }
.badge-needs_review { background: #fef9c3; color: #854d0e; }
.badge-recorded { background: #dcfce7; color: #166534; }
.badge-discarded,
.badge-duplicate { background: #e5e7eb; color: #4b5563; }
.badge-review { background: #ffedd5; color: #9a3412; }

/* The waiting count on the "Offline punches" nav link is the same .nav-count
 * the Requests link wears (above): one count style for every queue. */

.offline-card { margin-bottom: 1rem; }
/* Photo beside the facts and the form, because the photo is what the decision
 * is made from. One column on a phone, photo first. */
.offline-layout {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
/* A queued punch with no photo column (none stored) gives the body the card. */
.offline-layout > .offline-body:only-child { grid-column: 1 / -1; }
.offline-photo .frame-placeholder { min-height: 10rem; }
.offline-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.offline-reason { margin: 0 0 0.75rem; }
.offline-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.offline-facts dt { font-weight: 600; color: var(--text-muted); }
.offline-facts dd { margin: 0; }
.offline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr));
  gap: 0 1rem;
}

@media (max-width: 640px) {
  .offline-layout { grid-template-columns: minmax(0, 1fr); }
}
