/* spa.css — Sistema Virtualize */

/* ============================================================
   Tokens
   ============================================================ */
:root {
  /* Accent — Secretária */
  --navy:           #1B2B4B;
  --navy-light:     rgba(27,43,75,0.08);
  --navy-hover:     rgba(27,43,75,0.12);

  /* Accent — Médico */
  --teal:           #1A3A2A;
  --teal-light:     rgba(26,58,42,0.08);
  --teal-hover:     rgba(26,58,42,0.12);

  /* Superfícies */
  --bg:             rgba(240,241,245,0.60);
  --bg-card:        rgba(255,255,255,0.70);

  /* Glass — camada de controles apenas */
  --glass-sidebar:  rgba(255,255,255,0.72);
  --glass-topbar:   rgba(242,244,247,0.80);
  --glass-modal:    rgba(255,255,255,0.88);
  --glass-login:    rgba(255,255,255,0.10);
  --blur-sm:        blur(12px);
  --blur-md:        blur(20px);
  --blur-lg:        blur(40px);

  /* Texto */
  --text:           #111827;
  --text-muted:     #6B7280;
  --text-xmuted:    #9CA3AF;

  /* Bordas */
  --border:         #E5E7EB;
  --border-glass:   rgba(255,255,255,0.18);

  /* Sombras */
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:      0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);

  /* Tipografia */
  --font:           -apple-system, "SF Pro Text", BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display:   -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", sans-serif;
  --size-xs:        11px;
  --size-sm:        13px;
  --size-base:      15px;
  --size-md:        17px;
  --size-lg:        20px;
  --size-xl:        22px;
  --size-2xl:       28px;
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* Espaçamento */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* Status */
  --s-agendada:      #3B82F6;
  --s-agendada-bg:   rgba(59,130,246,0.10);
  --s-confirmada:    #10B981;
  --s-confirmada-bg: rgba(16,185,129,0.10);
  --s-atendida:      #8B5CF6;
  --s-atendida-bg:   rgba(139,92,246,0.10);
  --s-falta:         #F59E0B;
  --s-falta-bg:      rgba(245,158,11,0.10);
  --s-cancelada:     #EF4444;
  --s-cancelada-bg:  rgba(239,68,68,0.10);
  --s-pendente:      #F59E0B;
  --s-pendente-bg:   rgba(245,158,11,0.10);
  --s-paga:          #10B981;
  --s-paga-bg:       rgba(16,185,129,0.10);
  --s-vencida:       #EF4444;
  --s-vencida-bg:    rgba(239,68,68,0.10);

  /* Layout */
  --sidebar-w:       220px;
  --sidebar-w-mini:  64px;
  --topbar-h:        56px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--size-base);
  font-weight: var(--weight-regular);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }
ul, ol { list-style: none; }

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

/* ============================================================
   Utilitários
   ============================================================ */
.hidden  { display: none !important; }
.text-muted  { color: var(--text-muted); font-size: var(--size-sm); }
.text-xmuted { color: var(--text-xmuted); font-size: var(--size-xs); }

/* ============================================================
   Tela de Login
   ============================================================ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(180,170,220,0.28) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(160,185,215,0.22) 0%, transparent 55%),
    #F0F1F5;
  padding: var(--space-4);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(235,236,242,0.55);
  backdrop-filter: blur(40px) saturate(1.6);
  -webkit-backdrop-filter: blur(40px) saturate(1.6);
  border: 1px solid rgba(255,255,255,0.70);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  animation: fadeInDown 280ms ease-out both;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.login-icon {
  width: 56px;
  height: 56px;
  background: #1B2A4A;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(27,42,74,0.25);
}

.login-wordmark {
  font-family: -apple-system, "SF Pro Text", BlinkMacSystemFont, sans-serif;
  font-size: var(--size-md);
  font-weight: var(--weight-medium);
  letter-spacing: 0.02em;
  color: var(--text-muted);
  line-height: 1;
}

.login-welcome {
  font-family: -apple-system, "SF Pro Display", BlinkMacSystemFont, sans-serif;
  font-size: var(--size-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  margin-top: var(--space-3);
}

.login-card .field {
  margin-bottom: var(--space-4);
}

.login-card label {
  display: block;
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.login-card input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--size-base);
  transition: border-color 150ms, box-shadow 150ms;
}

.login-card input::placeholder { color: var(--text-xmuted); }
.login-card input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-light);
}

.input-icon-right { position: relative; }
.input-icon-right input { padding-right: 40px; }
.input-icon-right .btn-icon {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-icon-right .btn-icon:hover { color: var(--text); }

.login-error {
  font-size: var(--size-sm);
  color: #DC2626;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(220,38,38,0.06);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(220,38,38,0.15);
}

.btn-full { width: 100%; }

.login-forgot {
  display: block;
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--size-sm);
  color: var(--text-muted);
  transition: color 150ms;
}
.login-forgot:hover { color: var(--navy); }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(180,170,220,0.28) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(160,185,215,0.22) 0%, transparent 50%),
    #F0F1F5;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 220ms ease, transform 250ms ease;
  overflow: hidden;
  isolation: isolate;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.52);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(40px) saturate(1.4);
  border-right: 1px solid rgba(255,255,255,0.60);
  pointer-events: none;
  z-index: 0;
}

/* Mini sidebar (colapsada) */
.sidebar-collapsed {
  width: var(--sidebar-w-mini);
}

