/* App shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

.app[data-layout=login] {
  display: block;
  background: var(--color-bg);
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: var(--space-4);
  font-weight: 700;
  font-size: var(--font-lg);
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item:hover {
  background: var(--color-bg);
  text-decoration: none;
}
.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}

.nav-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-sm);
}

/* Topbar */
.topbar {
  grid-area: topbar;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
}

.topbar-title {
  font-size: var(--font-lg);
  font-weight: 600;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-sm);
}

/* Content */
.content {
  grid-area: content;
  padding: var(--space-6);
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-header h1 {
  margin: 0;
}

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

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: linear-gradient(135deg, var(--color-bg), var(--color-primary-light));
}

.login-card {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.login-card .subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  font-size: var(--font-sm);
}

.form-group { margin-bottom: var(--space-4); }
.form-error {
  color: var(--color-danger);
  font-size: var(--font-sm);
  margin-top: var(--space-1);
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas: "topbar" "content";
  }
}

/* ─── Select with search ─── */
.select-search { position: relative; }
.select-search-input {
  cursor: pointer;
  background: var(--color-surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236b7280' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 0.75rem center;
}
.select-search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-top: 2px;
  z-index: 100;
  max-height: 300px;
  display: flex; flex-direction: column;
}
.select-search-dropdown[hidden] { display: none !important; }
.select-search-filter {
  border: none !important;
  border-bottom: 1px solid var(--color-border) !important;
  border-radius: 0 !important;
  padding: var(--space-2) var(--space-3) !important;
}
.select-search-options { overflow-y: auto; max-height: 240px; }
.select-search-option {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  touch-action: manipulation;
  user-select: none;
}
.select-search-option:last-child { border-bottom: none; }
.select-search-option:hover { background: var(--color-bg); }
.select-search-option.selected { background: var(--color-primary-light, #eff6ff); color: var(--color-primary); }
.select-search-empty {
  padding: var(--space-4); text-align: center;
  color: var(--color-text-muted); font-size: var(--font-sm);
}

/* ─── Visit status badges ─── */
.status-pending          { background: #f3f4f6; color: #4b5563; }
.status-planned          { background: #dbeafe; color: #1e40af; }
.status-confirmed        { background: #cffafe; color: #155e75; }
.status-done             { background: #dcfce7; color: #166534; }
.status-refused          { background: #fee2e2; color: #991b1b; }
.status-postponed        { background: #fef3c7; color: #92400e; }
.status-transfer_pending { background: #fed7aa; color: #9a3412; }

/* ─── Multi-select checkbox group ─── */
.checkbox-group {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.checkbox-group label {
  display: flex; align-items: center; gap: 4px;
  margin: 0; font-weight: normal;
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  cursor: pointer; font-size: var(--font-sm);
}
.checkbox-group label:hover { background: var(--color-bg); }
.checkbox-group input[type=checkbox] { margin: 0; }

/* ─── Detail page layout ─── */
.detail-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap;
}
.detail-title h1 { margin: 0; font-size: var(--font-xl); }
.detail-meta {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
  font-size: var(--font-sm); color: var(--color-text-muted); margin-top: var(--space-2);
}
.detail-meta strong { color: var(--color-text); font-weight: 500; }
.detail-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ─── Form sections ─── */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.form-section h3 {
  font-size: var(--font-base);
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ─── Audit log ─── */
.audit-entry {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-sm);
}
.audit-entry:last-child { border-bottom: none; }
.audit-action {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  padding: 1px 6px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  margin-right: var(--space-2);
}

/* ─── Photos ─── */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.photo-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  position: relative;
  cursor: pointer;
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; }
.photo-card-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: var(--space-1) var(--space-2);
  background: rgba(0,0,0,0.6); color: white;
  font-size: var(--font-xs);
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.photo-upload-zone {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.photo-upload-zone:hover { border-color: var(--color-primary); }

/* ─── Multi-select ─── */
.multi-select {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: var(--space-2);
  display: flex; flex-direction: column; gap: var(--space-2);
  min-height: 60px;
}
.multi-select-tags {
  display: flex; flex-wrap: wrap; gap: var(--space-1);
  min-height: 24px;
}
.multi-select-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding-right: 4px !important;
}
.multi-select-remove {
  border: none; background: transparent; color: inherit;
  cursor: pointer; font-size: 16px; line-height: 1;
  padding: 0 2px; opacity: 0.7;
}
.multi-select-remove:hover { opacity: 1; }
.multi-select-add {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

/* ─── Collapsible sections ─── */
.collapsible {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
  background: var(--color-surface);
}
.collapsible summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  list-style: none;
  display: flex; align-items: center; gap: var(--space-2);
}
.collapsible summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.collapsible[open] summary::before { transform: rotate(90deg); }
.collapsible-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* Transfer bell */
.transfer-bell { position: relative; }
.bell-button {
  position: relative;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bell-button:hover { background: var(--color-bg); }
.bell-icon { font-size: 1.1rem; }
.bell-count {
  background: var(--color-danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.bell-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 360px;
  max-width: 480px;
  max-height: 500px;
  overflow-y: auto;
  z-index: 200;
}
.bell-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: var(--font-sm);
}
.bell-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.bell-item:last-child { border-bottom: none; }
.bell-item-title { font-weight: 500; font-size: var(--font-sm); }
.bell-item-meta { font-size: var(--font-xs); color: var(--color-text-muted); margin-top: 2px; }
.bell-item-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.bell-item-actions button { padding: 4px 12px; font-size: var(--font-xs); }

/* Activity feed (project detail) */
.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
}
.activity-item:hover { background: var(--color-bg); }
.activity-icon { font-size: 1.5rem; flex-shrink: 0; }
.activity-body { flex: 1; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}
.info-grid label {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.info-grid > div > div { font-size: var(--font-sm); }

/* Dashboard layout (C.5.3a) */
.dash-section { margin-bottom: 1.5rem; }
.dash-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}
.dash-toggle-icon {
  font-size: 0.7rem;
  margin-right: 0.4rem;
  display: inline-block;
  width: 0.8em;
  color: var(--color-text-muted, #6b7280);
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.dash-card {
  display: flex;
  flex-direction: column;
}
.dash-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
}
.dash-list { display: flex; flex-direction: column; }
.dash-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  gap: 1rem;
  cursor: pointer;
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-item:hover { background: var(--color-bg, rgba(0,0,0,0.03)); }

@media (max-width: 768px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-card[style*="grid-column"] { grid-column: auto !important; }
}

/* Dashboard charts (C.5.3b) */
.charts-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.chart-wrap {
  height: 240px;
  position: relative;
}
.chart-placeholder {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-muted, #6b7280);
  font-size: 0.875rem;
  padding: 0 1rem;
  background: var(--color-bg, rgba(0,0,0,0.03));
  border-radius: 4px;
}

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

/* ============================================
   QUICK SEARCH (Ctrl+K)  — C.5.4
   ============================================ */
#quick-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.qs-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }
.qs-panel {
  position: relative;
  width: 90%;
  max-width: 640px;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.qs-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}
.qs-icon { font-size: 16px; color: var(--color-text-muted, #6b7280); }
.qs-header input {
  flex: 1; border: none; outline: none;
  font-size: 16px; background: transparent; color: var(--color-text);
}
.qs-hint {
  font-family: monospace; font-size: 11px;
  background: var(--color-bg, rgba(0,0,0,0.05));
  padding: 2px 6px; border-radius: 3px;
  color: var(--color-text-muted, #6b7280);
  border: 1px solid var(--color-border, #e5e7eb);
}
.qs-results { overflow-y: auto; padding: 8px 0; flex: 1; }
.qs-empty {
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted, #6b7280);
  line-height: 1.6;
}
.qs-section { padding: 4px 0; }
.qs-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted, #6b7280);
  padding: 6px 16px;
  font-weight: 600;
}
.qs-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 8px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.qs-item:hover,
.qs-item.qs-selected {
  background: var(--color-bg, rgba(0,0,0,0.04));
  border-left-color: var(--color-primary, #2563eb);
}
.qs-item-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.qs-item-body { flex: 1; min-width: 0; }
.qs-item-title {
  font-weight: 500; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qs-item-sub {
  font-size: 12px;
  color: var(--color-text-muted, #6b7280);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================
   MOBILE RESPONSIVE — C.5.4
   ============================================ */
.topbar-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  margin-right: 0.75rem;
  color: var(--color-text);
}
.topbar-hamburger:hover { background: var(--color-bg, rgba(0,0,0,0.04)); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

@media (max-width: 768px) {
  .topbar-hamburger { display: inline-flex; align-items: center; }

  .app .sidebar {
    position: fixed;
    left: -260px;
    top: 0; bottom: 0;
    width: 260px;
    z-index: 100;
    transition: left 0.2s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
  }
  .app .sidebar.open { left: 0; }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: "topbar" "content" !important;
  }

  .data-table-wrap,
  .data-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
  }
  .info-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filters .form-group { width: 100%; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .qs-panel { width: 95%; max-height: 80vh; }
}

/* ============================================
   PRINT VIEWS — C.5.4
   ============================================ */
@media print {
  .topbar,
  .sidebar,
  .sidebar-overlay,
  .toast-container,
  .page-actions,
  .filters,
  .tabs,
  button,
  .btn-primary,
  .btn-ghost,
  .btn-danger,
  .topbar-hamburger,
  #quick-search-overlay,
  .transfer-bell,
  .dash-toggle-icon {
    display: none !important;
  }

  body, .app, main, #page-container {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
    display: block !important;
  }

  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: "content" !important;
  }

  .card,
  .form-section,
  .dash-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: white !important;
    margin-bottom: 0.5cm !important;
    page-break-inside: avoid;
  }

  h1, h2, h3, h4 { page-break-after: avoid; }
  table { page-break-inside: avoid; }

  a[href]:not([href^="#"])::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #666;
    word-break: break-all;
  }

  @page { margin: 1.5cm; }

  body::after {
    content: "Printed from VisitPlan";
    position: fixed;
    bottom: 0; right: 0;
    font-size: 9px;
    color: #999;
  }

  .data-table { display: table !important; width: 100%; }
}

/* ==============================================================
   UI PASS 3/5 — Sidebar dark rail + topbar + logo + bell
   Overrides earlier rules via cascade order.
   ============================================================== */

/* === SIDEBAR (dark navy rail) ============================== */

.sidebar {
  background: var(--color-nav);
  border-right: 1px solid var(--color-nav-border);
  color: var(--color-nav-text);
  width: var(--sidebar-width);
  padding: 0;
}

/* Brand block — wordmark with coral accent */
.sidebar-brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--color-nav-border);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: var(--font-size-lg);
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Coral pill ahead of brand text */
.sidebar-brand::before {
  content: "";
  width: 6px;
  height: 22px;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Eyebrow section labels */
.nav-section {
  padding: 18px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: #475569;
}
.nav-section:first-child { padding-top: 4px; }

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--color-nav-text);
  font-size: var(--font-size-base);
  font-weight: 500;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background var(--transition-button),
              color var(--transition-button),
              border-color var(--transition-button);
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-nav-text-hover);
  text-decoration: none;
}

.nav-item.active {
  background: var(--color-nav-active-bg);
  color: var(--color-nav-active-text);
  border-left-color: var(--color-nav-active-border);
  font-weight: 600;
}

/* Footer: user info + sign out */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--color-nav-border);
  font-size: var(--font-size-sm);
  color: var(--color-nav-text);
  background: var(--color-nav);
}

.sidebar-footer > div:first-child {
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 2px;
}

.sidebar-footer .text-muted {
  color: #64748b;
}

.sidebar-footer .btn-ghost {
  color: var(--color-accent);
  padding: 4px 0;
  margin-top: 6px;
  background: transparent;
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-align: left;
  justify-content: flex-start;
}
.sidebar-footer .btn-ghost:hover {
  background: transparent;
  color: #ff7a5c;
}

/* === TOPBAR (warm off-white with subtle line) ============== */

.topbar {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-line);
  padding: 0 var(--spacing-xl);
  height: var(--topbar-height);
  align-items: center;
}

.topbar-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-actions .text-muted {
  font-size: var(--font-size-sm);
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
  color: var(--color-text-soft);
}

/* Hamburger: ghost button */
.topbar-hamburger {
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 18px;
  color: var(--color-text);
  margin-right: 10px;
}
.topbar-hamburger:hover {
  background: var(--color-surface);
  border-color: var(--color-line-strong);
}

/* === TRANSFER BELL ========================================= */

.transfer-bell { position: relative; }

.bell-button {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
  font-size: var(--font-size-base);
  transition: background var(--transition-button), border-color var(--transition-button);
}
.bell-button:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-line-strong);
}

.bell-icon { font-size: 1.05rem; }

.bell-count {
  background: var(--color-accent);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
}

.bell-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  min-width: 360px;
  max-width: 480px;
  max-height: 500px;
  overflow-y: auto;
  z-index: 200;
}

.bell-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-line);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
}

