/* =========================================================================
   App design system
   -------------------------------------------------------------------------
   Single source of truth for visual style. Everything is built from CSS
   custom properties so a future dark mode is one block of overrides.
   ========================================================================= */

:root {
  /* Color — neutral surface palette + one indigo accent */
  --bg:             #f7f8fa;
  --surface:        #ffffff;
  --surface-2:      #f3f4f6;
  --surface-hover:  #f9fafb;

  --border:         #e5e7eb;
  --border-strong:  #d1d5db;

  --text:           #0f172a;
  --text-muted:     #64748b;
  --text-subtle:    #94a3b8;
  --text-inverse:   #ffffff;

  --accent:         #4f46e5;
  --accent-hover:   #4338ca;
  --accent-soft:    #eef2ff;
  --accent-text:    #3730a3;

  --danger:         #dc2626;
  --danger-hover:   #b91c1c;
  --danger-soft:    #fee2e2;
  --danger-text:    #991b1b;

  --success:        #059669;
  --success-soft:   #d1fae5;
  --success-text:   #065f46;

  --warning:        #d97706;
  --warning-soft:   #fef3c7;
  --warning-text:   #92400e;

  /* Effects */
  --shadow-sm:  0 1px 2px rgb(15 23 42 / 0.04);
  --shadow:     0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md:  0 4px 12px rgb(15 23 42 / 0.06), 0 2px 4px rgb(15 23 42 / 0.04);
  --shadow-lg:  0 10px 24px rgb(15 23 42 / 0.08), 0 4px 8px rgb(15 23 42 / 0.04);

  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

  --leading-tight:  1.25;
  --leading-snug:   1.4;
  --leading-normal: 1.55;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --nav-h:        60px;
  --container-w:  1200px;
  --container-px: var(--space-6);
}

/* =========================================================================
   Reset / base
   ========================================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p  { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-hover); }

button { font-family: inherit; }

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

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

/* =========================================================================
   App shell — top navbar + main container
   ========================================================================= */

.app-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(8px);
}

.app-nav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text);
  letter-spacing: -0.01em;
}

.app-nav__brand-logo {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, black) 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  transition: background var(--t-fast), color var(--t-fast);
}

.app-nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-nav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.app-nav__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* Secondary nav — workspace admin sections, sits directly under the top
   navbar. Markup lives in base_workspace.html (.app-subnav). */
.app-subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  z-index: 30;
}

.app-subnav__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--container-px);
  height: 46px;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
}

.app-subnav__link {
  display: inline-flex;
  align-items: center;
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}

.app-subnav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-subnav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Active-tenant chip in the navbar */
.nav-tenant-form { margin: 0; }
.nav-tenant {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  max-width: 220px;
}
.nav-tenant:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.nav-tenant__logo {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, black));
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.nav-tenant__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-tenant__chev {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.app-nav__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2) 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.app-nav__user:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

/* avatar circle */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, black));
  color: white;
  font-weight: 600;
  font-size: var(--text-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.avatar--lg { width: 40px; height: 40px; font-size: var(--text-base); }

/* =========================================================================
   Container + page header
   ========================================================================= */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: var(--space-10) var(--container-px) var(--space-16);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.page-header__titles { min-width: 0; }

.page-title {
  font-size: var(--text-3xl);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-2);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: var(--text-md);
  max-width: 64ch;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* =========================================================================
   Card / panel
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.card__body { padding: var(--space-6); }

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* tight card variant for auth screens */
.card--auth {
  width: 100%;
  max-width: 420px;
  margin: var(--space-12) auto;
  border-radius: var(--radius-lg);
}
.card--auth .card__body { padding: var(--space-8); }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), box-shadow var(--t-fast),
              transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverse);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

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

.btn--danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}
.btn--danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: var(--text-inverse);
}

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

.btn--sm   { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--lg   { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { padding: 0; width: 36px; }
.btn--full { width: 100%; }

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* =========================================================================
   Forms
   ========================================================================= */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field + .field { margin-top: var(--space-4); }

.label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0 var(--space-3);
  height: 38px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast);
  appearance: none;
}

.textarea {
  height: auto;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
  min-height: 96px;
}

.input::placeholder { color: var(--text-subtle); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--text-subtle); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field-error { color: var(--danger-text); }

/* horizontal form row (label left, input right) — for detail/edit pages */
.form-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  column-gap: var(--space-6);
  row-gap: var(--space-5);
  align-items: center;
}

