/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
  --teal:        #8B1A2B;
  --teal-light:  #F7E9EB;
  --teal-dark:   #6E1322;
  --teal-glow:   rgba(139,26,43,.15);
  --slate-50:    #F8FAFC;
  --slate-100:   #F1F5F9;
  --slate-200:   #E2E8F0;
  --slate-400:   #94A3B8;
  --slate-500:   #64748B;
  --slate-700:   #334155;
  --slate-800:   #1E293B;
  --slate-900:   #0F172A;
  --white:       #FFFFFF;
  --red:         #EF4444;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.07), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.05);
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  .2s cubic-bezier(.4,0,.2,1);
}


body.dark #darkToggle {
  border-color: #3f3f46;
  color: #a1a1aa;
}

body.dark #darkToggle:hover {
  border-color: #8B1A2B;
  color: #8B1A2B;
}

/* ── Dark Mode — neutro SaaS (zinc) + acento vinho ── */
body.dark {
  --slate-50:  #18181b;   /* fundo base (zinc-900) */
  --slate-100: #1f1f23;   /* superfícies/cards */
  --slate-200: #2e2e33;   /* bordas */
  --slate-300: #3f3f46;   /* bordas fortes / placeholder */
  --slate-400: #a1a1aa;   /* texto muted (zinc-400) */
  --slate-500: #d4d4d8;
  --slate-600: #e4e4e7;
  --slate-700: #f4f4f5;
  --slate-800: #fafafa;
  --white:     #1f1f23;   /* "papel" escuro neutro */
  --red:       #f87171;
  --teal:        #C24A5A;   /* vinho clareado p/ contraste em dark */
  --teal-dark:   #A83344;
  --teal-light:  #2c2026;   /* tint vinho discreto p/ item ativo */
  --teal-glow:   rgba(194,74,90,.20);
  background:  #18181b;
  color:       #e4e4e7;
}

/* Cards */
body.dark .chart-card,
body.dark .kpi-card,
body.dark .login-card {
  background: #1f1f23;
  border-color: #2e2e33;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Formulários */
body.dark .form-input,
body.dark .form-input:focus,
body.dark select.form-input,
body.dark textarea.form-input {
  background: #18181b;
  border-color: #2e2e33;
  color: #e4e4e7;
}

body.dark .form-input::placeholder {
  color: #3f3f46;
}

/* Header */
body.dark .header {
  background: #1f1f23;
  border-color: #2e2e33;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Nav */
body.dark .nav-tabs {
  border-color: #2e2e33;
}

body.dark .nav-tab {
  color: #a1a1aa;
}

body.dark .nav-tab:hover {
  color: #e4e4e7;
}

body.dark .nav-tab.active {
  color: #8B1A2B;
  border-color: #8B1A2B;
}

/* KPI */
body.dark .kpi-value {
  color: #f4f4f5;
}

body.dark .kpi-label {
  color: #a1a1aa;
}

/* Seletores */
body.dark .estab-select,
body.dark .periodo-select,
body.dark select {
  background: #1f1f23;
  border-color: #3f3f46;
  color: #e4e4e7;
}

/* Tabelas */
body.dark table thead tr {
  background: #1f1f23;
}

body.dark table th {
  color: #a1a1aa;
  border-color: #2e2e33;
}

body.dark table td {
  border-color: #1f1f23;
  color: #d4d4d8;
}

body.dark table tbody tr:hover {
  background: rgba(139,26,43,0.06);
}

/* Botão primário */
body.dark .btn-primary {
  background: #8B1A2B;
  color: white;
}

/* Logout */
body.dark .btn-logout {
  border-color: #2e2e33;
  color: #a1a1aa;
}

body.dark .btn-logout:hover {
  background: #2e2e33;
  color: #e4e4e7;
}

/* Badges status */
body.dark .badge-green,
body.dark .badge-status.badge-green  { background: #064e3b; color: #6ee7b7; }
body.dark .badge-yellow,
body.dark .badge-status.badge-yellow { background: #78350f; color: #fcd34d; }
body.dark .badge-red,
body.dark .badge-status.badge-red    { background: #7f1d1d; color: #fca5a5; }
body.dark .badge-gray,
body.dark .badge-status.badge-gray   { background: #1f1f23; color: #a1a1aa; }

/* Preview prompt */
body.dark #previewBox {
  background: #1f1f23 !important;
  border-color: #2e2e33 !important;
  color: #d4d4d8 !important;
}

/* Empty state */
body.dark .empty-state {
  color: #3f3f46;
}

/* Error banner */
body.dark .error-banner {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}

/* Chart area */
body.dark .chart-wrap {
  background: transparent;
}

/* Clinic selector label */
body.dark .estab-selector-label {
  color: #64748b;
}

/* Period badge */
body.dark .period-badge,
body.dark .periodo-badge {
  background: rgba(139,26,43,0.15);
  color: #8B1A2B;
}

/* Section titles */
body.dark .chart-title,
body.dark .section-title {
  color: #f4f4f5;
}

body.dark .chart-subtitle {
  color: #64748b;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--slate-800);
  background: var(--slate-50);
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(139,26,43,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%,  rgba(139,26,43,.06) 0%, transparent 60%),
    var(--slate-50);
  position: relative;
  overflow: hidden;
}

/* Subtle grid overlay */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--slate-200) 1px, transparent 1px),
    linear-gradient(90deg, var(--slate-200) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .35;
  pointer-events: none;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04);
  padding: 48px 44px 44px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: cardReveal .5s cubic-bezier(.22,1,.36,1) both;
}

@keyframes cardReveal {
  from { opacity:0; transform: translateY(20px) scale(.98); }
  to   { opacity:1; transform: translateY(0)    scale(1); }
}

/* Teal accent bar */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 44px; right: 44px;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: 0 0 4px 4px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139,26,43,.3);
}

