@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

/* =====================================================================
   Staff Pay - design tokens

   Style: Obsidian & Gold. The reference is a private bank statement, not
          a dashboard: near-black paper, one hairline of gold, a serif for
          the money and nothing else competing with it.

          GOLD IS A RULE AND A TOTAL, NEVER A BUTTON FILL. That restraint
          is the whole effect. A gold button would make this look like a
          casino promo, which is the one thing it must not look like.

   Themes: two, switched with data-theme on <html>.

            (none)          Obsidian - the default
            data-theme=plain  Ivory paper, obsidian ink, darker gold

          The attribute is written server-side from a cookie, so there is
          no flash of the wrong theme while the page loads.

   Type:  Playfair Display for money and headings; Inter for everything
          else, asked for its slashed zero and tailed l (cv05/zero) so a
          wage figure cannot be misread. Both Latin-only, so the stacks
          fall through to a CJK face for Chinese - a SERIF one for the
          display font, which suits this far better than a sans.

   Colour: measured, not eyeballed.
            #C8A96A gold on #0E0E11 ......... 8.57:1
            #8A8575 muted text on #0E0E11 ... 5.22:1
            #8A6D34 gold on #FAFAF9 ......... 4.66:1
          The dark theme's gold is UNUSABLE on paper - 2.15:1 - which is
          why the plain theme has a gold of its own rather than the same
          palette with the background flipped.
   ===================================================================== */

:root {
  --font-sans: Inter, 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB',
               'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', 'Noto Serif SC', 'Songti SC', 'SimSun',
                  Georgia, serif;

  /* ---- Obsidian: the default ---- */
  color-scheme: dark;        /* date pickers and scrollbars follow suit */

  --bg:          #0E0E11;
  --surface:     #16161A;
  --surface-2:   #1C1C21;
  --border:      #26262C;
  --border-firm: #3A3A44;

  --text:        #F3EFE4;
  --text-muted:  #A9A294;
  --text-faint:  #8A8575;

  --gold:        #C8A96A;
  --gold-dim:    #9C8A5E;
  --gold-hair:   rgba(200, 169, 106, .28);
  --gold-wash:   rgba(200, 169, 106, .10);

  /* The primary button is BONE, not gold - see the note at the top. */
  --primary:       #E8E3D7;
  --primary-press: #D4CDBC;
  --on-primary:    #14130F;

  --ok:     #76C3A1;
  --ok-wash:rgba(118, 195, 161, .12);
  --ok-line:rgba(118, 195, 161, .34);
  --warn:   #E0B45E;
  --warn-wash:rgba(224, 180, 94, .12);
  --warn-line:rgba(224, 180, 94, .34);
  --danger: #EC8C8C;
  --danger-wash:rgba(236, 140, 140, .12);
  --danger-line:rgba(236, 140, 140, .34);

  /* The attendance calendar. Five colours that must stay apart from each
     other at a glance, in both themes. */
  --cal-green:  #76C3A1;  --cal-green-wash:  rgba(118, 195, 161, .16);
  --cal-red:    #EC8C8C;  --cal-red-wash:    rgba(236, 140, 140, .16);
  --cal-orange: #F0A35E;  --cal-orange-wash: rgba(240, 163, 94, .16);
  --cal-blue:   #8FB3F0;  --cal-blue-wash:   rgba(143, 179, 240, .14);
  --cal-grey:   #8A8575;  --cal-grey-wash:   rgba(138, 133, 117, .12);

  --radius:    14px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  /* Density 6/10 - comfortable for touch without wasting a small screen */
  --gap-1: 4px;  --gap-2: 8px;  --gap-3: 12px;
  --gap-4: 16px; --gap-5: 24px; --gap-6: 32px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);

  --veil: rgba(8, 8, 10, .62);

  --bottom-nav-h: 64px;
  --tap: 44px;              /* never smaller: Apple HIG / Material */
}

/* ---- Plain: ivory paper, obsidian ink ----
   Not the dark theme inverted. The gold, the shadows and the washes are
   all redrawn, because every one of them fails when the background goes
   from near-black to paper. */