.bell-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-direction: row;
  flex-wrap: wrap;
}
.bell-item:last-child { border-bottom: none; }

.bell-item-info {
  flex: 1;
  min-width: 0;
}

.bell-item-title {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-text);
}

.bell-item-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 3px;
}

.bell-item-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-shrink: 0;
}
.bell-item-actions button {
  padding: 5px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* === MOBILE SIDEBAR (dark theme retained) ================== */

@media (max-width: 768px) {
  .app .sidebar {
    background: var(--color-nav);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35);
    width: 260px;
    left: -280px;
  }
  .app .sidebar.open { left: 0; }

  .topbar {
    padding: 0 var(--spacing-md);
  }
}

/* === CONTENT AREA: warm off-white background ============== */

.content {
  background: var(--color-bg);
}

/* ==============================================================
   UI PASS 3/5 — Navigation (sidebar + topbar + bell + logo E.1)
   ============================================================== */

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

.sidebar {
  background: var(--color-nav);
  border-right: 1px solid var(--color-nav-border);
  color: var(--color-nav-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 0 0 0;
}

/* === Brand block (logo E.1 + wordmark) === */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 18px 16px;
  border-bottom: 1px solid var(--color-nav-border);
  margin-bottom: 14px;
}

.sidebar-brand::before { content: none; }