/* Fix: Safari não anima width corretamente em elementos com backdrop-filter — remove o filtro durante a transição */
.sidebar-transitioning {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sidebar-transitioning::before {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Fix: no Safari, camadas com backdrop-filter podem "engolir" clique de filhos */
.sidebar > * {
  position: relative;
  z-index: 1;
}

.sidebar-collapsed .sidebar-logo-text,
.sidebar-collapsed .sidebar-item span,
.sidebar-collapsed .sidebar-logout-label,
.sidebar-collapsed .sidebar-footer-divider {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.sidebar-collapsed .sidebar-nav {
  padding: var(--space-3) 0;
  align-items: stretch;
  gap: var(--space-2);
}

.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: 0;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 14px;
  gap: 0;
}

.sidebar-collapsed .sidebar-footer {
  align-items: stretch;
  padding: var(--space-3) 0;
}

.sidebar-collapsed .sidebar-logout {
  justify-content: center;
  padding: 0;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 14px;
  gap: 0;
}

.sidebar-collapsed .sidebar-nav-divider {
  width: 24px;
  margin: var(--space-2) auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 calc(var(--space-3) * 2);
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-icon,
.sidebar-item svg,
.sidebar-logout-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-collapsed .sidebar-brand-icon {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
  transform: translateX(1px);
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--size-base);
  font-weight: var(--weight-medium);
  transition: background 140ms, color 140ms;
}

.sidebar-item:hover {
  background: var(--navy-light);
  color: var(--navy);
}

.sidebar-item-active {
  background: var(--navy) !important;
  color: #FFFFFF !important;
}

/* Variante médico */
.role-medico .sidebar-item:hover       { background: var(--teal-light); color: var(--teal); }
.role-medico .sidebar-item-active      { background: var(--teal) !important; }
.role-medico .sidebar-header           { color: var(--teal); }
.role-medico .sidebar-logo-text        { color: var(--teal); }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-footer-divider {
  height: 1px;
  background: var(--border);
  margin-top: var(--space-3);
  margin-bottom: 0;
}

.sidebar-nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) var(--space-3);
}

.sidebar-item-config {
  color: var(--text-muted);
}
.sidebar-item-config:hover { color: var(--text); }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--size-base);
  font-weight: var(--weight-medium);
  background: transparent;
  border: none;
  width: 100%;
  transition: background 140ms, color 140ms;
}
.sidebar-logout:hover { background: var(--navy-light); color: var(--navy); }

/* ============================================================
   Main wrapper
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 220ms ease;
  min-width: 0;
  overflow: hidden;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  z-index: 100;
  flex-shrink: 0;
  gap: var(--space-4);
  isolation: isolate;
}

.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.52);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(40px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,0.60);
  pointer-events: none;
  z-index: 0;
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--size-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.topbar-datetime {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 12px;
  background: rgba(255,255,255,0.44);
  border: 1px solid rgba(255,255,255,0.62);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
  font-size: var(--size-sm);
  color: var(--text);
  white-space: nowrap;
}

.topbar-datetime-icon {
  flex-shrink: 0;
  color: #7A8293;
}

.topbar-date {
  color: #6C7586;
  font-weight: var(--weight-medium);
}

.topbar-separator {
  color: #8E95A3;
}

.topbar-time {
  color: var(--text);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.hamburger { display: inline-flex; }

/* Select ghost (filtro de médico) */
.select-ghost {
  height: 34px;
  padding: 0 var(--space-3);
  background: rgba(255,255,255,0.44);
  border: 1px solid rgba(255,255,255,0.62);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
  font-size: var(--size-sm);
  color: var(--text);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}
.select-ghost:hover { background: rgba(255,255,255,0.54); }
.select-ghost:focus { outline: none; border-color: var(--navy); }

/* ============================================================
   Notificações
   ============================================================ */
.notif-wrap { position: relative; }

.topbar .btn-icon,
.topbar .select-ghost,
.notif-wrap,
.sidebar .sidebar-item,
.sidebar .sidebar-logout {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--s-cancelada);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg);
}

.notif-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: fadeInDown 180ms ease-out both;
}

.notif-loading, .notif-empty {
  padding: var(--space-4);
  font-size: var(--size-sm);
  color: var(--text-muted);
  text-align: center;
}

.notif-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }

.notif-content { font-size: var(--size-sm); line-height: 1.45; }
.notif-time    { font-size: var(--size-xs); color: var(--text-xmuted); }