:root[data-theme="plain"] {
  color-scheme: light;

  --bg:          #FAFAF9;
  --surface:     #FFFFFF;
  --surface-2:   #F5F3EF;
  --border:      #E7E3DA;
  --border-firm: #D2CCBF;

  --text:        #1C1914;
  --text-muted:  #6E6554;
  /* Both of these started lighter, to match the dark theme's proportions,
     and both failed AA on paper - 3.74:1 and 3.32:1, worse again on the
     table head. Measured and darkened; the look barely changes and the
     small-caps labels stop disappearing in daylight. */
  --text-faint:  #746C5E;

  --gold:        #8A6D34;
  --gold-dim:    #776C4E;
  --gold-hair:   rgba(138, 109, 52, .30);
  --gold-wash:   rgba(138, 109, 52, .07);

  --primary:       #1C1917;
  --primary-press: #000000;
  --on-primary:    #FFFFFF;

  --ok:     #166534;
  --ok-wash:#E7F2EB;
  --ok-line:#BFDFCB;
  --warn:   #8A5A0E;
  --warn-wash:#FBF1DF;
  --warn-line:#E8D3A6;
  --danger: #B3261E;
  --danger-wash:#FBECEB;
  --danger-line:#E8C2BF;

  --cal-green:  #166534;  --cal-green-wash:  #E3F1E8;
  --cal-red:    #B3261E;  --cal-red-wash:    #FBE9E8;
  --cal-orange: #B45309;  --cal-orange-wash: #FDEFE0;
  --cal-blue:   #1D4ED8;  --cal-blue-wash:   #E6EDFB;
  --cal-grey:   #6B6558;  --cal-grey-wash:   #F0EEE9;

  --shadow-1: 0 1px 2px rgba(28, 25, 20, .06), 0 1px 3px rgba(28, 25, 20, .04);
  --shadow-2: 0 8px 28px rgba(28, 25, 20, .14);

  --veil: rgba(28, 25, 20, .38);
}

* { box-sizing: border-box; }

/* Every icon() svg. An inline SVG with no explicit size is sized by its
   container - that is how a 20px clock came out 257px wide in a flex
   card header. The rules further down (buttons, nav, empty states) are
   more specific and deliberately override this. */
.ico { width: 20px; height: 20px; flex: none; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;          /* 16px stops iOS zooming on focus */
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* zero = slashed zero, cv05 = l with a tail. Ignored by any build that
     lacks them, which is why they are safe to ask for. */
  font-feature-settings: 'zero' 1, 'cv05' 1;
}

/* Money and times line up in columns only with tabular figures.
   LINING as well as tabular: Playfair's tabular set is old-style, so the
   big figure came out "RM 0.00" with x-height zeros - handsome on a menu,
   wrong on a payslip, where the digits must stand at cap height beside the
   currency. Caught on screen, not in the stylesheet. */
.num, .money, td.num, .stat-value, .amount,
.statement-amount, .row-total .value, h1, h2 {
  font-variant-numeric: lining-nums tabular-nums;
}

h1, h2, h3 { margin: 0 0 var(--gap-3); line-height: 1.25; }
h1 { font-family: var(--font-display); font-size: 24px; font-weight: 500;
     letter-spacing: -.01em; }
h2 { font-family: var(--font-display); font-size: 19px; font-weight: 500; }
h3 { font-size: 16px; font-weight: 600; }

a { color: var(--gold); text-underline-offset: 2px; }
a:hover { color: var(--text); }

