/* ============================================================
   Bombeiros Engenharia CRM — Dark Professional Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand palette */
  --bg:              #0f021e;
  --surface:         rgba(52, 10, 84, 0.82);
  --surface-strong:  rgba(68, 14, 108, 0.92);
  --surface-muted:   rgba(35, 6, 58, 0.72);
  --surface-sidebar: rgba(6, 1, 14, 0.97);
  --line:            rgba(255, 255, 255, 0.09);
  --line-strong:     rgba(255, 255, 255, 0.16);

  /* Text */
  --text:   #ede8ff;
  --muted:  rgba(188, 150, 222, 0.72);

  /* Accent — orange from logo sun */
  --accent:      #e87a1e;
  --accent-deep: #c05510;
  --accent-soft: rgba(232, 122, 30, 0.2);

  /* Status colors — vivid for dark bg */
  --green:  #34d399;
  --gold:   #f59e0b;
  --blue:   #818cf8;
  --danger: #f87171;

  /* Shadows */
  --shadow:    0 24px 56px rgba(0, 0, 0, 0.65);
  --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.45);

  /* Radii */
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;

  /* Layout */
  --sidebar-w: 264px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse at 12% 88%, rgba(232, 122, 30, 0.16) 0%, transparent 42%),
    radial-gradient(ellipse at 88% 12%, rgba(110, 22, 180, 0.22) 0%, transparent 44%),
    linear-gradient(155deg, #0f021e 0%, #1a0438 55%, #0f021e 100%);
  background-attachment: fixed;
}

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

/* ---- Scrollbars ---- */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232, 122, 30, 0.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232, 122, 30, 0.55); }

/* ---- Utility ---- */
.hidden { display: none !important; }

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--accent);
}

/* ============================================================
   SHARED SURFACES (glass-morphism dark)
   ============================================================ */
.auth-card,
.panel,
.topbar,
.hero-card,
.hero-stat-grid,
.profile-card,
.highlight-card,
.selected-service,
.stat-card,
.insight-card,
.stack-item {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Sidebar gets its own deeper dark */
.sidebar {
  border: 1px solid var(--line);
  background: var(--surface-sidebar);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ============================================================
   LOGO
   ============================================================ */
.sidebar-logo {
  width: 90%;
  max-width: 200px;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  margin: 0 auto;
}

.auth-logo {
  height: 76px;
  width: auto;
  display: block;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
}

/* ============================================================
   AUTH SCREEN — tela de login centralizada
   ============================================================ */
.auth-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-card { padding: 34px; }

.auth-login-card {
  width: min(440px, 100%);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-logo-main {
  width: 210px;
  height: auto;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  display: block;
}

.auth-domain-label {
  all: unset;
  cursor: default;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 22px;
  text-align: center;
}

.auth-login-card .auth-form {
  width: 100%;
}

.auth-otp-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 18px;
  line-height: 1.5;
}
.auth-otp-hint strong {
  color: var(--text);
}

#authCode {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.3em;
  font-weight: 700;
}

.auth-back-btn {
  width: 100%;
  margin-top: 8px;
  font-size: 0.85rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.mode-button,
.primary-button,
.ghost-button,
.nav-button,
.table-action {
  min-height: 44px;
  border-radius: var(--radius-md);
  transition: background 150ms, color 150ms, transform 130ms, box-shadow 150ms, border-color 150ms;
  font-weight: 600;
}

.mode-button,
.ghost-button,
.table-action {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
}

.table-action {
  font-size: 0.79rem;
  padding: 6px 12px;
  min-height: 32px;
  color: var(--muted);
}

.table-action:hover {
  color: var(--accent);
  border-color: rgba(232, 122, 30, 0.4);
  background: rgba(232, 122, 30, 0.08);
}

.mode-button.active,
.nav-button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(232, 122, 30, 0.36);
}

.ghost-button:hover,
.nav-button:hover,
.mode-button:hover {
  background: rgba(232, 122, 30, 0.08);
  border-color: rgba(232, 122, 30, 0.25);
  transform: translateY(-1px);
}

.nav-button.active:hover { transform: none; }

.primary-button {
  border: none;
  background: linear-gradient(135deg, #e87a1e, #c85510);
  color: white;
  font-weight: 700;
  padding: 13px 22px;
  box-shadow: 0 6px 24px rgba(232, 122, 30, 0.38);
  letter-spacing: 0.01em;
}

.primary-button:hover {
  box-shadow: 0 10px 32px rgba(232, 122, 30, 0.52);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(232, 122, 30, 0.3);
}

/* ============================================================
   FORMS
   ============================================================ */
.auth-form,
.entity-form {
  display: grid;
  gap: 14px;
}

.field { display: grid; gap: 6px; }

.field span {
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}

.field select option {
  background: #1a0438;
  color: var(--text);
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(232, 122, 30, 0.55);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 3px rgba(232, 122, 30, 0.14);
}

.field input[readonly] {
  background: rgba(232, 122, 30, 0.07);
  border-color: rgba(232, 122, 30, 0.18);
  color: var(--muted);
}

.field input[readonly]:focus {
  box-shadow: none;
  border-color: rgba(232, 122, 30, 0.18);
  background: rgba(232, 122, 30, 0.07);
}

.form-message {
  min-height: 20px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--accent);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  width: min(1520px, calc(100vw - 24px));
  margin: 12px auto 32px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9;
}
.sidebar-overlay.visible { display: block; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 6px 0 4px;
}

.profile-card {
  padding: 13px 15px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.profile-label {
  display: block;
  color: var(--muted);
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.profile-card strong {
  display: block;
  margin-top: 8px;
  font-size: 0.95rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
}

.profile-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.79rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav divider label */
.sidebar-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 0 13px;
  margin-bottom: 2px;
}

.sidebar-nav { display: grid; gap: 3px; }

.nav-button {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 13px;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  min-height: 44px;
  transition: background 140ms, color 140ms, border-color 140ms;
}

.nav-button:hover:not(.active) {
  background: rgba(232, 122, 30, 0.08);
  color: var(--text);
  border-color: rgba(232, 122, 30, 0.18);
}

.nav-button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(232, 122, 30, 0.36);
  font-weight: 700;
}

.sidebar-logout {
  margin-top: auto;
  font-size: 0.86rem;
  color: var(--muted);
  text-align: center;
  border-color: var(--line);
}

.sidebar-logout:hover {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
  transform: none;
}

/* Mobile toggle */
.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  color: var(--text);
  transition: background 150ms, transform 120ms;
  box-shadow: var(--shadow-sm);
}