.logo-mark { flex-shrink: 0; }

.logo-square {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(255, 90, 54, 0.30);
}

.logo-arc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.logo-letter {
  font-family: var(--font-mono);
  font-weight: 800;
  color: #ffffff;
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.logo-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.logo-name {
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo-version {
  color: var(--color-signal);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-top: 2px;
  text-transform: uppercase;
}

/* === Section groups === */
.sidebar-section {
  padding: 0 0 8px 0;
}

.sidebar-section-title {
  padding: 6px 18px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #475569;
  margin-bottom: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* === Nav items === */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-nav-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
}

.nav-item.active,
.nav-item[aria-current="page"] {
  color: var(--color-nav-active-text);
  background: var(--color-nav-active-bg);
  border-left-color: var(--color-nav-active-border);
  font-weight: 600;
}

.nav-glyph {
  font-size: 16px;
  width: 20px;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  font-size: 13px;
}

/* === Footer (user block + signout) === */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px 16px;
  border-top: 1px solid var(--color-nav-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-nav);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

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

.user-name {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.user-role {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
  margin-top: 1px;
}

.sidebar-signout {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted);
  border: 1px solid var(--color-nav-border);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  font-family: var(--font-sans);
}

.sidebar-signout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: var(--color-nav-border);
}

/* === TOPBAR ============================================== */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: var(--topbar-height);
}