/* ------------------------------------------------------------- shell */
.app {
  min-height: 100dvh;       /* dvh, not vh: iOS toolbars eat vh */
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: var(--gap-3) var(--gap-4);
  padding-top: calc(var(--gap-3) + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  margin: 0;
  letter-spacing: .01em;
}
.topbar-sub { color: var(--text-muted); font-size: 13px; }
.topbar-spacer { margin-left: auto; }
.min-w-0 { min-width: 0; }

.app-main {
  flex: 1;
  padding: var(--gap-4);
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + var(--gap-5));
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

/* --------------------------------------------------------- bottom nav */
/* Five items maximum, always icon + label. An icon alone is a guess. */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  min-height: var(--bottom-nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--text-faint);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  position: relative;
  transition: color .18s ease;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.is-active { color: var(--gold); }
/* A hairline over the active item, not a filled block: the same gold rule
   that runs under the hero and over the total. */
.bottom-nav a.is-active::before {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 2px;
  background: var(--gold);
}
.bottom-nav a:active { color: var(--text); }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--gap-4);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: var(--gap-2);
  padding: var(--gap-3) var(--gap-4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--surface-2);
  color: var(--text);
}
.card-head svg { color: var(--gold-dim); }
.card-body { padding: var(--gap-4); }
.card-foot {
  padding: var(--gap-3) var(--gap-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ------------------------------------------------------- the statement
   The one screen that matters: a number telling somebody what they
   earned. Gold hairline above, serif figure, nothing else on it. */
.statement {
  position: relative;
  text-align: center;
  padding: var(--gap-5) var(--gap-4);
  background: linear-gradient(170deg, var(--gold-wash) 0%, transparent 62%);
}
.statement::before {
  content: '';
  position: absolute;
  left: var(--gap-5); right: var(--gap-5); top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.statement-cap {
  font-size: 10px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--gold-dim);
}
.statement-amount {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 12vw, 52px);
  line-height: 1.05;
  letter-spacing: -.015em;
  margin: var(--gap-3) 0 var(--gap-2);
  font-variant-numeric: lining-nums tabular-nums;
}
.statement-sub { font-size: 12px; color: var(--text-muted); letter-spacing: .04em; }

/* ------------------------------------------------------------- stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--gap-3);
  margin-bottom: var(--gap-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-3) var(--gap-4);
  box-shadow: var(--shadow-1);
}
.stat-label {
  font-size: 10px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--text-faint);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 500; margin-top: 4px;
  letter-spacing: -.01em;
}
.stat-hint { font-size: 12px; color: var(--text-muted); }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* ----------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-2);
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, color .18s ease,
              transform .08s ease;
  touch-action: manipulation;        /* kills the 300ms tap delay */
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-press); color: var(--on-primary); }

.btn-ghost {
  background: transparent; color: var(--text);
  border-color: var(--border-firm);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--gold-hair); }

.btn-ok { background: var(--ok); color: var(--bg); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-wash); color: var(--danger); }

.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .40; pointer-events: none; }
/* Marked, never disabled: disabling the pressed button in its own submit
   handler drops its name and value from the POST. Proven, twice. */
.btn.is-loading { opacity: .60; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--gap-2); }

/* ------------------------------------------- a row of day checkboxes */
/* Used for the working week. Each box is a full tap target, and the gold
   is the TICK, not a fill - the rule at the top of this file. */
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  margin-bottom: var(--gap-4);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: var(--tap);
  padding: 0 var(--gap-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  cursor: pointer;
}
.check:has(input:checked) {
  border-color: var(--gold-hair);
  color: var(--text);
}
.check:focus-within {
  outline: 2px solid var(--gold-dim);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- forms */
.field { margin-bottom: var(--gap-4); }
.field > label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.req { color: var(--danger); }

.input, select.input, textarea.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-sm);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:hover { border-color: var(--gold-hair); }
textarea.input { min-height: 88px; resize: vertical; }

.input:focus-visible, .btn:focus-visible, .bottom-nav a:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.help { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.field-error { font-size: 13px; color: var(--danger); margin-top: 4px; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--gap-3); }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-wash);     color: var(--ok);     border-color: var(--ok-line); }
.badge-warn   { background: var(--warn-wash);   color: var(--warn);   border-color: var(--warn-line); }
.badge-danger { background: var(--danger-wash); color: var(--danger); border-color: var(--danger-line); }
.badge-muted  { background: var(--surface-2);   color: var(--text-muted); border-color: var(--border); }
.badge-info   { background: var(--gold-wash);   color: var(--gold);   border-color: var(--gold-hair); }

