/* ============================================================
   EES Resident Dashboard — Design Tokens & Components
   Spec: docs/superpowers/specs/2026-05-25-ees-resident-dashboard-redesign-design.md
   ============================================================ */

:root {
  /* Color — EES core (building-invariant) */
  --cream: #faf8f5;
  --white: #ffffff;
  --card: #fefdfb;
  --charcoal: #1f1d1a;
  --stone-700: #4a4540;
  --stone-500: #7a716a;
  --stone-400: #b3a89c;
  --stone-200: #ece6dd;
  --stone-100: #f5f0e8;

  /* Color — per-building accent. Defaults injected here; overridden
     inline by base.html using Building.primary_color. */
  --accent: #2563eb;
  --accent-soft: #e0e9ff;
  --accent-dark: #1e40af;

  /* Semantic statuses */
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #a16207;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;

  /* Typography */
  --font-serif: "Lora", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;

  /* 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;

  /* Shared vertical rhythm for the top breadcrumb bar and the page-title
     block beneath it, so the title lines up consistently with the header. */
  --bar-pad-y: 16px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-pill: 999px;

  /* Shadows — warm-tinted */
  --shadow-xs: 0 1px 1px rgba(31, 29, 26, 0.04), 0 1px 2px rgba(31, 29, 26, 0.05);
  --shadow-sm: 0 1px 2px rgba(31, 29, 26, 0.05), 0 2px 6px rgba(31, 29, 26, 0.06);
  --shadow-md:
    0 1px 2px rgba(31, 29, 26, 0.05),
    0 4px 12px rgba(31, 29, 26, 0.07),
    0 8px 24px rgba(31, 29, 26, 0.04);
  --shadow-lg:
    0 2px 4px rgba(31, 29, 26, 0.06),
    0 8px 20px rgba(31, 29, 26, 0.08),
    0 24px 48px rgba(31, 29, 26, 0.1);
  --shadow-accent:
    0 1px 1px rgba(31, 29, 26, 0.1),
    0 4px 12px rgba(37, 99, 235, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);

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

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

/* ============================================================
   Base resets
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--charcoal);
  background: var(--cream);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (max-width: 720px) {
  body { font-size: 17px; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* Accessibility */
.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--accent); color: white;
  padding: 12px 16px; font-weight: 600;
  z-index: 9999;
}
.skip-link:focus { top: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ============================================================
   Layout Shell
   ============================================================ */
.app-shell {
  container-type: inline-size;
  container-name: shell;
  height: 100vh;
  overflow: hidden;
}
.app-layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  height: 100%;
}
.app-layout > * { min-width: 0; min-height: 0; }

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, #2a2724, var(--charcoal));
  color: white;
  padding: 0 0 var(--space-5);
  display: flex; flex-direction: column;
  box-shadow: 4px 0 16px -4px rgba(31, 29, 26, 0.12);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}