.topbar-search-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  max-width: 320px;
  flex: 1;
  transition: border-color 0.15s;
}

.topbar-search-hint:hover {
  border-color: var(--color-line-strong);
}

.topbar-search-icon { font-size: 13px; }

.topbar-search-text {
  flex: 1;
  font-size: 13px;
}

.topbar-search-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--color-text-soft);
  font-weight: 500;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Hamburger button — keep showing only in mobile */
.topbar-hamburger {
  background: transparent;
  border: 1px solid var(--color-line);
  color: var(--color-text-soft);
  padding: 6px 10px;
}

/* === NOTIFICATION BELL ============================================== */

.topbar-bell {
  position: relative;
}

.bell-button {
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--color-text-soft);
  transition: background-color 0.15s, border-color 0.15s;
  position: relative;
}

.bell-button:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-line-strong);
}

.bell-icon { font-size: 14px; }

.bell-count {
  background: var(--color-accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

.bell-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  min-width: 380px;
  max-width: 460px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
}

.bell-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-line);
}
.bell-section:last-child {
  border-bottom: none;
}

.bell-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
  padding: 0 16px 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
}

.bell-section-count {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.bell-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-left: 3px solid transparent;
  transition: background-color 0.15s, border-color 0.15s;
}

.bell-item:hover {
  background: var(--color-surface-alt);
  border-left-color: var(--color-primary);
}