.mobile-nav-toggle:hover {
  background: rgba(232, 122, 30, 0.12);
  border-color: rgba(232, 122, 30, 0.3);
  transform: scale(1.05);
}

/* ============================================================
   MAIN SHELL
   ============================================================ */
.main-shell {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  /* extra glow strip at top */
  border-top: 2px solid var(--accent);
}

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

.topbar-left > div  { min-width: 0; }
.topbar-left .eyebrow { margin: 0 0 3px; }

.topbar h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.75rem);
  letter-spacing: -0.02em;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.topbar-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.topbar-stat {
  padding: 11px 13px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.topbar-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.topbar-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   TAB PANES
   ============================================================ */
.tab-pane { display: grid; gap: 16px; }

.tab-pane:not(.hidden) {
  animation: fadeUp 200ms ease both;
}

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

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.hero-grid    { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.split-layout { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 16px; align-items: start; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ============================================================
   PANEL
   ============================================================ */
.topbar,
.panel,
.hero-card,
.hero-stat-grid {
  padding: 22px;
}

.panel { min-width: 0; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel h3 {
  font-size: 1.06rem;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--text);
}

.form-panel .panel-header {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 12px;
}

.panel-badge {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid rgba(232, 122, 30, 0.25);
}

/* ============================================================
   HERO / DASHBOARD
   ============================================================ */
.hero-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(60, 14, 96, 0.9), rgba(88, 20, 140, 0.7));
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  right: -60px;
  bottom: -60px;
  background: radial-gradient(circle, rgba(232, 122, 30, 0.28), transparent 65%);
  pointer-events: none;
}

.hero-card h2 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.hero-copy {
  color: var(--muted);
  line-height: 1.6;
  margin: 12px 0 0;
  max-width: 50ch;
  font-size: 0.93rem;
  position: relative;
  z-index: 1;
}

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

.stat-card {
  padding: 17px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: box-shadow 150ms, transform 150ms, background 150ms;
  box-shadow: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  background: rgba(232, 122, 30, 0.08);
  border-color: rgba(232, 122, 30, 0.22);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  line-height: 1;
  font-weight: 800;
  color: var(--text);
}

/* ============================================================
   STACK LIST (dashboard panels)
   ============================================================ */
.stack-list { display: grid; gap: 8px; }

.stack-item {
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease;
}

.stack-item:hover {
  transform: translateY(-1px);
  background: rgba(232, 122, 30, 0.07);
  border-color: rgba(232, 122, 30, 0.2);
}

.stack-item strong {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.stack-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.empty-state {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.55;
}

/* ============================================================
   FORM PANEL — INTERNALS
   ============================================================ */
.selected-service {
  padding: 13px 15px;
  background: rgba(232, 122, 30, 0.08);
  border: 1px solid rgba(232, 122, 30, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.selected-label {
  display: block;
  color: var(--accent);
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.selected-service strong {
  display: block;
  margin-top: 7px;
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--text);
}

.selected-service small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-full { grid-column: 1 / -1; }

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

.insight-card {
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.insight-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1rem;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
  display: grid;
  grid-template-columns: 1fr repeat(2, minmax(120px, 0.36fr));
  gap: 10px;
  margin-bottom: 14px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-height: 52vh;
  min-height: 180px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--text);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(6, 1, 14, 0.98);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 110ms; }
tbody tr:hover { background: rgba(232, 122, 30, 0.06); }

.service-name,
.stack-item strong { font-weight: 700; }

.service-desc,
.row-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.81rem;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.badge-quente, .badge-fechado, .badge-concluida, .badge-alta {
  background: rgba(52, 211, 153, 0.14);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.22);
}

.badge-morno, .badge-proposta, .badge-negociacao, .badge-media, .badge-pendente {
  background: rgba(245, 158, 11, 0.14);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.22);
}

.badge-frio, .badge-novo, .badge-baixa {
  background: rgba(129, 140, 248, 0.14);
  color: var(--blue);
  border: 1px solid rgba(129, 140, 248, 0.22);
}

.badge-perdido {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.22);
}

