/* Desire Ops — layout and components. Tokens live in tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;   /* kill the grey tap flash on iOS */
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-3));   /* clear the sticky topbar on scroll-into-view */
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  overflow-x: clip;   /* belt-and-suspenders against horizontal scroll on mobile */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
/* Remove the 300ms double-tap delay on interactive controls (touch). */
button, a, input, select, textarea, label { touch-action: manipulation; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── Utilities ────────────────────────────────────────────────────────── */
.muted { color: var(--text-dim); }
.count-note { font-size: var(--fs-sm); color: var(--text-muted); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Boot loader ──────────────────────────────────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 50;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--surface-3);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--surface-3) 88%, var(--text)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--danger {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--danger);
}
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--sm { height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ── Brand logo ───────────────────────────────────────────────────────── */
.brand-logo { display: flex; align-items: center; }
.brand-logo__img {
  display: block;
  width: 100%;
  max-width: 184px;
  height: auto;
  /* The logo ships on a solid-black plate; screen-blend drops the black so
     only the white wordmark + azure/gold accents show on the dark surface. */
  mix-blend-mode: screen;
}
.brand-logo--lg { justify-content: center; }
.brand-logo--lg .brand-logo__img { max-width: 236px; }
/* Light mode: screen-blend can't drop black on a light surface, so present the
   logo on a clean dark plate sized to the wordmark. */
[data-theme="light"] .brand-logo {
  align-self: flex-start;
  background: #0a0d14;
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
}
[data-theme="light"] .brand-logo--lg { align-self: center; }
[data-theme="light"] .brand-logo__img { mix-blend-mode: normal; }

/* ── Fields ───────────────────────────────────────────────────────────── */
.field { display: block; }
.field__label {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
}
.input {
  width: 100%;
  height: 44px;
  padding: 0 var(--sp-3);
  /* 16px, not 14px: iOS Safari auto-zooms any field whose text is under 16px. */
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea.input { height: auto; padding: var(--sp-2) var(--sp-3); resize: vertical; min-height: 44px; }
.input::placeholder { color: var(--text-dim); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-sm);
}

/* ── Login ────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  min-height: 100dvh;   /* dvh tracks the mobile URL bar — no layout jump */
  display: grid;
  place-items: center;
  padding: max(var(--sp-4), env(safe-area-inset-top)) max(var(--sp-4), env(safe-area-inset-right))
           max(var(--sp-4), env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
  background:
    radial-gradient(820px 460px at 50% -12%, rgba(14, 159, 224, 0.13), transparent 70%),
    radial-gradient(560px 360px at 92% 110%, rgba(241, 188, 11, 0.07), transparent 72%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.login-card .brand-logo { margin-bottom: var(--sp-2); }
.login-card__sub {
  margin-top: calc(-1 * var(--sp-2));
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* ── App shell ────────────────────────────────────────────────────────── */
.app { min-height: 100vh; min-height: 100dvh; }
.app__main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: max(var(--sp-4), env(safe-area-inset-top)) var(--sp-3)
           max(var(--sp-4), env(safe-area-inset-bottom));
  padding-left: max(var(--sp-3), env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;   /* scrolling the drawer never chains to the page */
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  z-index: 30;
}
.sidebar > .brand-logo { padding: 0 var(--sp-2); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.nav__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--accent);
}
.nav__icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav__item span:nth-child(2) { flex: 1; }
.nav__badge {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: var(--surface-3);
  padding: 2px var(--sp-1);
  border-radius: var(--r-sm);
}

.sidebar__footer {
  margin-top: auto;
  padding: 0 var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.sidebar__vision {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { width: 15px; height: 15px; display: block; }
.theme-toggle__moon, .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: inline-flex; }
[data-theme="light"] .theme-toggle__sun { display: inline-flex; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 max(var(--sp-4), env(safe-area-inset-right)) 0 max(var(--sp-4), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__toggle { display: none; }
.topbar__title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.topbar__user { font-size: var(--fs-sm); color: var(--text-muted); }

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) max(var(--sp-4), env(safe-area-inset-right))
           calc(var(--sp-7) + env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left));
  animation: fade-in 220ms var(--ease);
}
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
  border: none;
}

/* ── Cards & grid ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.section-head h2 { font-size: var(--fs-md); font-weight: 600; }
.section-sub { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-4); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--transition), transform var(--transition);
}
.kpi--live { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.kpi__head { display: flex; align-items: center; gap: var(--sp-2); }
.kpi:has(.pill) .kpi__head { padding-right: var(--sp-7); }
.kpi__icon {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--accent);
  background: var(--accent-soft);
}
.kpi__icon svg { width: 17px; height: 17px; }
.kpi__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.kpi__value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: var(--lh-tight); }
.kpi__value--muted { color: var(--text-dim); }
.kpi__meta { font-size: var(--fs-xs); color: var(--text-dim); }
.pill {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-3);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-3);
}

/* ── Trend chart ──────────────────────────────────────────────────────── */
.trend {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  height: 160px;
  margin-top: var(--sp-3);
}
.trend__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); height: 100%; }
.trend__bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.trend__bar {
  width: 70%;
  max-width: 40px;
  min-height: 4px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 45%, transparent));
  transition: height 480ms var(--ease);
}
.trend__label { font-size: var(--fs-xs); color: var(--text-dim); }