.bell-item-overdue {
  border-left-color: var(--color-rose);
}

.bell-item-body {
  flex: 1;
  min-width: 0;
}

.bell-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bell-item-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.bell-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* === Mobile adjustments to topbar/sidebar === */
@media (max-width: 768px) {
  .topbar-search-hint {
    display: none;
  }

  .bell-dropdown {
    min-width: 280px;
    max-width: calc(100vw - 32px);
    right: -8px;
  }
}

/* ==============================================================
   UI PASS 4/5 — Pages (tables, forms, tabs, page header, empty)
   ============================================================== */

/* === PAGE HEADER ============================================== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 0;
  border-bottom: none;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--color-text);
  margin: 0;
  line-height: 1.2;
}

.page-header h1 .text-muted {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-text-muted);
}

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

.page-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  display: block;
}

.detail-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-line);
}

.detail-title h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 6px 0;
}

.detail-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.detail-meta > span {
  display: inline-flex;
  align-items: center;
}

/* === TABS ============================================== */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--color-line);
  align-items: stretch;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  border-radius: 0;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
}

.tab:hover {
  color: var(--color-text);
  background: transparent;
  border-bottom-color: transparent;
}

.tab.active {
  color: var(--color-primary);
  font-weight: 600;
  border-bottom-color: var(--color-primary);
}

.tab .tab-count,
.tab span:not(:first-child):not(.tab-icon) {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.tab.active .tab-count,
.tab.active span:not(:first-child):not(.tab-icon) {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}

/* === TABLES ============================================== */

.data-table,
table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 13px;
}

.data-table thead {
  background: var(--color-surface-alt);
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-line);
  white-space: nowrap;
}

.data-table th.actions {
  width: 1%;
  text-align: right;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0efec;
  vertical-align: middle;
  color: var(--color-text);
}

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

.data-table tbody tr {
  transition: background-color 0.12s;
}

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

.data-table tbody tr[data-id],
.data-table tbody tr[onclick] {
  cursor: pointer;
}