/* ============================================================
   View
   ============================================================ */
.view {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.view-content {
  max-width: 1200px;
}

/* ============================================================
   Botões
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  background: var(--navy);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  transition: opacity 150ms;
}
.btn-primary:hover   { opacity: 0.90; }
.btn-primary:active  { opacity: 0.82; }
.btn-primary:disabled { opacity: 0.50; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  transition: background 150ms, border-color 150ms;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--text-xmuted); }

.btn-destructive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  background: transparent;
  color: #DC2626;
  border: 1px solid #DC2626;
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  transition: background 150ms;
}
.btn-destructive:hover { background: rgba(220,38,38,0.06); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: background 140ms, color 140ms;
}
.btn-icon:hover { background: var(--navy-light); color: var(--navy); }

/* ============================================================
   Campos de formulário
   ============================================================ */
.field { display: flex; flex-direction: column; gap: var(--space-1); }

.field label {
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  height: 38px;
  padding: 0 var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--size-base);
  transition: border-color 150ms, box-shadow 150ms;
  width: 100%;
}

textarea {
  height: auto;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-light);
}

input::placeholder, textarea::placeholder { color: var(--text-xmuted); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
}

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

.card-title {
  font-size: var(--size-base);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

/* ============================================================
   KPIs grid
   ============================================================ */
.kpi-grid {
  display: block;
  margin-bottom: var(--space-6);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0;
  overflow: hidden;
}

.kpi-strip-item {
  min-width: 0;
  padding: 18px 22px 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kpi-strip-item + .kpi-strip-item {
  border-left: 1px solid rgba(17,24,39,0.07);
}

.kpi-strip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kpi-strip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7C8596;
  flex-shrink: 0;
}

.kpi-strip-label {
  min-width: 0;
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  color: #778092;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-strip-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.kpi-strip-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
}

.kpi-strip-desc {
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Tabelas
   ============================================================ */
.table-wrap  { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
}

thead th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

tbody td {
  padding: 11px var(--space-3);
  vertical-align: middle;
}

/* ============================================================
   Badges de status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.badge-agendada   { background: var(--s-agendada-bg);   color: var(--s-agendada); }
.badge-confirmada { background: var(--s-confirmada-bg); color: var(--s-confirmada); }
.badge-atendida   { background: var(--s-atendida-bg);   color: var(--s-atendida); }
.badge-falta      { background: var(--s-falta-bg);      color: var(--s-falta); }
.badge-cancelada  { background: var(--s-cancelada-bg);  color: var(--s-cancelada); }
.badge-pendente   { background: var(--s-pendente-bg);   color: var(--s-pendente); }
.badge-paga       { background: var(--s-paga-bg);       color: var(--s-paga); }
.badge-vencida    { background: var(--s-vencida-bg);    color: var(--s-vencida); }

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-pill);
  background: var(--navy-light);
  color: var(--navy);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.avatar-lg {
  width: 44px; height: 44px;
  font-size: var(--size-sm);
}

/* ============================================================
   Modais
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.modal-overlay.modal-visible { opacity: 1; }

.modal-overlay.modal-visible .modal {
  transform: scale(1);
  opacity: 1;
}

.modal {
  background: var(--glass-modal);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  transform: scale(0.96);
  opacity: 0;
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}

.modal-hide {
  animation: fadeOut 180ms ease-in both;
}

.modal-sm { max-width: 400px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 760px; }

.modal-stack { z-index: 410; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) 0;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--size-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
  flex-shrink: 0;
}

.modal-confirm-desc {
  color: var(--text-muted);
  font-size: var(--size-base);
  line-height: 1.5;
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 500;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--text);
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  max-width: 360px;
  pointer-events: all;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease-out, transform 220ms ease-out;
}

.toast-visible { opacity: 1; transform: translateY(0); }
.toast-hide    { opacity: 0; transform: translateY(8px); transition: opacity 180ms ease-in, transform 180ms ease-in; }

.toast-success { background: #064E3B; }
.toast-error   { background: #7F1D1D; }
.toast-warning { background: #78350F; }

.toast-msg  { flex: 1; }
.toast-icon { flex-shrink: 0; }

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.60);
  padding: 2px;
  display: flex;
  align-items: center;
  transition: color 140ms;
}
.toast-close:hover { color: #FFFFFF; }

.toast-undo-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #FFFFFF;
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  transition: background 140ms;
}
.toast-undo-btn:hover { background: rgba(255,255,255,0.25); }

/* ============================================================
   Paginação
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4) 0;
  justify-content: center;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  transition: background 140ms, color 140ms, border-color 140ms;
}
.page-btn:hover:not([disabled]) { background: var(--navy-light); color: var(--navy); }
.page-btn-active { background: var(--navy) !important; color: #FFFFFF !important; border-color: var(--navy); }
.page-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.page-ellipsis { color: var(--text-xmuted); padding: 0 var(--space-1); font-size: var(--size-sm); }

/* ============================================================
   Skeleton loading
   ============================================================ */
.skeleton-wrap { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-2); }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(229,231,235,0.5) 50%, var(--border) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.4s infinite;
}
.skeleton-title { height: 24px; width: 40%; }
.skeleton-row   { height: 40px; width: 100%; }
.skeleton-row.short { width: 70%; }