.sb-brand { padding: 20px 18px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 12px; flex-shrink: 0; }
.sb-brand-name { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 500; letter-spacing: 0.01em; line-height: 1.15; }
.sb-current-user { padding: 6px 15px 14px; }
.sb-current-user-name { font-size: 0.95rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sb-current-user-unit { font-size: 0.8rem; color: rgba(255,255,255,0.6); margin-top: 3px; }
.sb-brand-sub { font-size: 0.78rem; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 6px; font-weight: 500; }
.sb-section { padding: 4px 12px; flex-shrink: 0; }
.sb-label { font-size: 0.82rem; color: rgba(255,255,255,0.55); padding: 16px 8px 8px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; color: rgba(255,255,255,0.82);
  font-size: 0.92rem; font-weight: 500;
  border-left: 3px solid transparent; margin-left: -3px;
  cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sb-item:hover { color: white; background: rgba(255,255,255,0.04); text-decoration: none; }
.sb-item.active {
  color: white;
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.12), transparent);
}
.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.sb-item.active svg { opacity: 1; }
.sb-badge {
  margin-left: auto; font-size: 0.72rem;
  background: var(--accent); color: white;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-weight: 600; flex-shrink: 0;
}
.sb-badge.warn { background: var(--amber); }
.sb-badge.danger { background: var(--red); }
.sb-user {
  margin-top: auto; padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.sb-signout {
  margin-left: auto;
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
}
.sb-signout:hover { color: white; background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.sb-signout svg { width: 17px; height: 17px; }
.sb-signout.sb-signout-text {
  width: 100%; height: auto; margin-left: 0;
  justify-content: flex-start; gap: 12px;
  padding: 10px; font-size: 0.92rem; font-weight: 500;
  background: none; border: 0; cursor: pointer;
}

/* Main column */
.main-col {
  display: flex; flex-direction: column;
  height: 100%;
  background:
    radial-gradient(ellipse at top, rgba(255,250,240,0.4), transparent 50%),
    var(--cream);
  min-height: 0;
}
.topbar {
  padding: var(--bar-pad-y) 24px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--stone-200);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  gap: 12px; flex-shrink: 0; z-index: 2;
}
.mobile-menu {
  display: none; width: 38px; height: 38px;
  border-radius: var(--radius-md);
  align-items: center; justify-content: center;
  color: var(--charcoal); flex-shrink: 0;
  background: transparent; border: 0; cursor: pointer;
}
.crumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--stone-500);
  min-width: 0; flex-wrap: wrap;
}
.crumb a { color: var(--accent); }
.crumb strong { color: var(--charcoal); font-weight: 600; }
.crumb .sep { color: var(--stone-400); }
.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--stone-500); cursor: pointer; position: relative;
  background: transparent; border: 0;
}
.icon-btn:hover { background: var(--stone-100); color: var(--charcoal); }
.icon-btn svg { width: 17px; height: 17px; }
.topbar-user {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: var(--radius-md);
  color: var(--stone-700); font-size: 0.88rem; font-weight: 600;
  text-decoration: none; max-width: 220px;
}
.topbar-user:hover { background: var(--stone-100); color: var(--charcoal); text-decoration: none; }
.topbar-user svg { width: 17px; height: 17px; flex-shrink: 0; }
.topbar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--cream);
}

/* ===== Mobile nav overlay (full-screen) ===== */
.nav-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: var(--charcoal); color: var(--white);
  display: flex; flex-direction: column;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.nav-overlay[hidden] { display: none; }
.nav-overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; flex-shrink: 0;
}
.nav-overlay-title {
  font-family: var(--font-serif); font-size: 1.1rem; font-weight: 500; color: var(--white);
}
.nav-overlay-close { color: var(--white); width: 44px; height: 44px; }
.nav-overlay .nav-overlay-close:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-overlay-body { padding: 8px 12px 24px; }
/* Reuse .sb-item styling but enlarge tap targets inside the overlay */
.nav-overlay .sb-item {
  min-height: 52px; font-size: 1.05rem; gap: 14px; border-radius: var(--radius-md);
}
.nav-overlay .sb-section { padding: 4px; }

/* Lock background scroll while the overlay is open */
body.nav-open { overflow: hidden; }

/* Defensive: never show the overlay on desktop widths */
@container shell (min-width: 721px) {
  .nav-overlay { display: none !important; }
}
@media (prefers-reduced-motion: no-preference) {
  .nav-overlay:not([hidden]) { animation: navOverlayIn 0.18s ease-out; }
  @keyframes navOverlayIn { from { opacity: 0; } to { opacity: 1; } }
}

.content {
  flex: 1; overflow-y: auto;
  /* Top padding matches the breadcrumb bar's vertical padding so the page
     title aligns with the header; sides/bottom keep the larger rhythm.
     Bottom padding adds env(safe-area-inset-bottom) so the last element —
     often an .empty card — doesn't get clipped by the iOS home indicator
     on devices with a bottom safe area, and gets extra breathing room
     above the .site-footer on desktop. */
  padding:
    var(--bar-pad-y)
    clamp(20px, 3cqw, 36px)
    calc(clamp(32px, 4cqw, 56px) + env(safe-area-inset-bottom));
  display: grid; gap: clamp(16px, 2.2cqw, 22px);
  /* Pack rows from the top. Without this, grid's default align-content
     (stretch) inflates rows to fill the tall column; on pages with few
     rows that pushes flex-end page headers far down, leaving a big gap
     above the title. start keeps every page's title tight under the bar. */
  align-content: start;
  min-height: 0;
}

