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

:root {
  /* Dark, indigo brand system — unified with the landing page (#05070f + indigo/violet/cyan). */
  --bg: #05070f;
  --bg-elev: #0a0e1a;
  --bg-accent: radial-gradient(circle at top right, rgba(99, 102, 241, 0.18), transparent 32%),
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.10), transparent 26%),
    linear-gradient(180deg, #05070f 0%, #070a14 60%, #05070f 100%);
  --card: rgba(255, 255, 255, 0.04);
  --card-strong: rgba(255, 255, 255, 0.065);
  --card-hover: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --muted: #9aa3b8;
  --text-dim: #69728a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --secondary: #c7cee0;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --danger-strong: #ef4444;
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);
  --grad-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 130%);
  --grad-cta: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.5);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --topbar-h: 72px;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: #05070f;
  overflow-x: clip; /* clip prevents horizontal scroll without creating a scroll-container, so position:sticky still works */
}

body {
  font-family: "Rubik", "Heebo", "Segoe UI", sans-serif;
  color: var(--text);
  background-color: #05070f;
  background-image: var(--bg-accent);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button,
[role="button"],
a {
  font-family: inherit;
}

button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 2px;
}

.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;
}

.hidden {
  display: none !important;
}

/* ----------------- Topbar ----------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(7, 10, 20, 0.85);
  border-bottom: 1px solid rgba(99, 102, 241, 0.08);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
  border: none;
  cursor: pointer;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 24px;
  min-width: 220px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.user-menu-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.user-menu-item {
  color: var(--text);
  font-size: 0.9rem;
}

.user-menu-item.muted {
  color: var(--muted);
}

.user-menu-separator {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 8px 0;
}

.user-menu-logout {
  display: block;
  width: 100%;
  text-align: right;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: 0.9rem;
  color: #f87171;
  font-weight: 600;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.refresh-note {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.82rem;
  color: var(--muted);
}

.refresh-note.is-live {
  color: var(--success);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-dot.connected {
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.status-dot.disconnected {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

img,
svg,
canvas {
  max-width: 100%;
}

.tab-panel {
  display: block;
}

.overview-stack {
  display: grid;
  gap: 20px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.view-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  z-index: 12;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.view-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.view-tab:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary-strong);
}

.view-tab.is-active,
.view-tab[aria-selected="true"] {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* ----------------- Urgent Hero (new) ----------------- */

.urgent-hero {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.urgent-hero.urgent-alert {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.16) 0%, rgba(255, 255, 255, 0.03) 60%);
  border-color: rgba(185, 28, 28, 0.18);
}

.urgent-hero.urgent-calm {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.16) 0%, rgba(255, 255, 255, 0.03) 60%);
  border-color: rgba(21, 128, 61, 0.18);
}

.urgent-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.urgent-hero-title {
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}

.urgent-hero-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.urgent-hero-badge {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--danger);
  color: #fff;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.urgent-hero-badge.is-ok {
  background: var(--success);
}

.urgent-list {
  display: grid;
  gap: 10px;
}

.urgency-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.urgent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 5px solid var(--warning);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  text-align: right;
  appearance: none;
  color: inherit;
}

.urgent-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.urgent-row.is-critical {
  border-right-color: var(--danger);
  background: linear-gradient(90deg, rgba(185,28,28,0.06), rgba(255,255,255,0.05));
}

.urgent-row.is-high {
  border-right-color: var(--warning);
}

.urgent-row.is-medium {
  border-right-color: var(--info);
}

.urgent-row-main {
  min-width: 0;
  flex: 1;
}

.urgent-row-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.35;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.urgent-row-meta {
  color: var(--muted);
  font-size: 0.86rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.urgent-row-meta .sla-breach-inline {
  color: var(--danger);
  font-weight: 700;
}

.urgent-row-cta {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  text-decoration: underline;
}

.urgency-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.urgency-label.is-critical {
  background: var(--danger-soft);
  color: var(--danger);
}

.urgency-label.is-high {
  background: var(--warning-soft);
  color: var(--warning);
}

.urgency-label.is-medium,
.urgency-label.is-low {
  background: var(--info-soft);
  color: var(--info);
}

.urgent-empty {
  text-align: center;
  padding: 18px;
  color: var(--success);
  font-weight: 600;
}

/* ----------------- Stats grid ----------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-body {
  min-width: 0;
}

.stat-value {
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card.stat-open .stat-value { color: var(--warning); }
.stat-card.stat-open .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat-card.stat-progress .stat-value { color: var(--info); }
.stat-card.stat-progress .stat-icon { background: var(--info-soft); color: var(--info); }
.stat-card.stat-done .stat-value { color: var(--success); }
.stat-card.stat-done .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-card.stat-sla .stat-value { color: var(--danger); }
.stat-card.stat-sla .stat-icon { background: var(--danger-soft); color: var(--danger); }

/* ----------------- Layout columns ----------------- */

.dashboard-columns,
.area-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 360px;
  gap: 20px;
  align-items: start;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-heading.compact {
  margin-bottom: 10px;
}

.section-heading h2,
.side-card-head h3 {
  margin: 0;
  font-size: 1.2rem;
}

.dashboard-main,
.area-main,
.dashboard-side,
.area-side {
  display: grid;
  gap: 18px;
}

.overview-map-card {
  margin-top: 0;
}

/* ----------------- Map card ----------------- */

.map-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.map-summary {
  font-size: 0.88rem;
  color: var(--muted);
}

.map-canvas {
  height: 320px;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.map-canvas .leaflet-container {
  background: rgba(255, 255, 255, 0.05) !important;
  height: 100%;
  width: 100%;
}

.area-map {
  height: 240px;
}

.map-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 4px 0;
  font-size: 0.82rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.legend-danger { background: var(--danger); }
.legend-warning { background: var(--warning); }
.legend-ok { background: var(--success); }

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}

.eyebrow.dark {
  color: var(--muted);
}

/* ----------------- Area cards ----------------- */

.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.area-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  text-align: right;
  appearance: none;
  color: inherit;
}

.area-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(99, 102, 241, 0.2);
}

.area-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.area-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.area-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
}

.area-manager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--primary-strong);
  font-weight: 600;
}

