/* ════════════════════════════════════════════════════════════════════════
   admin-portal.css — Trigo Digital Admin CRM, single universal stylesheet.
   Merged from base.css + portal.css (load order preserved: base, then portal).
   Page-specific styles live in flat-named files (e.g. finance.css) via $page_styles.
   ════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────── base.css ─────────────────────────── */
/* ============================================================
   Trigo Digital — Admin Portal Base Design System
   Brand: Teal accent (#0ea5b7) on navy/dark (#0a1f2e), light surface
   Fonts: Inter for body/UI, system stack
   ============================================================ */

:root {
  /* Brand colors — pulled from main trigodigital.com */
  --color-ink:          #0a1f2e;
  --color-ink-light:    #1a3a4d;
  --color-ink-soft:     #2a4f64;
  --color-muted:        #5a7589;
  --color-muted-light:  #7a95a9;
  --color-line:         #e1e8ed;
  --color-line-soft:    #f0f4f7;

  --color-bg:           #ffffff;
  --color-bg-subtle:    #f8fafb;
  --color-bg-app:       #f1f5f8;

  --color-accent:       #0ea5b7;
  --color-accent-dark:  #0c8a9a;
  --color-accent-light: #3fc5d4;
  --color-accent-bg:    #e6f7f9;

  --color-success:      #10b981;
  --color-success-bg:   #d1fae5;
  --color-warning:      #f59e0b;
  --color-warning-bg:   #fef3c7;
  --color-danger:       #ef4444;
  --color-danger-bg:    #fee2e2;
  --color-info:         #3b82f6;
  --color-info-bg:      #dbeafe;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #0ea5b7 0%, #0c8a9a 100%);
  --gradient-dark:    linear-gradient(135deg, #0a1f2e 0%, #1a3a4d 100%);

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Layout */
  --sidebar-width: 240px;
  --container-max: 1200px;
  --container-pad: 24px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(10, 31, 46, 0.06);
  --shadow-md: 0 4px 6px rgba(10, 31, 46, 0.08), 0 1px 3px rgba(10, 31, 46, 0.06);
  --shadow-lg: 0 10px 15px rgba(10, 31, 46, 0.10), 0 4px 6px rgba(10, 31, 46, 0.05);
  --shadow-xl: 0 20px 25px rgba(10, 31, 46, 0.12), 0 10px 10px rgba(10, 31, 46, 0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-bg-app);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; height: auto; display: block; }

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

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============================================================
   Buttons
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}

.btn--primary {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: white;
}

.btn--outline {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-line);
}
.btn--outline:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn--dark {
  background: var(--color-ink);
  color: white;
  border-color: var(--color-ink);
}
.btn--dark:hover { background: var(--color-ink-light); border-color: var(--color-ink-light); color: white; }

.btn--danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn--danger:hover { opacity: 0.9; color: white; }

.btn--success {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}
.btn--success:hover { opacity: 0.9; color: white; }

.btn--ghost {
  background: transparent;
  color: var(--color-muted);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--color-bg-subtle); color: var(--color-ink); }

.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 12px 24px; font-size: 15px; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   Forms
============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
  letter-spacing: 0.01em;
}

.form-label--required::after { content: ' *'; color: var(--color-accent); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: white;
  color: var(--color-ink);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--color-muted-light);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row--phone { grid-template-columns: 1fr 80px 1fr; }

.form-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--color-line);
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--color-line);
  margin-top: 24px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-ink);
}
.checkbox-label input { accent-color: var(--color-accent); width: 16px; height: 16px; }

/* Type toggle (radios styled as pill buttons) */
.type-toggle {
  display: inline-flex;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}