/* ============================================================
   Spinner
   ============================================================ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.30);
  border-top-color: #FFFFFF;
  border-radius: var(--radius-pill);
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   Estado vazio
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10);
  color: var(--text-muted);
  text-align: center;
}

.empty-state p { font-size: var(--size-base); line-height: 1.5; }

/* ============================================================
   Sidebar mobile overlay
   ============================================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  z-index: 190;
  display: none; /* oculto no desktop */
}

/* ============================================================
   Animações
   ============================================================ */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Pacientes
   ============================================================ */
.pac-wrap { max-width: 1200px; }

.pac-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.pac-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.pac-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.pac-search {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-3) 0 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms;
}
.pac-search:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-light);
}

.pac-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.btn-active {
  background: var(--navy-light) !important;
  color: var(--navy) !important;
  border-color: var(--navy) !important;
}

.td-muted { color: var(--text-muted); font-size: var(--size-sm); }

.action-row { display: flex; align-items: center; gap: var(--space-1); justify-content: flex-end; }

/* Seção de form no modal */
.form-section-title {
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  margin-top: var(--space-1);
}

.form-grid   { display: grid; gap: var(--space-3); }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Status toggle */
.field-label {
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.status-toggle {
  display: flex;
  gap: var(--space-2);
}

.status-opt {
  height: 32px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
}
.status-opt:hover { border-color: var(--text-muted); color: var(--text); }

.status-opt-active  { border-color: transparent !important; color: #fff !important; }
.status-opt-lead    { background: var(--s-agendada) !important; }
.status-opt-ativo   { background: var(--s-confirmada) !important; }
.status-opt-inativo { background: var(--text-muted) !important; }

/* Origem pills */
.origem-pills {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.origem-pill {
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
}
.origem-pill:hover { border-color: var(--navy); color: var(--navy); }
.origem-pill-active {
  background: var(--navy-light);
  border-color: var(--navy);
  color: var(--navy);
}

/* ============================================================
   Home
   ============================================================ */
.home-wrap { max-width: 1200px; }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(340px, 0.84fr);
  gap: var(--space-4);
  align-items: start;
}

.home-pend-card { display: flex; flex-direction: column; min-height: 0; }
.home-pend-card-empty { align-self: start; }

.home-right-col { display: flex; flex-direction: column; gap: var(--space-5); }

/* Segmented control */
.seg-control {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}

.seg-opt {
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}

.seg-active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Pendências lista */
.pend-list {
  overflow-y: auto;
  max-height: 320px;
  flex: 1;
}

.pend-list-empty {
  max-height: none;
  min-height: 220px;
  display: flex;
}

.pend-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 11px var(--space-5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms;
}
.pend-item:last-child { border-bottom: none; }
.pend-item:hover { background: var(--bg); }

.pend-info { flex: 1; min-width: 0; }
.pend-name { font-size: var(--size-sm); font-weight: var(--weight-medium); }
.pend-desc { font-size: var(--size-xs); color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pend-chips { display: flex; gap: 3px; flex-shrink: 0; }
.pend-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
}

.pend-legend {
  padding: var(--space-2) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.pend-legend span {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--size-xs);
  color: var(--text-muted);
}

.empty-state-compact {
  width: 100%;
  padding: 28px var(--space-8);
  gap: var(--space-2);
}

.empty-state-subtle {
  font-size: var(--size-xs);
  color: var(--text-xmuted);
  text-align: center;
  line-height: 1.5;
  max-width: 260px;
}

/* Modal pendências */
.pm-header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.pm-nome { font-size: var(--size-md); font-weight: var(--weight-semibold); }
.pm-meta { font-size: var(--size-xs); color: var(--text-muted); margin-top: 2px; }

.pm-actions { display: flex; flex-direction: column; gap: 0; }

.pm-action-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.pm-action-row:last-child { border-bottom: none; }

.pm-action-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.pm-action-info { flex: 1; min-width: 0; }
.pm-action-label { font-size: var(--size-sm); font-weight: var(--weight-medium); }
.pm-action-desc  { font-size: var(--size-xs); color: var(--text-muted); margin-top: 2px; }

.pm-action-btns { display: flex; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.pm-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 140ms;
}
.pm-btn:hover { opacity: 0.85; }

.pm-btn-wa      { background: rgba(16,185,129,0.10); color: #059669; }
.pm-btn-primary { background: var(--navy-light); color: var(--navy); }
.pm-btn-orange  { background: rgba(245,158,11,0.10); color: #D97706; }
.pm-btn-purple  { background: rgba(139,92,246,0.10); color: #7C3AED; }
.pm-btn-red     { background: rgba(239,68,68,0.10); color: #DC2626; }

/* Notas */
.notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
}

.nota-card {
  border-radius: var(--radius-md);
  padding: 12px 14px 14px;
  position: relative;
  min-height: 148px;
  cursor: text;
  border: 1px solid rgba(27,43,75,0.08);
}

.nota-card-compose {
  min-height: 164px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.nota-del {
  width: 20px; height: 20px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 140ms, color 140ms;
  color: rgba(0,0,0,0.38);
}

.nota-card:hover .nota-del,
.nota-del:focus-visible,
.nota-compose-close {
  opacity: 1;
}

.nota-card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.nota-color-wrap {
  position: relative;
}

.nota-color-trigger {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nota-color-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px rgba(17,24,39,0.08);
}

.nota-color-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(17,24,39,0.08);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.nota-text {
  width: 100%;
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 0 8px 0 6px;
  font-size: var(--size-sm);
  line-height: 1.5;
  color: rgba(0,0,0,0.75);
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 92px;
}

.nota-compose-input {
  min-height: 112px;
}

.nota-text::placeholder,
.nota-compose-input::placeholder { color: rgba(0,0,0,0.38); }

.nota-color-btn {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  transition: transform 120ms, border-color 120ms;
}

.nota-color-btn-active {
  border-color: rgba(27,43,75,0.64);
  transform: scale(1.08);
}

.home-inline-empty {
  grid-column: 1 / -1;
  font-size: var(--size-sm);
  color: var(--text-muted);
  padding: var(--space-2) 0;
}

/* Tarefas */
.tarefas-list {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  padding: 0 var(--space-5) var(--space-5);
}

.tarefa-compose {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 0 var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}

.tarefa-chk-placeholder {
  opacity: 0.28;
  pointer-events: none;
}

.tarefa-compose-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: var(--size-md);
  color: var(--text);
  outline: none;
}

.tarefa-compose-input::placeholder { color: #A1A8B6; }

.tarefa-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 180ms ease, transform 180ms ease, background 140ms ease;
}
.tarefa-item:last-child { border-bottom: none; }
.tarefa-item:hover { background: rgba(255,255,255,0.28); }

.tarefa-chk {
  width: 18px; height: 18px;
  border-radius: var(--radius-pill);
  border: 2px solid #D8DCE4;
  background: transparent;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms;
  cursor: pointer;
}
.tarefa-chk svg {
  opacity: 0;
  transition: opacity 120ms ease;
}
.tarefa-item-completing .tarefa-chk {
  background: var(--navy);
  border-color: var(--navy);
}
.tarefa-item-completing .tarefa-chk svg { opacity: 1; }

.tarefa-text {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  line-height: 1.4;
  outline: none;
  color: rgba(17,24,39,0.92);
}

.tarefa-text:focus {
  color: var(--text);
}

.tarefa-done {
  color: var(--text-xmuted);
  text-decoration: line-through;
}

.tarefa-del {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #747C8C;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease;
}

.tarefa-item:hover .tarefa-del,
.tarefa-del:focus-visible {
  opacity: 1;
}

.tarefa-del:hover {
  color: var(--text);
}

.tarefa-item-completing {
  opacity: 0;
  transform: translateY(-4px);
}

.tarefas-empty {
  margin: auto 0;
  padding: var(--space-8) 0;
  text-align: center;
  font-size: var(--size-md);
  color: var(--text-muted);
}

/* ============================================================
   Responsive — Tablet (< 1024px)
   ============================================================ */
@media (max-width: 1023px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip-item:nth-child(3),
  .kpi-strip-item:nth-child(4) {
    border-top: 1px solid rgba(17,24,39,0.07);
  }
  .kpi-strip-item:nth-child(3) { border-left: none; }
}

/* ============================================================
   Responsive — Mobile (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .hamburger {
    display: inline-flex;
  }

  .topbar-datetime {
    display: none;
  }

  .view {
    padding: var(--space-4);
  }

  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-strip-item + .kpi-strip-item {
    border-left: none;
    border-top: 1px solid rgba(17,24,39,0.07);
  }
  .kpi-strip-item {
    padding: 16px 18px;
  }
  .kpi-strip-body {
    gap: 8px;
    flex-wrap: wrap;
  }
  .kpi-strip-value {
    font-size: 24px;
  }

  .modal { max-width: 100% !important; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }
  .toast { max-width: 100%; }

  /* Home mobile */
  .home-grid { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr 1fr; }
  .pm-action-btns { flex-direction: column; align-items: flex-end; }

  /* Agenda mobile */
  .ag-calendar { min-width: 600px; }
  .ag-calendar-wrap { overflow-x: auto; }

  /* Overlay mobile: mostrar apenas quando não tem hidden */
  .sidebar-overlay:not(.hidden) { display: block; }

  /* Fix: removido .sidebar-collapsed override — o JS nunca aplica essa classe no mobile (isMobile() guard em app.js:171) */
}

/* ============================================================
   Agenda
   ============================================================ */

/* Layout wrapper */
.ag-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: var(--space-4);
}

/* Toolbar */
.ag-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-shrink: 0;
}

.ag-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ag-nav-btn {
  width: 32px;
  height: 32px;
}

.ag-hoje-btn {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--size-sm);
}

.ag-periodo {
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  min-width: 140px;
}

.ag-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ag-loading {
  padding: var(--space-10);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--size-sm);
}