/* ------------------------------------------------------------- lists */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: flex-start; gap: var(--gap-3);
  padding: var(--gap-3) var(--gap-4);
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.row-end { text-align: right; white-space: nowrap; font-weight: 500; }

/* The closing line of a statement: gold rule, serif figure. */
.row-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--gap-4);
  border-top: 1px solid var(--gold-hair);
}
.row-total .label {
  font-size: 10px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold-dim);
}
.row-total .value {
  font-family: var(--font-display); font-size: 21px; font-weight: 500;
  color: var(--gold); font-variant-numeric: lining-nums tabular-nums;
}

/* --------------------------------------------------------------- QR */
.qr-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--gap-3);
  padding: var(--gap-5) var(--gap-4);
  text-align: center;
}
/* WHITE, SQUARE, GENEROUS QUIET ZONE - in both themes, deliberately.
   A till scanner reads a lit screen far better than a tinted one, so this
   box does NOT follow the theme. A dark-on-dark QR is a QR that does not
   scan, and the staff member gets blamed for it at the till. */
.qr-box {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-hair);
  line-height: 0;
}
.qr-box svg { width: min(68vw, 260px); height: auto; }
.qr-countdown { font-size: 14px; color: var(--text-muted); font-variant-numeric: lining-nums tabular-nums; }
.qr-name { font-family: var(--font-display); font-size: 22px; font-weight: 500; }

/* ------------------------------------------------------------ alerts */
.alert {
  padding: var(--gap-3) var(--gap-4);
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: var(--gap-4);
  font-size: 15px;
}
.alert-ok     { background: var(--ok-wash);     border-color: var(--ok-line);     color: var(--ok); }
.alert-warn   { background: var(--warn-wash);   border-color: var(--warn-line);   color: var(--warn); }
.alert-danger { background: var(--danger-wash); border-color: var(--danger-line); color: var(--danger); }
.alert-info   { background: var(--gold-wash);   border-color: var(--gold-hair);   color: var(--text); }
.alert ul { margin: var(--gap-2) 0 0; padding-left: 20px; }