.type-toggle__option {
  position: relative;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.type-toggle__option input { position: absolute; opacity: 0; pointer-events: none; }
.type-toggle__option:has(input:checked) {
  background: white;
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Alerts
============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  border-left: 4px solid;
}

.alert--success { background: var(--color-success-bg); color: #065f46; border-left-color: var(--color-success); }
.alert--info    { background: var(--color-info-bg);    color: #1e40af; border-left-color: var(--color-info); }
.alert--warning { background: var(--color-warning-bg); color: #92400e; border-left-color: var(--color-warning); }
.alert--error   { background: var(--color-danger-bg);  color: #991b1b; border-left-color: var(--color-danger); }

.error-list { list-style: disc; padding-left: 20px; margin: 0; }

/* ============================================================
   Utilities
============================================================ */
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--color-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-0 { margin-top: 0; } .mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }

.hidden { display: none !important; }

/* ─────────────────────────── portal.css ───────────────────────── */
/* ============================================================
   Trigo Digital — Admin Portal Layout
   Sidebar, topbar, sections, tables, status badges
   ============================================================ */

/* ---- Layout shell ---- */
.portal-body { background: var(--color-bg-app); min-height: 100vh; }

.portal-layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.portal-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--gradient-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  border-right: 3px solid var(--color-accent);
  transition: transform var(--transition-base);
}

.portal-sidebar.is-collapsed { transform: translateX(-100%); position: fixed; }

.portal-sidebar__header {
  padding: 24px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.portal-sidebar__logo-link { display: block; }
.portal-sidebar__logo {
  width: 56px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.portal-sidebar__brand {
  font-size: 14px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}
.portal-sidebar__title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent-light);
}

/* ---- Nav ---- */
.portal-nav { flex: 1; padding: 16px 8px; overflow-y: auto; }

.portal-nav__section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 8px 12px 6px;
  margin-top: 8px;
}

.portal-nav__list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.portal-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.portal-nav__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-nav__link:hover { background: rgba(255,255,255,0.07); color: white; }
.portal-nav__link--active {
  background: rgba(14, 165, 183, 0.18);
  color: var(--color-accent-light);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* ---- Environment badge ---- */
.env-badge {
  display: inline-block;
  font-size: 0.6em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.env-badge--staging {
  background: #f59e0b;
  color: #000;
}

/* ---- Sidebar footer ---- */
.portal-sidebar__footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.15);
}
.portal-sidebar__user-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.portal-sidebar__user-role {
  color: var(--color-accent-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.portal-sidebar__logout {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  margin-top: 8px;
  text-align: center;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.portal-sidebar__logout:hover { color: white; border-color: rgba(255,255,255,0.3); }

/* ---- Main area ---- */
.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevents grid blowout */
}

.portal-topbar {
  background: white;
  border-bottom: 1px solid var(--color-line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.portal-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
}
.portal-sidebar-toggle svg {
  width: 20px; height: 20px;
  stroke: var(--color-ink); fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.portal-topbar__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-ink);
  margin: 0;
}

.portal-topbar__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.portal-content {
  padding: 28px;
  max-width: 100%;
  overflow-x: auto;
}

/* ---- Sections ---- */
.portal-section {
  background: white;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.portal-section__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.portal-section__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-ink);
  margin: 0;
}

.portal-section__body { padding: 20px; }
.portal-section__body--p0 { padding: 0; }

.text-center-empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--color-muted);
}

/* ---- Toolbar (filters above tables) ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar__form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}
.toolbar__form .form-input,
.toolbar__form .form-select { margin: 0; }
.toolbar__form .form-input { min-width: 220px; }

.results-count {
  color: var(--color-muted);
  font-size: 13px;
  margin: 0;
}

/* ---- Data tables ---- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--color-bg-subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-line);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-line-soft);
  vertical-align: middle;
  color: var(--color-ink);
}

.data-table tbody tr { transition: background-color var(--transition-fast); }
.data-table tbody tr:hover { background: var(--color-bg-subtle); }
.data-table tbody tr:last-child td { border-bottom: none; }

.portal-link {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
}
.portal-link:hover { text-decoration: underline; }

/* ---- Status badges ---- */
.status-badge,
.profile-badge,
.type-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  white-space: nowrap;
}

