/* =====================================================================
   styles.css — one stylesheet for every page.

   Clean, minimal, BLACK design. The page is always black (there is no
   light theme, on purpose: color-scheme is locked to dark).

   RE-SKINNING: every colour, font, radius and shadow lives in the token
   block at the top. Change the green in ONE place (--accent) and the hover,
   pressed and tinted shades follow (they are derived with color-mix).
   ===================================================================== */

:root {
  /* ---- Brand ---- */
  /* Lime sampled from the gym logo (logo-intensity.png). Used sparingly: the Clock in
     button, active/selected states and small "on the clock" dots. */
  --accent: #92C102;                                                  /* fills: Clock in button, active states, dots */
  --on-accent: #000000;                                               /* text on top of green fills (always black) */
  --accent-hover: color-mix(in srgb, var(--accent) 86%, white);
  --accent-press: color-mix(in srgb, var(--accent) 80%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, black);        /* dark green-tinted backgrounds */
  --accent-line: color-mix(in srgb, var(--accent) 42%, black);        /* tinted borders */
  /* On black the lime is bright enough to be TEXT too (about 9.8:1). */
  --accent-text: var(--accent);
  --focus: var(--accent);                                             /* keyboard focus rings */

  /* ---- Surfaces and text ---- */
  --bg: #000000;                          /* page */
  --surface: #111111;                     /* cards, dialogs */
  --surface-2: #1a1a1a;                   /* second level: inset blocks, hover */
  --surface-3: #262626;                   /* third level: avatars, pills */
  --border: #262626;                      /* hairlines, card edges */
  --border-strong: #333333;               /* button edges, hover */
  --border-input: #737373;                /* form field edges (4.4:1 on black) */
  --text: #f5f5f5;
  --muted: #a3a3a3;                       /* 8.7:1 on black, 7.3:1 on cards */
  --scrim: rgba(0, 0, 0, .7);

  /* ---- Status colours (restrained, tuned for black) ---- */
  --success: #6fd08c;  --success-soft: #0f2418;
  --warning: #f0c75e;  --warning-soft: #241c08;  --warning-line: #4a3a12;
  --danger:  #ff8a80;  --danger-soft:  #2a1311;
  --danger-fill: #d92d20;                 /* destructive buttons only */
  --on-danger: #ffffff;

  /* ---- Radii ---- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* ---- Shadows (almost none) ---- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: none;
  --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .8), 0 0 0 1px #333333;

  /* ---- Type ---- */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  /* weights used everywhere: 400 regular, 500 medium, 600 semibold */

  /* ---- Spacing rhythm ---- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --gutter: 16px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--text-base)/1.5 var(--font);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-2); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent-text); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.unit { font-size: var(--text-sm); font-weight: 400; color: var(--muted); margin-left: 4px; }

/* ---------- layout ---------- */
.container { max-width: 720px; margin: 0 auto; padding: var(--space-5) var(--gutter) var(--space-7); }
.container.wide { max-width: 1040px; }
.container.medium { max-width: 560px; }
.container.narrow { max-width: 440px; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
@media (min-width: 640px) { .container { padding-top: var(--space-6); } }

/* ---------- brand (logo-intensity.png has a true black background, so it blends
   straight into the black page: no tile, radius, filter or border) ---------- */
.brand-logo { display: block; height: 72px; width: auto; }
.brand-link { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--text); border-radius: 6px; }
.wordmark-sub {
  font-size: var(--text-lg); font-weight: 500; line-height: 1; color: var(--muted);
  padding-left: var(--space-3); border-left: 1px solid var(--border);
}


/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1040px; margin: 0 auto; padding: 4px var(--gutter);
  display: flex; align-items: center; gap: var(--space-1) var(--space-4); flex-wrap: wrap;
}
.app-header nav { display: flex; align-items: center; gap: var(--space-1); margin-left: var(--space-3); }
.app-header nav:has(#nav-admin[hidden]) { display: none; }  /* employees only have one page */
.app-header nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-pill); text-decoration: none; color: var(--muted);
  font-weight: 500; font-size: var(--text-base);
  transition: background-color .15s, color .15s;
}
.app-header nav a:hover { background: var(--surface-2); color: var(--text); }
.app-header nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.user-bar { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.who { color: var(--muted); font-size: var(--text-sm); max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 599px) {
  .app-header nav { order: 3; flex-basis: 100%; margin: 0 0 var(--space-1); }
  .app-header nav a { flex: 1; }
}
@media (max-width: 479px) {
  .who { display: none; }   /* keep the phone header to one tidy row; the name is on the demo bar / not needed to clock in */
}

/* ---------- sign-in hero ---------- */
.hero-brand { text-align: center; margin: var(--space-5) 0 var(--space-2); font-size: var(--text-base); letter-spacing: 0; }
.hero-logo { display: block; width: min(220px, 62vw); height: auto; margin: 0 auto; }
.hero-brand .hero-sub { position: relative; display: block; margin-top: var(--space-3); font-size: var(--text-xl); font-weight: 500; color: var(--muted); }
.hero-tag { text-align: center; color: var(--muted); margin: 0 0 var(--space-2); }
/* Homepage (index.html): just the logo and one button to the sign-in page. */
.home { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-5); padding-top: 0; padding-bottom: 0; }
.home .hero-brand { margin: 0; }
/* Green letters and a green glow, never a solid green fill (Ashley's call). */
.btn.home-btn {
  min-width: min(260px, 100%); min-height: 56px; font-size: var(--text-xl);
  background: transparent; color: var(--accent); border-color: var(--accent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent);
  transition: box-shadow .2s var(--ease), transform .1s var(--ease);
}
.btn.home-btn:hover, .btn.home-btn:focus-visible {
  background: transparent;
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 65%, transparent), inset 0 0 14px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn.home-btn:active { background: transparent; }