/* ------------------------------------------------------- empty state */
.empty {
  text-align: center;
  padding: var(--gap-6) var(--gap-4);
  color: var(--text-muted);
}
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: var(--gap-2); color: var(--gold-dim); }
.empty-title { font-family: var(--font-display); font-size: 18px; color: var(--text); margin-bottom: 4px; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td {
  padding: 11px var(--gap-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em;
  font-weight: 600;
  color: var(--text-faint); background: var(--surface-2);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; }

/* -------------------------------------------------------- admin nav */
.tabs {
  display: flex; gap: var(--gap-2);
  overflow-x: auto;
  padding-bottom: var(--gap-2);
  margin-bottom: var(--gap-4);
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  flex: 0 0 auto;
  min-height: var(--tap);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid var(--border-firm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.tabs a.is-active {
  background: var(--gold-wash);
  border-color: var(--gold);
  color: var(--gold);
}
.tabs a svg { width: 16px; height: 16px; }

/* --------------------------------------------------------- utilities */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.gold  { color: var(--gold); }
.small { font-size: 13px; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--gap-2); }
.mb-3 { margin-bottom: var(--gap-3); }
.mb-4 { margin-bottom: var(--gap-4); }
.flex { display: flex; align-items: center; gap: var(--gap-2); }
.flex-wrap { flex-wrap: wrap; }
.spacer { margin-left: auto; }
.nowrap { white-space: nowrap; }

/* A rule, used to separate a statement from what follows it. */
.hair {
  height: 1px; border: 0; margin: var(--gap-4) 0;
  background: linear-gradient(90deg, transparent, var(--gold-hair), transparent);
}

/* ------------------------------------------------------------- toast */
.toast-host {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + var(--gap-3));
  z-index: 60;
  width: min(92vw, 420px);
}
.toast {
  padding: var(--gap-3) var(--gap-4);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  margin-bottom: var(--gap-2);
  font-weight: 500;
  animation: toast-in .22s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* -------------------------------------------------------- the veil */
.busy {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background: var(--veil);
}
.busy-card {
  display: flex; align-items: center; gap: var(--gap-3);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--gap-4) var(--gap-5);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-weight: 500;
}
.spin {
  width: 18px; height: 18px; flex: none;
  border: 2px solid var(--gold);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Motion dialled to 3/10 - these exist to show cause and effect, nothing
   decorative. Anybody who asks for less gets none. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ------------------------------------------------- cards that fold shut */
.card-fold > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  min-height: var(--tap);
}
.card-fold > summary::-webkit-details-marker { display: none; }
.card-fold > summary:hover { color: var(--gold); }
.card-fold > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
/* Shut, the heading is the whole card - no line under it. */
.card-fold:not([open]) > summary { border-bottom: 0; }
.fold-hint {
  margin-left: auto;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; font-size: 13px; color: var(--text-muted);
}
.fold-chev {
  flex: none;
  width: 9px; height: 9px;
  margin: 0 4px 3px 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .18s ease;
}
.card-fold[open] > summary .fold-chev { transform: rotate(-135deg); margin-bottom: -3px; }

/* ------------------------------------------- attendance: pay by shop */
table.by-shop tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: 0;
}
table.by-shop .by-shop-extra td { color: var(--text-muted); }

/* ----------------------------------------------- the working week card */
.week-sub {
  font-weight: 700; font-size: 13px; letter-spacing: .04em;
  color: var(--text-muted); margin: var(--gap-4) 0 var(--gap-2);
}
.week-sub:first-of-type { margin-top: 0; }
.week-apply {
  margin-top: var(--gap-3);
  padding-top: var(--gap-3);
  border-top: 1px solid var(--border);
}

/* -------------------------------------------- dates + one small button */
/* Attendance: From | To | Export, on one row at every width. The button
   sits on the inputs' baseline (the fields keep their bottom margin). */
.date-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: var(--gap-3);
  align-items: end;
}
.date-row .input { min-width: 0; }
.date-row-btn {
  margin-bottom: var(--gap-4);
  min-height: var(--tap);
  padding: 8px 14px;
  white-space: nowrap;
}
.show-row { display: flex; gap: var(--gap-3); align-items: stretch; }
.show-row .date-row-btn { margin-bottom: 0; }
.date-row-btn.is-narrow { display: none; }

/* A phone: the dates take the whole row (two boxes and a button left the
   year cut off), and Export moves beside Show as an icon. */
@media (max-width: 480px) {
  .date-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .date-row-btn.is-wide { display: none; }
  .date-row-btn.is-narrow {
    display: inline-flex; flex: none;
    min-width: var(--tap); padding: 8px 12px; justify-content: center;
  }
}

/* ------------------------------------------------- attendance calendar */
.cal-card { padding-bottom: var(--gap-3); }
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--gap-3) var(--gap-3) 0;
}
.cal-title {
  font-family: var(--font-display);
  font-size: 22px; letter-spacing: .02em; color: var(--text);
  padding-bottom: 6px; border-bottom: 2px solid var(--gold);
}
.cal-nav { min-height: 40px; min-width: 44px; padding: 4px 12px; font-size: 22px; line-height: 1; }

.cal-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: var(--gap-3); font-size: 12px; color: var(--text-muted);
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cal-dot.cal-green  { background: var(--cal-green); }
.cal-dot.cal-red    { background: var(--cal-red); }
.cal-dot.cal-orange { background: var(--cal-orange); }
.cal-dot.cal-blue   { background: var(--cal-blue); }
.cal-dot.cal-grey   { background: var(--cal-grey); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 0 var(--gap-2);
}
.cal-wd {
  text-align: center; font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); padding: 4px 0;
}
.cal-day {
  min-width: 0;
  min-height: 78px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface);
}
.cal-day[data-day] { cursor: pointer; }
.cal-day[data-day]:hover { border-color: var(--border-firm); }
.cal-day:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal-day.is-blank { border-color: transparent; background: transparent; }
.cal-day.is-holiday { background: var(--cal-blue-wash); border-color: var(--cal-blue); }
.cal-day.is-rest    { background: var(--cal-grey-wash); }
.cal-day.is-future  { opacity: .45; }
.cal-day.is-today   { box-shadow: inset 0 0 0 2px var(--gold); }