/* ── Recent / list ────────────────────────────────────────────────────── */
.entry-list { display: flex; flex-direction: column; }
.entry-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
}
.entry-row:first-child { border-top: none; }
.entry-row__main { flex: 1; min-width: 0; }
.entry-row__title { font-size: var(--fs-sm); font-weight: 500; }
.entry-row__sub { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-row__amount { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Table ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-3); text-align: left; vertical-align: top; }
.table th:first-child, .table td:first-child { white-space: nowrap; }
.table .num, .table .actions { white-space: nowrap; }
.table th {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-strong);
}
.table td { border-bottom: 1px solid var(--border); color: var(--text); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table .note-cell { color: var(--text-muted); max-width: 280px; white-space: normal; }
.table .actions { text-align: right; }
.row-actions { display: inline-flex; gap: var(--sp-1); }

/* ── Revenue form ─────────────────────────────────────────────────────── */
.rev-form {
  display: grid;
  grid-template-columns: 150px 150px 1fr;
  gap: var(--sp-3);
  align-items: end;
}
.rev-form .field--wide { grid-column: 1 / -1; }
.rev-form__actions { grid-column: 1 / -1; display: flex; gap: var(--sp-2); }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.total-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  margin-top: var(--sp-2);
  border-top: 1px solid var(--border-strong);
}
.total-line__label { font-size: var(--fs-sm); color: var(--text-muted); }
.total-line__value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ── Checkbox field & inline tag ──────────────────────────────────────── */
.field--check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 44px;
}
.field--check .field__label { margin-bottom: 0; }
.checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.tag {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}

/* ── KPI cards (KPIs view) ────────────────────────────────────────────── */
.kpi-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
.kpi-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.kpi-card__head { display: flex; align-items: center; gap: var(--sp-2); }
.kpi-card__name { font-size: var(--fs-sm); font-weight: 600; }
.kpi-card__del { margin-left: auto; width: 32px; height: 32px; }
.kpi-card__del svg { width: 16px; height: 16px; }
.kpi-card__del:hover { color: var(--danger); }
.kpi-card__value {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  font-variant-numeric: tabular-nums;
}
.kpi-card__target { font-size: var(--fs-xs); color: var(--text-dim); }
.kpi-card__auto { font-size: var(--fs-xs); color: var(--text-muted); align-self: center; }
.kpi-card__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.kpi-mini { flex: 1; min-width: 84px; display: flex; flex-direction: column; gap: var(--sp-1); }
.kpi-mini__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }
.input--sm { height: 36px; font-size: var(--fs-sm); }

.kpi-bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.kpi-bar__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 480ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .kpi-bar__fill, .trend__bar { transition: none; }
}