.area-primary-badge {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.area-primary-badge.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.area-primary-badge.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.area-primary-badge.is-ok {
  background: var(--success-soft);
  color: var(--success);
}

.area-card-stats {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  flex-wrap: wrap;
}

.area-card-stats strong {
  color: var(--text);
  font-weight: 700;
}

.area-card-footer {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.area-card-cta {
  color: var(--primary);
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  text-decoration: underline;
}

/* ----------------- Side cards / alerts ----------------- */

.side-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

/* .side-card-head now defined at bottom with full layout */

.alert-stack,
.insight-list,
.worker-list,
.building-list,
.ticket-list {
  display: grid;
  gap: 12px;
}

.alert-card,
.insight-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.alert-card[role="button"] {
  width: 100%;
  text-align: right;
  cursor: pointer;
}

.alert-card[role="button"]:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.insight-card.is-empty .insight-title,
.insight-card.is-empty .insight-body {
  color: #7f8c98;
}

.alert-card.is-danger {
  background: linear-gradient(180deg, rgba(185, 28, 28, 0.1), rgba(255, 255, 255, 0.05));
  border-right: 4px solid var(--danger);
}

.alert-card.is-warning {
  background: linear-gradient(180deg, rgba(180, 83, 9, 0.1), rgba(255, 255, 255, 0.05));
  border-right: 4px solid var(--warning);
}

.alert-title,
.insight-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.alert-body,
.insight-body {
  color: var(--muted);
  font-size: 0.92rem;
}

.alert-meta {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.insight-card.is-metric {
  display: flex;
  align-items: center;
  gap: 12px;
}

.insight-card .insight-icon {
  font-size: 1.5rem;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

/* ----------------- Ticket cards (flipped hierarchy) ----------------- */

.ticket-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  border-right: 5px solid transparent;
  scroll-margin-top: 100px;
}

.ticket-legend {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.list-search {
  min-width: 0;
}

.list-search-input,
.list-filter-select {
  width: 100%;
  min-height: 42px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
}

.list-search-input {
  padding: 9px 12px;
}

.list-filter-select {
  padding: 7px 10px;
  cursor: pointer;
}

.list-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
}

.list-filters label {
  display: grid;
  gap: 4px;
  min-width: 124px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.list-result-count {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
}

.ticket-card.urgency-CRITICAL { border-right-color: var(--danger); background: linear-gradient(90deg, rgba(185,28,28,0.06), var(--card)); }
.ticket-card.urgency-HIGH { border-right-color: var(--warning); }
.ticket-card.urgency-MEDIUM { border-right-color: var(--info); }
.ticket-card.urgency-LOW { border-right-color: var(--success); }

.ticket-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ticket-description {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 10px;
}

.ticket-meta {
  display: flex;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.84rem;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticket-id {
  direction: ltr;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--muted);
  opacity: 0.72;
}

.sla-breach {
  color: var(--danger);
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill-urgency-CRITICAL { background: var(--danger); color: #fff; }
.pill-urgency-HIGH { background: var(--warning); color: #fff; }
.pill-urgency-MEDIUM { background: var(--info); color: #fff; }
.pill-urgency-LOW { background: var(--success); color: #fff; }

.pill-building {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.pill-status-OPEN { background: var(--warning-soft); color: var(--warning); }
.pill-status-IN_PROGRESS { background: var(--info-soft); color: var(--info); }
.pill-status-DONE { background: var(--success-soft); color: var(--success); }

.pill-cat-CLEANING { background: rgba(16, 185, 129, 0.14); color: #34d399; }
.pill-cat-ELECTRIC { background: rgba(234, 179, 8, 0.18); color: #a16207; }
.pill-cat-PLUMBING { background: rgba(6, 182, 212, 0.16); color: #22d3ee; }
.pill-cat-ELEVATOR { background: rgba(217, 70, 239, 0.16); color: #a21caf; }
.pill-cat-GENERAL { background: rgba(100, 116, 139, 0.16); color: #9aa3b8; }

/* ----------------- Building cards ----------------- */

.building-card {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  width: 100%;
  text-align: right;
  appearance: none;
  color: inherit;
}

.building-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(99, 102, 241, 0.2);
}

.building-card.has-open {
  border-right: 4px solid var(--warning);
}

.building-card.has-critical {
  border-right: 4px solid var(--danger);
  background: linear-gradient(90deg, rgba(185,28,28,0.05), var(--card));
}

.building-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.building-title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.25;
}

.building-address {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

.building-open-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--success-soft);
  color: var(--success);
}

.building-open-pill.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.building-open-pill.is-danger {
  background: var(--danger);
  color: #fff;
}

.building-focus-line {
  font-size: 0.9rem;
  color: var(--text);
  margin: 8px 0;
  font-weight: 600;
}

.building-focus-line.muted {
  color: var(--muted);
  font-weight: 500;
}

.worker-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 600;
}

.worker-tag.is-missing {
  background: var(--danger-soft);
  color: var(--danger);
}

.worker-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.worker-tag.is-missing .worker-avatar {
  background: var(--danger);
}

.building-mini-meta {
  display: flex;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  flex-wrap: wrap;
  margin-top: 10px;
  list-style: none;
  padding: 0;
  margin-bottom: 0;
}

.building-mini-meta li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ----------------- Worker cards ----------------- */

.worker-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
  border-right: 4px solid transparent;
}

.worker-card.is-ready {
  border-right-color: var(--success);
}

.worker-card.is-busy {
  border-right-color: var(--warning);
}

.worker-card.is-critical {
  border-right-color: var(--danger);
  background: linear-gradient(90deg, rgba(185, 28, 28, 0.05), rgba(255, 255, 255, 0.05));
}

.worker-card.is-inactive {
  border-right-color: #94a3b8;
}

.worker-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.worker-card-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.worker-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  color: #ffffff;
  font-weight: 700;
  flex-shrink: 0;
}

.worker-card-name {
  font-size: 1rem;
  font-weight: 800;
}

.worker-card-phone {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.worker-state-badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.worker-state-badge.is-ready {
  background: var(--success-soft);
  color: var(--success);
}

.worker-state-badge.is-busy {
  background: var(--warning-soft);
  color: var(--warning);
}

.worker-state-badge.is-critical {
  background: var(--danger-soft);
  color: var(--danger);
}

.worker-state-badge.is-inactive {
  background: rgba(148, 163, 184, 0.16);
  color: #9aa3b8;
}

.worker-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.worker-metric {
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
  text-align: center;
}

.worker-metric-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.worker-metric-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.worker-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-strong);
  margin-bottom: 8px;
}

.worker-building-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.worker-building-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.worker-empty-note,
.worker-note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ----------------- Back button ----------------- */

.back-btn {
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--secondary);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.breadcrumb-nav {
  margin-bottom: 10px;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.breadcrumb-list a {
  color: var(--muted);
  text-decoration: underline;
}

.breadcrumb-separator {
  color: var(--muted);
}

.area-view-head {
  margin-bottom: 14px;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.back-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

/* ----------------- Modal ----------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 28px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: var(--secondary);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-title {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal-subtitle {
  color: var(--muted);
  margin-bottom: 18px;
}

.modal-section {
  margin-top: 22px;
}

.modal-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.modal-section-title.warn {
  color: var(--danger);
}

.modal-action-panel {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(52, 211, 153, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-md);
  padding: 18px;
}

.modal-action-panel.is-alert {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(248, 113, 113, 0.12) 100%);
  border-color: rgba(185, 28, 28, 0.18);
}

.modal-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-action-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.modal-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.modal-action-icon.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.modal-action-icon.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-action-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.modal-action-value {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
}

.modal-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.modal-detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.modal-detail-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.modal-detail-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.schedule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 8px;
}

.schedule-day {
  min-width: 74px;
  font-weight: 700;
}

.schedule-time {
  min-width: 58px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--primary);
}

.schedule-desc {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
}

.category-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

/* ----------------- Leaflet ----------------- */

.leaflet-container {
  font-family: "Rubik", "Heebo", "Segoe UI", sans-serif;
}

.map-popup h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.map-popup p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ----------------- Sim panel ----------------- */

#sim-panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 25;
}

#sim-toggle {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.88);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  font-weight: 600;
}

.sim-badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

#sim-content {
  width: min(360px, calc(100vw - 40px));
  margin-top: 10px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-lg);
}

#sim-content h3 {
  margin: 0 0 14px;
}

.sim-field {
  margin-bottom: 12px;
}

.sim-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.sim-field input,
.sim-field select,
.sim-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  font: inherit;
}

#sim-send {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#sim-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#sim-result {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  font-size: 0.9rem;
}

#sim-result.sim-success {
  background: var(--success-soft);
  color: var(--success);
}

#sim-result.sim-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ----------------- Toasts ----------------- */

#toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 16px);
  left: 24px;
  z-index: 40;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 300px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.12);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.28s ease-out;
}

.toast-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.toast-body {
  font-size: 0.9rem;
  color: var(--muted);
}

