/* =====================================================================
   Grimy Grills — Field App
   Linear-inspired dark theme. Mobile-first, large tap targets (>=44px).
   ===================================================================== */

:root {
  /* Surfaces */
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;

  /* Hairlines */
  --hairline: #23252a;
  --hairline-strong: #34343a;

  /* Ink */
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;

  /* Accent (lavender) */
  --accent: #5e6ad2;
  --accent-hover: #828fff;
  --accent-focus: #5e69d1;

  /* Semantic */
  --success: #27a644;
  --danger: #e5484d;

  /* Radii */
  --r-chip: 4px;
  --r-input: 8px;
  --r-card: 12px;
  --r-pill: 9999px;

  /* Spacing */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --font: -apple-system, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, Inter, sans-serif;

  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  /* Subtle depth: a faint lavender glow at the top, never a flat fill */
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(94, 106, 210, 0.10), transparent 60%),
    var(--canvas);
}

.hidden { display: none !important; }

/* iOS Safari can leave composited video layers visible when a view is hidden. */
.hidden video,
details:not([open]) video {
  display: none !important;
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0;
}

button { font-family: inherit; }

/* ---------------------------------------------------------------- Layout */
.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--s4) calc(var(--s7) + env(safe-area-inset-bottom));
}

.view { animation: viewIn 0.28s ease both; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: max(var(--s4), env(safe-area-inset-top)) 0 var(--s4);
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(var(--canvas) 75%, transparent);
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.topbar__spacer { flex: 1; }

.topbar__back {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: var(--tap);
  padding: var(--s2) var(--s3) var(--s2) var(--s2);
  background: var(--surface-1);
  color: var(--ink-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.topbar__back svg { width: 18px; height: 18px; }
.topbar__back:hover { border-color: var(--hairline-strong); color: var(--ink); }
.topbar__back:active { transform: scale(0.98); }

/* ------------------------------------------------------------ Chooser */
.chooser {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s7);
  padding: var(--s7) 0;
}

.chooser__brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}

.chooser__logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(94, 106, 210, 0.25));
}

.chooser__title {
  font-size: 32px;
  letter-spacing: -1px;
  margin-top: var(--s2);
}

.chooser__subtitle {
  margin: 0;
  color: var(--ink-subtle);
  font-size: 14px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 500;
}