/* Custom scrollbar */
.content::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb {
  background: var(--stone-200); border-radius: var(--radius-pill);
  border: 2px solid var(--cream);
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12); border-radius: var(--radius-pill);
  border: 2px solid var(--charcoal);
}
.content::-webkit-scrollbar-thumb:hover { background: var(--stone-400); }

/* ============================================================
   Typography helpers
   ============================================================ */
.hero-eyebrow {
  font-size: 0.74rem; color: var(--stone-500);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600; margin-bottom: 8px;
}
.hero-eyebrow::before { content: "— "; color: var(--accent); }

.h1 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(1.5rem, 3cqw, 2.1rem);
  color: var(--charcoal); line-height: 1.1;
  letter-spacing: -0.015em; overflow-wrap: break-word;
  margin: 0 0 8px;
}
.h2 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(1.15rem, 1.8cqw, 1.4rem);
  color: var(--charcoal); margin: 0 0 12px;
  letter-spacing: -0.005em;
}
.lede {
  font-size: clamp(0.9rem, 1.2cqw, 1rem);
  color: var(--stone-700); line-height: 1.55;
  max-width: 720px; margin: 0;
}
.lede strong { color: var(--charcoal); font-weight: 600; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  height: 48px; padding: 0 22px; border-radius: var(--radius);
  font-size: 0.98rem; font-weight: 600; letter-spacing: -0.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition-fast);
  font-family: var(--font-sans); text-decoration: none;
}
.btn-primary {
  background: linear-gradient(180deg, #3373f3 0%, var(--accent) 100%);
  color: white;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: white; color: var(--charcoal); border-color: #d4ccc2;
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--stone-100); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--stone-700); box-shadow: none; }
.btn-ghost:hover { background: var(--stone-100); }
.btn-danger {
  background: linear-gradient(180deg, #d63838 0%, var(--red) 100%);
  color: white;
  box-shadow:
    0 1px 1px rgba(31, 29, 26, 0.1),
    0 4px 12px rgba(185, 28, 28, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 0.85rem; border-radius: var(--radius-md); }
.btn .icon { width: 18px; height: 18px; }
.btn:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none !important; box-shadow: var(--shadow-xs) !important;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-block { width: 100%; }

/* ============================================================
   Form fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 0.92rem; font-weight: 600; color: var(--charcoal);
  display: flex; align-items: center; gap: 6px;
}
.field-required { color: var(--red); font-weight: 700; }
.field-help { font-size: 0.82rem; color: var(--stone-500); line-height: 1.5; }
.field-error {
  font-size: 0.82rem; color: var(--red);
  display: flex; align-items: center; gap: 6px;
}
.field-error svg { width: 14px; height: 14px; }

.input, .select, .textarea {
  height: 48px; padding: 0 14px;
  font-size: 1rem; color: var(--charcoal);
  background: white; border: 1px solid #d4ccc2;
  border-radius: var(--radius);
  box-shadow: inset 0 1px 2px rgba(31,29,26,0.04);
  font-family: var(--font-sans); width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a716a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 42px;
}
.textarea {
  height: auto; padding: 12px 14px;
  resize: vertical; min-height: 120px; line-height: 1.6;
}
.input::placeholder, .textarea::placeholder { color: var(--stone-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 1px 2px rgba(31,29,26,0.04);
}
.input.is-error { border-color: var(--red); }
.input.is-error:focus { box-shadow: 0 0 0 3px var(--red-soft), inset 0 1px 2px rgba(31,29,26,0.04); }

/* Site footer — copyright line at the bottom of every page. In the app shell it
   sits below the scrollable .content as a persistent bar; on auth pages it renders
   centered beneath the card. */
.site-footer {
  flex-shrink: 0;
  padding: 13px 24px;
  border-top: 1px solid var(--stone-200);
  text-align: center;
  font-size: 0.78rem;
  color: var(--stone-500);
  background: rgba(255, 255, 255, 0.6);
}
/* Auth pages center a card in a flex row; pin the footer to the viewport bottom
   so it doesn't sit beside the card. */
.site-footer--fixed { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; }

/* File inputs: replace the raw native "Browse…" control with a tidy button that
   matches the design system. Applies to every .input[type=file] app-wide. */
.input[type="file"] {
  height: auto; padding: 8px 12px; line-height: 1.6;
  cursor: pointer; color: var(--stone-500);
}
.input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 16px;
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-md);
  background: var(--stone-100); color: var(--charcoal);
  font-family: var(--font-sans); font-weight: 600; font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.input[type="file"]::file-selector-button:hover {
  background: var(--stone-200); border-color: var(--stone-400);
}

.file-upload {
  border: 2px dashed #d4ccc2; border-radius: var(--radius-lg);
  padding: 24px; background: white;
  color: var(--stone-500); font-size: 0.92rem;
  box-shadow: inset 0 1px 2px rgba(31,29,26,0.03);
  cursor: pointer; text-align: center;
  transition: all var(--transition-fast);
}
.file-upload:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.file-upload.is-uploaded {
  border-style: solid; border-color: var(--green);
  background: linear-gradient(180deg, white, var(--green-soft));
  text-align: left;
}

.checkbox-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 4px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 22px; height: 22px; margin-top: 1px;
  accent-color: var(--accent); flex-shrink: 0;
}
.checkbox-row label {
  font-size: 0.95rem; color: var(--charcoal); line-height: 1.5;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 22px; border: 1px solid rgba(31,29,26,0.06);
  box-shadow: var(--shadow-sm);
}
.card-featured {
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-sm), -3px 0 12px -4px rgba(37,99,235,0.15);
}
.card-action {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 22px; border: 1px solid rgba(31,29,26,0.06);
  border-left: 3px solid var(--accent);
  display: flex; align-items: flex-start; gap: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none; color: inherit;
}
.card-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), -4px 0 16px -6px rgba(37,99,235,0.2);
  text-decoration: none;
}
.card-action-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft) 0%, #f0f4ff 100%);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.card-action-icon svg { width: 22px; height: 22px; }
.card-action-title {
  font-family: var(--font-serif); font-size: 1.1rem; font-weight: 500;
  color: var(--charcoal); margin-bottom: 2px;
}
.card-action-desc { font-size: 0.9rem; color: var(--stone-500); line-height: 1.5; }