.data-table .id-cell,
.data-table .mono-num,
.data-table td[class*="id-"],
.data-table strong + .text-xs {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.data-table .id-cell {
  color: var(--color-primary);
}

.data-table .date-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.data-table td.actions,
.data-table td .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.data-table td.actions button,
.data-table td .actions button {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

.data-table .spinner-row td {
  text-align: center;
  padding: 32px 14px;
  color: var(--color-text-muted);
}

/* === EMPTY STATES ============================================== */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.empty-state-glyph {
  font-size: 28px;
  color: var(--color-text-subtle);
  display: block;
  margin-bottom: 12px;
  line-height: 1;
}

.empty-state-message {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.empty-state-cta {
  margin-top: 4px;
}

td.empty-state,
.data-table .empty-state {
  text-align: center;
  padding: 48px 24px;
  font-style: normal;
}

/* === FORMS ============================================== */

.form-section {
  margin-bottom: 18px;
}

.form-section h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.form-group + .form-group {
  margin-top: 12px;
}

.form-grid-2 .form-group,
.form-grid-3 .form-group {
  margin-top: 0;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 5px;
  line-height: 1.3;
}

.form-group label .required {
  color: var(--color-accent);
  margin-left: 2px;
  font-weight: 700;
}

.form-group .hint,
.form-group .help-text {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 20px;
  margin-bottom: 8px;
}

.info-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-grid > div > label,
.info-grid > div > .info-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.info-grid > div > div {
  font-size: 13px;
  color: var(--color-text);
  font-weight: 500;
}

.info-grid .data-num,
.info-grid .mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* === FILTERS row ============================================== */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
}

.filters .form-group {
  flex: 0 1 200px;
  margin: 0;
  min-width: 160px;
}

.filters .form-group:has(input[type="search"]) {
  flex: 1 1 240px;
}

.filters label {
  font-size: 10px;
  margin-bottom: 4px;
}

.filters input,
.filters select {
  padding: 6px 10px;
  font-size: 13px;
  height: 32px;
}

.filters .checkbox-group,
.filters .radio-group {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
}

/* === Avatar (small, used in lists) === */
.avatar-sm {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 600;
  font-size: 10px;
  flex-shrink: 0;
  line-height: 1;
}

/* === Page container spacing === */
main,
#page-container {
  padding: 28px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  main,
  #page-container {
    padding: 18px 14px 76px 14px;
    max-width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

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

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filters .form-group {
    flex: 1 1 100%;
  }
}

/* === Detail meta separators === */
.detail-meta > span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-text-subtle);
  margin: 0 8px;
  vertical-align: middle;
}

/* ==============================================================
   UI PASS 5/5 — Special (calendar, map, charts, quick-search, hero)
   ============================================================== */

/* === CALENDAR (FullCalendar) ============================================== */

.fc {
  font-family: var(--font-sans);
  font-size: 13px;
  background: transparent;
  padding: 0;
  border: none;
}

.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--color-line);
}

.fc .fc-toolbar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text);
}

.fc .fc-button-primary {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  color: var(--color-text);
  font-weight: 500;
  font-size: 12px;
  padding: 6px 12px;
  text-transform: capitalize;
  box-shadow: none;
}

.fc .fc-button-primary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-line-strong);
  color: var(--color-text);
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.fc .fc-button-primary:focus {
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.fc .fc-col-header-cell {
  background: var(--color-surface-alt);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: 6px 0;
}

.fc-day-today {
  background: var(--color-accent-soft) !important;
}

.fc .fc-daygrid-day-number {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-soft);
  padding: 6px 8px;
  letter-spacing: -0.01em;
}

.fc-day-today .fc-daygrid-day-number {
  color: var(--color-accent);
  font-weight: 800;
}

.fc-day-other .fc-daygrid-day-number {
  color: var(--color-text-subtle);
}

.fc .fc-event {
  border: none;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
}

.fc .fc-event:hover {
  filter: brightness(0.95);
}

.fc .fc-list-event:hover td {
  background: var(--color-surface-alt);
}

.fc-list-day-cushion {
  background: var(--color-surface-alt) !important;
  font-weight: 600;
}

/* === MAP (Leaflet) — popup style harmonization === */

.leaflet-container {
  font-family: var(--font-sans);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-line);
  background: var(--color-surface);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  padding: 0;
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.leaflet-popup-content strong {
  font-weight: 600;
  color: var(--color-text);
  font-size: 14px;
}