/* ============================================================
   ACTIVITY LOG (Histórico)
   ============================================================ */
.log-list { display: grid; gap: 0; }

.log-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.log-entry:last-child { border-bottom: none; }

.log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.log-dot-client   { background: var(--blue); }
.log-dot-deal     { background: var(--accent); }
.log-dot-activity { background: var(--green); }

.log-info {
  flex: 1;
  min-width: 0;
}
.log-info strong {
  font-size: 0.87rem;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.log-info small {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.log-type {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.log-user {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}
.log-time {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ============================================================
   RESPONSIVE — 1280px: sidebar vira drawer
   ============================================================ */
@media (max-width: 1280px) {
  .auth-screen {
    grid-template-columns: 1fr;
    max-width: 500px;
    min-height: auto;
    margin: 20px auto;
  }

  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    height: 100vh;
    width: min(300px, 82vw);
    z-index: 10;
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    transition: left 270ms cubic-bezier(0.32, 0, 0.04, 1);
    box-shadow: 6px 0 56px rgba(0, 0, 0, 0.7);
  }

  .sidebar.open { left: 0; }
  .mobile-nav-toggle { display: flex; }

  .hero-grid    { grid-template-columns: 1fr; }
  .split-layout { grid-template-columns: 1fr; }
  .three-column { grid-template-columns: repeat(2, 1fr); }
}

/* ---- 880px ---- */
@media (max-width: 880px) {
  .three-column { grid-template-columns: 1fr; }

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

  .topbar-stats    { grid-template-columns: repeat(3, 1fr); }
  .hero-stat-grid  { grid-template-columns: repeat(2, 1fr); }
  .grid.two        { grid-template-columns: 1fr; }
  .insights        { grid-template-columns: 1fr; }
  .toolbar         { grid-template-columns: 1fr; }
}

/* ---- 640px ---- */
@media (max-width: 640px) {
  :root {
    --radius-xl: 21px;
    --radius-lg: 16px;
    --radius-md: 12px;
  }

  .auth-screen,
  .app-shell {
    width: calc(100vw - 16px);
    margin: 8px auto 20px;
  }

  .auth-card,
  .panel,
  .topbar,
  .hero-card,
  .hero-stat-grid {
    padding: 16px;
  }

  .topbar-stats    { grid-template-columns: 1fr 1fr; }
  .hero-stat-grid  { grid-template-columns: 1fr 1fr; }
  .table-wrap      { max-height: 45vh; }
  .stat-card strong { font-size: 1.6rem; }
}