.card-stat {
  background: var(--card); border-radius: var(--radius-xl);
  padding: 22px; border: 1px solid rgba(31,29,26,0.06);
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.card-stat::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,250,240,0.4), transparent 60%);
  pointer-events: none;
}
.card-stat-num {
  font-family: var(--font-serif); font-size: clamp(1.7rem, 3cqw, 2.4rem);
  font-weight: 400; color: var(--charcoal);
  line-height: 1.05; letter-spacing: -0.02em;
  position: relative;
}
.card-stat-label {
  font-size: 0.86rem; color: var(--stone-500);
  position: relative; margin-top: 4px;
}

/* ============================================================
   Status badges (pill style)
   ============================================================ */
.badge-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 0.78rem; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(31,29,26,0.04);
  white-space: nowrap;
}
.badge-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}
.b-success { background: var(--green-soft); color: var(--green); }
.b-success .dot { background: #22c55e; }
.b-warning { background: var(--amber-soft); color: var(--amber); }
.b-warning .dot { background: #eab308; }
.b-danger { background: var(--red-soft); color: var(--red); }
.b-danger .dot { background: #dc2626; }
.b-info { background: #e7e5e4; color: #44403c; }
.b-info .dot { background: #78716c; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs-container {
  background: var(--card); border: 1px solid rgba(31,29,26,0.06);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); overflow: hidden;
  /* Floors the strip's height. .content is display:grid, and the
     horizontally-scrollable .tabs child (overflow-x:auto) contributes 0 height
     to its track, which would otherwise collapse the strip behind
     overflow:hidden — making the tab labels invisible. */
  min-height: 54px;
}
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--stone-200);
  padding: 0 8px; overflow-x: auto; overflow-y: hidden;
  touch-action: pan-x;                 /* horizontal pan only — no vertical drift */
  overscroll-behavior-x: contain;      /* don't chain-scroll the page */
  scroll-snap-type: x proximity;
}
.tab {
  padding: 14px 16px; font-size: 0.92rem; font-weight: 600;
  color: var(--stone-500); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  text-decoration: none;
  transition: color var(--transition-fast);
  scroll-snap-align: start;
}
.tab:hover { color: var(--charcoal); text-decoration: none; }
.tab.active {
  color: var(--accent); border-bottom-color: var(--accent);
  background: linear-gradient(180deg, transparent, rgba(37, 99, 235, 0.04));
}
.tab .count {
  background: var(--stone-100); color: var(--stone-500);
  border-radius: var(--radius-pill);
  padding: 2px 8px; font-size: 0.72rem;
  margin-left: 6px; font-weight: 700;
}
.tab.active .count { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   List rows / table
   ============================================================ */
.list-table {
  background: var(--card); border: 1px solid rgba(31,29,26,0.06);
  border-radius: var(--radius-xl); overflow: hidden;
  box-shadow: var(--shadow-md);
}
.list-row, .list-row-head {
  display: grid; gap: 16px;
  padding: 14px 22px; align-items: center;
  border-bottom: 1px solid var(--stone-200);
}
.list-row { cursor: pointer; transition: background var(--transition-fast); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover {
  background: linear-gradient(90deg, var(--stone-100), rgba(245, 240, 232, 0.4));
}
.list-row-head {
  background: var(--stone-100);
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--stone-500); font-weight: 700;
}
.th-sort {
  background: none; border: 0; cursor: pointer; padding: 0;
  font: inherit; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700; color: var(--stone-500);
  display: inline-flex; align-items: center; gap: 5px; text-align: left;
}
.th-sort:hover { color: var(--charcoal); }
.th-sort::after { content: "\2195"; opacity: 0.35; font-size: 0.85em; }
.th-sort[data-dir="asc"]::after { content: "\2191"; opacity: 1; color: var(--accent); }
.th-sort[data-dir="desc"]::after { content: "\2193"; opacity: 1; color: var(--accent); }
.list-title {
  font-size: 0.95rem; font-weight: 600; color: var(--charcoal);
  overflow-wrap: break-word;
}
.list-meta { font-size: 0.82rem; color: var(--stone-500); margin-top: 2px; }
.list-date { font-size: 0.82rem; color: var(--stone-500); }
.list-action { font-size: 0.85rem; font-weight: 600; color: var(--accent); text-align: right; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex; gap: 14px; padding: 16px 20px;
  border-radius: var(--radius-lg);
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.alert > svg { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; }
.alert-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; }
.alert-body { font-size: 0.88rem; line-height: 1.5; }
.alert-emergency {
  background: linear-gradient(180deg, #fff1f1, var(--red-soft));
  border: 1px solid #fecaca; color: #7f1d1d;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.5);
}
.alert-success {
  background: linear-gradient(180deg, #f0fdf4, var(--green-soft));
  border: 1px solid #bbf7d0; color: #14532d;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.5);
}
.alert-info {
  background: linear-gradient(180deg, #fafaf8, var(--stone-100));
  border: 1px solid var(--stone-200); color: var(--stone-700);
  box-shadow: var(--shadow-xs);
}
.alert-warning {
  background: linear-gradient(180deg, #fffbf0, var(--amber-soft));
  border: 1px solid #fde68a; color: #713f12;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.5);
}

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  background: var(--card); border: 1px solid var(--stone-200);
  border-radius: var(--radius-xl);
  padding: 56px 24px; text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.empty::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at top, rgba(255,250,240,0.5), transparent 50%);
  pointer-events: none;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--stone-100), var(--stone-200));
  color: var(--stone-500);
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), var(--shadow-xs);
  position: relative;
}
.empty-title {
  font-family: var(--font-serif); font-size: 1.3rem; font-weight: 500;
  color: var(--charcoal); margin-bottom: 6px; position: relative;
}
.empty-desc {
  font-size: 0.95rem; color: var(--stone-500);
  margin: 0 auto 22px; max-width: 380px; line-height: 1.55;
  position: relative;
}

/* ============================================================
   Confirmation modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(31,29,26,0.5), rgba(31,29,26,0.7));
  display: flex; align-items: center; justify-content: center;
  padding: 36px; z-index: 100;
}
.modal-card {
  background: var(--card); border-radius: 16px;
  padding: 30px; max-width: 460px; width: 100%;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal-title {
  font-family: var(--font-serif); font-size: 1.5rem;
  font-weight: 500; color: var(--charcoal);
  margin-bottom: 10px;
}
.modal-body { font-size: 0.95rem; color: var(--stone-700); line-height: 1.55; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   Progress stepper (status display)
   ============================================================ */
.progress-stepper {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0; padding: 4px 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--stone-200);
}
.step {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 8px; min-width: 0; padding: 0 4px;
}
.step::after {
  content: ""; position: absolute;
  left: 50%; right: -50%; top: 14px;
  height: 2px; background: var(--stone-200); z-index: 0;
}
.step:last-child::after { display: none; }
.step.is-done::after { background: var(--green); }
.step.is-current::after { background: linear-gradient(90deg, var(--accent) 50%, var(--stone-200) 50%); }
.step-marker {
  position: relative; z-index: 1;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--stone-200);
  display: flex; align-items: center; justify-content: center;
  color: var(--stone-400); font-weight: 700; font-size: 0.82rem;
}
.step.is-done .step-marker { background: var(--green); border-color: var(--green); color: white; }
.step.is-done .step-marker svg { width: 14px; height: 14px; }
.step.is-current .step-marker {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.step-label {
  font-size: 0.82rem; font-weight: 600;
  color: var(--stone-500); text-align: center; line-height: 1.25;
}
.step.is-done .step-label { color: var(--charcoal); }
.step.is-current .step-label { color: var(--accent); }

/* ============================================================
   Wizard indicator (multi-step form)
   ============================================================ */
.wizard {
  background: var(--card); border: 1px solid rgba(31,29,26,0.06);
  border-radius: var(--radius-xl);
  padding: 22px 28px; box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
}
.wiz-step {
  position: relative; display: flex; align-items: center;
  gap: 14px; padding: 0 4px; min-width: 0;
}
.wiz-step::after {
  content: ""; position: absolute;
  left: calc(100% - 4px); right: -4px; top: 50%;
  height: 2px; background: var(--stone-200);
  transform: translateY(-50%);
}
.wiz-step:last-child::after { display: none; }
.wiz-step.is-done::after { background: var(--green); }
.wiz-step.is-current::after { background: linear-gradient(90deg, var(--accent) 50%, var(--stone-200) 50%); }
.wiz-marker {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--stone-200);
  display: flex; align-items: center; justify-content: center;
  color: var(--stone-400); font-weight: 700; font-size: 0.95rem;
  flex-shrink: 0;
}
.wiz-step.is-done .wiz-marker { background: var(--green); border-color: var(--green); color: white; }
.wiz-step.is-done .wiz-marker svg { width: 16px; height: 16px; }
.wiz-step.is-current .wiz-marker {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.wiz-text { min-width: 0; }
.wiz-step-label {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--stone-500);
}
.wiz-step.is-done .wiz-step-label, .wiz-step.is-current .wiz-step-label { color: var(--accent); }
.wiz-step-title {
  font-family: var(--font-serif); font-size: 1rem; font-weight: 500;
  color: var(--stone-500); margin-top: 2px; line-height: 1.2;
}
.wiz-step.is-done .wiz-step-title, .wiz-step.is-current .wiz-step-title { color: var(--charcoal); }