.login-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.login-logo-text .brand {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: -.3px;
}

.login-logo-text .tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--slate-400);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.login-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.4px;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
  color: var(--slate-500);
  margin-bottom: 32px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
  letter-spacing: .1px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14.5px;
  color: var(--slate-800);
  transition: var(--transition);
  outline: none;
}

.form-input::placeholder { color: var(--slate-400); }

.form-input:focus {
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(139,26,43,.3);
  letter-spacing: .1px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139,26,43,.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}

.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  display: none;
}
.error-msg.show { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--slate-400);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-700);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background .2s;
  margin-bottom: 6px;
}
.btn-google:hover {
  border-color: #4285F4;
  box-shadow: 0 2px 8px rgba(66,133,244,0.15);
  background: #F8FBFF;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--slate-400);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--slate-200);
}
.login-divider span { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD PAGE
═══════════════════════════════════════════════════════════ */
.dashboard-page {
  min-height: 100vh;
  background: var(--slate-100);
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--slate-100);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: hidden;
  max-width: 100vw;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.header-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 64px;
}

.header-row-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  width: 100%;
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo svg {
  display: block;
  height: 36px;
  width: auto;
}

.header-logo-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(139,26,43,.25);
}

.header-brand {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: -.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Desktop: linha 1 e linha 2 ficam na mesma row */
@media (min-width: 641px) {
  .header-inner {
    flex-direction: row;
    align-items: stretch;
    min-height: 64px;
  }
  .header-row-main {
    flex: 1;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
  }
  .header-row-sub {
    flex: 0 0 auto;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 0;
    border-top: none;
    height: 64px;
    gap: 16px;
  }
  .btn-logout span { display: inline; }
  .header-estab { display: block; }
  .header-right { display: flex; align-items: center; gap: 16px; }
}

.header-estab {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-estab-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--slate-800);
  line-height: 1.2;
}

#headerEstabLogo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
  padding: 2px;
  border: 1px solid var(--slate-200);
  display: none;
}

.header-estab-label {
  font-size: 11px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Clinic selector (admin) ─────────────────────────────── */
.estab-selector {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.estab-selector-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.estab-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: var(--transition);
  min-width: 180px;
  max-width: 100%;
  box-sizing: border-box;
}

.estab-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

/* Admin badge */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--teal), #D4A760);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
  background: #FEF2F2;
}

/* ── Main Content ────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) both;
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.5px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--slate-400);
  margin-top: 3px;
}

.period-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-top: 10px;
  letter-spacing: .2px;
}

/* ── Período selector ────────────────────────────────────── */
.periodo-selector {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  margin-left: 8px;
}

.periodo-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #8B1A2B;
  background: #F7E9EB;
  border: none;
  border-radius: 20px;
  padding: 4px 28px 4px 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B1A2B' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-color: #F7E9EB;
}

.charts-grid--full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) both;
}

.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .10s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .20s; }

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Teal accent corner */
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: var(--transition);
}
.kpi-card:hover::after { opacity: 1; }

.kpi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  background: var(--teal-light);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1;
  letter-spacing: -1px;
  margin-bottom: 6px;
}

.kpi-value.currency::before {
  content: 'R$ ';
  font-size: 16px;
  font-weight: 500;
  color: var(--slate-500);
  vertical-align: top;
  line-height: 2;
  letter-spacing: 0;
}

.kpi-value.hours::after {
  content: 'h';
  font-size: 16px;
  font-weight: 500;
  color: var(--slate-500);
  vertical-align: bottom;
  line-height: 1.8;
}

.kpi-meta {
  font-size: 12px;
  color: var(--slate-400);
}

/* ── Charts ──────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  animation: slideUp .4s cubic-bezier(.22,1,.36,1) .3s both;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
}

.chart-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
  margin-bottom: 4px;
  letter-spacing: -.2px;
}

.chart-subtitle {
  font-size: 12px;
  color: var(--slate-400);
  margin-bottom: 20px;
}

.chart-wrap {
  position: relative;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--slate-400);
  font-size: 13px;
  gap: 8px;
}

/* ── Loading skeleton ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Error banner ────────────────────────────────────────── */
.error-banner {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 24px;
  display: none;
}
.error-banner.show { display: block; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}

/* ── Section label ───────────────────────────────────────── */
.section-label {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 28px 0 12px;
}