/* ── Empty state & placeholders ───────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-muted);
}
.empty__icon { color: var(--text-dim); }
.empty__icon svg { width: 32px; height: 32px; }
.empty h3 { font-size: var(--fs-md); color: var(--text); font-weight: 600; }
.empty p { font-size: var(--fs-sm); max-width: 380px; }

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  text-align: center;
}
.placeholder__badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
}
.placeholder__icon { color: var(--text-dim); }
.placeholder__icon svg { width: 40px; height: 40px; }
.placeholder h2 { font-size: var(--fs-lg); font-weight: 600; }
.placeholder p { font-size: var(--fs-sm); color: var(--text-muted); max-width: 420px; }

.toast {
  position: fixed;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 2 * var(--sp-4));
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  z-index: 60;
  animation: fade-in 160ms var(--ease);
}
.toast--error { border-color: var(--danger); color: var(--danger); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app__main { margin-left: 0; }
  .topbar__toggle { display: inline-grid; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .rev-form { grid-template-columns: 1fr 1fr; }
  .rev-form .field--source { grid-column: 1 / -1; }
  .kpi-card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .rev-form { grid-template-columns: 1fr; }
  .view {
    padding: var(--sp-4) max(var(--sp-3), env(safe-area-inset-right))
             calc(var(--sp-6) + env(safe-area-inset-bottom)) max(var(--sp-3), env(safe-area-inset-left));
  }
  .topbar { padding: 0 max(var(--sp-3), env(safe-area-inset-right)) 0 max(var(--sp-3), env(safe-area-inset-left)); }
  .topbar__user { display: none; }
}

/* ── Field Revenue (ServiceM8) ────────────────────────────────────────── */
.fr-weeknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
}
.fr-weeknav__center { text-align: center; }
.fr-weeknav__label {
  display: block;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.fr-weeknav__dates {
  display: block;
  font-size: var(--fs-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fr-weeknav__tag { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--accent-strong); }

.fr-chip {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--warning);
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  vertical-align: middle;
  margin-left: var(--sp-2);
}

.fr-day-group { margin-bottom: var(--sp-3); }
.fr-day-group:last-child { margin-bottom: 0; }

.fr-day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
}
.fr-day__label { display: flex; align-items: baseline; gap: var(--sp-2); }
.fr-day__wd { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.fr-day__dt { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fr-day__meta { display: flex; align-items: center; gap: var(--sp-3); }
.fr-day__total { font-size: var(--fs-md); font-weight: 700; color: var(--positive); font-variant-numeric: tabular-nums; }
.fr-day__flag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}
.fr-day__flag svg { width: 12px; height: 12px; flex-shrink: 0; }
.fr-day--below { border-left-color: var(--danger); background: var(--danger-soft); }
.fr-day--below .fr-day__total { color: var(--danger); }

.fr-jobs { display: flex; flex-direction: column; gap: var(--sp-2); }
.fr-job {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.fr-job:hover { border-color: var(--border-strong); }
.fr-job--open { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

.fr-job__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  background: transparent;
  border: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.fr-job__header:hover { background: var(--surface-3); }

.fr-job__info { flex: 1; min-width: 0; }
.fr-job__name { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-job__loc { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.fr-badge {
  display: inline-block;
  margin-top: var(--sp-1);
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid currentColor;
}
.fr-badge--wo { color: var(--accent-strong); background: var(--accent-soft); }
.fr-badge--complete { color: var(--positive); background: var(--positive-soft); }
.fr-badge--other { color: var(--text-muted); background: var(--surface-3); border-color: var(--border-strong); }

.fr-job__right { text-align: right; flex-shrink: 0; min-width: 92px; }
.fr-job__total { display: block; font-size: var(--fs-md); font-weight: 700; color: var(--positive); font-variant-numeric: tabular-nums; }
.fr-job__gst { display: block; font-size: 0.625rem; color: var(--text-dim); }
.fr-job__upsell { display: block; font-size: var(--fs-xs); color: var(--positive); margin-top: 2px; }

.fr-job__chev {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 20px; height: 20px;
  color: var(--text-dim);
  transition: transform var(--transition), color var(--transition);
}
.fr-job__chev svg { width: 16px; height: 16px; }
.fr-job--open .fr-job__chev { transform: rotate(180deg); color: var(--accent-strong); }

.fr-job__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--transition); }
.fr-job--open .fr-job__body { grid-template-rows: 1fr; }
.fr-job__body-inner { overflow: hidden; }
.fr-job--open .fr-job__body-inner { border-top: 1px solid var(--border); }
.fr-job__body-pad { padding: var(--sp-3) var(--sp-4); }

.fr-block { margin-bottom: var(--sp-3); }
.fr-block:last-child { margin-bottom: 0; }
.fr-block__label {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.fr-li { display: flex; gap: var(--sp-3); font-size: var(--fs-sm); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.fr-li:last-child { border-bottom: none; }
.fr-li__name { flex: 1; min-width: 0; }
.fr-li__qty { color: var(--text-muted); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.fr-li__price { color: var(--text-muted); min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.fr-li__sub { color: var(--positive); min-width: 80px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.fr-li--muted { color: var(--text-dim); border-bottom: none; }

.fr-utags { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.fr-utag {
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  color: var(--positive);
  background: var(--positive-soft);
  border: 1px solid color-mix(in srgb, var(--positive) 35%, transparent);
}

@media (max-width: 480px) {
  .fr-job__upsell { display: none; }
}

/* ── DM Payment Audit ────────────────────────────────────────────────────── */
.dm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.dm-head__title { font-size: var(--fs-lg); margin: 0; }
.dm-head__sub { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 60ch; }
.dm-rerun { display: inline-flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.dm-rerun svg { width: 16px; height: 16px; }

.dm-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.dm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--r-md);
}
.dm-row--ok { border-left-color: var(--positive); }
.dm-row--flag { border-left-color: var(--danger); }
.dm-row__main { min-width: 0; }
.dm-row__name { display: block; font-size: var(--fs-sm); font-weight: 600; }
.dm-row__detail { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.dm-row__right { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.dm-row__amount { font-size: var(--fs-md); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.dm-row__per { font-size: var(--fs-xs); color: var(--text-dim); font-weight: 500; margin-left: 2px; }

.dm-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.dm-badge--ok { color: var(--positive); background: var(--positive-soft); }
.dm-badge--danger { color: var(--danger); background: var(--danger-soft); }
.dm-badge--muted { color: var(--text-muted); background: var(--surface-3); border-color: var(--border-strong); }

/* ── Staff Hours (ServiceM8 clock-on/off) ───────────────────────────────── */
.ts-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; justify-content: flex-end; }
.ts-updated { font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ts-refresh { display: inline-flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.ts-refresh svg { width: 16px; height: 16px; }
.ts-refresh.is-loading svg { animation: spin 0.7s linear infinite; }
@media (prefers-reduced-motion: reduce) { .ts-refresh.is-loading svg { animation: none; } }

.ts-hrs { font-variant-numeric: tabular-nums; color: var(--text); font-size: var(--fs-sm); }
.ts-hrs--zero { color: var(--text-dim); }
.ts-unit { color: var(--text-muted); font-size: var(--fs-xs); }
.ts-status {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.ts-dot { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--text-dim); }
.ts-on { color: var(--positive); font-weight: 600; }
.ts-on .ts-dot { background: var(--positive); box-shadow: 0 0 0 3px var(--positive-soft); }
.ts-capped {
  display: inline-block; margin-left: var(--sp-1);
  padding: 1px 6px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  color: var(--gold); background: var(--gold-soft); cursor: default;
}
.ts-caveat { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--text-dim); line-height: var(--lh-base); }
.ts-caveat .ts-capped { margin-left: 2px; }
.ts-caveat a { color: var(--accent-strong); text-decoration: none; }
.ts-caveat a:hover { text-decoration: underline; }

/* ── Staff Hours: crew punch rows ────────────────────────────────────────
   One responsive component: aligned self-labelled columns on desktop, a
   stacked card per crew member on phones (same markup, grid re-templated). */
.tsr-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.tsr {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.tsr:hover { border-color: var(--border-strong); }
.tsr--on { border-color: color-mix(in srgb, var(--positive) 30%, var(--border)); }

.tsr-main {
  display: grid;
  align-items: start;
  gap: var(--sp-3) var(--sp-2);
  padding: var(--sp-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "id    id    tg"
    "today on    off"
    "week  week  week"
    "month month month";
}
.tsr-id { grid-area: id; display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.tsr-main > .tsc-toggle { grid-area: tg; justify-self: end; }
.tsr-stat--today { grid-area: today; }
.tsr-stat--on    { grid-area: on; }
.tsr-stat--off   { grid-area: off; }
.tsr-stat--week  { grid-area: week; }
.tsr-stat--month { grid-area: month; }

.tsr-avatar {
  display: grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700; font-size: var(--fs-base);
}
.tsr--on .tsr-avatar {
  background: var(--positive-soft); color: var(--positive);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--positive) 40%, transparent);
}
.tsr-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tsr-name {
  font-size: var(--fs-base); font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tsr-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tsr-stat__label {
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}
.tsr-stat__value { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.tsr-stat__value .ts-hrs { font-size: inherit; font-weight: inherit; }
.tsr-stat__value .ts-unit { font-size: 0.72em; font-weight: 500; }
.tsr-stat--today .tsr-stat__value { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }

/* Phone: times one step smaller so they never wrap in a third-width column;
   week + month read as a quieter footer line under the day trio */
@media (max-width: 899px) {
  .tsr-main > .tsc-toggle { align-self: center; }
  .tsr-stat--on .tsr-stat__value, .tsr-stat--off .tsr-stat__value { font-size: var(--fs-sm); line-height: 1.6; }
  .tsr-stat--week, .tsr-stat--month {
    flex-direction: row; align-items: baseline; gap: var(--sp-2);
    padding-top: var(--sp-1);
  }
  .tsr-stat--week .tsr-stat__value, .tsr-stat--month .tsr-stat__value { font-size: var(--fs-sm); }
}

/* Desktop: everything on one aligned line */
@media (min-width: 900px) {
  .tsr-main {
    grid-template-columns: minmax(0, 1.9fr) repeat(5, minmax(0, 1fr)) auto;
    grid-template-areas: "id today on off week month tg";
    padding: var(--sp-3) var(--sp-4);
  }
}

.tsr-detail { border-top: 1px solid var(--border); background: var(--surface-1); }

/* ── Staff Hours: per-staff calendar (More info) ──────────────────────── */
.tsc-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.tsc-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.tsc-toggle:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.tsc-toggle svg { width: 16px; height: 16px; transition: transform var(--transition); }
.tsc-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.tsc-panel { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-4); }
.tsr-detail:not([hidden]) .tsc-panel { animation: tsc-in 180ms var(--ease); }
@keyframes tsc-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.tsc-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.tsc-nav-group { display: flex; align-items: center; gap: var(--sp-2); }
.tsc-nav { width: 32px; height: 32px; padding: 0; font-size: var(--fs-md); line-height: 1; }
.tsc-nav:disabled { opacity: 0.4; cursor: not-allowed; }
.tsc-month { min-width: 9ch; text-align: center; font-weight: 600; color: var(--text); }
.tsc-summary { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Month strip — each square is a day, tinted by hours worked */
.tsc-strip { display: flex; flex-direction: column; gap: var(--sp-2); max-width: 360px; }
.tsc-weekdays, .tsc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-1); }
.tsc-weekdays span { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--text-dim); }
.tsc-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: var(--fs-xs); font-variant-numeric: tabular-nums; color: var(--text-muted);
  background: var(--surface-3);
}
button.tsc-cell { cursor: pointer; transition: transform var(--transition), box-shadow var(--transition); }
button.tsc-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
button.tsc-cell:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.tsc-cell--pad { background: transparent; }
.tsc-cell--empty { background: var(--surface-1); color: var(--text-dim); }
.tsc-cell--h1 { background: color-mix(in srgb, var(--accent) 20%, var(--surface-1)); color: var(--text); }
.tsc-cell--h2 { background: color-mix(in srgb, var(--accent) 40%, var(--surface-1)); color: var(--text); }
.tsc-cell--h3 { background: color-mix(in srgb, var(--accent) 64%, var(--surface-1)); color: var(--accent-contrast); font-weight: 600; }
.tsc-cell--h4 { background: color-mix(in srgb, var(--accent) 88%, var(--surface-1)); color: var(--accent-contrast); font-weight: 600; }
.tsc-cell--on { background: var(--gold-soft); color: var(--gold-strong); border-color: var(--gold); font-weight: 700; }
.tsc-cell--flag { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.tsc-cell--today { box-shadow: inset 0 0 0 2px var(--accent-ring); }

/* Day list — the legible on/off detail */
.tsc-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.tsc-list-empty { padding: var(--sp-3) 0; font-size: var(--fs-sm); color: var(--text-dim); }
.tsc-week__label { margin-bottom: var(--sp-1); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.tsc-day { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-top: 1px solid var(--border); border-radius: var(--r-sm); transition: background var(--transition); }
.tsc-day--flash { background: var(--accent-soft); }
.tsc-day__date { min-width: 96px; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.tsc-day__shifts { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.tsc-shift {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: var(--r-full); background: var(--surface-3); color: var(--text);
  font-size: var(--fs-xs); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tsc-shift--live { background: var(--gold-soft); color: var(--gold-strong); font-weight: 600; }
.tsc-shift--live .ts-dot { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.tsc-shift--miss { background: var(--danger-soft); color: var(--danger); }
.tsc-shift--long { background: var(--gold-soft); color: var(--gold-strong); }
.tsc-total { font-size: var(--fs-sm); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tsc-total--live { color: var(--gold-strong); }
.tsc-total--zero { color: var(--text-dim); font-weight: 400; }
.tsc-fix {
  padding: 1px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-full);
  background: transparent; color: var(--accent-strong); font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
}
.tsc-fix:hover { background: var(--accent-soft); }
.tsc-fix:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

/* Admin: add / fix a punch */
.tsc-admin { padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.tsc-admin-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); }
.tsc-admin-toggle svg { width: 16px; height: 16px; }
.tsc-admin-form { margin-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.tsc-admin-grid { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.tsc-admin-grid label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.tsc-admin-grid input, .tsc-admin-grid select {
  padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-1); color: var(--text); font: inherit; font-weight: 400; color-scheme: dark;
}
[data-theme="light"] .tsc-admin-grid input, [data-theme="light"] .tsc-admin-grid select { color-scheme: light; }
.tsc-admin-grid input:focus-visible, .tsc-admin-grid select:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; border-color: var(--accent); }
.tsc-admin-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.tsc-admin-hint { font-size: var(--fs-xs); color: var(--text-dim); }

@media (max-width: 640px) {
  .tsc-panel { padding: var(--sp-3); }
  .tsc-day__date { min-width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .tsr-detail:not([hidden]) .tsc-panel { animation: none; }
  button.tsc-cell:hover { transform: none; }
}

/* ── Payments (Stripe) ────────────────────────────────────────────────── */
.pay-list { display: flex; flex-direction: column; }
.pay-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
}
.pay-row:first-child { border-top: none; }
.pay-row__day { text-align: center; min-width: 44px; flex-shrink: 0; }
.pay-row__wd { display: block; font-size: var(--fs-sm); color: var(--accent-strong); font-weight: 700; }
.pay-row__dt { display: block; font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pay-row__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; }
.pay-row__desc {
  width: 100%;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pay-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid currentColor;
  text-transform: capitalize;
}
.pay-badge--ok { color: var(--positive); background: var(--positive-soft); }
.pay-badge--refund { color: var(--warning); background: var(--gold-soft); }
.pay-row__amount {
  flex-shrink: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--positive);
  font-variant-numeric: tabular-nums;
}
.pay-row__amount--refund { color: var(--text-dim); text-decoration: line-through; }

/* ── Tasks (Notion) ───────────────────────────────────────────────────── */
.task-hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.task-groups { display: flex; flex-direction: column; gap: var(--sp-4); }
.task-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.task-group__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.task-group__label--overdue { color: var(--danger); }
.task-group__label--today { color: var(--accent-strong); }

.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
}
.task-row:first-child { border-top: none; }
.task-row__marker {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: var(--r-full);
  background: var(--text-dim);
}
.task-row__marker--ok { background: var(--positive); }
.task-row__marker--info { background: var(--accent); }
.task-row__marker--warn { background: var(--warning); }
.task-row__marker--danger { background: var(--danger); }
.task-row__marker--muted { background: var(--text-dim); }

.task-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.task-row__title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
a.task-row__title { display: inline-flex; align-items: center; gap: var(--sp-1); }
a.task-row__title:hover { color: var(--accent-strong); }
.task-row__ext { display: inline-grid; place-items: center; color: var(--text-dim); }
.task-row__ext svg { width: 13px; height: 13px; }
a.task-row__title:hover .task-row__ext { color: var(--accent-strong); }

.task-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.task-chip {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  border: 1px solid currentColor;
}
.task-chip--ok { color: var(--positive); background: var(--positive-soft); }
.task-chip--info { color: var(--accent-strong); background: var(--accent-soft); }
.task-chip--warn { color: var(--warning); background: var(--gold-soft); }
.task-chip--danger { color: var(--danger); background: var(--danger-soft); }
.task-chip--muted { color: var(--text-muted); background: var(--surface-3); border-color: var(--border-strong); }
.task-row__due { font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.task-row__due--over { color: var(--danger); font-weight: 600; }

/* ── Xero (read-only accounting) ──────────────────────────────────────── */
.pay-badge--over { color: var(--danger); background: var(--danger-soft); }
.pay-row__amount--out { color: var(--text); }
.amount-pos { color: var(--positive); }
.amount-neg { color: var(--danger); }
.xero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.xero-sub {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.placeholder .btn { margin-top: var(--sp-2); text-decoration: none; }

/* ── Dashboard — section summary cards ────────────────────────────────── */
.spinner--sm { width: 18px; height: 18px; border-width: 2px; }

.dash-head { margin-bottom: var(--sp-1); }
.dash-head__title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }
.dash-head__sub { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--text-muted); }
.dash-head__stamp { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }

.sum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  gap: var(--sp-3);
}
.sum-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 172px;
  padding: var(--sp-4);
  text-align: left;
  color: var(--text);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.sum-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.sum-card__top { display: flex; align-items: center; justify-content: space-between; }
.sum-card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
}
.sum-card__icon svg { width: 19px; height: 19px; }
.sum-card__icon--azure { color: var(--accent); background: var(--accent-soft); }
.sum-card__icon--gold { color: var(--gold); background: var(--gold-soft); }
.sum-card__tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-3);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}
.sum-card__title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.sum-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  justify-content: flex-end;
}
.sum-card__stat { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: var(--lh-tight); }
.sum-card__stat--muted { color: var(--text-dim); font-size: var(--fs-lg); }
.sum-card__label { font-size: var(--fs-xs); color: var(--text-dim); }
.sum-card__sub { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--text-muted); }
.sum-card__warn { margin-top: var(--sp-1); font-size: var(--fs-xs); font-weight: 600; color: var(--gold); }

@media (max-width: 480px) {
  .sum-grid { grid-template-columns: 1fr; }
}

/* ══ Mobile optimisation ══════════════════════════════════════════════════
   Touch ergonomics + phone layout. Keyed on POINTER type (touch targets)
   and WIDTH (layout reflow). The JARVIS azure/gold system is unchanged —
   this only changes how existing components sit on a small/touch screen. */

/* ── Touch targets ───────────────────────────────────────────────────────
   Enlarge to the 44px HIG minimum on coarse pointers only, so a narrow
   desktop window keeps the tight controls while phones/tablets get room. */
@media (pointer: coarse) {
  .btn { min-height: var(--tap-min); }
  .btn--sm { min-height: var(--tap-min); }
  .icon-btn { width: var(--tap-min); height: var(--tap-min); }
  .theme-toggle { min-height: var(--tap-min); }
  .nav__item { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
  .tsc-toggle { width: var(--tap-min); height: var(--tap-min); }
  .tsc-nav { width: var(--tap-min); height: var(--tap-min); }
  .tsc-fix { min-height: 36px; padding: var(--sp-1) var(--sp-3); }
  .tsc-cell { min-height: 40px; }
  .input--sm { font-size: var(--fs-base); min-height: var(--tap-min); }
  .tsc-admin-grid input, .tsc-admin-grid select { min-height: var(--tap-min); }
}

/* ── Small screens: headers wrap, calendar detail stacks ────────────────── */
@media (max-width: 640px) {
  .section-head { flex-wrap: wrap; }
  .tsc-admin-grid { flex-direction: column; align-items: stretch; }
  .tsc-admin-grid label { width: 100%; }
  .tsc-day { flex-wrap: wrap; }
}