/* ============================================================
   Container-query responsive rules (shell scope)
   ============================================================ */
@container shell (max-width: 1024px) {
  .grid-2, .detail-grid { grid-template-columns: 1fr !important; }
}
@container shell (max-width: 820px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .field-row { grid-template-columns: 1fr !important; }
  .wizard { grid-template-columns: 1fr; }
  .wiz-step::after { display: none; }
  .progress-stepper { grid-template-columns: 1fr; gap: 14px; padding: 4px 0; }
  .step { flex-direction: row; gap: 12px; justify-content: flex-start; align-items: center; padding: 0; }
  .step::after { display: none; }
  .step-label { text-align: left; }
}
@container shell (max-width: 720px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-menu { display: flex; }
  /* Mobile: drop the breadcrumb — the page <h1> already gives context, and the
     topbar keeps the menu button (left) and notification bell (right). */
  .crumb { display: none; }

  /* iOS auto-zooms on focus when input font-size < 16px; force 16px */
  input, select, textarea, .input { font-size: 16px; }
  /* 44x44 minimum touch targets for interactive controls */
  .mobile-menu, .icon-btn, .tab, .sb-item, .nav-overlay-close,
  .btn { min-height: 44px; }
  .icon-btn, .mobile-menu, .nav-overlay-close { min-width: 44px; }
  /* Flat look on mobile: drop shadows, rely on borders for separation. */
  .card, .panel, .form-card, .list-table, .tabs-container, .card-stat, .card-action { box-shadow: none !important; }

  /* List tables → stacked cards (applies to ALL .list-table pages app-wide) */
  .list-table .list-row-head { display: none; }          /* hide normalized header row */
  .list-table .list-row {
    display: block; padding: 12px 14px;
    border: 1px solid var(--stone-200); border-radius: var(--radius-lg);
    margin-bottom: 10px; grid-template-columns: none !important;
  }
  .list-table .list-row > * { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
  /* Prefix each cell with its column label, supplied via data-label */
  .list-table .list-row > *[data-label]::before {
    content: attr(data-label);
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--stone-400); flex-shrink: 0;
  }

  /* Residents list: compact name + unit rows on mobile (tap the row to open
     the resident's detail page). Email/Status/Notes stay hidden. */
  .residents-table .list-row { padding: 12px 14px; margin-bottom: 6px; }
  .residents-table .list-row > *:not([data-label="Name"]):not([data-label="Unit"]) { display: none; }
  .residents-table .list-row > *[data-label="Name"],
  .residents-table .list-row > *[data-label="Unit"] { padding: 0; justify-content: flex-start; }
  .residents-table .list-row > *[data-label="Name"]::before,
  .residents-table .list-row > *[data-label="Unit"]::before { display: none; }
  .residents-table .list-row > *[data-label="Unit"] { font-size: 0.8rem; color: var(--stone-500); margin-top: 2px; }
}
@container shell (max-width: 520px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

/* Generic grid helpers (use with .grid-N classes) */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--space-4); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: clamp(16px, 2cqw, 20px); }