/* Calendário */
.ag-calendar-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.ag-calendar {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Cabeçalho dos dias */
.ag-header {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.60);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
}

.ag-time-gutter {
  border-right: 1px solid var(--border);
}

.ag-col-header {
  padding: var(--space-2) var(--space-2);
  text-align: center;
  border-right: 1px solid var(--border);
}
.ag-col-header:last-child { border-right: none; }

.ag-col-hoje {
  background: rgba(27,43,75,0.04);
}

.ag-dow {
  display: block;
  font-size: var(--size-xs);
  color: var(--text-muted);
  text-transform: capitalize;
  line-height: 1;
  margin-bottom: 4px;
}

.ag-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.ag-day-hoje {
  background: var(--navy);
  color: #fff;
}

/* Body scrollável */
.ag-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Linhas de horário */
.ag-row {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  min-height: 32px;
  border-bottom: 1px solid var(--border);
}

.ag-row-half {
  border-bottom: 1px dashed rgba(229,231,235,0.6);
}

.ag-time-label {
  font-size: 10px;
  color: var(--text-xmuted);
  padding: 0 var(--space-2);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 4px;
  border-right: 1px solid var(--border);
  user-select: none;
}

.ag-time-label.ag-half {
  border-right: 1px solid var(--border);
}

/* Células do grid */
.ag-cell {
  border-right: 1px solid var(--border);
  min-height: 32px;
  padding: 2px;
  position: relative;
  cursor: pointer;
  transition: background 100ms;
}
.ag-cell:last-child { border-right: none; }
.ag-cell:hover { background: rgba(27,43,75,0.03); }