.chooser__cards {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.role-card {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  text-align: left;
  padding: var(--s5) var(--s4);
  background: var(--surface-1);
  /* lighter top edge = subtle lift */
  border: 1px solid var(--hairline);
  border-top-color: var(--hairline-strong);
  border-radius: var(--r-card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.role-card:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.role-card:active { transform: scale(0.99); }

.role-card__icon {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  color: var(--accent-hover);
}
.role-card__icon svg { width: 24px; height: 24px; }

.role-card__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.role-card__label { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
.role-card__desc { font-size: 13px; color: var(--ink-subtle); }

.role-card__chev { flex: none; color: var(--ink-tertiary); }
.role-card__chev svg { width: 20px; height: 20px; display: block; }

/* -------------------------------------------------------- Admin PIN gate */
.admin-gate {
  padding: var(--s5) 0 var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.admin-gate__hint {
  margin: 0;
  font-size: 15px;
  color: var(--ink-subtle);
  line-height: 1.45;
}

.admin-gate__pin {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
  padding: var(--s4);
}

.admin-gate__error {
  margin: calc(var(--s2) * -1) 0 0;
  font-size: 14px;
  color: var(--danger);
}

/* --------------------------------------------------------- Placeholder */
.placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s4);
  margin-top: var(--s7);
}
.placeholder__icon { color: var(--ink-tertiary); }
.placeholder__icon svg { width: 40px; height: 40px; }
.placeholder__title { font-size: 20px; letter-spacing: -0.4px; }
.placeholder__text { margin: 0; color: var(--ink-subtle); font-size: 14px; }

/* ------------------------------------------------------- Employee hub */
.hub-intro { margin-top: var(--s5); }
.hub-intro__title { font-size: 24px; letter-spacing: -0.6px; }
.hub-intro__text { margin: var(--s2) 0 0; color: var(--ink-subtle); font-size: 15px; }

.hub-tiles {
  margin-top: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.hub-tile {
  display: flex;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  text-align: left;
  padding: var(--s5) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-top-color: var(--hairline-strong);
  border-radius: var(--r-card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.hub-tile:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.hub-tile:active { transform: scale(0.99); }
.hub-tile--primary {
  border-color: rgba(94, 106, 210, 0.45);
  background: rgba(94, 106, 210, 0.08);
}
.hub-tile--primary:hover { border-color: var(--accent); background: rgba(94, 106, 210, 0.12); }

.hub-tile__icon {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  color: var(--accent-hover);
}
.hub-tile__icon svg { width: 24px; height: 24px; }

.hub-tile__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hub-tile__label { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.hub-tile__desc { font-size: 13px; color: var(--ink-subtle); }

.hub-tile__chev { flex: none; color: var(--ink-tertiary); }
.hub-tile__chev svg { width: 20px; height: 20px; display: block; }

/* -------------------------------------------------------- Payment links */
.paylink-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin-top: var(--s5);
}

.paylink {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}

.paylink__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.paylink__label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.paylink__price {
  font-size: 14px;
  color: var(--accent-hover);
  font-weight: 600;
}

.paylink__url {
  font-size: 12px;
  color: var(--ink-subtle);
  word-break: break-all;
  line-height: 1.4;
  margin-top: var(--s1);
}

.paylink__copy {
  flex-shrink: 0;
  width: auto;
  min-height: 40px;
  padding: 0 16px;
}

/* --------------------------------------------------------------- SOP */
.sop__lead { margin-top: var(--s5); }
.sop__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent-hover);
}
.sop__title { font-size: 24px; letter-spacing: -0.6px; margin-top: var(--s1); }
.sop__text { margin: var(--s2) 0 0; color: var(--ink-subtle); font-size: 14px; }

.acc {
  margin-top: var(--s3);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  overflow: hidden;
}
.acc--accent { border-color: rgba(94, 106, 210, 0.45); }

.acc__summary {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s4);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.acc__summary::-webkit-details-marker { display: none; }
.acc__summary:hover { background: var(--surface-2); }

.acc__heading {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}
.acc__tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent-hover);
  background: rgba(94, 106, 210, 0.15);
  border: 1px solid rgba(94, 106, 210, 0.4);
  border-radius: var(--r-chip);
  padding: 2px 6px;
}

.acc__chev { flex: none; color: var(--ink-subtle); transition: transform 0.2s ease; }
.acc__chev svg { width: 18px; height: 18px; display: block; }
.acc[open] > .acc__summary .acc__chev { transform: rotate(180deg); }

.acc__body {
  padding: 0 var(--s4) var(--s4);
  border-top: 1px solid var(--hairline);
}
.acc[open] > .acc__body { animation: viewIn 0.22s ease both; }

.sop__para { margin: var(--s3) 0 0; color: var(--ink-muted); font-size: 14px; }
.sop__list {
  margin: var(--s3) 0 0;
  padding-left: var(--s4);
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.sop__list--defs { gap: var(--s3); }
.sop__list strong { color: var(--ink); font-weight: 600; }
.sop__link { color: var(--accent-hover); font-weight: 600; text-decoration: none; }
.sop__link:hover { text-decoration: underline; }

/* ----------------------------------------------------------- Checkbox */
.checkbox {
  margin-top: var(--s4);
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s4);
  min-height: var(--tap);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  cursor: pointer;
}
.checkbox__input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox__box {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--r-input);
  border: 2px solid var(--accent);
  background: transparent;
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.checkbox__box svg { width: 14px; height: 14px; }
.checkbox__input:checked + .checkbox__box {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.checkbox__input:focus-visible + .checkbox__box {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}
.checkbox__label { font-size: 14px; color: var(--ink-muted); line-height: 1.45; }

/* ----------------------------------------------------- Employee intro */
.intro-card {
  margin-top: var(--s5);
  padding: var(--s5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-top-color: var(--hairline-strong);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.intro-card__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent-hover);
}
.intro-card__title { font-size: 24px; letter-spacing: -0.6px; }
.intro-card__text { margin: 0 0 var(--s2); color: var(--ink-muted); font-size: 15px; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r-input);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn--block { width: 100%; }

.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:disabled {
  background: var(--surface-3);
  border-color: var(--hairline);
  color: var(--ink-tertiary);
  cursor: not-allowed;
  transform: none;
}

.btn--secondary {
  background: var(--surface-1);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn--secondary:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  font-size: 12px;
}
.btn--ghost:hover { background: var(--surface-1); color: var(--ink); }

/* Focus rings — accent, 2px */
.btn:focus-visible,
.topbar__back:focus-visible,
.role-card:focus-visible,
.segmented__option:focus-visible,
.input:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- Fields */
.field { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }

.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 11px var(--s3);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  color: var(--ink);
  font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
  font-family: inherit;
}
.input::placeholder { color: var(--ink-tertiary); }
.input:focus { border-color: var(--accent-focus); outline: 2px solid var(--accent-focus); outline-offset: 0; }
/* Make the native date picker icon visible on dark */
.input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.divider { border: none; border-top: 1px solid var(--hairline); margin: var(--s5) 0 0; }

/* --------------------------------------------------------- Segmented */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s1);
  padding: var(--s1);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
}