.leaflet-popup-content a {
  color: var(--color-primary);
  font-weight: 500;
}

.leaflet-popup-tip {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
}

.leaflet-control-zoom a {
  background: var(--color-surface);
  border-color: var(--color-line) !important;
  color: var(--color-text);
  font-weight: 500;
}

.leaflet-control-zoom a:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* === QUICK SEARCH — destaque mais forte === */

#quick-search-overlay .qs-backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.qs-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.20);
}

.qs-header {
  border-bottom: 1px solid var(--color-line);
  padding: 14px 18px;
  gap: 10px;
}

.qs-header input {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--color-text);
}

.qs-icon {
  color: var(--color-text-muted);
  font-size: 14px;
}

.qs-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-line);
  color: var(--color-text-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.qs-section {
  padding: 6px 0;
}

.qs-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
  padding: 6px 18px;
}

.qs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background-color 0.12s, border-color 0.12s;
}

.qs-item:hover,
.qs-item.qs-selected {
  background: var(--color-primary-soft);
  border-left-color: var(--color-primary);
}

.qs-item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: var(--color-text-soft);
}

.qs-item:hover .qs-item-icon,
.qs-item.qs-selected .qs-item-icon {
  color: var(--color-primary);
}

.qs-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.005em;
}

.qs-item-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.qs-empty {
  padding: 32px 24px;
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: center;
}

.qs-empty .text-xs {
  font-size: 11px;
  color: var(--color-text-subtle);
  margin-top: 8px;
  display: inline-block;
}

/* === HERO PATTERN — Dashboard "Today" === */

.dash-hero {
  background: var(--color-nav);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  border-right: 6px solid var(--color-accent);
}

.dash-hero::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 90, 54, 0.08);
  pointer-events: none;
}

.dash-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 90, 54, 0.15);
  color: var(--color-accent);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.dash-hero-eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

.dash-hero h2 {
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  position: relative;
  z-index: 1;
}

.dash-hero-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.dash-hero-content {
  position: relative;
  z-index: 1;
}

.dash-hero-content a {
  color: #ffffff;
}

.dash-hero-content .dash-list-item {
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 4px;
}

.dash-hero-content .dash-list-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dash-hero-content .dash-list-item strong {
  color: #ffffff;
}

.dash-hero-content .text-muted,
.dash-hero-content .text-xs {
  color: rgba(255, 255, 255, 0.6) !important;
}

.dash-hero-content .badge {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

/* === DASHBOARD ajustes finais === */

.dash-section {
  margin-bottom: 28px;
}

.dash-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 0;
  border-bottom: none;
}

.dash-section-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dash-section-header h3 .text-muted {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text-subtle);
}

.dash-toggle-icon {
  font-size: 9px;
  color: var(--color-text-subtle);
}

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

.dash-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
}

.dash-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
  margin: 0 0 12px 0;
}

.dash-list-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--color-line);
  border-left: none;
  border-radius: 4px;
  transition: background-color 0.12s;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}

.dash-list-item:hover {
  background: var(--color-surface-alt);
  border-left-color: transparent;
}

.dash-list-item:last-child {
  border-bottom: none;
}

.dash-list-item strong {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
}

.dash-list-item .text-xs {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--color-text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.charts-grid {
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.chart-wrap {
  height: 220px;
}

.dash-card .stat-num,
.dash-card .data-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

#dash-transfers-area .form-section {
  border-left: 4px solid var(--color-accent);
  background: var(--color-accent-soft);
  border-color: rgba(255, 90, 54, 0.3);
}

#dash-transfers-area h3 {
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* ==============================================================
   FIX RESPONSIVIDADE — filtros + tabelas + mapa + mobile
   Override regras anteriores via cascade order
   ============================================================== */

/* === FILTROS — corrigir flex distribution === */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
}

.filters .form-group {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 320px;
  margin: 0;
}

.filters .form-group:has(input[type="search"]) {
  flex: 2 1 240px;
  max-width: 400px;
}