.ag-cell-bloqueio {
  background: repeating-linear-gradient(
    45deg,
    rgba(0,0,0,0.02),
    rgba(0,0,0,0.02) 4px,
    transparent 4px,
    transparent 8px
  );
  cursor: not-allowed;
}
.ag-cell-bloqueio:hover { background: repeating-linear-gradient(
  45deg,
  rgba(0,0,0,0.04),
  rgba(0,0,0,0.04) 4px,
  transparent 4px,
  transparent 8px
); }

.ag-bloqueio-label {
  font-size: 10px;
  color: var(--text-xmuted);
  padding: 2px 4px;
  user-select: none;
}

/* Eventos */
.ag-event {
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: var(--size-xs);
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: filter 100ms;
  min-height: 32px;
}
.ag-event:hover { filter: brightness(0.95); }

.ag-ev-agendada   { background: var(--s-agendada-bg);   border-left: 3px solid var(--s-agendada); }
.ag-ev-confirmada { background: var(--s-confirmada-bg); border-left: 3px solid var(--s-confirmada); }
.ag-ev-atendida   { background: var(--s-atendida-bg);   border-left: 3px solid var(--s-atendida); }
.ag-ev-falta      { background: var(--s-falta-bg);      border-left: 3px solid var(--s-falta); }
.ag-ev-cancelada  { background: var(--s-cancelada-bg);  border-left: 3px solid var(--s-cancelada); opacity: 0.6; }

.ag-ev-nome {
  font-weight: var(--weight-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-ev-serv {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-ev-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: var(--weight-medium);
  padding: 0 4px;
  border-radius: 3px;
  align-self: flex-start;
}

.ag-ev-badge-agendada   { background: var(--s-agendada-bg);   color: var(--s-agendada); }
.ag-ev-badge-confirmada { background: var(--s-confirmada-bg); color: var(--s-confirmada); }
.ag-ev-badge-atendida   { background: var(--s-atendida-bg);   color: var(--s-atendida); }
.ag-ev-badge-falta      { background: var(--s-falta-bg);      color: var(--s-falta); }
.ag-ev-badge-cancelada  { background: var(--s-cancelada-bg);  color: var(--s-cancelada); }

/* -------- Formulário de agendamento -------- */
.ag-form { display: flex; flex-direction: column; gap: var(--space-4); }

/* Autocomplete de paciente */
.ag-pac-search-wrap {
  position: relative;
}

.ag-pac-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--glass-modal);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}

.ag-pac-item {
  padding: var(--space-2) var(--space-3);
  font-size: var(--size-sm);
  color: var(--text);
  cursor: pointer;
  transition: background 100ms;
}
.ag-pac-item:hover { background: var(--navy-light); }
.ag-pac-empty { color: var(--text-muted); cursor: default; }
.ag-pac-empty:hover { background: transparent; }