.form-grid > .label { justify-self: end; text-align: right; }

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
    row-gap: var(--space-2);
  }
  .form-grid > .label { justify-self: start; text-align: left; }
}

/* search-style input with leading icon */
.input-search {
  position: relative;
  display: flex;
  align-items: center;
}
.input-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}
.input-search .input {
  padding-left: 36px;
}

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

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover { background: var(--surface-hover); }

.table a {
  color: var(--text);
  font-weight: 500;
}
.table a:hover { color: var(--accent); }

.table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* =========================================================================
   Badges / status pills
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.badge--accent  { background: var(--accent-soft);  color: var(--accent-text);  border-color: transparent; }
.badge--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: transparent; }

.badge::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.65;
}

/* =========================================================================
   Alerts (flash messages)
   ========================================================================= */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  border: 1px solid transparent;
}

.alert + .alert { margin-top: var(--space-2); }

.alert--info    { background: var(--accent-soft);  color: var(--accent-text);  }
.alert--success { background: var(--success-soft); color: var(--success-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text);  }

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.flash-stack {
  margin-bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* =========================================================================
   Stat cards (admin dashboards)
   ========================================================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-card__sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* =========================================================================
   Empty states + utility
   ========================================================================= */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state h3 { margin-bottom: var(--space-2); color: var(--text); }

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-6) 0;
}

.muted   { color: var(--text-muted); }
.subtle  { color: var(--text-subtle); }
.mono    { font-family: var(--font-mono); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }

.stack > * + *      { margin-top: var(--space-4); }
.stack-sm > * + *   { margin-top: var(--space-2); }
.stack-lg > * + *   { margin-top: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.cluster--end { justify-content: flex-end; }

/* =========================================================================
   Hero / landing
   ========================================================================= */

.hero-landing {
  padding: var(--space-16) 0 var(--space-12);
  text-align: center;
}

.hero-landing__eyebrow {
  display: inline-block;
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-6);
}

.hero-landing__title {
  font-size: var(--text-4xl);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
  background: linear-gradient(180deg, var(--text) 0%, #475569 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-landing__lede {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 56ch;
  margin: 0 auto var(--space-8);
}

/* =========================================================================
   Confirm-destruction screen
   ========================================================================= */

.confirm-card {
  border-color: var(--danger-soft);
  background: linear-gradient(180deg, #fff 0%, var(--danger-soft) 240%);
}

.confirm-card .card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* =========================================================================
   Error pages (403 / 404 / 429 / 500) — self-contained, no app nav
   ========================================================================= */

.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.error-card {
  max-width: 420px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-10) var(--space-8);
}

.error-card__code {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.error-card__title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-xl);
  color: var(--text);
}

.error-card__msg {
  margin: 0 0 var(--space-6);
  color: var(--text-muted);
  line-height: 1.5;
}

/* =========================================================================
   Responsive tweaks
   ========================================================================= */

@media (max-width: 720px) {
  :root { --container-px: var(--space-4); }
  .app-nav__links { gap: 0; }
  .app-nav__link { padding: 6px var(--space-2); }
  .app-subnav__inner { gap: 0; height: 42px; }
  .app-subnav__link { padding: 6px var(--space-2); }
  .page-title { font-size: var(--text-2xl); }
  .hero-landing__title { font-size: var(--text-3xl); }
}

/* ---- Language switcher (project/templates/_macros/forms.html) ---------- */
.locale-switch {
  display: inline-flex;
  gap: 2px;
  margin: 0;
}
.locale-switch__btn {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--text-xs, 0.75rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.6;
  cursor: pointer;
}
.locale-switch__btn:hover { opacity: 1; }
.locale-switch__btn.is-active { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }

/* ---- Product helpers (The Maid) ----------------------------------------- */
/* List + side form layout used by catalog screens; stacks on narrow screens. */
.catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-5, 20px);
  align-items: start;
}
@media (max-width: 900px) {
  .catalog-layout { grid-template-columns: minmax(0, 1fr); }
}
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.nowrap { white-space: nowrap; }
.table tbody tr.is-muted td { opacity: 0.55; }
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.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;
}