/* ── Follow-up status cards ──────────────────────────────── */
.followup-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.fu-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  border-top: 3px solid transparent;
  text-align: center;
}
.fu-aguardando  { border-top-color: #94A3B8; }
.fu-t1          { border-top-color: #F59E0B; }
.fu-t2          { border-top-color: #F97316; }
.fu-responderam { border-top-color: #10B981; }
.fu-esgotados   { border-top-color: #EF4444; }

.fu-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--slate-800);
  line-height: 1;
  margin-bottom: 6px;
}
.fu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Agents table ─────────────────────────────────────────── */
.agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.agents-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--slate-200);
}
.agents-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  vertical-align: middle;
}
.agents-table tr:last-child td { border-bottom: none; }
.agents-table tr:hover td { background: var(--slate-50); }

.agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.badge-resolved {
  background: #D1FAE5;
  color: #065F46;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 4px;
}
.badge-pct {
  font-size: 11px;
  color: var(--slate-400);
}

/* Procedimentos chart wrap height */
.procedimentos-wrap { height: 220px; }

/* Agents table: sem height fixo — cresce com o conteúdo */
.agents-wrap { height: auto !important; }

/* Heatmap card: overflow visível para o scroll horizontal funcionar */
.heatmap-card { overflow: visible; }

/* ── Heatmap mobile/desktop visibility ───────────────────── */
#heatmapMobile { display: none; }   /* hidden on desktop */