.segmented__option {
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented__option[aria-checked="true"] {
  background: var(--accent);
  color: #fff;
}
.segmented__option:not([aria-checked="true"]):hover { color: var(--ink); }

/* -------------------------------------------------------- Media items */
.media-item {
  margin-top: var(--s4);
  padding: var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}

.media-item__head { display: flex; align-items: flex-start; gap: var(--s3); }

.media-item__meta { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.media-item__label { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.media-item__hint { font-size: 13px; color: var(--ink-subtle); }

.media-item__body { margin-top: var(--s3); }
.media-item__action, .slot__action { width: 100%; }

/* Check indicator — lavender ring → green when done */
.check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  border: 2px solid var(--accent);
  position: relative;
  margin-top: 1px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.media-item.is-done .check,
.media-item--group.is-done .check {
  background: var(--success);
  border-color: var(--success);
}
.media-item.is-done .check::after,
.media-item--group.is-done .check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ------------------------------------------------------------- Slots */
.slots {
  margin-top: var(--s3);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.slot {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
}
.slot__name { font-size: 13px; font-weight: 500; color: var(--ink-muted); }

/* ----------------------------------------------------------- Preview */
.media-preview {
  margin-top: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.media-preview__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-input);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--surface-3);
  cursor: pointer;
}
.media-preview__frame img,
.media-preview__frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-preview__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}
.media-preview__play svg { width: 20px; height: 20px; }

.media-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}
.media-preview__status {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}
.media-preview__replace {
  background: none;
  border: none;
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: var(--s2);
  min-height: var(--tap);
}

/* Uploading state */
.media-preview__uploading {
  font-size: 13px;
  color: var(--ink-subtle);
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--hairline-strong);
  border-top-color: var(--accent-hover);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- Progress */
.checklist__progress {
  position: sticky;
  top: 64px;
  z-index: 4;
  padding: var(--s3) 0;
  background: linear-gradient(var(--canvas) 80%, transparent);
}
.progress { display: flex; align-items: center; gap: var(--s3); }
.progress__track {
  flex: 1;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 0.3s ease, background 0.3s ease;
}
.progress__fill.is-complete { background: var(--success); }
.progress__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.checklist__footer { margin-top: var(--s6); }