.toast.toast-out {
  animation: toast-out 0.28s ease-in forwards;
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ----------------- Responsive ----------------- */

@media (max-width: 1120px) {
  .dashboard-columns,
  .area-columns {
    grid-template-columns: 1fr;
  }

  .dashboard-side,
  .area-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }

  .modal-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  :root {
    --topbar-h: 60px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
  }

  .topbar-inner,
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar-inner {
    padding-top: 10px;
    padding-bottom: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 0.9rem;
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-subtitle {
    display: none;
  }

  .topbar-status {
    width: 100%;
    justify-content: space-between;
  }

  .refresh-note {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
  }

  .live-chip .chip-text {
    display: inline;
  }

  .live-chip {
    padding: 8px;
    min-height: 30px;
    width: auto;
    height: auto;
    justify-content: center;
  }

  .urgent-hero {
    padding: 18px;
  }

  .view-tabs {
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .view-tab {
    white-space: nowrap;
    padding: 10px 14px;
  }

  .urgent-hero-head {
    align-items: stretch;
  }

  .urgent-hero-badge {
    align-self: flex-start;
  }

  .urgent-row {
    padding: 12px 14px;
    align-items: flex-start;
  }

  .urgent-row-cta {
    display: none;
  }

  .stats-grid,
  .stats-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }

  .area-grid {
    grid-template-columns: 1fr;
  }

  .area-card,
  .building-card,
  .ticket-card,
  .side-card,
  .map-card {
    padding: 14px;
  }

  .area-card-top,
  .building-card-top {
    flex-direction: column;
    align-items: stretch;
  }

  .area-primary-badge,
  .building-open-pill {
    align-self: flex-start;
  }

  .dashboard-side,
  .area-side {
    grid-template-columns: 1fr;
  }

  .insights-grid,
  .overview-stack {
    gap: 14px;
  }

  .worker-card-top {
    flex-direction: column;
    align-items: stretch;
  }

  .worker-state-badge {
    align-self: flex-start;
  }

  .worker-metrics {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    height: 240px;
  }

  .area-map {
    height: 220px;
  }

  .building-mini-meta,
  .ticket-meta,
  .urgent-row-meta,
  .area-card-stats,
  .area-card-footer {
    gap: 6px 10px;
  }

  .area-card-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-action-row {
    grid-template-columns: 1fr;
  }

  .modal-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-card {
    width: 100%;
    max-height: 90vh;
    padding: 22px 18px;
    border-radius: 24px 24px 0 0;
  }

  .modal-title {
    font-size: 1.35rem;
  }

  .schedule-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  #toast-container {
    left: 12px;
    right: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  #sim-panel {
    left: 12px;
    bottom: 12px;
    right: 12px;
  }

  #sim-toggle {
    width: 100%;
    justify-content: center;
  }

  #sim-content {
    width: 100%;
  }

  .user-menu {
    right: 16px;
    left: 16px;
    min-width: 0;
  }
}

@media (min-width: 721px) {
  .shell {
    min-height: calc(100vh - var(--topbar-h));
  }
}

@media (hover: none) and (pointer: coarse) {
  .area-card:hover,
  .building-card:hover,
  .urgent-row:hover,
  .alert-card[role="button"]:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
}

/* =============================================================================
   SCHEDULE & SWAPS
   ============================================================================= */

.schedule-header {
  margin-bottom: 1.25rem;
}

.schedule-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.schedule-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.schedule-date-input {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.schedule-date-input:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
}

.schedule-day-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted, #9aa3b8);
  margin-bottom: 1rem;
}

.schedule-workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.sched-worker-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.sched-worker-card.worker-inactive {
  opacity: 0.6;
}

.sched-worker-card.unassigned-card {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.10);
}

.sched-worker-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.sched-worker-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.sched-worker-info {
  flex: 1;
  min-width: 0;
}

.sched-worker-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.sched-worker-phone {
  font-size: 0.8rem;
  color: var(--muted, #9aa3b8);
}

.sched-worker-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}