/* Project / invoice statuses */
.status--lead         { background: #f0f4f7; color: #5a7589; }
.status--planning     { background: var(--color-info-bg);    color: #1e40af; }
.status--estimate     { background: var(--color-warning-bg); color: #92400e; }
.status--sent         { background: var(--color-info-bg);    color: #1e40af; }
.status--approved     { background: var(--color-success-bg); color: #065f46; }
.status--in_progress  { background: #dbeafe; color: #1e40af; }
.status--review       { background: #ede9fe; color: #5b21b6; }
.status--complete     { background: #e0e7ff; color: #3730a3; }
.status--invoiced     { background: var(--color-warning-bg); color: #92400e; }
.status--partial_paid { background: #fed7aa; color: #9a3412; }
.status--paid         { background: var(--color-success-bg); color: #065f46; }
.status--on_hold      { background: #f3f4f6; color: #374151; }
.status--archived,
.status--void,
.status--cancelled    { background: #fee2e2; color: #991b1b; }

.profile-badge--business { background: var(--color-accent-bg); color: var(--color-accent-dark); }
.profile-badge--personal { background: #ede9fe; color: #5b21b6; }

.type-badge--estimate { background: var(--color-warning-bg); color: #92400e; }
.type-badge--invoice  { background: var(--color-success-bg); color: #065f46; }

/* ---- Stat cards ---- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-line);
  border-top: 3px solid var(--color-accent);
  position: relative;
}

.dash-stat-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: 8px;
}
.dash-stat-card__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-ink);
  line-height: 1.1;
  margin-bottom: 4px;
}
.dash-stat-card__sub { font-size: 12px; color: var(--color-muted); }
.dash-stat-card__sub a { color: var(--color-accent); font-weight: 600; }

/* ---- Dash grid ---- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ---- Attention banner ---- */
.attention-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}
.attention-banner__header { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.attention-banner__icon { font-size: 24px; }
.attention-banner__title {
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
  margin: 0 0 2px 0;
}
.attention-count {
  background: var(--color-warning);
  color: white;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
.attention-banner__sub { font-size: 13px; color: #78350f; margin: 0; }
.attention-list { display: flex; flex-direction: column; gap: 10px; }
.attention-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  gap: 16px;
}
.attention-item__tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}
.attention--changes  .attention-item__tag { background: var(--color-info-bg); color: #1e40af; }
.attention--rejected .attention-item__tag { background: var(--color-danger-bg); color: #991b1b; }
.attention-item__wo { font-weight: 600; font-family: var(--font-mono); font-size: 13px; }
.attention-item__customer { font-size: 14px; color: var(--color-ink); }
.attention-item__time { font-size: 12px; color: var(--color-muted); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 18px 16px;
  border-top: 1px solid var(--color-line);
  flex-wrap: wrap;
}

/* ---- Form layout helpers ---- */
.form-max-width { max-width: 880px; margin: 0 auto; }
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1024px) {
  .form-grid-2col { grid-template-columns: 1fr; }
}

.form-grid-2col__sticky { position: sticky; top: 88px; }

/* ---- Project property card ---- */
.property-card {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.property-card__type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: 4px;
}
.property-card__label { font-weight: 600; color: var(--color-ink); margin-bottom: 2px; }
.property-card__value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-muted);
  word-break: break-all;
}

/* ---- Progress bar ---- */
.progress-track {
  width: 100%;
  height: 10px;
  background: var(--color-line);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 600ms ease;
}
.progress-detail {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-muted);
}

/* ---- Milestone item ---- */
.milestone-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px dashed var(--color-line);
}
.milestone-item:last-child { border-bottom: none; }
.milestone-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--color-line);
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  margin-top: 2px;
}
.milestone-check--done {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.milestone-title { font-weight: 600; color: var(--color-ink); margin-bottom: 2px; }
.milestone-meta { font-size: 12px; color: var(--color-muted); }

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
  .portal-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
  }
  .portal-sidebar.is-open { transform: translateX(0); }
  .portal-sidebar-toggle { display: inline-flex; }
  .portal-content { padding: 16px; }
  .portal-topbar { padding: 12px 16px; }

  .form-row--2, .form-row--3, .form-row--phone { grid-template-columns: 1fr; }
}

/* ---- Login page (no sidebar) ---- */
.portal-auth-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--gradient-dark);
}
.login-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { width: 64px; height: auto; margin: 0 auto 12px; }
.login-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-ink);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
}
.login-fields { display: flex; flex-direction: column; gap: 16px; }
.login-submit { width: 100%; }
.login-note {
  text-align: center;
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 12px;
}
.login-back { text-align: center; margin-top: 16px; }
.login-back-link { color: rgba(255,255,255,0.7); font-size: 13px; }
.login-back-link:hover { color: white; }
.login-alert { max-width: 420px; width: 100%; margin: 0 auto 12px; }
/* ════════════════════════════════════════════════════════════════════════
   UNIVERSAL UTILITY LAYER (added for strict-CSP refactor)
   Mirrors the customer portal's utility vocabulary; admin's existing
   .text-*/.fw-*/.mb-*/.mt-* helpers are kept and unchanged.
   ════════════════════════════════════════════════════════════════════════ */

/* Headings */
.page-title   { font-size: 24px; font-weight: 800; }
.detail-title { font-size: 26px; font-weight: 800; margin: 8px 0 4px; }

/* Margins */
.u-m-0  { margin: 0; }
.u-mt-2 { margin-top: 2px; } .u-mt-4 { margin-top: 4px; } .u-mt-6 { margin-top: 6px; }
.u-mt-8 { margin-top: 8px; } .u-mt-10 { margin-top: 10px; } .u-mt-12 { margin-top: 12px; }
.u-mt-16 { margin-top: 16px; } .u-mt-20 { margin-top: 20px; } .u-mt-24 { margin-top: 24px; }
.u-mb-0 { margin-bottom: 0; } .u-mb-2 { margin-bottom: 2px; } .u-mb-4 { margin-bottom: 4px; }
.u-mb-6 { margin-bottom: 6px; } .u-mb-8 { margin-bottom: 8px; } .u-mb-10 { margin-bottom: 10px; }
.u-mb-12 { margin-bottom: 12px; } .u-mb-16 { margin-bottom: 16px; } .u-mb-20 { margin-bottom: 20px; }
.u-mb-24 { margin-bottom: 24px; } .u-mb-28 { margin-bottom: 28px; }
.u-ml-auto { margin-left: auto; }

/* Padding */
.u-p-0  { padding: 0; } .u-p-48 { padding: 48px; }
.u-pt-0 { padding-top: 0; } .u-pt-6 { padding-top: 6px; }
.u-pr-16 { padding-right: 16px; }

/* Font size / weight */
.u-fs-11 { font-size: 11px; } .u-fs-13 { font-size: 13px; } .u-fs-14 { font-size: 14px; }
.u-fs-15 { font-size: 15px; } .u-fs-16 { font-size: 16px; } .u-fs-18 { font-size: 18px; }
.u-fs-20 { font-size: 20px; } .u-fs-22 { font-size: 22px; } .u-fs-26 { font-size: 26px; }
.u-fs-32 { font-size: 32px; } .u-fs-36 { font-size: 36px; }
.u-fw-400 { font-weight: 400; } .u-fw-600 { font-weight: 600; }
.u-fw-700 { font-weight: 700; } .u-fw-800 { font-weight: 800; }

/* Flex / grid helpers */
.u-flex { display: flex; } .u-inline-flex { display: inline-flex; }
.u-flex-col { flex-direction: column; } .u-flex-1 { flex: 1; } .u-flex-wrap { flex-wrap: wrap; }
.u-items-center { align-items: center; } .u-items-start { align-items: flex-start; }
.u-items-end { align-items: flex-end; } .u-items-baseline { align-items: baseline; }
.u-justify-between { justify-content: space-between; } .u-justify-end { justify-content: flex-end; }
.u-justify-center { justify-content: center; }
.u-gap-6 { gap: 6px; } .u-gap-8 { gap: 8px; } .u-gap-10 { gap: 10px; } .u-gap-12 { gap: 12px; }
.u-gap-16 { gap: 16px; } .u-gap-20 { gap: 20px; } .u-gap-24 { gap: 24px; }
.u-min-w-0 { min-width: 0; } .u-min-w-160 { min-width: 160px; } .u-min-w-180 { min-width: 180px; }
.u-min-w-200 { min-width: 200px; } .u-min-w-240 { min-width: 240px; }

/* Colors */
.u-c-accent { color: var(--color-accent); } .u-c-muted { color: var(--color-muted); }
.u-c-success { color: var(--color-success); } .u-c-warning { color: var(--color-warning); }
.u-c-danger { color: var(--color-danger); } .u-c-ink { color: var(--color-ink); }

/* Text / misc */
.u-text-left { text-align: left; } .u-text-center { text-align: center; } .u-text-right { text-align: right; }
.u-uppercase { text-transform: uppercase; }
.u-pre-wrap { white-space: pre-wrap; }
.u-eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.u-link-inherit { color: inherit; text-decoration: underline; }
.u-bg-subtle { background: var(--color-bg-subtle); }
.u-bg-none { background: none; }
.u-border-none { border: none; }
.u-hidden { display: none !important; }

/* State helpers */
.is-warning { color: var(--color-warning); }

/* Progress modifier */
.progress-fill--success { background: var(--color-success); }

/* Collapsible inline form panel (admin: + Add / Cancel toggles).
   Toggled by portal-nav.js via [data-form-open]/[data-form-close]. */
.inline-form { display: none; background: var(--color-bg-subtle); border-bottom: 1px solid var(--color-line); }
.inline-form.is-open { display: block; }

/* Progress track height modifiers */
.progress-track--h8  { height: 8px; }
.progress-track--h10 { height: 10px; }
.progress-track--h14 { height: 14px; }

/* A few more utilities used across admin pages */
.u-ml-8 { margin-left: 8px; }
.u-pt-8 { padding-top: 8px; }
.u-pt-24 { padding-top: 24px; }
.u-min-w-280 { min-width: 280px; }
.u-gap-32 { gap: 32px; }
.u-pointer { cursor: pointer; }
.u-strike { text-decoration: line-through; }
.u-border-b { border-bottom: 1px solid var(--color-line); }
.u-word-break { word-break: break-all; }
.u-flex-shrink-0 { flex-shrink: 0; }
.u-inline { display: inline; }
.u-min-w-240b { min-width: 240px; }
.u-mx-8 { margin: 0 8px; }
.u-min-w-50 { min-width: 50px; }
.u-min-w-110 { min-width: 110px; }
.u-p-20 { padding: 20px; }
.u-pt-12 { padding-top: 12px; }
.u-pt-4 { padding-top: 4px; }
.u-p-60-24 { padding: 60px 24px; }
.u-border-t { border-top: 1px solid var(--color-line); }
.u-fs-48 { font-size: 48px; }
.u-min-w-140 { min-width: 140px; }
.u-gap-4 { gap: 4px; }
.u-mt-48 { margin-top: 48px; }
.is-hidden { display: none; }
.is-inactive { opacity: 0.55; }
.u-nowrap { white-space: nowrap; }
.u-max-w-240 { max-width: 240px; }
.u-ml-12 { margin-left: 12px; }
.u-mb-32 { margin-bottom: 32px; }
.u-mt-32 { margin-top: 32px; }
.u-max-w-860 { max-width: 860px; }
.code-chip { background: var(--color-bg-subtle); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.u-caps { text-transform: uppercase; letter-spacing: 0.06em; }
.u-w-full { width: 100%; }
.u-pt-16 { padding-top: 16px; }
.u-gap-14 { gap: 14px; }
.u-word-break { word-break: break-all; }
.u-mb-20 { margin-bottom: 20px; }
.u-mt-20 { margin-top: 20px; }
.u-pb-0 { padding-bottom: 0; }
.u-mb-10 { margin-bottom: 10px; }
.u-mt-3 { margin-top: 3px; }
.u-py-8 { padding: 8px 0; }
.u-pl-2 { padding-left: 2px; }
/* ── Dashboard Configuration toggles (Admin > Settings) ─────────── */
.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
}

.settings-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--color-accent, #0ea5b7);
  cursor: pointer;
}

/* ── Dashboard Configuration switch table (Admin > Settings) ────── */
.toggle-table-wrap {
  border: 1px solid var(--color-line, #e1e8ed);
  border-radius: 12px;
  overflow: hidden;
}

.toggle-table {
  width: 100%;
  border-collapse: collapse;
}

.toggle-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted, #5a7589);
  background: var(--color-bg-subtle, #f8fafb);
  border-bottom: 1px solid var(--color-line, #e1e8ed);
}

.toggle-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-line-soft, #f0f4f7);
  vertical-align: middle;
}

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

.toggle-table tbody tr:hover {
  background: var(--color-bg-subtle, #f8fafb);
}

.toggle-table__name label {
  font-weight: 600;
  color: var(--color-ink, #0a1f2e);
  cursor: pointer;
}

td.toggle-table__desc {
  color: var(--color-muted, #5a7589);
  font-size: 0.9rem;
}

th.toggle-table__switch-col,
td.toggle-table__switch-col {
  width: 72px;
  text-align: right;
  white-space: nowrap;
}

/* Switch control. Same POST contract as before: hidden 0 + checkbox 1,
   so the settings save loop needs no changes. */
.switch {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.switch input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch__track {
  display: block;
  width: 40px;
  height: 22px;
  background: #cbd6dd;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(10, 31, 46, 0.25);
  transition: transform 0.2s ease;
}

.switch input[type="checkbox"]:checked + .switch__track {
  background: var(--color-accent, #0ea5b7);
}

.switch input[type="checkbox"]:checked + .switch__track::after {
  transform: translateX(18px);
}

.switch input[type="checkbox"]:focus-visible + .switch__track {
  outline: 2px solid var(--color-accent, #0ea5b7);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .toggle-table__desc {
    display: none;
  }
}