/* ---------- cards & notices ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-4); box-shadow: var(--shadow);
}
@media (min-width: 640px) { .card { padding: 20px; } }
.card > :last-child { margin-bottom: 0; }
.notice { border-left: 3px solid var(--border-strong); background: var(--surface-2); }
.notice-warning { border-color: var(--warning-line); border-left-color: var(--warning); background: var(--warning-soft); }
.notice-warning h2 { color: var(--warning); }
.notice-error { border-color: color-mix(in srgb, var(--danger) 25%, white); border-left-color: var(--danger); background: var(--danger-soft); }
.notice-error h2 { color: var(--danger); }
.notice-success { border-color: var(--accent-line); border-left-color: var(--accent); background: var(--accent-soft); }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 8px 22px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  font: 600 var(--text-base)/1.2 var(--font); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, transform .1s var(--ease), color .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { background: var(--accent-press); transform: scale(.985); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); border-color: #4d4d4d; }
.btn-ghost:active { background: var(--surface-3); }
.btn-danger { background: var(--danger-fill); color: var(--on-danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger-fill) 88%, black); }
.btn-danger:active { background: color-mix(in srgb, var(--danger-fill) 78%, black); }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: var(--text-sm); }
@media (max-width: 720px), (pointer: coarse) { .btn-small { min-height: 44px; } }
.btn-block { width: 100%; }
.link-btn {
  background: none; border: 0; padding: 12px 4px; min-height: 44px; color: var(--accent-text);
  font: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { text-decoration-thickness: 2px; }
/* "Try as" demo buttons: intentional, but secondary to the real sign-in. */
.btn-demo {
  justify-content: space-between; width: 100%; text-align: left;
  background: transparent; color: var(--text); border-color: var(--border-strong); font-weight: 500;
}
.btn-demo::after { content: "\203A"; font-size: 1.5rem; line-height: 1; color: var(--muted); transition: transform .15s var(--ease); }
.btn-demo:hover { background: var(--surface-2); border-color: #4d4d4d; }
.btn-demo:hover::after { transform: translateX(2px); }

/* ---------- the clock (hero) ---------- */
.clock-card {
  position: relative; overflow: hidden; text-align: center;
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-radius: var(--radius-lg);
  transition: border-color .3s;
}
.clock-card > * { position: relative; }
.clock-card.is-on { border-color: var(--accent-line); }
.clock-card .notice { text-align: left; margin: 0 0 var(--space-4); }

.status-line {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 var(--space-3); font-size: var(--text-base); color: var(--muted);
}
.status-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.status-line strong { color: var(--text); font-weight: 500; }
.clock-card.is-on .status-line::before { background: var(--accent); }

.timer {
  margin: 0 0 var(--space-5);
  font-weight: 400; font-size: clamp(3.25rem, 17vw, 5rem); line-height: 1.05;
  letter-spacing: -.02em; text-align: center; font-variant-numeric: tabular-nums;
  color: var(--text);
  animation: fade-in .3s ease;
}

.clock-btn {
  width: 100%; min-height: 112px; border-radius: var(--radius); gap: 12px;
  font-size: clamp(1.5rem, 7vw, 1.75rem); font-weight: 600; letter-spacing: -.01em;
}
.clock-btn:disabled, .clock-btn[aria-busy="true"] { opacity: .6; }
.clock-btn .spinner { width: .75em; height: .75em; border-width: 2px; }
.clock-btn.is-out { background: var(--text); color: #000; }
.clock-btn.is-out:hover { background: #d9d9d9; }
.clock-btn.is-out:active { background: #bdbdbd; }

#clock-error { margin-top: var(--space-3); }

/* success confirmation overlay (added by clock.js): a quiet check + text that fades */
.clock-card > .clock-confirm {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--surface);
  animation: confirm-life 1.6s ease both;
  cursor: pointer;
}
.clock-confirm svg { width: 56px; height: 56px; overflow: visible; margin-bottom: var(--space-1); }
.clock-confirm .c-ring { fill: var(--accent); stroke: none; }
.clock-confirm .c-tick { fill: none; stroke: var(--on-accent); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; animation: draw-tick .3s .15s ease both; }
.clock-confirm .c-title { font-weight: 600; font-size: var(--text-xl); letter-spacing: -.01em; }
.clock-confirm .c-sub { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: var(--text-sm); margin-bottom: 6px; }
.field { margin-bottom: var(--space-4); }
.hint { font-size: var(--text-sm); color: var(--muted); margin: 6px 0 0; font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font: inherit; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #8a8a8a; }
input:hover, select:hover, textarea:hover { border-color: #a3a3a3; }
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}
.radio-row { display: flex; flex-direction: column; gap: var(--space-2); }
.radio-row label {
  display: flex; align-items: center; gap: var(--space-3); font-weight: 400; font-size: var(--text-base);
  min-height: 52px; padding: 8px 14px; margin: 0; background: transparent;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.radio-row label:hover { background: var(--surface-2); }
.radio-row label:has(input:checked) { border-color: var(--accent-text); background: var(--accent-soft); }
.radio-row input { width: 20px; height: 20px; accent-color: var(--accent-text); flex: none; }
.form-error { color: var(--danger); font-weight: 500; min-height: 1.5em; margin: var(--space-2) 0 0; }
.form-error:empty { min-height: 0; margin: 0; }

/* ---------- badges / status pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 500; line-height: 1.5;
  background: var(--surface-3); color: #d4d4d4; vertical-align: middle; white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-line); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.badge-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.badge-danger::before, .badge-warning::before, .badge-success::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- shift lists (employee screen) ---------- */
.period-nav { display: flex; align-items: center; gap: var(--space-2); }
.period-nav .label { flex: 1; text-align: center; font-weight: 600; font-size: var(--text-base); line-height: 1.3; }
#shifts-title { margin-bottom: var(--space-3); }

.total-line {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  margin: var(--space-4) 0; padding: var(--space-3) var(--space-4);
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-weight: 500;
}
.total-line > span:last-child { font-size: var(--text-sm); font-weight: 400; color: var(--muted); white-space: nowrap; }
.total-line .num { font-weight: 600; font-size: var(--text-2xl); line-height: 1.1; color: var(--text); margin-right: 2px; }
.total-line .small { font-weight: 400; }

.day-group {
  margin-top: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3);
  padding-bottom: var(--space-2); margin-bottom: var(--space-1); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: var(--text-base);
}
.day-head .num { font-size: var(--text-base); font-weight: 600; white-space: nowrap; }
.shift-line { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); min-height: 36px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shift-line > span:first-child { color: var(--text); }

/* ---------- admin: shift rows, people, audit ---------- */
.shift-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "when hrs" "times times" "actions actions";
  gap: var(--space-1) var(--space-3); align-items: center;
  padding: var(--space-3) 0; border-top: 1px solid var(--border);
}
.shift-row .when { grid-area: when; font-weight: 500; }
.shift-row .times { grid-area: times; color: var(--muted); font-variant-numeric: tabular-nums; }
.shift-row .hrs { grid-area: hrs; text-align: right; font-weight: 600; font-size: var(--text-lg); }
.shift-row .actions { grid-area: actions; display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.shift-row .actions .btn { flex: 1; padding-inline: 8px; }
@media (min-width: 640px) {
  .shift-row { grid-template-columns: 9.5rem 1fr 5rem auto; grid-template-areas: "when times hrs actions"; }
  .shift-row .actions { margin-top: 0; }
  .shift-row .actions .btn { flex: none; }
}

.emp-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.emp-head h3 { margin: 0; flex: 1; min-width: 0; font-size: var(--text-lg); overflow-wrap: anywhere; }
.emp-head .emp-total { text-align: right; line-height: 1.2; white-space: nowrap; }
.emp-head .emp-total .num { font-weight: 600; font-size: var(--text-xl); color: var(--text); }
.avatar {
  flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface-3);
  font-weight: 600; font-size: var(--text-sm); color: var(--text);
}

.person-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.person-row .who-block { flex: 1; min-width: 0; }
.person-row .name { font-weight: 500; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.person-row .email { color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
.person-row .row { flex: none; }
@media (max-width: 559px) {
  .person-row { flex-wrap: wrap; }
  .person-row .row { flex-basis: 100%; }
  .person-row .row .btn { flex: 1; }
}

.audit-item { padding: var(--space-3) 0 var(--space-3) var(--space-4); border-left: 1px solid var(--border-strong); margin-left: 4px; position: relative; }
.audit-item + .audit-item { margin-top: 2px; }
.audit-item::before { content: ""; position: absolute; left: -5px; top: 19px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-sizing: content-box; margin-left: -1px; }
.audit-item .reason { margin-top: 4px; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }

.on-now { border-color: var(--accent-line); background: var(--accent-soft); }
.on-now strong { font-weight: 600; color: var(--text); }
.on-now strong::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) 0; border-top: 1px solid var(--warning-line); }

/* pending / inactive account message (employee screen) */
#account-msg { text-align: center; padding: var(--space-6) var(--space-5); border-left-width: 1px; border-color: var(--border); background: var(--surface); }
#account-msg::before {
  content: ""; display: block; width: 48px; height: 48px; margin: 0 auto var(--space-4); border-radius: 50%;
  border: 2px solid var(--text);
  background:
    linear-gradient(var(--text), var(--text)) 50% 7px / 2px 14px no-repeat,
    linear-gradient(var(--text), var(--text)) 62% 20px / 11px 2px no-repeat;
}
#account-msg h2 { color: var(--text); font-size: var(--text-xl); }
#account-msg p { color: var(--muted); max-width: 32em; margin-inline: auto; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; flex-wrap: nowrap; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  border-bottom: 1px solid var(--border); margin-bottom: var(--space-4);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: var(--space-2);
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 10px 16px; min-height: 48px;
  font: 500 var(--text-base)/1.2 var(--font);
  color: var(--muted); cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s, background-color .15s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
@media (max-width: 720px) {
  .tabs { margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
}
@media (max-width: 420px) {
  .tabs { gap: 0; }
  .tabs button { flex: 1 0 auto; justify-content: center; padding: 10px 6px; font-size: var(--text-sm); gap: 4px; }
}
[role="tabpanel"] { animation: fade-in .2s ease; }

/* ---------- dialog ---------- */
dialog {
  width: min(540px, calc(100vw - 2 * var(--gutter))); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.dialog-danger h2 { color: var(--danger); }
dialog[open] { animation: dialog-in .2s var(--ease); }
dialog::backdrop { background: var(--scrim); }
dialog[open]::backdrop { animation: fade-in .2s ease; }
dialog form, dialog .dialog-body { padding: var(--space-5) var(--space-5) var(--space-4); }
dialog h2 { font-size: var(--text-xl); }
.dialog-actions { display: flex; gap: var(--space-3); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--space-4); }
@media (max-width: 559px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
  dialog[open] { animation: sheet-in .25s var(--ease); }
  dialog form, dialog .dialog-body { padding: var(--space-4) var(--gutter) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .dialog-actions .btn { flex: 1; }
}

/* ---------- loading / empty ---------- */
.loading { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); padding: var(--space-6) 0; justify-content: center; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .7s linear infinite; flex: none;
}
.loading .spinner { color: var(--text); }
.empty {
  text-align: center; color: var(--muted); padding: var(--space-5) var(--space-4);
  background: var(--surface-2); border-radius: var(--radius-sm); margin: var(--space-2) 0;
}
.card.empty { box-shadow: none; border: 1px solid var(--border); }

/* ---------- demo banner (calm pale-yellow strip) ---------- */
.demo-banner { background: var(--warning-soft); color: var(--text); border-bottom: 1px solid var(--warning-line); }
.demo-inner { max-width: 1040px; margin: 0 auto; padding: 4px var(--gutter); display: flex; gap: var(--space-1) var(--space-4); align-items: center; flex-wrap: wrap; }
.demo-inner strong { color: var(--text); font-weight: 500; font-size: var(--text-sm); }
.demo-controls { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-left: auto; }
.demo-controls label { margin: 0; font-size: var(--text-sm); }
.demo-controls select { width: auto; max-width: 100%; min-height: 44px; padding: 4px 10px; background-color: var(--surface-2); }
.demo-controls .btn { border-color: var(--warning-line); }
@media (max-width: 599px) { .demo-controls { margin-left: 0; width: 100%; } .demo-controls .btn { margin-left: auto; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: var(--radius-sm); text-align: center;
  background: var(--text); color: #000; font-weight: 500; font-size: var(--text-sm); box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease); z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger-fill); color: var(--on-danger); }
.toast-success { background: var(--text); color: #000; }

/* ---------- small extras ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
.mt { margin-top: var(--space-3); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 400; font-size: var(--text-sm); min-height: 44px; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent-text); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
::selection { background: var(--accent); color: var(--on-accent); }

/* ---------- motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes confirm-life { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes draw-tick { from { stroke-dashoffset: 60; } to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }   /* keep the "working" cue, just slower */
  .btn:active { transform: none; }
}

/* ---------- sign-in: demo card ---------- */
.demo-card { background: var(--surface-2); box-shadow: none; }
.demo-card h2 { font-size: var(--text-base); color: var(--text); }
.demo-card .stack { gap: var(--space-2); }

/* ---------- phone refinements ---------- */
@media (max-width: 599px) {
  .demo-controls { flex-wrap: nowrap; }
  .demo-controls select { flex: 1; min-width: 0; }
  .demo-controls .btn { margin-left: 0; white-space: nowrap; }
}
.clock-btn[aria-busy="true"] { font-size: clamp(1.25rem, 6vw, 1.5rem); }
.card form + p { margin-top: var(--space-3); }
.total-line .small { white-space: nowrap; }