/* ============================================================
   Financeiro
   ============================================================ */

.fin-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* KPIs */
.fin-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.fin-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.fin-kpi-skeleton { min-height: 72px; }

.fin-kpi-label {
  font-size: var(--size-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fin-kpi-valor {
  font-size: var(--size-xl);
  font-weight: var(--weight-semibold);
  color: var(--text);
  letter-spacing: -0.02em;
}

.fin-kpi-positivo .fin-kpi-valor { color: var(--s-confirmada); }
.fin-kpi-negativo .fin-kpi-valor { color: var(--s-cancelada); }
.fin-kpi-pendente .fin-kpi-valor { color: var(--s-pendente); }

/* Toolbar */
.fin-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.fin-tabs {
  display: flex;
  background: rgba(0,0,0,0.04);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.fin-tab {
  height: 30px;
  padding: 0 var(--space-4);
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
}
.fin-tab-active {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.fin-nav-mes {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.fin-mes-label {
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  min-width: 72px;
  text-align: center;
}

.fin-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  flex-wrap: wrap;
}

/* Status pills */
.fin-status-pills {
  display: flex;
  gap: var(--space-1);
}

.fin-spill {
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
}
.fin-spill:hover { border-color: var(--navy); color: var(--navy); }
.fin-spill-active { background: var(--navy-light); border-color: var(--navy); color: var(--navy); }

/* Loading */
.fin-loading {
  padding: var(--space-10);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--size-sm);
}

/* Tabela */
.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
}

.fin-table thead th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fin-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 100ms;
}

.fin-tr-click {
  cursor: pointer;
}
.fin-tr-click:hover { background: var(--navy-light); }

.fin-table td {
  padding: var(--space-3);
  color: var(--text);
  vertical-align: middle;
}

.fin-td-nome {
  font-weight: var(--weight-medium);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fin-td-date { color: var(--text-muted); white-space: nowrap; }
.fin-td-serv { color: var(--text-muted); }

.fin-td-valor {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.fin-valor-despesa { color: var(--s-cancelada); }

.fin-td-action {
  width: 36px;
  text-align: center;
  color: var(--text-xmuted);
}
.fin-edit-icon { opacity: 0; transition: opacity 150ms; }
.fin-tr-click:hover .fin-edit-icon { opacity: 1; }

/* Status badges */
.fin-status {
  display: inline-block;
  font-size: var(--size-xs);
  font-weight: var(--weight-medium);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.fin-s-pendente  { background: var(--s-pendente-bg);  color: var(--s-pendente);  }
.fin-s-paga      { background: var(--s-paga-bg);      color: var(--s-paga);      }
.fin-s-cancelada { background: var(--s-cancelada-bg); color: var(--s-cancelada); }

/* NF badge */
.fin-nf-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: var(--weight-medium);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--s-atendida-bg);
  color: var(--s-atendida);
}
.fin-nf-enviada { background: var(--s-confirmada-bg); color: var(--s-confirmada); }
.fin-nf-none    { background: transparent; color: var(--text-xmuted); }

/* Seção NF no modal */
.fin-nf-section {
  padding: var(--space-3);
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.fin-nf-row {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.fin-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-sm);
  color: var(--text);
  cursor: pointer;
}

.fin-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
  cursor: pointer;
}

/* Mobile */
@media (max-width: 768px) {
  .fin-kpis { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .fin-toolbar { gap: var(--space-3); }
  .fin-toolbar-right { margin-left: 0; width: 100%; }
  .fin-table td, .fin-table th { padding: var(--space-2); }
  .fin-td-serv { display: none; }
}

/* ============================================================
   Configurações
   ============================================================ */

.cfg-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  height: 100%;
}

/* Tabs */
.cfg-tabs-bar {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,0.04);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cfg-tab {
  height: 30px;
  padding: 0 var(--space-4);
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}
.cfg-tab-active { background: white; color: var(--text); box-shadow: var(--shadow-sm); }

.cfg-body { flex: 1; min-height: 0; overflow-y: auto; }
.cfg-loading { padding: var(--space-10); text-align: center; color: var(--text-muted); font-size: var(--size-sm); }

/* Section wrap */
.cfg-section-wrap { display: flex; flex-direction: column; gap: var(--space-6); }
.cfg-section { display: flex; flex-direction: column; gap: var(--space-3); }
.cfg-section-title { font-size: var(--size-sm); font-weight: var(--weight-semibold); color: var(--text); letter-spacing: -0.01em; }
.cfg-section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.cfg-section-h2 { font-size: var(--size-lg); font-weight: var(--weight-semibold); color: var(--text); }
.cfg-section-desc { font-size: var(--size-sm); color: var(--text-muted); margin-top: var(--space-1); }
.cfg-empty-text { font-size: var(--size-sm); color: var(--text-muted); padding: var(--space-3) 0; }
.cfg-footer-actions { padding-top: var(--space-4); border-top: 1px solid var(--border); }

/* Médicos layout */
.cfg-medicos-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
  height: 100%;
  min-height: 0;
}