/* ---- Forms & detail pages ------------------------------------------------ */
.form-narrow { max-width: 860px; }
.form-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4, 16px) var(--space-5, 20px);
}
.form-cols > .field + .field { margin-top: 0; }
.form-cols--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-cols .span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .form-cols, .form-cols--4 { grid-template-columns: minmax(0, 1fr); }
  .form-cols .span-2 { grid-column: auto; }
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 16px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-5, 20px);
}
.section { margin-bottom: var(--space-5, 20px); }
.detail-grid--2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }
.table tfoot th { border-top: 2px solid var(--border-strong); text-align: left; }
.table tfoot th.num { text-align: right; }
.kv-list { margin: 0; }
.kv { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 8px; padding: 6px 0; }
.kv + .kv { border-top: 1px solid var(--border, rgba(0,0,0,.06)); }
.kv dt { color: var(--text-muted, #6b7280); font-size: 0.875rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.notes { white-space: pre-line; margin-top: var(--space-3, 12px); }
.warn-text { color: var(--warning-text); }
.table tbody tr.is-current td { background: var(--success-soft); }
.table-wrap--flush { border: 0; border-radius: 0; }
.table-divider td { padding-top: 12px; }
.absence-form { border-top: 1px solid var(--border, rgba(0,0,0,.08)); padding-top: var(--space-4, 16px); }

/* ---- Availability grid -------------------------------------------------- */
.avail-wrap { overflow-x: auto; }
.avail { border-collapse: separate; border-spacing: 3px; user-select: none; }
.avail th { font-size: 0.75rem; font-weight: 600; color: var(--text-muted, #6b7280); padding: 0 6px; text-align: center; }
.avail tbody th { text-align: right; font-variant-numeric: tabular-nums; }
.avail td {
  width: 44px; height: 22px; border-radius: 4px;
  background: var(--surface-2);
}
.avail td.is-on { background: var(--accent); }
.avail--edit td { cursor: pointer; }
.avail--edit td:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.avail td label { display: block; width: 100%; height: 100%; cursor: pointer; }
.avail td input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avail td:focus-within { outline: 2px solid var(--brand-accent, var(--success)); outline-offset: 1px; }
.form-cols--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .form-cols--3 { grid-template-columns: minmax(0, 1fr); } }
.location-card + .location-card { border-top: 1px solid var(--border); }
.location-card { padding: var(--space-4) var(--space-5); }
.access-notes {
  white-space: pre-line;
  background: var(--warning-soft);
  color: var(--warning-text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 8px;
  font-size: var(--text-sm);
}
.location-card.is-muted { opacity: 0.55; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.section-title { font-size: var(--text-lg); margin: 0 0 var(--space-3); }
.visit-card { margin-bottom: var(--space-3); }
.visit-card--alert { box-shadow: inset 4px 0 0 var(--danger); }
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0; }
.inline-form { display: inline; margin: 0; }
.inline-details summary { list-style: none; cursor: pointer; }
.inline-details summary::-webkit-details-marker { display: none; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0; }
.price-helper summary { cursor: pointer; color: var(--accent-text); }

/* ---- Contracts ---------------------------------------------------------- */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list li { line-height: 1.4; }

/* ---------------------------------------------------------------------------
   Calendar (The Maid)
   ------------------------------------------------------------------------- */
.cal-card { padding: var(--space-4); }
#calendar {
  --fc-border-color: var(--border);
  --fc-today-bg-color: var(--accent-soft);
  --fc-now-indicator-color: var(--danger);
  --fc-button-bg-color: var(--surface);
  --fc-button-text-color: var(--text);
  --fc-button-border-color: var(--border-strong);
  --fc-button-hover-bg-color: var(--surface-hover);
  --fc-button-hover-border-color: var(--border-strong);
  --fc-button-active-bg-color: var(--accent);
  --fc-button-active-border-color: var(--accent);
  --fc-page-bg-color: var(--surface);
  font-size: var(--text-sm);
}
#calendar .fc-button-primary:not(:disabled).fc-button-active { color: var(--text-inverse); }
#calendar .fc-toolbar-title { font-size: var(--text-lg); }
#calendar .fc-toolbar-title::first-letter { text-transform: uppercase; }
#calendar .fc-button { font-size: var(--text-sm); text-transform: capitalize; }
.cal-ev { overflow: hidden; line-height: 1.25; padding: 1px 2px; }
.cal-ev__top { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.cal-ev__time { font-weight: 600; }
.cal-ev__title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev__team { opacity: .9; font-size: var(--text-xs); }
.cal-ev__staff, .cal-ev__status {
  background: var(--danger); color: #fff; border-radius: var(--radius-full);
  padding: 0 6px; font-size: var(--text-xs); font-weight: 600;
}
.cal-ev__status { background: rgb(15 23 42 / .55); }
.fc-event.cal-understaffed { box-shadow: 0 0 0 2px var(--danger); }
.fc-event.cal-status-cancelled { opacity: .55; text-decoration: line-through; }
.fc-event.cal-status-closed, .fc-event.cal-status-accepted { opacity: .8; }
.fc .cal-holiday { background: var(--danger-soft); opacity: .7; }
.fc .cal-holiday .fc-event-title { color: var(--danger-text); font-style: normal; font-size: var(--text-xs); }
.fc-event.cal-absence { background: repeating-linear-gradient(45deg, #e5e7eb, #e5e7eb 6px, #f3f4f6 6px, #f3f4f6 12px);
  border-color: var(--border-strong); color: var(--text); }
.fc-event.cal-absence .fc-event-main { color: var(--text); }
.fc-list-event.cal-understaffed td { box-shadow: inset 3px 0 0 var(--danger); }
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-3); align-items: center; }
.cal-swatch { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.cal-swatch--understaffed { border: 2px solid var(--danger); }
.cal-swatch--holiday { background: var(--danger-soft); }
.cal-swatch--absence { background: repeating-linear-gradient(45deg, #d1d5db, #d1d5db 3px, #f3f4f6 3px, #f3f4f6 6px); }
.cal-text-danger { color: var(--danger-text); }

.cal-popover {
  position: absolute; z-index: 50; width: 300px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-3) var(--space-4);
}
.cal-popover p { margin: 0 0 6px; }
.cal-popover__head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: start; margin-bottom: 4px; }
.cal-toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--text); color: var(--text-inverse); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-lg); font-size: var(--text-sm);
}
.cal-toast[hidden], .cal-popover[hidden] { display: none; }
.cal-toast--warning { background: var(--warning-text); }
.cal-toast--danger { background: var(--danger-text); }
.cal-toast .btn { color: inherit; border-color: rgb(255 255 255 / .5); }
.cal-toast__warnings { flex-basis: 100%; margin: 0; padding-left: 18px; order: 2; }
.cal-toast__close { background: none; border: 0; color: inherit; cursor: pointer; font-size: 14px; padding: 2px 4px; }
.cal-popover .cal-toast__close { color: var(--text-muted); }

/* Day sheet */
.daysheet__date { margin: 0 0 var(--space-4); }
.daysheet__date::first-letter { text-transform: uppercase; }
.daysheet__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.daysheet__pick { display: flex; gap: 6px; align-items: center; margin: 0; }
.daysheet__route { margin-bottom: var(--space-4); padding: var(--space-4); break-inside: avoid; }
.daysheet__route h3 { margin: 0 0 var(--space-3); }
.daysheet__route--warn { border-color: var(--danger); }
.daysheet__visits { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.daysheet__visit { display: grid; grid-template-columns: 96px 1fr; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.daysheet__visit:first-child { border-top: 0; padding-top: 0; }
.daysheet__time { font-weight: 600; font-variant-numeric: tabular-nums; }
.daysheet__briefing { white-space: pre-line; margin-top: 4px; }
@media print {
  .app-nav, .app-subnav, .no-print, .workspace-footer, .flash-stack, .alert { display: none !important; }
  body, .daysheet__route { background: #fff !important; box-shadow: none !important; }
  .daysheet__route { border: 1px solid #999; }
}
@media (max-width: 640px) {
  .daysheet__visit { grid-template-columns: 1fr; gap: 2px; }
  #calendar .fc-header-toolbar { flex-direction: column; gap: var(--space-2); }
}

/* Stat row (client balance) */
.stat-row { display: flex; flex-wrap: wrap; gap: var(--space-6); margin-bottom: var(--space-3); }
.stat__label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat__value { font-size: var(--text-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.input--sm { padding: 4px 8px; font-size: var(--text-sm); }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }

/* The Maid has many top-level sections: keep the bars on one line and let
   the link list scroll sideways instead of pushing the page wider. */
.app-nav__inner { gap: var(--space-4); }
.app-nav__links, .app-subnav__inner { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.app-nav__links::-webkit-scrollbar, .app-subnav__inner::-webkit-scrollbar { display: none; }
.app-nav__link, .app-subnav__link { white-space: nowrap; flex-shrink: 0; }
.app-nav__right { flex-shrink: 0; }
@media (max-width: 1440px) {
  .app-nav__inner { gap: var(--space-3); }
  .app-nav__links { gap: 0; }
  .app-nav__link { padding: 6px 7px; font-size: var(--text-sm); }
  .app-nav__user { padding-right: 4px; }
  .app-nav__user-name { display: none; }
}

/* Finance tabs + payout statement */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs__link { padding: 8px var(--space-3); color: var(--text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs__link:hover { color: var(--text); }
.tabs__link.is-active { color: var(--text); border-bottom-color: var(--brand-primary, var(--accent)); }
.statement { max-width: 760px; }
.statement__head { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.statement__meta { text-align: right; }
.statement__sign { margin-top: var(--space-10); max-width: 360px; }
.statement__line { border-bottom: 1px solid var(--text); height: 48px; margin-bottom: 6px; }
@media print {
  .tabs, .alert { display: none !important; }
  .statement { box-shadow: none !important; border: 0 !important; max-width: none; }
}

/* Reports */
.tabs--sub { border-bottom: 0; margin-top: calc(-1 * var(--space-3)); }
.tabs--sub .tabs__link { font-size: var(--text-sm); padding: 6px var(--space-3); border-radius: var(--radius-full); border-bottom: 0; }
.tabs--sub .tabs__link.is-active { background: var(--accent-soft); color: var(--accent-text); }
.chart-box { position: relative; height: 280px; }
.table--report th[scope="row"] { text-align: left; font-weight: 500; white-space: nowrap;
  position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table--report thead th:first-child { position: sticky; left: 0; z-index: 2; }
.table--report td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table--report tr.is-subtotal th, .table--report tr.is-subtotal td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.table--report tr.is-detail th { padding-left: var(--space-6); color: var(--text-muted); font-weight: 400; }
.table--report tr.is-detail td { color: var(--text-muted); }
.table tr.is-current td { background: var(--accent-soft); }

/* Dashboard (home) */
.dash-date::first-letter { text-transform: uppercase; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-5); align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-visit { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); }
.dash-visit:first-child { border-top: 0; }
.dash-visit.is-alert { box-shadow: inset 3px 0 0 var(--danger); }
.dash-visit.is-past { opacity: .6; }
.dash-visit__time { font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-item { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); }
.dash-item:first-child { border-top: 0; }
.dash-item--danger { box-shadow: inset 3px 0 0 var(--danger); }
.dash-item--warning { box-shadow: inset 3px 0 0 var(--warning); }
.dash-item__title { font-weight: 500; }
.dash-sublist { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: var(--text-sm); }
.dash-ok { color: var(--success-text); font-weight: 500; }

/* Top bar: search, user menu, phone menu */
.nav-search { position: relative; }
.nav-search__input {
  width: 200px; height: 34px; padding: 0 12px 0 32px; border: 1px solid var(--border);
  border-radius: var(--radius-full); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center;
  font-size: var(--text-sm); color: var(--text); transition: width .15s, background-color .15s;
}
.nav-search__input:focus { width: 280px; outline: none; background-color: var(--surface); border-color: var(--brand-primary, var(--accent)); }
.nav-search__results {
  position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px 0; z-index: 60;
}
.nav-search__group { padding: 8px 14px 4px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.nav-search__item { display: flex; justify-content: space-between; gap: var(--space-3); padding: 7px 14px; color: var(--text); text-decoration: none; }
.nav-search__item:hover, .nav-search__item.is-active { background: var(--accent-soft); }
.nav-search__empty { padding: 10px 14px; color: var(--text-muted); }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px 0;
}
.user-menu__who { display: grid; padding: 8px 14px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu__item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 14px; color: var(--text); text-decoration: none; font: inherit; font-size: var(--text-sm); }
a.user-menu__item:hover, .user-menu__item--button:hover { background: var(--surface-2); }
.user-menu__item--button { background: none; border: 0; cursor: pointer; text-align: left; }
.user-menu__lang .locale-switch { margin: 0; }

.app-nav__burger { display: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; padding: 0 9px; flex-direction: column; justify-content: center; gap: 4px; flex-shrink: 0; }
.app-nav__burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

@media (max-width: 1100px) {
  .app-nav__burger { display: inline-flex; order: -1; }
  .app-nav__brand span:not(.app-nav__brand-logo) { display: none; }
  .app-nav__links {
    display: none; position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; align-items: stretch; gap: 0; padding: var(--space-2) var(--container-px) var(--space-4);
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md);
    overflow: visible; max-height: calc(100vh - var(--nav-h)); overflow-y: auto;
  }
  .nav-open .app-nav__links { display: flex; }
  .app-nav__links .app-nav__link { padding: 12px var(--space-3); font-size: var(--text-base); }
  .app-nav__right { margin-left: auto; }
}
@media (max-width: 520px) {
  .nav-search__input, .nav-search__input:focus { width: 150px; }
  .nav-search__results { position: fixed; left: 8px; right: 8px; top: calc(var(--nav-h) + 4px); width: auto; }
}

/* "⋯" menus, page tabs, collapsible add-forms */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px 0;
}
.more-menu__panel form { margin: 0; }
.more-menu__item { display: block; width: 100%; padding: 8px 14px; background: none; border: 0; text-align: left;
  font: inherit; font-size: var(--text-sm); color: var(--text); text-decoration: none; cursor: pointer; }
.more-menu__item:hover { background: var(--surface-2); }
.more-menu__item--danger { color: var(--danger-text); }
.more-menu__sep { height: 1px; background: var(--border); margin: 6px 0; }
.more-menu__sub { padding: 6px 14px 10px; }
.page-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.page-tabs a { padding: 10px var(--space-3); color: var(--text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.page-tabs a:hover { color: var(--text); }
.page-tabs a.is-active { color: var(--text); border-bottom-color: var(--brand-primary, var(--accent)); }
.page-tabs .tab-count { color: var(--text-muted); font-weight: 400; margin-left: 4px; }
html:not(.has-tabs) .page-tabs { display: none; }
.adder > summary { list-style: none; cursor: pointer; display: inline-flex; }
.adder > summary::-webkit-details-marker { display: none; }
.adder[open] > summary { display: none; }
.adder__form { margin-top: var(--space-3); }
.status-cta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.status-cta .note-toggle > summary { list-style: none; cursor: pointer; font-size: var(--text-sm); color: var(--text-muted); text-decoration: underline; }
.status-cta .note-toggle > summary::-webkit-details-marker { display: none; }
.status-cta .note-toggle[open] > summary { display: none; }
.job-hint { margin: calc(-1 * var(--space-3)) 0 var(--space-4); }

/* Type-to-search select */
.combobox { position: relative; }
.combobox__input { width: 100%; padding-right: 30px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat right 10px center; }
.combobox__list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 280px; overflow-y: auto;
  margin: 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.combobox__option { padding: 7px 12px; cursor: pointer; }
.combobox__option:hover, .combobox__option.is-active { background: var(--accent-soft); }
.combobox__empty { padding: 7px 12px; color: var(--text-muted); }
details.more-details > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
details.more-details > summary::-webkit-details-marker { display: none; }
details.more-details > summary .card__title::before { content: "▸ "; color: var(--text-muted); }
details.more-details[open] > summary .card__title::before { content: "▾ "; }
details.more-details:not([open]) > summary { border-bottom: 0; }
.btn--icon { min-width: 38px; justify-content: center; font-size: 18px; line-height: 1; padding-left: 10px; padding-right: 10px; }
.list-subtitle { margin: 0; padding: var(--space-3) var(--space-5) 4px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.stat__value.text-md { font-size: var(--text-md); }

/* Quick-filter chips + collapsible filters */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-3); }
.chip { display: inline-flex; align-items: center; padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  font-size: var(--text-sm); color: var(--text); text-decoration: none; background: var(--surface); white-space: nowrap; }
.chip:hover { border-color: var(--brand-primary, var(--accent)); }
.chip.is-active { background: var(--brand-primary, var(--accent)); border-color: var(--brand-primary, var(--accent)); color: #fff; }
details.filters { margin-bottom: var(--space-5); }
details.filters > summary { list-style: none; cursor: pointer; display: inline-flex; margin-bottom: var(--space-3); }
details.filters > summary::-webkit-details-marker { display: none; }
details.filters > summary::after { content: " ▾"; }
details.filters[open] > summary::after { content: " ▴"; }
details.filters > form { margin-bottom: 0 !important; }

/* Tables that turn into cards on phones: add .table--cards and data-label on cells */
@media (max-width: 720px) {
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tfoot { display: block; }
  .table--cards tfoot tr { display: flex; justify-content: space-between; }
  .table--cards tbody tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
  .table--cards tbody td { padding: 2px 0 !important; border: 0 !important; text-align: left !important; white-space: normal !important; }
  .table--cards tbody td[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 6px; }
  .table--cards tbody td.card-title-cell { font-size: var(--text-md); }
  .table--cards td.col-actions { margin-top: 6px; }
  .table--cards td.col-actions .cluster { justify-content: flex-start; }
}

/* =========================================================================
   Workspace layout with a vertical sidebar (signed-in pages)
   ========================================================================= */
.has-sidebar { --sidebar-w: 224px; }
.has-sidebar .app-nav__inner { max-width: none; padding: 0 var(--space-5); gap: var(--space-4); }
.has-sidebar .app-nav__brand { width: calc(var(--sidebar-w) - var(--space-5)); flex-shrink: 0; min-width: 0; }
.has-sidebar .app-nav__brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar {
  position: fixed; top: var(--nav-h); left: 0; bottom: 0; width: var(--sidebar-w); z-index: 35;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: var(--space-4) var(--space-3) var(--space-8);
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; text-decoration: none; font-size: var(--text-base);
}
.side-link .icon { flex-shrink: 0; opacity: .85; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: var(--accent-soft); color: var(--accent-text); }
.side-link.is-active .icon { opacity: 1; }
.side-sep { height: 1px; background: var(--border); margin: var(--space-3) 4px; }
.side-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 var(--space-2) 22px; padding-left: 12px; border-left: 1px solid var(--border); }
.side-sublink { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: var(--text-sm); text-decoration: none; }
.side-sublink:hover { background: var(--surface-2); color: var(--text); }
.side-sublink.is-active { color: var(--accent-text); background: var(--accent-soft); font-weight: 500; }
.has-sidebar .app-main { width: auto; margin-left: var(--sidebar-w); margin-right: 0; max-width: none; padding-left: var(--space-8); padding-right: var(--space-8); }
.has-sidebar .app-main > * { max-width: 1280px; }
.has-sidebar .workspace-footer { margin-left: var(--sidebar-w); }
.sidebar-backdrop { display: none; }
/* The old horizontal menu pieces are gone on signed-in pages. */
.has-sidebar .app-nav__links, .has-sidebar .app-subnav { display: none; }

@media (max-width: 1100px) {
  .has-sidebar .app-nav__brand { width: auto; }
  .has-sidebar .app-nav__brand-name { display: inline; }
  .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); width: 260px; }
  .nav-open .app-sidebar { transform: none; }
  .nav-open .sidebar-backdrop { display: block; position: fixed; inset: var(--nav-h) 0 0 0; background: rgb(15 23 42 / .3); z-index: 34; }
  .has-sidebar .app-main, .has-sidebar .workspace-footer { margin-left: 0; }
  .has-sidebar .app-main { padding-left: var(--container-px); padding-right: var(--container-px); }
}
@media (max-width: 520px) {
  .has-sidebar .app-nav__brand-name { display: none; }
  .has-sidebar .app-nav__inner { padding: 0 var(--space-3); gap: var(--space-2); }
}
@media print {
  .app-sidebar, .sidebar-backdrop { display: none !important; }
  .has-sidebar .app-main { margin-left: 0; }
}

/* =========================================================================
   Employee portal (phone-first)
   ========================================================================= */
body.portal { background: var(--bg); padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.portal-top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-top__brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.portal-main { width: 100%; max-width: 640px; margin: 0 auto; padding: 16px; box-sizing: border-box; }
.portal-head { margin: 8px 0 16px; }
.portal-head h1 { font-size: var(--text-2xl); margin: 0 0 4px; }
.portal-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.portal-tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px;
  font-size: 11px; color: var(--text-muted); text-decoration: none; }
.portal-tabs a.is-active { color: var(--brand-primary, var(--accent)); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-full); overflow: hidden; margin-top: 8px; }
.seg a { padding: 6px 16px; font-size: var(--text-sm); color: var(--text); text-decoration: none; }
.seg a.is-active { background: var(--brand-primary, var(--accent)); color: #fff; }
.pday { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 20px 0 8px; }
.pday::first-letter { text-transform: uppercase; }
.pempty { margin-top: 0; }
.pvisit { display: grid; grid-template-columns: 56px 1fr 16px; gap: 12px; align-items: center; padding: 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); text-decoration: none; }
.pvisit.is-running { border-color: var(--brand-primary, var(--accent)); box-shadow: inset 4px 0 0 var(--brand-primary, var(--accent)); }
.pvisit.is-past { opacity: .75; }
.pvisit__time { font-weight: 700; font-variant-numeric: tabular-nums; }
.pvisit__time span { display: block; font-weight: 400; color: var(--text-muted); font-size: var(--text-sm); }
.pvisit__body .badge { margin-top: 6px; }
.pvisit__go { color: var(--text-subtle); font-size: 22px; }
.pcard { padding: 16px; margin-bottom: 12px; }
.pcard h2 { font-size: var(--text-md); margin: 0 0 10px; }
.pcard--row { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.pactions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.btn--block { width: 100%; justify-content: center; padding-top: 14px; padding-bottom: 14px; font-size: var(--text-md); }
.phours { margin-top: 12px; }
.phours > summary { cursor: pointer; color: var(--text-muted); font-size: var(--text-sm); }
.phours__form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; align-items: end; }
.phours__form label { display: grid; gap: 4px; font-size: var(--text-sm); color: var(--text-muted); }
.phours__form button { grid-column: 1 / -1; }
.portal-grid { overflow-x: auto; }
@media print { .portal-tabs, .portal-top { display: none !important; } body.portal { padding: 0; } }
.portal-tabs--4 { grid-template-columns: repeat(4, 1fr); }
.portal-head .btn { margin-top: 8px; }
.side-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }

/* ---- To cover (absence → replacement) ---------------------------------- */
.cover-all { border-bottom: 1px solid var(--border); padding-top: 0; }
.cover-list { list-style: none; margin: 0; padding: 0; }
.cover-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: var(--space-4, 16px);
  padding: var(--space-4, 16px) var(--space-5, 20px); border-top: 1px solid var(--border); }
.cover-row:first-child { border-top: 0; }
.cover-options { display: grid; gap: 6px; }
.cover-option { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md, 8px); cursor: pointer; }
.cover-option:has(input:checked) { border-color: var(--brand-primary, var(--accent)); background: var(--accent-soft); }
.cover-option__name { font-weight: 600; }
.cover-more { margin-top: 8px; }
.cover-more summary { cursor: pointer; margin-bottom: 6px; color: var(--text-muted); }
.cover-row__actions { margin-top: 10px; }
@media (max-width: 760px) { .cover-row { grid-template-columns: 1fr; } }

/* ---- Time picker (static/js/timepicker.js) ----------------------------- */
.time-input { font-variant-numeric: tabular-nums; max-width: 140px; cursor: pointer; }
.time-input.is-invalid { border-color: var(--danger); }
.tp { position: fixed; z-index: 1000; width: 264px; padding: 12px; background: var(--surface, #fff);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(15, 23, 42, .18); }
.tp[hidden] { display: none; }
.tp--sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.tp--sheet .tp__face { max-width: 300px; }
.tp__head { display: flex; align-items: center; justify-content: center; gap: 2px; margin-bottom: 10px; }
.tp__seg { font: inherit; font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 10px;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-muted); cursor: pointer; }
.tp__seg.is-active { background: var(--accent-soft); color: var(--brand-primary, var(--accent)); }
.tp__colon { font-size: 28px; font-weight: 600; color: var(--text-muted); }
.tp__face { position: relative; width: 100%; aspect-ratio: 1; margin: 0 auto; border-radius: 50%; background: var(--bg); }
.tp__center { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: var(--brand-primary, var(--accent)); }
.tp__num { position: absolute; width: 36px; height: 36px; margin: -18px 0 0 -18px; border: 0; border-radius: 50%;
  background: transparent; font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text); cursor: pointer; }
.tp__num--inner { width: 30px; height: 30px; margin: -15px 0 0 -15px; font-size: 12px; color: var(--text-muted); }
.tp__num:hover { background: var(--accent-soft); }
.tp__num.is-selected { background: var(--brand-primary, var(--accent)); color: #fff; }
.tp__foot { display: flex; justify-content: space-between; margin-top: 10px; }
.tp-quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip--sm { padding: 2px 10px; font-size: 13px; background: transparent; cursor: pointer; }

/* ---- Job edit: visits list / team picker ------------------------------- */
.visit-pick { list-style: none; margin: 0; padding: 0; }
.visit-pick li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
.visit-pick li:first-child { border-top: 0; }
.team-pick.is-locked { cursor: default; opacity: .85; }

/* ---- Staff utilisation (reports/utilisation.html) ---------------------- */
.util-filter { margin-bottom: var(--space-3); }
.util-cell { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.util-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2, #eef0f4); overflow: hidden; }
.util-bar span { display: block; height: 100%; border-radius: inherit; background: var(--text-muted); opacity: .55; }
.util-bar--success span { background: var(--success); opacity: 1; }
.util-bar--danger span { background: var(--danger); opacity: 1; }
.util-bar--warning span { background: var(--warning); opacity: 1; }
.util-pct { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.util-pct--success { color: var(--success-text); }
.util-pct--danger { color: var(--danger-text); }
.util-pct--warning { color: var(--warning-text); }
.util-line { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.segmented { display: inline-flex; gap: 4px; }
.util-table tfoot th { padding: var(--space-3) var(--space-4); }