/* Form sections (for grouped forms) */
.form-card {
  background: var(--card); border-radius: var(--radius-xl);
  border: 1px solid rgba(31,29,26,0.06);
  box-shadow: var(--shadow-sm);
  padding: clamp(20px, 2.5cqw, 32px);
}
.form-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--stone-200); }
.form-section:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section-title {
  font-family: var(--font-serif); font-size: 1.05rem; font-weight: 500;
  color: var(--charcoal); margin: 0 0 4px; letter-spacing: -0.005em;
}
.form-section-sub { font-size: 0.84rem; color: var(--stone-500); margin: 0 0 16px; line-height: 1.5; }
.form-actions {
  display: flex; gap: 12px; justify-content: flex-end;
  padding-top: 24px; margin-top: 6px;
  border-top: 1px solid var(--stone-200); flex-wrap: wrap;
}

/* Panel (used inside detail pages) */
.panel {
  background: var(--card); border-radius: var(--radius-xl);
  border: 1px solid rgba(31,29,26,0.06);
  box-shadow: var(--shadow-sm);
  padding: clamp(18px, 2.5cqw, 26px);
}
.panel-title {
  font-family: var(--font-serif); font-weight: 500; font-size: 1.1rem;
  color: var(--charcoal); margin: 0 0 14px; letter-spacing: -0.005em;
}
.panel-text { font-size: 0.94rem; color: var(--stone-700); line-height: 1.65; overflow-wrap: break-word; }