.cfg-medicos-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  overflow-y: auto;
}

.cfg-medico-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 140ms;
}
.cfg-medico-item:hover { background: var(--navy-light); }
.cfg-medico-item-active { background: var(--navy-light); }

.cfg-medico-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--size-xs);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.cfg-medico-info { flex: 1; min-width: 0; }
.cfg-medico-nome { display: block; font-size: var(--size-sm); font-weight: var(--weight-medium); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg-medico-esp  { display: block; font-size: var(--size-xs); color: var(--text-muted); }

.cfg-medico-badge { font-size: 10px; font-weight: var(--weight-medium); padding: 2px 6px; border-radius: var(--radius-pill); flex-shrink: 0; }
.badge-ativo   { background: var(--s-confirmada-bg); color: var(--s-confirmada); }
.badge-inativo { background: var(--s-cancelada-bg);  color: var(--s-cancelada); }

.cfg-add-btn {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  cursor: pointer;
  transition: all 150ms;
  margin-top: auto;
}
.cfg-add-btn:hover { border-color: var(--navy); color: var(--navy); }
.cfg-add-btn-inline { margin-top: 0; }

/* Painel edição */
.cfg-medico-painel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cfg-empty-painel { padding: var(--space-10); text-align: center; color: var(--text-muted); }

.cfg-painel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cfg-painel-nome { font-size: var(--size-lg); font-weight: var(--weight-semibold); color: var(--text); }
.cfg-painel-sub  { font-size: var(--size-sm); color: var(--text-muted); }
.cfg-painel-actions { display: flex; align-items: center; gap: var(--space-3); }

.cfg-painel-body {
  flex: 1; overflow-y: auto;
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-6);
}

.cfg-painel-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
  flex-shrink: 0;
}

/* Serviços table */
.cfg-servicos-table { width: 100%; border-collapse: collapse; font-size: var(--size-sm); }
.cfg-servicos-table th { padding: var(--space-2); text-align: left; font-size: var(--size-xs); font-weight: var(--weight-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.cfg-servicos-table td { padding: var(--space-2); border-bottom: 1px solid var(--border); }
.cfg-servicos-table input, .cfg-servicos-table select { width: 100%; }
.cfg-srv-del { color: var(--text-xmuted); }
.cfg-srv-del:hover { color: var(--s-cancelada); }

/* Dias de atendimento */
.cfg-dias-wrap { display: flex; gap: var(--space-2); }
.cfg-dia-pill {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all 150ms;
}
.cfg-dia-pill:hover { border-color: var(--navy); color: var(--navy); }
.cfg-dia-active { background: var(--navy); border-color: var(--navy); color: white; }

/* Acesso */
.cfg-acesso-actions { display: flex; gap: var(--space-2); }

/* WhatsApp / NF */
.cfg-wa-vars {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.cfg-vars-label { font-size: var(--size-xs); font-weight: var(--weight-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cfg-var-pill {
  height: 26px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--navy);
  font-size: var(--size-xs);
  font-family: monospace;
  cursor: pointer;
  transition: all 150ms;
}
.cfg-var-pill:hover { background: var(--navy-light); border-color: var(--navy); }

.cfg-wa-templates { display: flex; flex-direction: column; gap: var(--space-4); }
.cfg-wa-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cfg-wa-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.02);
}
.cfg-wa-card-label { font-size: var(--size-sm); font-weight: var(--weight-medium); color: var(--text); }
.cfg-wa-card-hint  { font-size: var(--size-xs); color: var(--text-muted); }
.cfg-wa-textarea {
  width: 100%; padding: var(--space-3) var(--space-4);
  border: none; resize: vertical;
  font-size: var(--size-sm); color: var(--text);
  background: transparent; font-family: var(--font);
  line-height: 1.6;
  box-sizing: border-box;
}
.cfg-wa-textarea:focus { outline: none; background: rgba(27,43,75,0.02); }

/* NF preview */
.cfg-nf-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.cfg-nf-preview { display: flex; flex-direction: column; gap: var(--space-2); }
.cfg-nf-preview-box {
  flex: 1; padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--size-sm); color: var(--text); line-height: 1.6;
  min-height: 120px;
}

/* Dados / Exportar */
.cfg-export-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.cfg-export-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.cfg-export-label { font-size: var(--size-sm); font-weight: var(--weight-medium); color: var(--text); }
.cfg-export-actions { display: flex; flex-direction: column; gap: var(--space-2); }

/* Minha conta */
.cfg-conta-wrap { align-items: flex-start; max-width: 480px; }
.cfg-conta-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--navy); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--size-lg); font-weight: var(--weight-semibold);
}
.cfg-conta-form { width: 100%; }
.cfg-conta-actions { display: flex; gap: var(--space-3); }

.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--size-xs); }