.cal-num { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-day.is-holiday .cal-num { color: var(--cal-blue); }
.cal-day.is-rest .cal-num { color: var(--cal-grey); }
.cal-hol {
  font-size: 10px; line-height: 1.2; color: var(--cal-blue);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cal-pills { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-pill {
  min-width: 24px; height: 22px; padding: 0 6px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font: 700 12px/20px var(--font-sans);
  cursor: pointer;
  touch-action: manipulation;
}
.cal-pill.cal-green  { background: var(--cal-green-wash);  color: var(--cal-green);  border-color: var(--cal-green); }
.cal-pill.cal-red    { background: var(--cal-red-wash);    color: var(--cal-red);    border-color: var(--cal-red); }
.cal-pill.cal-orange { background: var(--cal-orange-wash); color: var(--cal-orange); border-color: var(--cal-orange); }
.cal-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* A phone is ~50px a day: the pills stack and the holiday name goes. */
@media (max-width: 520px) {
  .cal-grid { gap: 2px; padding: 0 2px; }
  .cal-day { min-height: 70px; padding: 3px 2px; }
  .cal-hol { display: none; }
  .cal-pills { flex-direction: column; align-items: stretch; gap: 2px; }
  .cal-pill { min-width: 0; height: 18px; font-size: 11px; line-height: 16px; padding: 0 2px; }
}

.cal-dialog {
  width: min(92vw, 480px);
  max-height: 80vh;
  padding: 0;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}
.cal-dialog::backdrop { background: var(--veil); }
.cal-dialog-head {
  display: flex; align-items: center; gap: var(--gap-2);
  padding: var(--gap-3) var(--gap-4);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.cal-dialog-title { font-weight: 600; flex: 1; min-width: 0; }
.cal-close { min-height: 40px; min-width: 44px; font-size: 22px; padding: 0 10px; }
.cal-dialog-body { padding: var(--gap-2) var(--gap-4) var(--gap-4); overflow: auto; }
.cal-sec { margin-top: var(--gap-3); }
.cal-sec-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .02em; margin-bottom: 4px;
}
.cal-sec-g { color: var(--cal-green); }
.cal-sec-o { color: var(--cal-orange); }
.cal-sec-r { color: var(--cal-red); }
.cal-person {
  display: flex; align-items: center; gap: var(--gap-2);
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.cal-person:last-child { border-bottom: 0; }
.cal-person-main { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.cal-person-main:hover .cal-person-name { color: var(--gold); }
.cal-person-name { font-weight: 600; }
.cal-fix { min-height: 36px; padding: 6px 10px; font-size: 13px; }

/* ------------------------------------------------------ wider screens */
@media (min-width: 900px) {
  /*
   * The bar STAYS fixed to the bottom of the window on a wide screen too.
   * It used to drop into the page here (position: static), which put it
   * under the last row of a long report - Daniel had to scroll to the end
   * of the attendance list just to change page. The page keeps room for it
   * underneath so it never covers the last line.
   */
  .app-main {
    padding: var(--gap-5);
    padding-bottom: calc(52px + env(safe-area-inset-bottom) + var(--gap-6));
  }
  .bottom-nav a { flex-direction: row; font-size: 14px; min-height: 52px; }
  .bottom-nav a svg { width: 18px; height: 18px; }
  .bottom-nav a.is-active::before { left: 24%; right: 24%; }
  .toast-host { bottom: calc(52px + env(safe-area-inset-bottom) + var(--gap-3)); }
}

/* --------------------------------------------------------- print
   A payslip that goes on paper is printed on WHITE, whichever theme is
   on screen. Printing the obsidian theme would empty a toner cartridge
   and come back grey. */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --text: #000; --text-muted: #333; --text-faint: #555;
    --gold: #6B5522; --gold-dim: #6B5522; --gold-hair: #BBB;
    --border: #CCC; --border-firm: #999;
  }
  .topbar, .bottom-nav, .btn, .tabs, .toast-host { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; }
  .statement { background: none; }
}