/* ── Notification bell + dropdown ─────────────────────────────────────── */
.notif { position: relative; }
.notif > summary { list-style: none; }
.notif > summary::-webkit-details-marker { display: none; }
.notif > summary::marker { content: ""; }
.notif-count {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: var(--red); color: #fff;
  border: 2px solid var(--cream);
  font-size: 0.62rem; font-weight: 700; line-height: 12px;
  display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--card); border: 1px solid var(--stone-200);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--stone-200);
  font-family: var(--font-serif); font-weight: 500; font-size: 0.98rem;
  color: var(--charcoal);
}
.notif-mark {
  background: none; border: 0; cursor: pointer;
  font-size: 0.78rem; font-weight: 600; color: var(--accent);
}
.notif-mark:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: block; padding: 12px 16px;
  border-bottom: 1px solid var(--stone-200);
  text-decoration: none; color: inherit;
}
a.notif-item:hover { background: var(--stone-100); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: var(--accent-soft); }
.notif-item-title { font-size: 0.88rem; font-weight: 600; color: var(--charcoal); }
.notif-item-body { font-size: 0.8rem; color: var(--stone-500); line-height: 1.45; margin-top: 2px; }
.notif-item-date { font-size: 0.72rem; color: var(--stone-400); margin-top: 4px; }
.notif-empty { padding: 24px 16px; text-align: center; font-size: 0.86rem; color: var(--stone-500); }
.notif-foot {
  display: block; padding: 11px 16px; text-align: center;
  font-size: 0.8rem; font-weight: 600; color: var(--accent);
  background: var(--cream);
}
.notif-foot:hover { background: var(--stone-100); }