.filters .form-group:has(.checkbox-group),
.filters .form-group:has(.radio-group) {
  flex: 1 1 100%;
  max-width: 100%;
}

.filters > button,
.filters .filter-actions {
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }

  .filters .form-group {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .filters .checkbox-group,
  .filters .radio-group {
    flex-wrap: wrap;
    gap: 8px 14px;
  }
}

/* === TABELAS — wrapper scrollable === */

.table-wrap,
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  margin-bottom: 18px;
}

.table-wrap > .data-table,
.data-table-wrap > .data-table {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  min-width: 100%;
}

.data-table {
  display: table;
  width: 100%;
}

.data-table td.id-cell,
.data-table td .mono-num,
.data-table th {
  white-space: nowrap;
}

.data-table td {
  word-wrap: break-word;
  max-width: 320px;
}

/* === Page container — não bloquear conteúdo === */

main,
#page-container {
  padding: 28px 32px;
  max-width: clamp(960px, 92vw, 1600px);
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

@media (max-width: 1024px) {
  main,
  #page-container {
    padding: 22px 20px;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  main,
  #page-container {
    padding: 16px 12px 76px 12px;
    max-width: 100%;
  }
}

/* === MAPA — altura responsiva === */

#map-root {
  height: 640px;
  width: 100%;
  position: relative;
}

@media (max-width: 1024px) {
  #map-root {
    height: 500px;
  }
}

@media (max-width: 768px) {
  #map-root {
    height: 60vh;
    min-height: 360px;
    max-height: 500px;
  }

  #map-root::after {
    content: "Tap map to interact";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    z-index: 400;
    pointer-events: none;
    opacity: 0.9;
  }

  #map-root.leaflet-focused::after {
    display: none;
  }
}

/* === Charts — alturas mais flexíveis === */

.chart-wrap {
  height: 220px;
  width: 100%;
  position: relative;
}

@media (max-width: 768px) {
  .chart-wrap {
    height: 200px;
  }
}

/* === Hero pattern em mobile === */

@media (max-width: 768px) {
  .dash-hero {
    padding: 18px;
    border-right-width: 4px;
  }

  .dash-hero h2 {
    font-size: 18px;
  }

  .dash-hero .dash-grid {
    grid-template-columns: 1fr !important;
  }
}

/* === Page header em mobile === */

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .page-actions {
    flex-wrap: wrap;
  }

  .page-actions button {
    flex: 1 1 auto;
  }
}

/* === Modal: largura responsiva === */

@media (max-width: 768px) {
  .modal,
  .modal-panel,
  .modal-dialog,
  [class*="modal-content"] {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 40px);
    margin: 12px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
  }
}

/* === Topbar em mobile === */

@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-search-hint {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }
}

/* === Detail-meta em mobile === */

@media (max-width: 768px) {
  .detail-meta {
    font-size: 12px;
  }

  .detail-meta > span:not(:last-child)::after {
    margin: 0 6px;
  }
}

/* === Body-level fix: previne horizontal scroll global === */

html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

.app {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr !important;
  }
}

/* ==============================================================
   Sidebar layout fix (Fase A.2.2 — 2026-05-09)
   Earlier rule had overflow-y: auto on .sidebar, which scrolled the
   entire column including the footer. With many sections the user-info
   + sign-out block could disappear off-screen.

   Fix: scroll lives on .sidebar-nav only. Brand and footer use
   flex-shrink: 0 so they keep their natural size. .sidebar-nav already
   has flex: 1 (declared above), so it grows and absorbs overflow.
   Sidebar itself sticks at top of viewport with full height.

   Mobile (≤768px) keeps the existing slide-in drawer; this override
   applies only on the desktop grid.
   ============================================================== */
@media (min-width: 769px) {
  .sidebar {
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
  }
  .sidebar-brand,
  .sidebar-footer {
    flex-shrink: 0;
  }
  .sidebar-nav {
    overflow-y: auto;
    min-height: 0;
  }
}