/* ----------------------------------------------------------- Success */
.success {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s4);
  margin-top: var(--s7);
}
.success__icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: rgba(39, 166, 68, 0.12);
  border: 1px solid rgba(39, 166, 68, 0.4);
  color: var(--success);
}
.success__icon svg { width: 30px; height: 30px; }
.success__title { font-size: 22px; letter-spacing: -0.4px; }
.success__text { margin: 0 0 var(--s4); color: var(--ink-muted); font-size: 15px; max-width: 320px; }
.success .btn { max-width: 320px; }

/* ------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: calc(100% - 32px);
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(229, 72, 77, 0.6); }
.toast.is-error::before { content: ""; }
.toast.is-success { border-color: rgba(39, 166, 68, 0.6); }

/* ----------------------------------------------------------- Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: var(--s5);
  animation: fade 0.18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lightbox__stage {
  max-width: 100%;
  max-height: 90dvh;
  display: grid;
  place-items: center;
}
.lightbox__stage img,
.lightbox__stage video {
  max-width: 100%;
  max-height: 90dvh;
  border-radius: var(--r-card);
  border: 1px solid var(--hairline-strong);
}

.lightbox__close {
  position: absolute;
  top: max(var(--s4), env(safe-area-inset-top));
  right: var(--s4);
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  color: var(--ink);
  cursor: pointer;
}
.lightbox.hidden {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

/* -------------------------------------------------------- Config error */
.config-error {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background: var(--canvas);
  z-index: 100;
}
.config-error__card {
  max-width: 360px;
  text-align: center;
  padding: var(--s5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}
.config-error__card h1 { font-size: 20px; margin-bottom: var(--s3); }
.config-error__card p { margin: 0; color: var(--ink-muted); font-size: 14px; }

/* ------------------------------------------------------- Wider screens */
@media (min-width: 600px) {
  .chooser__title { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =====================================================================
   Admin finance — spending dashboard
   ===================================================================== */
.fin { padding: var(--s4) var(--s4) var(--s7); max-width: 860px; margin: 0 auto; }

.fin-tabs { display: flex; gap: var(--s2); margin-bottom: var(--s5); }
.fin-tab {
  appearance: none; border: 1px solid var(--hairline); background: var(--surface-1);
  color: var(--ink-subtle); border-radius: var(--r-pill); padding: 8px 18px;
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; min-height: var(--tap);
  transition: color .15s, border-color .15s, background .15s;
}
.fin-tab:hover { color: var(--ink); }
.fin-tab.is-active { color: var(--ink); border-color: var(--accent); background: rgba(94,106,210,.12); }

.fin-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.fin-actions .btn { width: auto; min-height: 40px; padding: 0 16px; }
.fin-btn-danger { color: var(--danger) !important; }
.fin-note { margin: var(--s3) 0 0; color: var(--success); font-size: 13px; font-weight: 500; }
.fin-hint { margin: var(--s3) 0 0; color: var(--ink-subtle); font-size: 13px; line-height: 1.45; }
.fin-empty { color: var(--ink-subtle); font-size: 14px; margin: var(--s2) 0; }
.fin-h {
  font-size: 10px; font-weight: 700; color: var(--ink-tertiary); letter-spacing: 1.2px;
  text-transform: uppercase; margin: 28px 0 10px;
  display: flex; align-items: center; gap: 10px;
}
.fin-h::after { content: ''; flex: 1; height: 1px; background: var(--hairline); }
.fin-divider { height: 1px; background: var(--hairline); margin: var(--s6) 0; }

/* container used by renderSpending for hero + chart */
.fin-cards { display: block; margin-top: var(--s4); }

/* ---- Hero metric ---- */
.fin-hero {
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 18px;
}
.fin-hero__eyebrow {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--ink-tertiary); margin-bottom: 8px;
}
.fin-hero__amount {
  font-size: 46px; font-weight: 700; letter-spacing: -2.5px; color: var(--ink);
  line-height: 1; font-variant-numeric: tabular-nums;
}
.fin-hero__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.fin-hero__chip {
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--r-pill); padding: 3px 10px; color: var(--ink-subtle); white-space: nowrap;
}
.fin-hero__chip--accent {
  border-color: rgba(94,106,210,0.4); color: var(--accent-hover);
  background: rgba(94,106,210,0.1);
}

/* ---- Monthly bar chart ---- */
.fin-month-chart {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-card); padding: 14px 14px 0; overflow: hidden; margin-bottom: 24px;
}
.fin-month-chart__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--ink-tertiary); margin-bottom: 10px;
}
.fin-month-chart__bars { display: flex; gap: 8px; align-items: flex-end; }
.fin-month-bar { flex: 1; display: flex; flex-direction: column; }
.fin-month-bar__fill {
  flex: 1; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(94,106,210,0.9) 0%, var(--accent) 100%);
  opacity: 0.65; transition: opacity 0.2s;
}
.fin-month-bar__fill.is-current {
  opacity: 1;
  background: linear-gradient(180deg, #828fff 0%, var(--accent) 100%);
}
.fin-month-bar:hover .fin-month-bar__fill { opacity: 1; }

.fin-month-chart__meta {
  display: flex; gap: 8px; padding: 10px 0; border-top: 1px solid var(--hairline);
}
.fin-month-meta { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fin-month-meta__label {
  font-size: 10px; color: var(--ink-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fin-month-meta__value {
  font-size: 12px; font-weight: 700; color: var(--ink-muted); letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.fin-month-meta.is-current .fin-month-meta__value { color: var(--ink); }
.fin-month-meta__count { font-size: 10px; color: var(--ink-tertiary); }

/* ---- Category bars ---- */
/* ---- Month sections ---- */
.fin-month { margin-bottom: 20px; }
.fin-month__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 8px; margin-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.fin-month__label {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-subtle);
}
.fin-month__meta { display: flex; align-items: baseline; gap: 6px; }
.fin-month__total {
  font-size: 15px; font-weight: 700; letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.fin-month__count { font-size: 11px; color: var(--ink-tertiary); }
.fin-month__cats { display: flex; flex-direction: column; gap: 5px; }

.fin-cats { display: flex; flex-direction: column; }
.fin-cat {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-input); padding: 10px 12px 10px 18px;
  position: relative; overflow: hidden; transition: border-color 0.15s;
  cursor: pointer; user-select: none;
}
.fin-cat:hover { border-color: var(--hairline-strong); }
.fin-cat__strip {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.fin-cat__top {
  display: flex; align-items: baseline; gap: 6px;
}
.fin-cat__name { font-size: 13px; font-weight: 500; color: var(--ink); flex: 1; }
.fin-cat__chev {
  font-size: 12px; color: var(--ink-tertiary); transition: transform 0.18s ease;
  flex-shrink: 0; line-height: 1;
}
.fin-cat.is-expanded .fin-cat__chev { transform: rotate(90deg); }
.fin-cat__amount {
  font-size: 14px; font-weight: 700; letter-spacing: -0.5px; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.fin-bar { height: 4px; background: var(--surface-3); border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.fin-bar__fill { height: 100%; background: var(--accent); border-radius: 3px; }
.fin-cat__foot { font-size: 10px; color: var(--ink-tertiary); }

/* Merchant breakdown (revealed on expand) */
.fin-cat__merchants {
  max-height: 0; overflow: hidden;
  transition: max-height 0.22s ease;
}
.fin-cat.is-expanded .fin-cat__merchants {
  max-height: 400px;
}
.fin-cat__merchants-inner {
  padding-top: 8px; margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.fin-merchant {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; gap: 8px;
}
.fin-merchant__name {
  font-size: 12px; color: var(--ink-muted); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.fin-merchant__amt {
  font-size: 12px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.fin-cat__misc-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--danger); background: rgba(229,72,77,0.12);
  border: 1px solid rgba(229,72,77,0.3); border-radius: var(--r-chip);
  padding: 1px 5px; vertical-align: middle; margin-left: 5px;
}

/* Category color tokens */
.fin-cat--supplies .fin-cat__strip,
.fin-cat--supplies .fin-bar__fill { background: #4ade80; }
.fin-cat--payroll .fin-cat__strip,
.fin-cat--payroll .fin-bar__fill { background: #facc15; }
.fin-cat--marketing .fin-cat__strip,
.fin-cat--marketing .fin-bar__fill { background: #60a5fa; }
.fin-cat--fuel .fin-cat__strip,
.fin-cat--fuel .fin-bar__fill { background: #fb923c; }
.fin-cat--insurance .fin-cat__strip,
.fin-cat--insurance .fin-bar__fill { background: #c084fc; }
.fin-cat--tech .fin-cat__strip,
.fin-cat--tech .fin-bar__fill { background: #22d3ee; }
.fin-cat--meals .fin-cat__strip,
.fin-cat--meals .fin-bar__fill { background: #fb7185; }
.fin-cat--labor .fin-cat__strip,
.fin-cat--labor .fin-bar__fill { background: #94a3b8; }
.fin-cat--misc { border-color: rgba(229,72,77,0.2); }
.fin-cat--misc .fin-cat__strip,
.fin-cat--misc .fin-bar__fill { background: var(--danger); opacity: 0.7; }

/* ---- Transaction rows ---- */
.fin-txns, .fin-emps { display: flex; flex-direction: column; }
.fin-txn, .fin-emp {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: var(--r-input);
  border: 1px solid transparent; transition: background 0.1s, border-color 0.1s;
}
.fin-txn:hover, .fin-emp:hover { background: var(--surface-1); border-color: var(--hairline); }
.fin-txn__main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.fin-txn__name, .fin-emp__name {
  font-size: 13px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  transition: color 0.1s;
}
.fin-txn__name:hover { color: var(--ink-muted); }
.fin-txn__name.is-expanded { white-space: normal; overflow: visible; text-overflow: clip; word-break: break-word; }
.fin-txn__date { font-size: 11px; color: var(--ink-tertiary); }
.fin-txn__amt, .fin-emp__amt {
  font-size: 14px; font-weight: 600; color: var(--ink);
  min-width: 80px; text-align: right; font-variant-numeric: tabular-nums;
}
.fin-emp__name { flex: 1; }
.fin-emp__flag { font-size: 10px; color: var(--accent-hover); font-weight: 600; }

.fin-txn__cat, .fin-emp__role {
  appearance: none; background: var(--surface-2); color: var(--ink-muted);
  border: 1px solid var(--hairline); border-radius: var(--r-chip);
  padding: 5px 8px; font: inherit; font-size: 12px; cursor: pointer;
  max-width: 130px; transition: border-color 0.15s, color 0.15s;
}
.fin-txn__cat:hover, .fin-emp__role:hover { border-color: var(--hairline-strong); color: var(--ink); }
.fin-txn__cat:focus-visible, .fin-emp__role:focus-visible { outline: 2px solid var(--accent-focus); }

@media (max-width: 560px) {
  .fin-txn__cat, .fin-emp__role { max-width: 100px; }
}

/* ---- Import progress ----------------------------------------------- */
.imp-progress {
  margin-top: var(--s4);
  padding: var(--s5);
  background: var(--surface-1);
  border: 1px solid var(--accent);
  border-radius: var(--r-card);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.imp-body {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.imp-steps {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.imp-sep {
  color: var(--ink-tertiary);
  font-size: 12px;
  flex-shrink: 0;
}

.imp-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-tertiary);
  transition: color 0.2s ease;
}

.imp-step.is-active { color: var(--ink); }
.imp-step.is-done { color: var(--success); }
.imp-step.is-error { color: var(--danger); }

.imp-step__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  position: relative;
}

.imp-step__icon::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hairline-strong);
  transition: background 0.2s ease;
}

.imp-step.is-active .imp-step__icon::before { display: none; }
.imp-step.is-active .imp-step__icon::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  position: absolute;
}

.imp-step.is-done .imp-step__icon::before {
  width: 14px; height: 14px; background: var(--success); border-radius: 50%;
}
.imp-step.is-done .imp-step__icon::after {
  content: '';
  position: absolute;
  left: 5px; top: 2px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.imp-step.is-error .imp-step__icon::before { background: var(--danger); width: 14px; height: 14px; }
.imp-step.is-error .imp-step__icon::after {
  content: '×';
  position: absolute;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.imp-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.imp-status__msg {
  font-size: 12px;
  color: var(--ink-secondary);
}

.imp-timer {
  font-size: 12px;
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Needs Review queue -------------------------------------------- */
.fin-review {
  margin: 20px 0 24px;
  border: 1px solid rgba(251,146,60,0.3);
  border-radius: var(--r-card);
  background: rgba(251,146,60,0.04);
  overflow: hidden;
}
.fin-review__head {
  display: flex; align-items: center; gap: var(--s2);
  padding: 10px var(--s4);
  border-bottom: 1px solid rgba(251,146,60,0.15);
}
.fin-review__title { font-size: 13px; font-weight: 600; color: var(--ink); flex: 1; }
.fin-review__count {
  font-size: 11px; font-weight: 700;
  color: #fb923c; background: rgba(251,146,60,0.15);
  border: 1px solid rgba(251,146,60,0.3);
  border-radius: var(--r-pill); padding: 2px 8px;
}
.fin-review__hint {
  font-size: 12px; color: var(--ink-subtle); margin: 0;
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid rgba(251,146,60,0.12);
  line-height: 1.4;
}
.fin-review .fin-txns { padding: var(--s2); max-height: 360px; overflow-y: auto; }
.fin-review .fin-txn { border-radius: var(--r-input); }
.fin-review .fin-txn:hover {
  background: rgba(251,146,60,0.06);
  border-color: rgba(251,146,60,0.2);
}
.fin-txn__cat--unset {
  border-color: rgba(251,146,60,0.5) !important;
  color: #fb923c !important;
}

/* ---- Admin checklists ---------------------------------------------- */
.chk-list { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }

.chk-item {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  overflow: hidden;
}
.chk-item[open] { border-color: var(--hairline-strong); }

.chk-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  cursor: pointer;
  list-style: none;
  min-height: var(--tap);
}
.chk-item__head::-webkit-details-marker { display: none; }
.chk-item__head::after {
  content: '';
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-tertiary);
  border-bottom: 2px solid var(--ink-tertiary);
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-right: 4px;
  transition: transform .15s;
}
.chk-item[open] .chk-item__head::after { transform: rotate(-135deg); margin-top: 4px; }

.chk-item__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chk-item__name { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.chk-item__meta { font-size: 12px; color: var(--ink-tertiary); margin-top: 2px; }
.chk-item__when { font-size: 11px; color: var(--ink-subtle); white-space: nowrap; flex-shrink: 0; }

.chk-item__body { padding: 0 var(--s4) var(--s4); border-top: 1px solid var(--hairline); }
.chk-item__signoff { margin: var(--s3) 0 var(--s4); font-size: 13px; color: var(--ink-muted); }

.chk-media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s3);
}
@media (min-width: 480px) {
  .chk-media-grid { grid-template-columns: repeat(3, 1fr); }
}

.chk-media {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: var(--r-input);
  padding: var(--s2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color .15s, background .15s;
}
.chk-media:hover { border-color: var(--accent); background: var(--surface-3); }
.chk-media:focus-visible { outline: 2px solid var(--accent-focus); outline-offset: 2px; }

.chk-media__thumb {
  aspect-ratio: 4 / 3;
  border-radius: var(--r-chip);
  overflow: hidden;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chk-media__thumb img,
.chk-media__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chk-media__video-thumb {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--ink-muted);
}
.chk-media__video-thumb svg {
  width: 32px;
  height: 32px;
  opacity: 0.85;
}
.chk-media__label { font-size: 11px; font-weight: 500; color: var(--ink-subtle); line-height: 1.3; }