/* ===== Mobile hardening ===== */
/* Prevent whole-page horizontal scroll from any stray overflow */
html, body { max-width: 100%; }
/* Long URLs / code wrap instead of forcing width */
.list-meta, code { overflow-wrap: anywhere; word-break: break-word; }

/* ============================================================
   Client-side tables (List.js enhancer: toolbar / search / pager)
   ============================================================ */
.list-tbl-toolbar {
  display: flex; justify-content: flex-end;
  margin-bottom: var(--space-4);
}
.list-tbl-search {
  max-width: 320px; width: 100%;
}
.list-tbl-empty {
  text-align: center; color: var(--stone-500);
  font-size: 0.9rem; padding: 28px 16px;
}
.list-tbl-pager {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap;
}
.list-tbl-pager li { display: inline-flex; }
.list-tbl-pager .page {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--stone-200); border-radius: var(--radius-md);
  background: var(--card); color: var(--charcoal);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast);
}
.list-tbl-pager .page:hover { background: var(--stone-100); }
/* List.js marks the current page; cover both `active` on the <li> and on the <a>. */
.list-tbl-pager .active .page,
.list-tbl-pager .page.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* Mobile: the shell container goes flat at ≤720px; let the search box span full
   width and sit above the stacked card rows. */
@container shell (max-width: 720px) {
  .list-tbl-toolbar { justify-content: stretch; }
  .list-tbl-search { max-width: none; }
}