/* ── Peak list (mobile heatmap substituto) ───────────────── */
.peak-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.peak-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.peak-rank {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-400);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.peak-icon {
  display: flex;
  align-items: center;
  color: var(--teal);
  flex-shrink: 0;
}
.peak-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
  flex-shrink: 0;
  min-width: 120px;
}
.peak-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--slate-100);
  border-radius: 99px;
  overflow: hidden;
}
.peak-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #D4A760);
  border-radius: 99px;
  transition: width .4s ease;
}
.peak-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
}
body.dark .peak-label { color: #d4d4d8; }
body.dark .peak-bar-wrap { background: #2e2e33; }

/* ── Heatmap ──────────────────────────────────────────────── */
.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}
.heatmap-hours-row, .hm-day-col {
  display: flex;
  align-items: center;
  gap: 3px;
}
.heatmap-hours-row { margin-bottom: 3px; }
.hm-day-label {
  width: 32px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  text-align: right;
  padding-right: 6px;
  flex-shrink: 0;
}
.hm-hour-label {
  width: 26px;
  font-size: 10px;
  color: var(--slate-400);
  text-align: center;
  flex-shrink: 0;
}
.hm-cell {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: default;
  transition: transform .1s;
}
.hm-cell:hover { transform: scale(1.15); z-index: 1; position: relative; }

/* Dark mode for new components */
body.dark .fu-card,
body.dark .agents-table th,
body.dark .agents-table td { border-color: #2e2e33; }
body.dark .fu-card { background: #1f1f23; }
body.dark .fu-value { color: #f4f4f5; }
body.dark .agents-table tr:hover td { background: #1f1f23; }
body.dark .agents-table td { color: #d4d4d8; }
body.dark .badge-resolved { background: rgba(16,185,129,.15); color: #34d399; }

/* ── Responsive ──────────────────────────────────────────── */

/* Tablet (640–1024px): KPIs 2×2, gráficos lado a lado */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (< 640px) */
@media (max-width: 640px) {
  /* Header: logo + sair na linha 1, dropdown na linha 2 */
  .header { height: auto; }

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0 16px;
    gap: 0;
    align-items: center;
  }

  .header-logo {
    flex: 1;
    padding: 10px 0;
  }

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

  /* Dropdown vai para linha 2, ocupando 100% */
  .estab-selector {
    flex: 0 0 100% !important;
    width: 100% !important;
    order: 99;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f4f4f5;
    padding: 8px 0 10px;
    margin: 0;
    box-sizing: border-box;
  }

  .estab-select {
    flex: 1;
    min-width: 0;
    max-width: 100%;
  }

  .estab-selector-label {
    white-space: nowrap;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* Esconde nome da clínica e texto do sair */
  .header-estab { display: flex !important; }
  .logout-text { display: none; }
  .btn-logout { padding: 8px; }

  /* Conteúdo (valores já definidos no breakpoint 768px acima) */
  .chart-wrap { height: 220px; }
  .login-card { padding: 36px 24px 32px; }
  .login-card::before { left: 24px; right: 24px; }

  /* 1. Follow-up cards: 2 colunas no mobile */
  .followup-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .fu-card { padding: 14px 12px 12px; }
  .fu-value { font-size: 22px; }

  /* 2. Heatmap: ocultar grid, mostrar peak list no mobile */
  #heatmapWrap { display: none; }
  #heatmapMobile { display: block; }

  /* 3. Procedimentos: chart menor no mobile */
  .procedimentos-wrap { height: 180px; }

  /* 4. Tabela atendentes: esconder Tempo Médio, avatar compacto */
  .agents-table th:last-child,
  .agents-table td:last-child { display: none; }
  .agents-table { font-size: 12px; }
  .agents-table td, .agents-table th { padding: 8px 6px; }
  .agent-avatar { width: 22px; height: 22px; font-size: 9px; margin-right: 5px; }

  /* 5. Espaçamentos menores */
  .section-label { margin: 18px 0 10px; }
  .charts-grid { gap: 12px; }
  .charts-grid--full { gap: 12px; margin-top: 12px; }
  .chart-card { padding: 16px; }
  .chart-subtitle { margin-bottom: 14px; }
}

/* ═══════════════════════════════════════════════════════════
   NAV TABS
═══════════════════════════════════════════════════════════ */
.nav-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--slate-200);
  overflow: hidden;
}

.nav-tab {
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-500);
  padding: 10px 20px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-tab:hover { color: var(--teal); }

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

/* ═══════════════════════════════════════════════════════════
   CLINICA FORM FEEDBACK
═══════════════════════════════════════════════════════════ */
.form-feedback {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  animation: fadeIn .2s ease;
}

.feedback-ok {
  background: #F0FDF4;
  border: 1px solid #86EFAC;
  color: #166534;
}

.feedback-err {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
}

/* ── KPI icon variants ───────────────────────────────────── */
.kpi-icon--green  { background: #F0FDF4; color: #16A34A; }
.kpi-icon--blue   { background: #EFF6FF; color: #2563EB; }
.kpi-icon--teal   { background: var(--teal-light); color: var(--teal); }
.kpi-icon--amber  { background: #FFFBEB; color: #D97706; }

.kpi-desc { font-size: 12px; color: var(--slate-400); margin-top: 4px; }

.chart-header { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT — SIDEBAR
═══════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar-logo {
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--slate-100);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--slate-500);
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  line-height: 1;
  white-space: nowrap;
}

.sidebar-item:hover {
  background: var(--slate-50);
  color: var(--slate-700);
}

.sidebar-item.active {
  background: var(--teal-light);
  color: var(--teal);
  font-weight: 600;
}

.sidebar-item svg { flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }

.sidebar-separator {
  height: 1px;
  background: var(--slate-200);
  margin: 6px 8px;
}

.sidebar-footer {
  padding: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--slate-100);
}

.sidebar-logout-btn:hover {
  color: var(--red) !important;
  background: #fef2f2 !important;
}

.app-content {
  flex: 1;
  margin-left: 220px;
  min-width: 0;
  max-width: calc(100% - 220px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header overrides inside sidebar layout */
.app-content .header {
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

.app-content .header-inner {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: none;
  margin: 0;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
}

/* Hamburger / sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--slate-500);
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--slate-100);
  color: var(--slate-700);
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
  backdrop-filter: blur(1px);
}
.sidebar-overlay.show { display: block; }

/* ── Dark mode — sidebar ─────────────────────────────────── */
body.dark .sidebar {
  background: #1f1f23;
  border-color: #2e2e33;
}
body.dark .sidebar-logo { border-color: #2e2e33; }
body.dark .sidebar-footer { border-color: #2e2e33; }
body.dark .sidebar-item:hover { background: #2e2e33; color: #e4e4e7; }
body.dark .sidebar-item.active { background: rgba(139,26,43,.15); color: #8B1A2B; }
body.dark .sidebar-separator { background: #2e2e33; }
body.dark .sidebar-logout-btn:hover { background: rgba(239,68,68,.12) !important; }
body.dark .app-content .header { background: #1f1f23; border-color: #2e2e33; }
body.dark .sidebar-toggle:hover { background: #2e2e33; color: #e4e4e7; }

/* ── Mobile (≤768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-220px); }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .app-content {
    margin-left: 0;
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
  }
  .sidebar-toggle { display: flex; }

  /* Layout principal no mobile */
  .main {
    padding: 16px;
    width: 100%;
    max-width: 100%;
  }

  /* KPI grid: 2 colunas, sem overflow */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  .kpi-card { padding: 14px 14px 12px; }
  .kpi-value { font-size: 1.75rem; }

  /* Charts */
  .charts-grid, .charts-grid--full { grid-template-columns: 1fr; }
  .chart-card { padding: 16px; }

  /* Page header no mobile */
  .page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }
  .periodo-selector { margin-left: 0; margin-top: 0; }
  .page-title { font-size: 22px; }

  /* Header */
  .app-content .header-inner { padding: 0 12px; gap: 8px; }
  #headerEstabLogo { display: block !important; width: 32px; height: 32px; }
  .header-estab-name { font-size: 14px; }
  #userName { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   UX/Dark Mode — Pente fino 2026-06-03
   Foco: WCAG AA contraste + paleta SaaS moderna (zinc + accent vibrante)
   Não-destrutivo: sobrescreve regras anteriores no fim do CSS.
═══════════════════════════════════════════════════════════════ */

/* color-scheme: inputs nativos, scrollbar, autofill seguirem dark do SO */
body.dark { color-scheme: dark; }
body:not(.dark) { color-scheme: light; }

/* Tokens dark refinados (zinc consistente, sem mistura slate/zinc) */
body.dark {
  --bg-base:       #09090b;  /* zinc-950 — ainda mais profundo (Linear/Vercel pattern) */
  --bg-surface-1:  #18181b;  /* zinc-900 — superfície base (sidebar, body) */
  --bg-surface-2:  #1f1f23;  /* zinc-900+ — cards, headers */
  --bg-surface-3:  #27272a;  /* zinc-800 — hovers, modals elevation */
  --border-subtle: #27272a;  /* zinc-800 (era #2e2e33 — agora padronizado) */
  --border-strong: #3f3f46;  /* zinc-700 — bordas fortes/focus */
  --text-primary:  #fafafa;  /* zinc-50 */
  --text-secondary:#a1a1aa;  /* zinc-400 — passa AA sobre surface-2 (5.6:1) */
  --text-tertiary: #71717a;  /* zinc-500 — placeholder/muted (4.6:1 sobre surface-1) */
  --accent:        #f87171;  /* red-400 — accent vibrante p/ dark (era #C24A5A wine) */
  --accent-hover:  #fca5a5;  /* red-300 — hover */
  --accent-tint:   rgba(248,113,113,.12);  /* tint p/ backgrounds ativos */
  --success:       #34d399;  /* emerald-400 */
  --warning:       #fbbf24;  /* amber-400 */
  --danger:        #f87171;  /* red-400 */

  background: var(--bg-base);
  color: var(--text-primary);
}

/* ─── Fixes de contraste WCAG AA ────────────────────────────── */

/* Placeholder (era #3f3f46 = 1.6:1 FAIL → #71717a = 4.6:1 PASS) */
body.dark .form-input::placeholder,
body.dark input::placeholder,
body.dark textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

/* Empty state (era #3f3f46 invisível → #71717a + itálico) */
body.dark .empty-state {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Chart subtitle (era #64748b = 3.4:1 FAIL → #a1a1aa = 5.6:1 PASS) */
body.dark .chart-subtitle,
body.dark .estab-selector-label,
body.dark .clinica-selector-label,
body.dark .form-help,
body.dark .text-muted,
body.dark small {
  color: var(--text-secondary);
}

/* ─── Acento vinho → red-400 vibrante em dark (era #8B1A2B hardcoded) ─── */

body.dark .nav-tab.active,
body.dark .sidebar-item.active {
  color: var(--accent);
}

body.dark .nav-tab.active {
  border-color: var(--accent);
}

body.dark .sidebar-item.active {
  background: var(--accent-tint);
}

body.dark .period-badge,
body.dark .periodo-badge {
  background: var(--accent-tint);
  color: var(--accent);
}

body.dark table tbody tr:hover {
  background: rgba(255,255,255,.03);  /* hover neutro, mais visível que wine glow */
}

body.dark .btn-primary {
  background: linear-gradient(135deg, var(--accent), #ef4444);
  color: #18181b;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(248,113,113,.25);
}

body.dark .btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
}

/* ─── Padronização de bordas (todas → border-subtle) ────────── */

body.dark .chart-card,
body.dark .kpi-card,
body.dark .login-card,
body.dark .header,
body.dark .nav-tabs,
body.dark .sidebar,
body.dark .sidebar-logo,
body.dark .sidebar-footer,
body.dark .sidebar-separator,
body.dark .fu-card,
body.dark .agents-table th,
body.dark .agents-table td,
body.dark .app-content .header {
  border-color: var(--border-subtle);
}

/* Cards: surface-2 + sutil ring (mais elevação do que box-shadow em dark) */
body.dark .chart-card,
body.dark .kpi-card,
body.dark .login-card,
body.dark .fu-card {
  background: var(--bg-surface-2);
  box-shadow: 0 0 0 1px var(--border-subtle), 0 1px 3px rgba(0,0,0,.4);
}

/* Headers/sidebars/inputs: surface-2 consistente */
body.dark .header,
body.dark .sidebar,
body.dark .app-content .header,
body.dark .estab-select,
body.dark .periodo-select,
body.dark select,
body.dark select.form-input {
  background: var(--bg-surface-2);
}

body.dark .form-input,
body.dark .form-input:focus,
body.dark textarea.form-input {
  background: var(--bg-surface-1);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

body.dark .form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Hovers: surface-3 (zinc-800) — mais perceptível */
body.dark .sidebar-item:hover,
body.dark .sidebar-toggle:hover,
body.dark .btn-logout:hover {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

/* ─── Texto secundário/labels padronizado ──────────────────── */

body.dark .nav-tab,
body.dark .kpi-label,
body.dark table th,
body.dark .btn-logout {
  color: var(--text-secondary);
}

body.dark .nav-tab:hover {
  color: var(--text-primary);
}

/* KPI value + section titles: text-primary */
body.dark .kpi-value,
body.dark .chart-title,
body.dark .section-title,
body.dark .fu-value {
  color: var(--text-primary);
}

/* Table td: surface-aware (clara sobre escuro) */
body.dark table td,
body.dark .agents-table td {
  color: #e4e4e7;  /* zinc-200 — entre primary e secondary */
}

/* ─── Scrollbar dark (WebKit) ──────────────────────────────── */

body.dark ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
body.dark ::-webkit-scrollbar-track {
  background: var(--bg-surface-1);
}
body.dark ::-webkit-scrollbar-thumb {
  background: var(--bg-surface-3);
  border-radius: 8px;
  border: 2px solid var(--bg-surface-1);
}
body.dark ::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ─── Selection ─────────────────────────────────────────────── */

body.dark ::selection {
  background: rgba(248,113,113,.30);
  color: var(--text-primary);
}

/* ─── Badges status (mantém HSL mas calibra contraste WCAG) ── */

body.dark .badge-green,
body.dark .badge-status.badge-green {
  background: rgba(52,211,153,.15);
  color: #6ee7b7;
}
body.dark .badge-yellow,
body.dark .badge-status.badge-yellow {
  background: rgba(251,191,36,.15);
  color: #fcd34d;
}
body.dark .badge-red,
body.dark .badge-status.badge-red {
  background: rgba(248,113,113,.15);
  color: #fca5a5;
}
body.dark .badge-gray,
body.dark .badge-status.badge-gray {
  background: var(--bg-surface-3);
  color: var(--text-secondary);
}

/* Error banner: tom de fundo mais discreto, texto OK */
body.dark .error-banner {
  background: rgba(248,113,113,.10);
  color: #fca5a5;
  border-color: rgba(248,113,113,.30);
}

/* ─── Focus visible global (a11y keyboard nav) ─────────────── */

body.dark *:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Dark logo accent gradient (vinho → âmbar fica feio em dark) ─── */

body.dark .login-logo-mark,
body.dark .login-card::before {
  background: linear-gradient(135deg, var(--accent), #fb923c);
}

body.dark .login-logo-mark {
  box-shadow: 0 4px 12px rgba(248,113,113,.25);
}

/* ─── Toggle dark/light: visibilidade ──────────────────────── */

body.dark #darkToggle {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

body.dark #darkToggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — Pente fino iPhone (2026-06-03)
   Refs: iOS HIG (44px tap target), WCAG mobile, Safari quirks
═══════════════════════════════════════════════════════════════ */

/* ─── iOS auto-zoom fix: inputs ≥ 16px sempre (era 14.5px) ─────
   Quando iOS detecta font-size < 16px ao focar, faz auto-zoom
   forçado no input. Solução universal: 16px na base.
*/
.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
  font-size: 16px;
}

/* ─── Safe-area iPhone (notch/home indicator) ──────────────────
   Requer <meta name="viewport" content="...viewport-fit=cover">
*/
body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.app-layout,
.app-content {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.sidebar {
  padding-bottom: max(env(safe-area-inset-bottom, 0), 0px);
}

.header {
  padding-top: env(safe-area-inset-top, 0);
}

.login-page {
  padding-top: max(24px, env(safe-area-inset-top, 0));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0));
}

/* ─── 100vh fix iOS Safari (address bar muda altura) ──────────
   Usar dvh (dynamic viewport height) com fallback.
*/
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ─── Tap targets ≥ 44x44px (iOS HIG) ─────────────────────────
   Botões, sidebar items, badges clicáveis.
*/
.btn-primary,
.btn-secondary,
.btn-logout,
.btn-google,
.btn-cta,
.sidebar-item,
.sidebar-toggle,
.nav-tab,
button:not(.icon-btn-sm) {
  min-height: 44px;
}

/* Icon buttons pequenos (toggle dark, etc): 36px é OK desktop,
   mas 44px no mobile. */
@media (max-width: 768px) {
  #darkToggle,
  .icon-btn,
  .icon-btn-sm,
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ─── Touch action: sem delay 300ms iOS antigo ─────────────── */
a, button, .btn-primary, .btn-secondary, .sidebar-item, .nav-tab,
input[type="submit"], input[type="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Overscroll bounce: sem bounce horizontal global ─────── */
html, body {
  overscroll-behavior-x: none;
}

/* ─── Tabelas: scroll horizontal envelopado ──────────────────
   Evita vazamento; usuário arrasta horizontalmente.
*/
.table-wrap,
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

@media (max-width: 768px) {
  /* Toda tabela top-level sem wrap explícito ganha scroll */
  .main table,
  .main .agents-table,
  .main .fu-card table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
  }

  /* Td/th mantém comportamento normal dentro do scroll */
  .main table thead,
  .main table tbody,
  .main table tr {
    display: table-row-group;
  }
  .main table thead { display: table-header-group; }
  .main table tr { display: table-row; }
  .main table th,
  .main table td { display: table-cell; }
}

/* ─── Containers sem vazar (overflow-x global) ──────────────── */
@media (max-width: 768px) {
  body, html { overflow-x: hidden; max-width: 100vw; }

  .app-layout,
  .app-content,
  .main,
  .header,
  .card,
  .chart-card,
  .kpi-card,
  .login-card,
  .form-group,
  .page-header {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Images: max-width auto, sem distorcer */
  img, svg, video, canvas, iframe {
    max-width: 100%;
    height: auto;
  }

  /* Texto longo (URLs, IDs) quebra em vez de vazar */
  .card *, .chart-card *, p, span, td, li {
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
}

/* ─── Breakpoint extra-pequeno: iPhone SE/Mini (≤ 375px) ──── */
@media (max-width: 375px) {
  .main { padding: 12px; }
  .kpi-grid { gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 1.5rem; }
  .page-title { font-size: 20px; }
  .login-card { padding: 32px 24px 28px; max-width: 100%; }
  .login-heading { font-size: 22px; }
  .header-inner { padding: 0 12px !important; }
}

/* ─── Mobile-only refinements ───────────────────────────────── */
@media (max-width: 768px) {
  /* Form inputs: padding mais generoso (touch) */
  .form-input {
    padding: 13px 14px;
  }

  /* Btn primário ocupa largura toda na coluna principal */
  .btn-primary,
  .btn-cta {
    padding: 14px 16px;
    font-size: 16px;
  }

  /* Sidebar mobile: largura ajustada, padding bottom seguro */
  .sidebar {
    width: 280px;
    transform: translateX(-280px);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Sidebar items: mais altos (touch) */
  .sidebar-item {
    padding: 14px 16px;
    font-size: 15px;
  }

  /* Modal/dialog ocupa quase tela toda */
  .modal,
  .dialog {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 48px);
    margin: 24px auto;
  }

  /* Inputs date/time: nativo iOS funciona, sem custom */
  input[type="date"],
  input[type="time"] {
    -webkit-appearance: none;
    min-height: 44px;
  }

  /* Cards com padding consistente */
  .chart-card,
  .kpi-card,
  .fu-card {
    padding: 16px;
    border-radius: 12px;
  }

  /* Page header empilhado, sem horizontal scroll */
  .page-header {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ─── Landscape iPhone ≤ 600px altura ──────────────────────── */
@media (max-height: 600px) and (max-width: 900px) {
  .login-page {
    align-items: flex-start;
    padding-top: env(safe-area-inset-top, 24px);
  }
  .login-card {
    padding: 28px 32px 24px;
    margin: 24px 0;
  }
}

/* ─── No-select em UI chrome (badges/labels): texto principal selecionável ── */
.sidebar-item,
.nav-tab,
.btn-primary,
.btn-secondary,
.kpi-label,
.badge,
.badge-status {
  -webkit-user-select: none;
  user-select: none;
}

/* ─── Smooth scroll inertia iOS ─────────────────────────────── */
* {
  -webkit-overflow-scrolling: touch;
}

/* ─── Fix dark mode em mobile: sidebar overlay com blur ──── */
@media (max-width: 768px) {
  body.dark .sidebar.open {
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar-overlay {
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

/* ═══════════════════════════════════════════════════════════════
   FIX dark mode — Tons claros (azul/violet/amarelo/vermelho)
   2026-06-03: badges/tags com bg-light + texto-dark adaptados
═══════════════════════════════════════════════════════════════ */

/* ─── Indigo (jantar, neg) ─────────────────────────────────── */
body.dark .rv-jantar .ic,
body.dark .dk-c-neg {
  background: rgba(129,140,248,.15) !important;  /* indigo-400 tint */
  color: #a5b4fc !important;                      /* indigo-300 */
}

/* ─── Violet (evento) ──────────────────────────────────────── */
body.dark .rv-tag-evt,
body.dark .bq-evento {
  background: rgba(167,139,250,.15) !important;   /* violet-400 tint */
  color: #c4b5fd !important;                       /* violet-300 */
}

/* ─── Amber (almoço, buffet, warn) ─────────────────────────── */
body.dark .rv-almoco .ic,
body.dark .rv-tag-buf,
body.dark .bq-red,
body.dark .dk-c-sol,
body.dark .esp-time.amarelo {
  background: rgba(251,191,36,.15) !important;    /* amber-400 tint */
  color: #fcd34d !important;                       /* amber-300 */
}

/* ─── Red/danger (erros, fechados, vermelho) ───────────────── */
body.dark .bq-fechado,
body.dark .esp-time.vermelho,
body.dark [class*="error"],
body.dark [class*="-error"] {
  background: rgba(248,113,113,.12) !important;   /* red-400 tint */
  color: #fca5a5 !important;                       /* red-300 */
}

/* Erros com border (não overrided pelo error-banner geral) */
body.dark .esp-error {
  background: rgba(248,113,113,.10);
  border: 1px solid rgba(248,113,113,.30);
  color: #fca5a5;
}

/* ─── Green (sucesso, confirmado, verde) ───────────────────── */
body.dark .dk-c-conf,
body.dark .bq-aum,
body.dark .esp-time.verde {
  background: rgba(52,211,153,.15) !important;    /* emerald-400 tint */
  color: #6ee7b7 !important;                       /* emerald-300 */
}

/* ─── KPI indicator bars (ficam OK em ambos, mas refinamos) ─ */
body.dark .dk-kpi.k2::before { background: #818cf8; }  /* indigo-400 mais luminoso */
body.dark .dk-kpi.k3::before { background: #34d399; }  /* emerald-400 */
body.dark .dk-kpi.k4::before { background: #fbbf24; }  /* amber-400 */

/* ─── Week/month dots (calendário reservas) ────────────────── */
body.dark .rv-week-dot.almoco,
body.dark .rv-month-stat .dot.almoco { background: #fbbf24; }   /* amber-400 */
body.dark .rv-week-dot.jantar,
body.dark .rv-month-stat .dot.jantar { background: #818cf8; }   /* indigo-400 */

/* ─── Equipe.html: cores específicas (teal #0f766e, slate-blue) ─── */
body.dark .badge-ativo {
  background: rgba(52,211,153,.15) !important;
  color: #6ee7b7 !important;
  border-color: rgba(52,211,153,.30) !important;
}
body.dark .badge-pendente {
  background: rgba(251,191,36,.15) !important;
  color: #fcd34d !important;
  border-color: rgba(251,191,36,.30) !important;
}

/* Equipe — text colors muito escuras hardcoded #1e293b/#334155/#374151/#475569 */
body.dark .eq-name-text { color: #fafafa !important; }
body.dark .eq-email-text,
body.dark .eq-modal p.subtitle,
body.dark .eq-empty h3,
body.dark .eq-empty p { color: #a1a1aa !important; }
body.dark .eq-modal h2 { color: #fafafa !important; }
body.dark .eq-modal label { color: #d4d4d8 !important; }

/* Configuracoes — Avatar laranja com bg vinho hardcoded fica OK
   Mas botões com border #ef4444 + color #ef4444 sobre dark = bom contraste já. OK. */

/* ─── Garantia: todos textos slate hardcoded → token consistente ─── */
body.dark .text-slate-900,
body.dark .text-slate-800,
body.dark [style*="color:#1e293b"],
body.dark [style*="color: #1e293b"],
body.dark [style*="color:#0f172a"],
body.dark [style*="color: #0f172a"],
body.dark [style*="color:#334155"],
body.dark [style*="color: #334155"] {
  color: #fafafa !important;
}

body.dark [style*="color:#64748b"],
body.dark [style*="color: #64748b"],
body.dark [style*="color:#475569"],
body.dark [style*="color: #475569"],
body.dark [style*="color:#94a3b8"],
body.dark [style*="color: #94a3b8"] {
  color: #a1a1aa !important;
}

/* ─── Toast escuro fica OK em dark (já é dark sobre dark — mantém) ── */
body.dark .rv-toast,
body.dark .bq-toast {
  background: #27272a !important;
  border: 1px solid #3f3f46;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
}

/* ═══════════════════════════════════════════════════════════════
   FIX dark — sidebar items e textos slate-azulados (2026-06-04)
   Problema: --slate-500 (#64748B) é cinza-azulado, fica difícil ler
   em dark. Override EXPLÍCITO no sidebar-item base + tabelas.
═══════════════════════════════════════════════════════════════ */

/* Sidebar-item base (Dashboard, Meu Restaurante, Reservas, etc) */
body.dark .sidebar-item {
  color: #e4e4e7;    /* zinc-200, MUITO mais legível que slate-500 azulado */
}

body.dark .sidebar-item svg {
  opacity: .85;
}

body.dark .sidebar-item:hover {
  color: #fafafa;
}

/* Equipe.html tons #64748b hardcoded (não pegou pelo selector inline anterior) */
body.dark .eq-empty p,
body.dark .role-option-desc,
body.dark .equipe-table th {
  color: #a1a1aa !important;
}

body.dark .eq-name-text { color: #fafafa !important; }
body.dark .eq-email-text { color: #a1a1aa !important; }

/* Pagamento.html tons #64748b/94a3b8 */
body.dark .assinatura-info,
body.dark .historico-table td::before,
body.dark .equipe-table td:not(:first-child)::before {
  color: #a1a1aa !important;
}

/* Cor SLATE token forçado mesmo em escopos com fallback inline.
   Algumas inline-styles tem `color: var(--slate-500, #64748b)` -- 
   garantir que o token resolva pra zinc luminoso sempre em dark. */
body.dark {
  --slate-50:  #18181b;
  --slate-100: #1f1f23;
  --slate-200: #27272a;
  --slate-300: #3f3f46;
  --slate-400: #a1a1aa;   /* text muted (era #94a3b8 slate-blue) */
  --slate-500: #a1a1aa;   /* WAS #64748b slate-blue invisivel */
  --slate-600: #d4d4d8;
  --slate-700: #e4e4e7;
  --slate-800: #fafafa;   /* text primary */
  --slate-900: #fafafa;
}

/* HARDCODED override pro CSS antigo */
body.dark .chart-subtitle,
body.dark .estab-selector-label,
body.dark .form-label,
body.dark .login-sub,
body.dark .login-logo-text .tagline,
body.dark .form-help {
  color: #a1a1aa;
}

/* Tabela: text-azul-mediano #64748b → zinc-300 */
body.dark th,
body.dark .table-th,
body.dark .rv-tbl th,
body.dark .cl-tbl th,
body.dark .bq-tbl th,
body.dark .dk-tbl th,
body.dark .equipe-table th {
  color: #a1a1aa !important;
}

/* td default mais claro */
body.dark td,
body.dark .table-td {
  color: #e4e4e7 !important;
}

/* Page title / headings — fallback cor escura sobre dark */
body.dark .page-title,
body.dark h1, body.dark h2, body.dark h3, body.dark h4 {
  color: #fafafa;
}

/* Headers azuis (.header-estab-name etc usam slate-800 light = mt escuro) */
body.dark .header-estab-name,
body.dark .login-heading,
body.dark .brand,
body.dark .login-logo-text .brand {
  color: #fafafa;
}

/* ═══════════════════════════════════════════════════════════════
   FIX largura container — Padroniza todas abas (2026-06-04)
   Reservas usava 1480px enquanto outras 1280px. Unificar em 1480px.
═══════════════════════════════════════════════════════════════ */

.main {
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* @media mobile (.main padding override) já está OK, sem mudança */