.sched-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.sched-badge.critical { background: rgba(248, 113, 113, 0.14); color: #f87171; }
.sched-badge.open     { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.sched-badge.swap     { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
.sched-badge.warn     { background: rgba(251, 191, 36, 0.14); color: #fbbf24; }

.sched-buildings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sched-building-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sched-building-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.sched-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent, #6366f1);
  background: rgba(99, 102, 241, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  direction: ltr;
}

.sched-building-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.sched-tickets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sched-ticket-count {
  font-size: 0.75rem;
  color: var(--muted, #9aa3b8);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

.sched-ticket-count.critical {
  background: rgba(248, 113, 113, 0.14);
  color: #f87171;
}

.sched-swap-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: #c7cee0;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.sched-swap-btn:hover {
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

.schedule-unassigned {
  margin-top: 1.5rem;
}

.schedule-empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted, #9aa3b8);
}

/* Swaps table */
.swaps-table {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.swaps-table-head,
.swaps-table-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr 1fr 1fr 80px;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  align-items: center;
  font-size: 0.85rem;
}

.swaps-table-head {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  color: #c7cee0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.swaps-table-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.swaps-table-row:last-child {
  border-bottom: none;
}

.swap-replacement-name {
  font-weight: 600;
  color: #38bdf8;
}

.swap-reason {
  color: var(--muted, #9aa3b8);
  font-size: 0.8rem;
}

.sched-cancel-btn {
  padding: 4px 8px;
  border: 1.5px solid #f87171;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #f87171;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.sched-cancel-btn:hover {
  background: rgba(248, 113, 113, 0.14);
}

/* Swap modal */
.swap-modal-card {
  max-width: 460px;
}

.swap-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}

.swap-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-row label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #c7cee0;
}

.form-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.swap-error {
  color: #f87171;
  font-size: 0.875rem;
  background: rgba(248, 113, 113, 0.14);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.swap-submit-btn {
  margin-top: 0.5rem;
  width: 100%;
}

/* Generic buttons */
.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }

.btn-ghost {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #9aa3b8;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { border-color: #69728a; color: #c7cee0; }

/* Toast */
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  animation: toast-in 0.2s ease;
}
.toast-success { background: #d1fae5; color: #34d399; }
.toast-error   { background: rgba(248, 113, 113, 0.14); color: #f87171; }
.toast-info    { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loading-state {
  padding: 2rem;
  text-align: center;
  color: var(--muted, #9aa3b8);
  font-size: 0.9rem;
}

.schedule-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3rem 2rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  text-align: center;
}

.schedule-empty-icon { font-size: 2.5rem; }

.schedule-empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #c7cee0;
}

.schedule-empty-sub {
  font-size: 0.9rem;
  color: var(--muted, #9aa3b8);
  margin-bottom: 0.5rem;
}

.schedule-jump-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
}

.sched-day-jump {
  padding: 0.4rem 0.875rem;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #c7cee0;
  transition: border-color 0.15s, color 0.15s;
}

.sched-day-jump:hover {
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

/* ============================================================
   ATTENDANCE WIDGET (worker dashboard)
   ============================================================ */

.worker-attendance-widget {
  margin-bottom: 1.25rem;
}

.attendance-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.10);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.attendance-card.clocked-in { border-color: #34d399; background: rgba(52, 211, 153, 0.10); }
.attendance-card.clocked-out { border-color: #9aa3b8; background: rgba(255, 255, 255, 0.03); }
.attendance-card.idle { border-color: #6366f1; background: rgba(99, 102, 241, 0.10); }

.attendance-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.attendance-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.attendance-dot.active { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.attendance-dot.done   { background: #69728a; }
.attendance-dot.idle   { background: #6366f1; }

.attendance-status-label { font-weight: 600; font-size: 1rem; }
.attendance-building { font-size: 1.1rem; font-weight: 700; color: #111; }
.attendance-time { font-size: 0.85rem; color: #9aa3b8; }

.attendance-clock-in-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.attendance-select { flex: 1; min-width: 200px; }

.attendance-btn {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.clock-in-btn  { background: #6366f1; color: #fff; }
.clock-in-btn:hover { background: #2451d4; }
.clock-out-btn { background: #ef4444; color: #fff; }
.clock-out-btn:hover { background: #f87171; }

.attendance-report-btn {
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  align-self: flex-start;
}

/* ============================================================
   PAYROLL PANEL
   ============================================================ */

.payroll-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.payroll-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.payroll-month-picker { display: flex; align-items: center; gap: 0.5rem; }

.payroll-info-bar {
  font-size: 0.85rem;
  color: #9aa3b8;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  margin-bottom: 0.75rem;
}

.payroll-workers-list { display: flex; flex-direction: column; gap: 1rem; }

.payroll-worker-row {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
}

.payroll-worker-row[open] {
  background: rgba(255, 255, 255, 0.05);
}

.payroll-worker-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.payroll-worker-summary::-webkit-details-marker {
  display: none;
}

.payroll-worker-summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.payroll-worker-row:not([open]) .payroll-worker-summary::before {
  transform: rotate(45deg);
}

.payroll-worker-name {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.payroll-worker-total {
  color: #34d399;
  font-weight: 800;
  white-space: nowrap;
}

.payroll-detail-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
}

.payroll-worker-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: #c7cee0;
  flex-wrap: wrap;
  margin: 0.6rem 0 0.5rem;
}

.payroll-rate   { color: #9aa3b8; }
.payroll-earned { color: #34d399; font-weight: 700; }

.payroll-buildings-mini { display: flex; flex-direction: column; gap: 0.3rem; }

.payroll-bldg-mini {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  color: #c7cee0;
  padding: 0.2rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.payroll-bldg-name { font-weight: 600; flex: 1; min-width: 120px; }
.payroll-rate-mini { color: #9aa3b8; }
.payroll-swap { color: #38bdf8; font-weight: 600; }
.payroll-ded  { color: #ef4444; font-weight: 600; }

/* Last-entry table */

.last-entry-grid { display: flex; flex-direction: column; gap: 0; }

.le-head, .le-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.5fr;
  gap: 0.5rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  align-items: center;
}

.le-head {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #69728a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.le-row { border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.le-row:last-child { border-bottom: none; }
.le-building { font-weight: 600; }
.le-time { color: #c7cee0; }
.le-ago { display: block; font-size: 0.75rem; color: #69728a; }

/* Deductions list */
.deductions-list { margin-top: 0.5rem; }

/* Payroll report modal */
.payroll-report-card { max-width: 700px; width: 95vw; }

.payroll-report-head {
  padding: 1.5rem 1.5rem 0;
}

.payroll-report-head h3 { margin: 0 0 0.75rem; font-size: 1.2rem; }

.payroll-report-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.payroll-report-body { padding: 1rem 1.5rem 1.5rem; }

.pr-buildings { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }

.pr-building-row {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.pr-building-name { font-weight: 700; margin-bottom: 0.3rem; }

.pr-building-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}

.pr-building-total { margin-right: auto; font-weight: 700; color: #34d399; }

.pr-summary {
  border-top: 2px solid rgba(255, 255, 255, 0.10);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.pr-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.2rem 0;
}

.pr-total {
  font-weight: 700;
  font-size: 1.1rem;
  color: #34d399;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding-top: 0.4rem;
  margin-top: 0.3rem;
}

.muted { color: #69728a; font-size: 0.82rem; }

/* ============================================================
   FINANCIAL SUMMARY
   ============================================================ */

.financial-header {
  margin-bottom: 1.25rem;
}

.financial-title-row,
.financial-range-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.financial-title-row {
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.range-sep { color: #9aa3b8; font-size: 0.85rem; }

/* KPI bar */
.fin-summary-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.fin-summary-bar.company-level {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.10);
  margin-bottom: 1.5rem;
}

.fin-kpi {
  flex: 1;
  min-width: 120px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fin-kpi-main {
  border-width: 2px;
}

.fin-kpi-label { font-size: 0.75rem; color: #69728a; text-transform: uppercase; font-weight: 600; }
.fin-kpi-val   { font-size: 1.3rem; font-weight: 800; }

.fin-revenue { color: #34d399; }
.fin-expense { color: #ef4444; }
.fin-profit-pos { color: #34d399; }
.fin-profit-neg { color: #ef4444; }

/* Breakdown */
.fin-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .fin-breakdown { grid-template-columns: 1fr; }
}

.fin-section { display: flex; flex-direction: column; gap: 0.25rem; }

.fin-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding-bottom: 0.3rem;
  margin-bottom: 0.25rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.10);
}

.fin-revenue-title { color: #34d399; border-color: rgba(52, 211, 153, 0.18); }
.fin-expense-title { color: #ef4444; border-color: #f87171; }

.fin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: 0.5rem;
}

.fin-row:last-child { border-bottom: none; }
.fin-label { flex: 1; font-weight: 500; }
.fin-rate  { font-size: 0.75rem; }
.fin-value { font-weight: 700; white-space: nowrap; }

/* Area rows (company view) */
.fin-areas-list { display: flex; flex-direction: column; gap: 0.75rem; }

.fin-area-row {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
}

.fin-area-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.fin-area-stats {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.fin-area-profit { font-weight: 800; font-size: 1rem; }
.fin-area-expand-btn { margin-right: auto; font-size: 0.78rem; padding: 0.2rem 0.5rem; }

.fin-area-breakdown { margin-top: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.10); padding-top: 0.75rem; }

.fin-breakdown-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 580px) {
  .fin-breakdown-cols { grid-template-columns: 1fr; }
}

/* ── Worker Detail Modal ──────────────────────────────────── */

.worker-detail-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 680px;
  width: 95vw;
}

.worker-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

.wd-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-soft) 0%, transparent 100%);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 1px solid var(--line);
}

.wd-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wd-header-info {
  flex: 1;
}

.wd-header-info h3 {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.wd-header-info p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  direction: ltr;
}

.wd-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #25d366;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.wd-wa-btn:hover { background: #1ebe5a; }

.wd-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.wd-metric {
  padding: 1rem 1.25rem;
  text-align: center;
  border-left: 1px solid var(--line);
}

.wd-metric:last-child { border-left: none; }

.wd-metric-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
  line-height: 1.1;
}

.wd-metric-label {
  font-size: 0.73rem;
  color: var(--muted);
  display: block;
  margin-top: 0.2rem;
}

.wd-body {
  padding: 1.25rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.wd-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.wd-buildings-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wd-building-chip {
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Attendance table */
.wd-att-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.wd-att-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.wd-att-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem 0.75rem;
  text-align: right;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.wd-att-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  white-space: nowrap;
}

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

.wd-att-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.wd-att-badge.present { background: var(--success-soft); color: var(--success); }
.wd-att-badge.absent  { background: var(--danger-soft);  color: var(--danger);  }
.wd-att-badge.swap    { background: var(--info-soft);    color: var(--info);    }

/* Payroll grid */
.wd-payroll-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.wd-payroll-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
  gap: 0.5rem;
}

.wd-bldg-name {
  font-weight: 600;
  color: var(--text);
}

.wd-payroll-row-meta {
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1;
  text-align: center;
}

.wd-earnings {
  font-weight: 700;
  color: var(--primary-strong);
  white-space: nowrap;
}

.wd-payroll-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  margin-top: 0.25rem;
}

.wd-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.worker-card-cta {
  font-size: 0.72rem;
  color: var(--primary);
  margin-top: 0.3rem;
  text-align: center;
  opacity: 0.7;
}

@media (max-width: 600px) {
  .wd-metrics { grid-template-columns: repeat(2, 1fr); }
  .wd-header { flex-wrap: wrap; }
  .wd-body { padding: 1rem; }
}

/* ── Global Search ─────────────────────────────────────────── */

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.global-search-input {
  width: 100%;
  padding: 0.45rem 0.85rem 0.45rem 2.2rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: rgba(255,255,255,0.05);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23607487' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.7rem center;
  direction: rtl;
}

.global-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}

.gs-section-label {
  padding: 0.4rem 0.85rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
}

.gs-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: right;
  transition: background 0.1s;
  font-family: inherit;
}

.gs-row:last-child { border-bottom: none; }
.gs-row:hover { background: var(--primary-soft); }

.gs-icon { font-size: 1.1rem; flex-shrink: 0; }
.gs-main { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.gs-name { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-sub { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-cta { font-size: 0.75rem; color: var(--primary); flex-shrink: 0; font-weight: 600; }

.gs-empty {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Alerts Badge & Button ─────────────────────────────────── */

.alerts-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.3rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.alerts-btn:hover { color: var(--primary); background: var(--primary-soft); }

.alerts-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ── Alerts Drawer ─────────────────────────────────────────── */

.alerts-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 40;
}

.alerts-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.alerts-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.alerts-drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.alerts-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.alerts-drawer-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: right;
  font-family: inherit;
  transition: background 0.1s;
}

.alerts-drawer-item:last-child { border-bottom: none; }
.alerts-drawer-item:hover { background: rgba(255, 255, 255, 0.04); }
.alerts-drawer-item.severity-critical { border-right: 3px solid var(--danger); }
.alerts-drawer-item.severity-warning { border-right: 3px solid var(--warning); }

.adi-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 0.1rem; }
.adi-body { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.adi-title { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.adi-desc { font-size: 0.8rem; color: var(--muted); }
.adi-sub { font-size: 0.75rem; color: var(--primary); }
.adi-cta { font-size: 0.75rem; color: var(--primary); flex-shrink: 0; font-weight: 600; margin-top: 0.1rem; }

.alerts-drawer-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Financial Chart ───────────────────────────────────────── */

.fin-chart-wrap {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 1rem 1.25rem 0.5rem;
  margin-bottom: 1.25rem;
}

.fin-chart-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.fin-chart-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.fin-chart-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Area Card Profit ──────────────────────────────────────── */

.area-card-profit {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.area-profit-pos {
  background: var(--success-soft);
  color: var(--success);
}

.area-profit-neg {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── Area Switcher ─────────────────────────────────────────── */

.area-view-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.area-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}

.area-switcher-label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.area-switcher-select {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  max-width: 200px;
}

.area-switcher-select:focus { border-color: var(--primary); }

@media (max-width: 640px) {
  .topbar-search { max-width: 160px; }
  .area-switcher { display: none; }
}

/* ── Schedule Day Navigation ───────────────────────────────── */

.schedule-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sched-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  flex-shrink: 0;
}

.sched-nav-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.sched-today-btn {
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.sched-today-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* ── Add Building Modal ────────────────────────────────────── */

.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-row-checks {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.form-row-checks label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
}

.form-row-checks input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Worker Detail Month Picker ────────────────────────────── */

.wd-month-picker {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  max-width: 140px;
}

/* ── Toast typed variants ──────────────────────────────────── */

.toast-success { border-right: 3px solid var(--success); }
.toast-error   { border-right: 3px solid var(--danger);  }
.toast-warning { border-right: 3px solid var(--warning); }
.toast-info    { border-right: 3px solid var(--info);    }

/* ── Worker Home Dashboard ─────────────────────────────────── */

.worker-home {
  margin-bottom: 1.25rem;
}

.worker-home-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.wh-greeting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wh-hello {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.wh-date {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.wh-quick-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.wh-action-btn {
  white-space: nowrap;
}

.wh-stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.wh-stat {
  flex: 1;
  min-width: 80px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  text-align: center;
}

.wh-stat-warn { background: var(--warning-soft); }
.wh-stat-critical { background: var(--danger-soft); }

.wh-stat-val {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.wh-stat-warn .wh-stat-val { color: var(--warning); }
.wh-stat-critical .wh-stat-val { color: var(--danger); }

.wh-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.wh-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wh-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.wh-buildings-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wh-building-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}

.wh-building-name {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.wh-swap-badge { font-size: 0.72rem; }

.wh-empty-day {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.wh-tickets-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wh-ticket-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.83rem;
}

.wh-ticket-row.urgency-CRITICAL { background: var(--danger-soft); }
.wh-ticket-row.urgency-HIGH { background: var(--warning-soft); }

.wh-ticket-urgency {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.wh-ticket-desc {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wh-ticket-building {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Worker Weekly Schedule ────────────────────────────────── */

.my-sched-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.my-sched-day {
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  overflow: hidden;
}

.my-sched-today {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.my-sched-empty { opacity: 0.55; }

.my-sched-day-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
}

.my-sched-today .my-sched-day-header { background: var(--primary-soft); }

.my-sched-dow {
  font-weight: 700;
  font-size: 0.85rem;
}

.my-sched-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.my-sched-today-badge {
  margin-right: auto;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.my-sched-building {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.my-sched-building:last-child { border-bottom: none; }

.my-sched-time {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
}

.my-sched-bname {
  font-weight: 600;
  color: var(--text);
}

.my-sched-swap {
  font-size: 0.68rem;
  background: var(--info-soft);
  color: var(--info);
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  align-self: flex-start;
  font-weight: 700;
}

.my-sched-tickets {
  font-size: 0.72rem;
  color: var(--warning);
  font-weight: 600;
}

.my-sched-rest {
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 500px) {
  .my-sched-grid { grid-template-columns: 1fr 1fr; }
  .worker-home-card { padding: 1rem; }
}

/* ── Side card head layout (button alignment) ──────────────── */

.side-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ===================== SIDEBAR NAV ===================== */

:root {
  --sidebar-w: 220px;
}

body.has-sidebar {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

body.has-sidebar .topbar {
  grid-area: topbar;
}

body.has-sidebar .main-sidebar {
  grid-area: sidebar;
}

body.has-sidebar .shell {
  grid-area: main;
  max-width: none;
  padding: 24px 28px 80px;
}

/* Also ensure alerts drawer, modals and overlays sit above sidebar */
body.has-sidebar .alerts-drawer,
body.has-sidebar .modal-overlay,
body.has-sidebar .ticket-detail-overlay,
body.has-sidebar #sim-panel {
  z-index: 200;
}

.main-sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 0 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s;
  position: relative;
  white-space: nowrap;
}

.sidebar-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-item.active,
.sidebar-item[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sidebar-label {
  flex: 1;
}

.sidebar-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* Mobile bottom nav — hidden on desktop */
.sidebar-mobile-bottom {
  display: none;
}

/* ── WhatsApp Simulator ──────────────────────────────────── */
.wa-sim-fab {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
  z-index: 200;
  transition: transform 0.12s, box-shadow 0.12s;
}
.wa-sim-fab:hover { transform: scale(1.08); }
.wa-sim-fab:active { transform: scale(0.95); }

.wa-sim-card {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wa-sim-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.wa-sim-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.wa-sim-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.wa-sim-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 3px 0 0;
}
.wa-sim-textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  direction: rtl;
  box-sizing: border-box;
}
.wa-sim-textarea:focus { outline: none; border-color: var(--primary); }
.wa-sim-result { animation: fadeIn 0.2s; }
.wa-sim-success {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(52, 211, 153, 0.14);
  border-radius: 10px;
  color: #34d399;
  font-size: 0.92rem;
}
.wa-sim-success strong { font-weight: 700; }
.wa-sim-success span {
  background: rgba(52, 211, 153, 0.18);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===================== TICKET DETAIL SLIDE-OVER ===================== */

.ticket-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 300;
  backdrop-filter: blur(2px);
}

.ticket-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  z-index: 301;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.ticket-detail-panel:not(.hidden) {
  transform: translateX(0);
}

.ticket-detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
  flex-shrink: 0;
}

.ticket-detail-id {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.ticket-detail-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.td-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.td-description {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.td-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.td-meta-item {
  background: rgba(15,118,110,0.05);
  border-radius: 10px;
  padding: 10px 12px;
}

.td-meta-key {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.td-meta-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.td-status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.td-status-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: var(--text);
}

.td-status-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.td-status-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.td-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.td-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 88%;
}

.td-msg.inbound {
  background: rgba(15,118,110,0.10);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.td-msg.outbound {
  background: var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.td-msg-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ===================== MOBILE RESPONSIVE ===================== */

@media (max-width: 768px) {
  :root {
    --topbar-h: 60px;
  }

  body.has-sidebar {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  body.has-sidebar .main-sidebar {
    grid-area: sidebar;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    top: auto;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 0;
    z-index: 100;
    background: rgba(255,255,255,0.05);
  }

  body.has-sidebar .shell {
    padding: 16px 16px 24px;
  }

  .sidebar-nav {
    display: none;
  }

  .sidebar-mobile-bottom {
    display: flex;
    justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 4px);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
  }

  .mobile-nav-item.active {
    color: var(--primary);
  }

  .mobile-nav-item:active {
    background: var(--primary-soft);
  }

  .mobile-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 0.62rem;
    font-weight: 600;
  }

  /* Topbar compact on mobile */
  .topbar-inner {
    padding: 8px 16px;
    gap: 8px;
  }

  .brand-subtitle {
    display: none;
  }

  /* Ticket detail full-width on mobile */
  .ticket-detail-panel {
    width: 100vw;
  }

  /* Stat cards scroll horizontally */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Area cards single column */
  .area-grid {
    grid-template-columns: 1fr;
  }

  /* Larger tap targets for buttons */
  .btn-primary,
  .btn-ghost,
  .view-tab {
    min-height: 44px;
  }
}

/* =====================================================================
   MOBILE UX FIX LAYER  (max-width: 768px, appended after all earlier
   breakpoints so these rules win for all phone-sized viewports)
   ===================================================================== */

@media (max-width: 768px) {

  /* ── 0. Grid column blowout fix ───────────────────────────────────
     grid 1fr resolves to the widest child (≈491px on a 375px screen)
     because grid items default to min-width:auto. minmax(0,1fr) forces
     the column to respect the viewport width.  Shell and topbar also
     need min-width:0 so they don't push the column wider.            */
  body.has-sidebar {
    grid-template-columns: minmax(0, 1fr);
    max-width: 100vw;
  }

  body.has-sidebar .topbar {
    min-width: 0;
    max-width: 100vw;
  }

  /* Shell: no overflow set (avoids creating a scroll container which
     breaks sticky positioning of .view-tabs). The minmax(0,1fr) grid
     fix already prevents the column from blowing past 100vw.         */
  body.has-sidebar .shell {
    min-width: 0;
    max-width: 100vw;
    padding-top: 0;
  }

  /* ── 0b. View-tabs: sticky under topbar ────────────────────────────
     overflow-x:clip (not hidden) on html preserves sticky context.
     position:sticky scrolls naturally with content and snaps when
     it reaches the topbar — no jitter, no layout shift.             */
  .view-tabs {
    position: sticky;
    top: var(--topbar-h);
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 4px 8px;
    margin: 0;
    width: 100%;
    z-index: 50;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  /* ── 1. Topbar: stay single row ───────────────────────────────────
     The 720px block sets flex-wrap:wrap + topbar-status:width:100%,
     which pushes the status chips to a second row.  The --topbar-h
     variable stays at 60px, so the sticky tab bar and sidebar top
     offset are both ~40px too low.  Override here to keep one row.   */
  .topbar-inner {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .topbar-status {
    width: auto;
    flex-shrink: 0;
    gap: 4px;
  }

  /* Timestamp (last-refresh) is not useful on a small screen */
  .refresh-note { display: none; }

  /* Collapse live-indicator to dot only — label wastes width */
  .live-chip { padding: 5px 7px; }
  .live-chip .chip-text { display: none; }

  /* Global search has no room on phone; hidden via class for admins
     but also force-hide by breakpoint so layout doesn't break       */
  .topbar-search { display: none !important; }

  /* ── 2. Input font-size: prevent iOS auto-zoom on focus ──────────
     iOS zooms any focused input whose font-size < 16px.  The app
     uses 0.9 rem (≈ 14.4px) everywhere, so every tap zooms the
     page.  Override to 1rem (= 16px) for all form controls.        */
  input,
  select,
  textarea,
  .schedule-date-input {
    font-size: 1rem;
  }

  /* ── 3. Sim / DEMO panel: default position (no bottom nav to avoid) */
  #sim-panel {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 4. Shell padding: just safe area for iPhone home indicator ── */
  body.has-sidebar .shell {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 5. Bottom nav: hidden entirely ─────────────────────────────*/
  .sidebar-mobile-bottom,
  #mobile-bottom-nav {
    display: none !important;
  }

  /* ── 6. Modals: safe area on bottom edge ─────────────────────────
     The 720px bottom-sheet modal has fixed padding; extend it for
     phones with a home bar.                                         */
  .modal-card {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 7. View tabs: guarantee no-wrap + scroll (belt & braces) ────
     The 720px block already sets overflow-x:auto; flex-wrap:nowrap
     but the 768px block above doesn't touch it.  Confirm here so
     both dashboard (5 tabs) and area (6 tabs) scroll horizontally.  */
  .view-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* ── 8. Financial / payroll header rows: stack on small screens── */
  .financial-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .financial-range-controls {
    width: 100%;
  }

  .financial-range-controls input[type="date"] {
    flex: 1;
    min-width: 0;
  }

  .payroll-head-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .payroll-month-picker {
    width: 100%;
  }

  /* ── 9. Area view header: stack back-btn and switcher ────────────*/
  .area-view-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 10px;
  }

  /* ── 10. Schedule controls: don't overflow on narrow screens ─────*/
  .schedule-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .schedule-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .schedule-nav {
    flex: 1;
    min-width: 0;
  }

  /* ── 11. Ticket detail panel: true full-screen on mobile ─────────*/
  .ticket-detail-panel {
    top: 0;
    width: 100vw;
    border-radius: 0;
  }

  .ticket-detail-header {
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }

  /* Larger close button tap target */
  .ticket-detail-panel .modal-close {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
  }

  /* ── 12. Side-card padding: recover space on phone ───────────────*/
  .side-card {
    padding: 16px;
    border-radius: 16px;
  }

  /* ── 13. Insights grid: single column (also handled at 1120px but
     confirm here for phones that only hit the 768 breakpoint)      */
  .insights-grid {
    grid-template-columns: 1fr;
  }

  /* ── 14. Worker detail modal: full-height bottom sheet ───────────*/
  .worker-detail-card,
  .payroll-report-card {
    width: 100%;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* ── 15. Urgency legend: hide on mobile (cards are already colored) ─ */
  .urgency-legend {
    display: none;
  }

  /* ── 16. Compact urgent hero (mobile) ───────────────────────────── */
  .urgent-hero {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 12px;
  }
  .urgent-hero-head.compact {
    display: block;
    margin-bottom: 10px;
  }
  .urgent-hero-head.compact .urgent-hero-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
  }
  .urgent-hero-head.compact .urgent-hero-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 2px;
  }

  /* ── 17. Simplified urgent-row on mobile ───────────────────────── */
  .urgent-row-mobile {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--line);
    border-right-width: 4px;
    min-height: 64px;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
  }
  .urgent-row-mobile:active {
    transform: scale(0.985);
  }
  .urgent-row-mobile.is-critical {
    border-right-color: var(--danger);
  }
  .urgent-row-mobile.is-high {
    border-right-color: var(--warning);
  }
  .urgent-row-mobile.is-medium {
    border-right-color: var(--info);
  }
  .urgent-row-mobile .urgent-row-body {
    flex: 1;
    min-width: 0;
  }
  .urgent-row-mobile .urgent-row-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    margin: 0;
  }
  .urgent-row-mobile .urgent-row-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .urgent-row-mobile .urgent-row-sub .sla-breach-inline {
    color: var(--danger);
    font-weight: 600;
  }
  .urgent-row-mobile .urgent-row-chevron {
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
  }

  /* ── 18. Company overview map: too small on 375px, hide ────────── */
  /* Only hide the company-level map (#map-card in dashboard), not the area map */
  #map-card { display: none !important; }

  /* ── 19. Stats grid: 2 cols, tighter, smaller label ────────────── */
  .stats-grid {
    gap: 8px;
    margin-bottom: 12px;
  }
  .stats-grid .stat-card {
    padding: 12px;
  }

  /* ── 20. My-day strip (AREA_MANAGER mobile home) ───────────────── */
  .my-day-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .my-day-cell {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 78px;
  }
  .my-day-cell:active { transform: scale(0.97); }
  .my-day-cell .md-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
  }
  .my-day-cell .md-label {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
    margin-top: 6px;
    line-height: 1.2;
  }
  .my-day-cell.is-danger .md-value { color: var(--danger); }
  .my-day-cell.is-warning .md-value { color: var(--warning); }
  .my-day-cell.is-success .md-value { color: var(--success); }

  /* ── 21. Ticket card: compact mobile variant ─────────────────── */
  .ticket-legend { display: none; }
  .ticket-card-mobile {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    padding: 12px 12px 12px 16px;
    margin-bottom: 10px;
    min-height: 88px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.12s;
    -webkit-tap-highlight-color: transparent;
  }
  .ticket-card-mobile:active { transform: scale(0.98); }
  .ticket-card-mobile .tc-edge {
    position: absolute;
    top: 0; bottom: 0; right: 0;
    width: 4px;
    background: var(--muted);
  }
  .ticket-card-mobile.urgency-CRITICAL .tc-edge { background: var(--danger); }
  .ticket-card-mobile.urgency-HIGH     .tc-edge { background: var(--warning); }
  .ticket-card-mobile.urgency-MEDIUM   .tc-edge { background: var(--info, #38bdf8); }
  .ticket-card-mobile.urgency-LOW      .tc-edge { background: var(--muted); }

  .ticket-card-mobile .tc-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
  }
  .ticket-card-mobile .tc-title {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .ticket-card-mobile .tc-sub {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ticket-card-mobile .tc-late { color: var(--danger); font-weight: 700; }
  .ticket-card-mobile .tc-chips {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
  }
  .ticket-card-mobile .tc-chip {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.4;
  }
  .ticket-card-mobile .tc-chip-urgent {
    background: rgba(248, 113, 113, 0.14);
    color: var(--danger);
  }
  .ticket-card-mobile .tc-chip-high {
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
  }
  .ticket-card-mobile .tc-chip-status {
    background: rgba(99, 102, 241, 0.16);
    color: #a5b4fc;
  }
  .ticket-card-mobile .tc-chip-status-IN_PROGRESS {
    background: rgba(56, 189, 248, 0.16);
    color: #38bdf8;
  }
  .ticket-card-mobile .tc-chip-status-DONE {
    background: rgba(52, 211, 153, 0.14);
    color: #34d399;
  }
  .ticket-card-mobile .tc-chevron {
    align-self: center;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
  }

  /* ── 22. Bottom nav with center FAB ────────────────────────── */
  .sidebar-mobile-bottom {
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px) 4px;
  }
  .mobile-nav-item {
    flex: 1;
    min-height: 56px;
    padding: 6px 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.12s;
  }
  .mobile-nav-item .mobile-nav-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
  }
  .mobile-nav-item .mobile-nav-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
  }
  .mobile-nav-item .mobile-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
  }
  .mobile-nav-item.active,
  .mobile-nav-item:active {
    color: var(--primary, #6366f1);
  }
  .mobile-nav-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger, #f87171);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-nav-fab {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary, #6366f1);
    color: #fff;
    border: 4px solid #fff;
    transform: translateY(-14px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s;
  }
  .mobile-nav-fab:active { transform: translateY(-14px) scale(0.95); }
  .mobile-nav-fab svg {
    width: 26px;
    height: 26px;
    stroke-width: 2.5;
  }

  /* ── 23. Mobile menu bottom sheet ─────────────────────────── */
  .mobile-menu-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 89;
    animation: fadeIn 0.15s ease-out;
  }
  .mobile-menu-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
    z-index: 90;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.22s ease-out;
    max-height: 80vh;
    overflow-y: auto;
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .mobile-menu-sheet::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.10);
    margin: 0 auto 12px;
  }
  .mobile-menu-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  .mobile-menu-sheet-title { font-size: 1rem; font-weight: 700; color: var(--text); }
  .mobile-menu-sheet-role { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
  .mobile-menu-sheet-items {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
  }
  .mobile-menu-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 8px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    border-radius: 8px;
    transition: background 0.1s;
  }
  .mobile-menu-sheet-item:active { background: rgba(255, 255, 255, 0.05); transform: scale(0.99); }
  .mobile-menu-sheet-item svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
  .mobile-menu-sheet-item.is-danger { color: var(--danger); }
  .mobile-menu-sheet-item.is-danger svg { color: var(--danger); }
  .mobile-menu-sheet-divider { height: 1px; background: rgba(255, 255, 255, 0.05); margin: 6px 0; }

  /* Keep topbar alerts button visible but hide its label clash — the mobile nav alerts handles it */
  #alerts-btn { display: none !important; }

  /* ── 24. Tap feedback ─────────────────────────────────────── */
  .urgent-row,
  .ticket-card,
  .ticket-card-mobile,
  .stat-card,
  .view-tab,
  .btn-primary,
  .btn-ghost,
  .pill,
  .modal-close {
    -webkit-tap-highlight-color: transparent;
  }
  .urgent-row:active,
  .ticket-card:active,
  .stat-card:active {
    transform: scale(0.98);
    transition: transform 0.08s;
  }
  .btn-primary:active,
  .btn-ghost:active {
    transform: scale(0.97);
    transition: transform 0.08s;
  }

  /* ── 25. 44px min tap targets ─────────────────────────────── */
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .view-tab { min-height: 44px; }

  /* ── 26. Empty state for calm hero ────────────────────────── */
  .urgent-hero.urgent-calm .urgent-hero-head.compact {
    text-align: center;
    padding: 16px 4px;
  }
  .urgent-hero.urgent-calm .urgent-hero-title {
    font-size: 1.15rem;
    color: var(--success, #15803d);
  }
  .urgent-hero.urgent-calm .urgent-hero-subtitle {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--muted);
  }
}

/* =====================================================================
   PHONE-FIRST ENHANCEMENTS (375px+)
   ===================================================================== */

/* sr-only — screen-reader only labels for date inputs etc */
.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;
}

/* Ensure all interactive elements meet 44px touch target minimum */
button,
[role="button"],
.view-tab,
.sidebar-item,
.mobile-nav-item,
.btn-primary,
.btn-ghost {
  min-height: 44px;
}

/* Modal overlay: click outside to close — visual affordance */
.modal-overlay {
  cursor: pointer;
}
.modal-card,
.worker-detail-card,
.payroll-report-card,
.wa-sim-card {
  cursor: default;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Tab focus rings for tab buttons */
.view-tab:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

/* Smooth open/close animation for modals */
.modal-overlay:not(.hidden) {
  animation: fadeIn 0.15s ease-out;
}
.modal-overlay:not(.hidden) .modal-card,
.modal-overlay:not(.hidden) .worker-detail-card,
.modal-overlay:not(.hidden) .payroll-report-card {
  animation: slideUp 0.2s ease-out;
}

/* Larger close button for all modals */
.modal-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
.modal-close:focus-visible {
  outline: 3px solid #6366f1;
}

/* Improve alerts drawer for mobile */
@media (max-width: 480px) {
  .alerts-drawer {
    width: 100vw;
    right: 0;
    left: 0;
    border-radius: 16px 16px 0 0;
    bottom: 0;
    top: auto;
    max-height: 75vh;
  }
}

/* Compact form rows on very small screens */
@media (max-width: 375px) {
  .form-row label {
    font-size: 0.88rem;
  }
  .swap-modal-title {
    font-size: 1.05rem;
  }
  .btn-primary, .btn-ghost {
    font-size: 0.9rem;
    padding: 10px 14px;
  }
}

/* Payroll layout: stack cards on mobile */
@media (max-width: 768px) {
  .payroll-layout {
    display: grid;
    gap: 16px;
  }
}

/* Final UX pass: mobile shell, dense lists, and detail surfaces */
body.modal-open .wa-sim-fab,
body.detail-open .wa-sim-fab {
  display: none !important;
}

@media (max-width: 768px) {
  body.has-sidebar .shell {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  body.has-sidebar .main-sidebar {
    display: block;
  }

  #mobile-bottom-nav.sidebar-mobile-bottom,
  #mobile-bottom-nav {
    display: flex !important;
  }

  body.detail-open #mobile-bottom-nav {
    display: none !important;
  }

  .wa-sim-fab {
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    left: 18px;
    width: 48px;
    height: 48px;
    z-index: 120;
  }

  .view-tabs {
    scroll-padding-inline: 16px;
    box-shadow:
      inset 18px 0 16px -18px rgba(0, 0, 0, 0.32),
      inset -18px 0 16px -18px rgba(0, 0, 0, 0.32),
      0 2px 8px rgba(0,0,0,0.06);
  }

  .list-toolbar {
    grid-template-columns: 1fr;
    padding: 10px;
    border-radius: 12px;
    gap: 10px;
  }

  .list-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .list-filters label {
    min-width: 0;
  }

  .ticket-detail-overlay {
    background: rgba(0, 0, 0, 0.28);
  }

  .ticket-detail-panel {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(255, 255, 255, 0.05);
  }

  .ticket-detail-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .ticket-detail-body {
    padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    gap: 16px;
  }

  .td-meta-grid {
    grid-template-columns: 1fr;
  }

  .td-status-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 4px);
    background: linear-gradient(180deg, rgba(5,7,15,0), #05070f 28%);
  }

  .td-status-btn {
    flex: 1;
    min-width: 88px;
    min-height: 46px;
  }

  .fin-summary-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .payroll-worker-row {
    padding: 0.7rem;
  }

  .payroll-worker-summary {
    gap: 8px;
  }

  .payroll-detail-btn {
    min-width: 52px;
  }

  .payroll-bldg-mini {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }

  .le-head {
    display: none;
  }

  .le-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 10px 0;
  }

  .mobile-nav-fab,
  .mobile-nav-item,
  .wa-sim-fab {
    touch-action: manipulation;
  }
}

/* ===================== Super-admin customer onboarding ===================== */
.customers-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--line); cursor: pointer;
  color: var(--muted); padding: 0.34rem 0.7rem; border-radius: 10px;
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
  transition: color .15s, background .15s, border-color .15s;
}
.customers-btn:hover { color: var(--text); background: var(--primary-soft); border-color: var(--primary); }
.customers-btn svg { color: var(--primary); }
.customers-btn-label { white-space: nowrap; }

.onb-card { width: min(640px, 100%); }
.onb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.onb-new-btn { white-space: nowrap; }

.onb-companies-list { display: flex; flex-direction: column; gap: 10px; }
.onb-company-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
}
.onb-company-row:hover { border-color: var(--line-strong); }
.onb-company-name { font-weight: 700; color: var(--text); }
.onb-company-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.onb-company-badges { display: flex; gap: 8px; flex-shrink: 0; }
.onb-badge {
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.onb-empty { text-align: center; color: var(--muted); padding: 28px 8px; }

.onb-stepper { display: flex; gap: 8px; list-style: none; padding: 0; margin: 14px 0 22px; }
.onb-step {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; font-weight: 600;
}
.onb-step-num {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.07); color: var(--muted); font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}
.onb-step.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.onb-step.is-active .onb-step-num { background: var(--grad-cta); color: #fff; }
.onb-step.is-done { color: var(--text); }
.onb-step.is-done .onb-step-num { background: var(--success); color: #05070f; }

.onb-section-title { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin: 16px 0 8px; }
.onb-input {
  width: 100%; box-sizing: border-box; padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--line-strong); border-radius: 10px;
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  font-size: 0.95rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.onb-input::placeholder { color: #5a6379; }
.onb-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.onb-input { cursor: pointer; }
.onb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.onb-actions { margin-top: 18px; display: flex; justify-content: flex-end; }
.onb-actions-split { justify-content: space-between; align-items: center; }
.onb-btn-ghost {
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 0.55rem 1rem; font-weight: 600; font-size: 0.9rem; cursor: pointer; font-family: inherit;
  transition: background .15s, border-color .15s;
}
.onb-btn-ghost:hover { background: var(--primary-soft); border-color: var(--primary); }
.onb-btn-ghost:disabled, .btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.onb-added-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.onb-added-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 13px; border-radius: 12px;
  background: var(--success-soft); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--text); font-size: 0.88rem;
}
.onb-added-row .onb-added-meta { color: var(--muted); font-size: 0.8rem; }
.onb-co-chip { color: var(--primary); font-weight: 700; }

.onb-done { text-align: center; padding: 24px 8px 8px; }
.onb-done-check {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #05070f;
  background: var(--grad-brand); box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
}
.onb-done h4 { margin: 0 0 6px; font-size: 1.2rem; color: var(--text); }

@media (max-width: 560px) {
  .onb-grid-2 { grid-template-columns: 1fr; }
  .onb-head { flex-direction: column; }
  .onb-step-label { display: none; }
  .customers-btn-label { display: none; }
}
