/* ============================================================
   MED ANGEL — DESIGN SYSTEM · "OBSIDIAN CLINIC"
   main.css — Variáveis, tipografia, grid, utilitários globais
   Estética: Luxo cirúrgico — Obsidiana + Ouro Champagne
   ============================================================ */

/* Fontes carregadas via <link rel="stylesheet"> no HTML — sem @import duplicado */

/* ─── CSS Custom Properties — Obsidian Clinic Design System ─── */
:root {
  /* Gold Accent — o elemento inesquecível */
  --gold: #B8962E;
  --gold-light: #D4B060;
  --gold-pale: #EDD898;
  --gold-dim: rgba(184, 150, 46, 0.14);
  --gold-border: rgba(184, 150, 46, 0.22);
  --gold-glow: 0 0 32px rgba(184, 150, 46, 0.18);
  --gold-gradient: linear-gradient(135deg, #8B6914 0%, #C9A030 45%, #E8CC78 100%);

  /* Brand Colors — mapeados para gold */
  --brand-primary: #8B6914;
  --brand-secondary: #C9A030;
  --brand-accent: #D4B060;
  --brand-gradient: linear-gradient(135deg, #8B6914 0%, #C9A030 50%, #D4B060 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(139, 105, 20, 0.7) 0%, rgba(201, 160, 48, 0.5) 100%);

  /* Backgrounds — Obsidiana profunda */
  --bg-base: #08090E;
  --bg-surface: #0D0F17;
  --bg-card: #13151F;
  --bg-card-hover: #191C28;
  --bg-input: #0A0C13;
  --bg-overlay: rgba(8, 9, 14, 0.88);

  /* Glassmorphism Tokens */
  --glass-bg: rgba(19, 21, 31, 0.85);
  --glass-border: rgba(184, 150, 46, 0.16);
  --glass-blur: blur(16px);

  /* Text — hierarquia clara e quente */
  --text-primary: #EDE9E0;
  --text-secondary: #8A8479;
  --text-muted: #504C44;
  --text-accent: #D4B060;
  --text-white: #F5F2EB;

  /* Status Médico */
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.12);
  --error: #EF4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --danger: var(--error);
  --danger-bg: var(--error-bg);
  --info: #6366F1;
  --info-bg: rgba(99, 102, 241, 0.12);

  /* Borders — sutis como instrumentos de precisão */
  --border: rgba(184, 150, 46, 0.14);
  --border-hover: rgba(184, 150, 46, 0.35);
  --border-accent: rgba(184, 150, 46, 0.55);

  /* Shadows */
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65);
  --shadow-glow: var(--gold-glow);
  --shadow-card: 0 4px 24px -4px rgba(0, 0, 0, 0.6);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border Radius — mais contidos, mais precisos */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Typography — Cormorant (display) + IBM Plex Sans (body) */
  --font-base: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Transitions — clínicas, rápidas, sem bounce */
  --transition: 180ms ease-out;
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar */
  --sidebar-width: 256px;
  --sidebar-collapsed: 68px;

  /* Z-Index */
  --z-dropdown: 100;
  --z-modal: 200;
  --z-toast: 300;
  --z-sidebar: 400;
}


/* ─── Reset ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-base);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-attachment: scroll;
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--brand-accent); }

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

/* ─── Typography — Cormorant Display + IBM Plex Sans ─── */
h1, h2, h3, h4, h5 {
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.75rem); font-family: var(--font-display); font-weight: 600; }
h3 { font-size: clamp(1rem, 2.5vw, 1.25rem); font-weight: 600; }
h4 { font-size: 1.0625rem; font-weight: 600; }
h5 { font-size: 0.9375rem; font-weight: 600; }
p  { font-size: 0.9375rem; color: var(--text-secondary); line-height: 1.7; }

/* Monospace for clinical data */
.mono, .patient-id, [data-type="id"], [data-type="code"] {
  font-family: var(--font-mono);
  font-size: 0.875em;
  letter-spacing: 0.05em;
  color: var(--gold-light);
}

.display-title {
  font-family: var(--font-display);
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ─── Layout ─── */
#app {
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl);
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-slow);
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    padding: var(--space-md);
  }
}

/* ─── Cards — Obsidian Clinic ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
/* Acento dourado vertical — a assinatura visual */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent 0%, var(--gold) 30%, var(--gold-light) 70%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition);
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--gold-glow);
}
.card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ─── Stat Cards — Obsidian Clinic ─── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
/* Top accent line — fina linha dourada no topo */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--gold-glow);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-md);
  background: rgba(184, 150, 46, 0.1);
  border: 1px solid var(--gold-border);
  box-shadow: 0 2px 12px rgba(184, 150, 46, 0.12);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* ─── Buttons — Obsidian Clinic ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* Shimmer effect on primary button */
.btn-primary {
  background: linear-gradient(135deg, #8B6914 0%, #C9A030 50%, #D4B060 100%);
  color: #0A0A0E;
  border: 1px solid rgba(212, 176, 96, 0.4);
  box-shadow: 0 2px 12px rgba(184, 150, 46, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  font-weight: 700;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(184, 150, 46, 0.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: rgba(184, 150, 46, 0.06);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
}
.btn-secondary:hover {
  background: rgba(184, 150, 46, 0.14);
  border-color: var(--gold);
  color: var(--gold-pale);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--error);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}
.btn-warning:hover {
  background: rgba(217, 119, 6, 0.2);
  border-color: var(--warning);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  text-transform: none;
  letter-spacing: 0.01em;
}
.btn-ghost:hover {
  color: var(--gold-light);
  background: rgba(184, 150, 46, 0.06);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: none;
  letter-spacing: 0;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 28px;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Form Elements — Obsidian Clinic ─── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 13px;
  font-size: 0.9375rem;
  font-family: var(--font-base);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184, 150, 46, 0.16);
  outline: none;
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-control.error { border-color: var(--error); }
.form-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23B8962E' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.65;
}

/* ─── Grid System ─── */
.grid { display: grid; gap: var(--space-lg); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ─── Tables ─── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  background: var(--bg-surface);
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--bg-card-hover); }

/* ─── Badges (Pill Shape) ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-master    { background: rgba(155, 89, 182, 0.22); color: #d4a5f5; border: 1px solid rgba(155,89,182,0.45); }
.badge-admin     { background: var(--info-bg); color: var(--info); border: 1px solid rgba(62,146,204,0.35); }
.badge-concierge { background: rgba(245, 166, 35, 0.18); color: var(--warning); border: 1px solid rgba(245,166,35,0.35); }
.badge-patient   { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,211,163,0.35); }
.badge-active    { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,211,163,0.35); }
.badge-suspended { background: var(--error-bg); color: var(--error); border: 1px solid rgba(255,91,91,0.35); }
.badge-pending   { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,166,35,0.35); }
.badge-success   { background: rgba(46,204,113,0.15); color: #2ecc71; border: 1px solid rgba(46,204,113,0.35); }
.badge-danger    { background: rgba(231,76,60,0.13);  color: #e74c3c; border: 1px solid rgba(231,76,60,0.3);  }

/* ─── Tags de Agendamento ─── */
.tag-consulta    { background: rgba(62,146,204,0.18); color: #3E92CC; border-radius: var(--radius-sm); padding: 3px 8px; font-weight:600; }
.tag-cirurgia    { background: rgba(255,91,91,0.15); color: #FF5B5B; border-radius: var(--radius-sm); padding: 3px 8px; font-weight:600; }
.tag-exame       { background: rgba(245,166,35,0.15); color: #F5A623; border-radius: var(--radius-sm); padding: 3px 8px; font-weight:600; }
.tag-avaliacao   { background: rgba(34,211,163,0.15); color: #22D3A3; border-radius: var(--radius-sm); padding: 3px 8px; font-weight:600; }
.tag-interconsulta { background: rgba(155,89,182,0.15); color: #d4a5f5; border-radius: var(--radius-sm); padding: 3px 8px; font-weight:600; }

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ─── Search ─── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184, 150, 46, 0.16);
}
.search-bar input {
  background: none;
  border: none;
  color: var(--text-primary);
  width: 100%;
  font-size: 0.92rem;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 1.05rem; }

/* ─── Modal (Glassmorphism & Material 3 Elevation) ─── */
.modal-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--space-md);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  animation: fadeIn 200ms ease;
  overflow-y: auto;
}

.modal-backdrop.active,
.modal-overlay.active {
  display: flex !important;
}

.modal,
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  width: 100%;
  max-width: min(92vw, 580px);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  margin: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  box-sizing: border-box;
}

.modal-lg { max-width: min(94vw, 800px) !important; }
.modal-xl { max-width: min(96vw, 960px) !important; }

/* ─── Formatação de Exibição de Documentos (Layout Responsivo Sem Transbordo) ─── */
.print-document-container {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 20px !important;
  margin: 0 auto !important;
  overflow-x: auto !important;
  overflow-wrap: break-word !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
}

.print-document-container .print-document-container {
  padding: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  width: 100% !important;
  max-width: 100% !important;
}

.print-document-container * {
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  word-wrap: break-word !important;
}

.print-document-container div,
.print-document-container p,
.print-document-container span,
.print-document-container pre {
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  white-space: pre-wrap !important;
}

.print-document-container img,
.print-document-container canvas,
.print-document-container svg,
.print-document-container iframe {
  max-width: 100% !important;
  height: auto !important;
}

.print-document-container table {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  overflow-x: auto !important;
}

.print-document-container td,
.print-document-container th {
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

/* Card de documento na aba Documentos */
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
  transition: all var(--transition);
}
.doc-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-input);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--error-bg); color: var(--error); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal-body {
  overflow-y: auto;
  max-height: calc(88vh - 140px);
  -webkit-overflow-scrolling: touch;
}

/* Confirmação e modais em telas pequenas */
@media (max-width: 600px) {
  .modal-overlay,
  .modal-backdrop {
    padding: 10px;
    align-items: flex-start;
  }
  .modal {
    max-width: 100%;
    max-height: calc(100vh - 20px);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin-top: 10px;
  }
  .modal-body {
    max-height: calc(100vh - 180px);
  }
  .modal-lg,
  .modal-xl {
    max-width: 100%;
  }
}

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: max-content;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn .icon { opacity: 0.8; }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.tab-btn:hover:not(.active) { color: var(--text-secondary); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 200ms ease; }

/* ─── Avatar ─── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 1.75rem; }

/* ─── Empty State ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
  display: flex;
  justify-content: center;
}
.empty-icon .icon { width: 48px; height: 48px; }
.empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}
.empty-desc { font-size: 0.875rem; max-width: 320px; }

/* ─── Timeline ─── */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-lg);
}
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--brand-secondary);
  border: 2px solid var(--bg-base);
  box-shadow: 0 0 0 2px var(--brand-secondary);
}
.timeline-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ─── File Upload ─── */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.file-upload-area:hover,
.file-upload-area.drag-over {
  border-color: var(--brand-secondary);
  background: rgba(184, 150, 46, 0.05);
}
.file-upload-area input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.upload-icon { font-size: 2.5rem; opacity: 0.5; margin-bottom: var(--space-sm); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--brand-secondary); }

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fade { animation: fadeIn 300ms ease; }
.animate-slide { animation: slideUp 300ms ease; }

/* ─── Loading Skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ─── Spinner ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand-secondary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
}

/* ─── Toast Notifications ─── */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  max-width: 360px;
  animation: slideIn 300ms ease;
  backdrop-filter: blur(8px);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

.toast-icon { flex-shrink: 0; margin-top: 1px; display: inline-flex; }
.toast-icon .icon { width: 19px; height: 19px; }
.toast.success .toast-icon { color: var(--success, #10B981); }
.toast.error .toast-icon { color: var(--error, #EF4444); }
.toast.warning .toast-icon { color: var(--warning, #D97706); }
.toast.info .toast-icon { color: var(--info, #6366F1); }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.toast-msg   { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 2px; }

/* ─── Divider ─── */
.divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* ─── Chip ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ─── Flex Utilities ─── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-wrap { flex-wrap: wrap; }

/* ─── Text Utilities ─── */
.text-accent   { color: var(--text-accent); }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-primary  { color: var(--text-primary); }
.text-success  { color: var(--success); }
.text-error    { color: var(--error); }
.text-warning  { color: var(--warning); }
.text-center   { text-align: center; }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Margin/Padding shortcuts ─── */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ─── Role Colors ─── */
.role-master    { color: #c792f0; }
.role-admin     { color: var(--info); }
.role-concierge { color: var(--warning); }
.role-patient   { color: var(--success); }

/* ─── PDF Viewer ─── */
.pdf-viewer-container {
  width: 100%;
  height: 600px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.pdf-viewer-container iframe {
  width: 100%; height: 100%; border: none;
}

/* ─── Brand Customization (override via JS) ─── */
[data-brand="custom"] {
  --brand-primary: var(--custom-primary, #0A2463);
  --brand-secondary: var(--custom-secondary, #3E92CC);
  --brand-accent: var(--custom-accent, #1BFFDB);
}

/* ═══════════════════════════════════════════════
   TEMA CLARO — [data-theme="light"]
   ═══════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-base: #F0F4F8;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F7FAFC;
  --bg-input: #F0F4F8;
  --bg-overlay: rgba(15, 30, 50, 0.55);

  --text-primary: #0D2137;
  --text-secondary: #2E5077;
  --text-muted: #6B87A2;
  --text-accent: #0077AA;
  --text-white: #FFFFFF;

  --border: rgba(62, 146, 204, 0.18);
  --border-hover: rgba(62, 146, 204, 0.45);
  --border-accent: rgba(0, 119, 170, 0.35);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.15);
  --shadow-glow: 0 0 30px rgba(62, 146, 204, 0.1);
  --shadow-card: 0 4px 24px rgba(62, 146, 204, 0.08);

  --success-bg: rgba(16, 185, 129, 0.1);
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --info-bg: rgba(62, 146, 204, 0.1);
}

[data-theme="light"] body {
  background-color: var(--bg-base);
  color: var(--text-primary);
}

[data-theme="light"] .card,
[data-theme="light"] .modal,
[data-theme="light"] .stat-card {
  box-shadow: 0 2px 16px rgba(62, 146, 204, 0.08);
  border-color: rgba(62, 146, 204, 0.15);
}

[data-theme="light"] .form-control {
  background: #FFFFFF;
  border-color: rgba(62, 146, 204, 0.2);
  color: var(--text-primary);
}

[data-theme="light"] .form-control::placeholder {
  color: var(--text-muted);
}

[data-theme="light"] .tabs {
  background: #E2EBF4;
}

[data-theme="light"] .tab-btn.active {
  background: #FFFFFF;
  color: var(--text-primary);
}

[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #FFFFFF 0%, #EDF2F7 100%);
  border-right: 1px solid rgba(62, 146, 204, 0.15);
}

[data-theme="light"] .sidebar-nav .nav-item:hover,
[data-theme="light"] .sidebar-nav .nav-item.active {
  background: rgba(62, 146, 204, 0.08);
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(62, 146, 204, 0.12);
  backdrop-filter: blur(12px);
}

[data-theme="light"] .search-bar {
  background: #FFFFFF;
  border-color: rgba(62, 146, 204, 0.2);
}

[data-theme="light"] .toast {
  background: #FFFFFF;
  border-color: rgba(62, 146, 204, 0.2);
}

[data-theme="light"] .btn-ghost:hover {
  background: rgba(62, 146, 204, 0.08);
  color: var(--text-primary);
}

[data-theme="light"] .data-table th {
  background: #F0F4F8;
  color: var(--text-muted);
}

[data-theme="light"] .data-table td {
  border-bottom-color: rgba(62, 146, 204, 0.1);
}

[data-theme="light"] .data-table tbody tr:hover {
  background: #F7FAFC;
}

[data-theme="light"] .prontuario-section {
  background: #FFFFFF;
  border-color: rgba(62, 146, 204, 0.12);
}

[data-theme="light"] .welcome-banner {
  background: linear-gradient(135deg, #EDF2F7 0%, #DBEAFE 100%);
}

/* Light Theme Badges & Tags Contrast Overrides */
[data-theme="light"] .badge-master    { background: #F3E8FF !important; color: #7E22CE !important; border-color: #D8B4FE !important; }
[data-theme="light"] .badge-admin     { background: #EFF6FF !important; color: #1D4ED8 !important; border-color: #93C5FD !important; }
[data-theme="light"] .badge-concierge { background: #FFFBEB !important; color: #B45309 !important; border-color: #FCD34D !important; }
[data-theme="light"] .badge-patient   { background: #ECFDF5 !important; color: #047857 !important; border-color: #6EE7B7 !important; }
[data-theme="light"] .badge-active    { background: #ECFDF5 !important; color: #047857 !important; border-color: #6EE7B7 !important; }
[data-theme="light"] .badge-suspended { background: #FEF2F2 !important; color: #B91C1C !important; border-color: #FCA5A5 !important; }
[data-theme="light"] .badge-pending   { background: #FFFBEB !important; color: #B45309 !important; border-color: #FCD34D !important; }
[data-theme="light"] .badge-success   { background: #ECFDF5 !important; color: #047857 !important; border-color: #6EE7B7 !important; }
[data-theme="light"] .badge-danger    { background: #FEF2F2 !important; color: #B91C1C !important; border-color: #FCA5A5 !important; }
[data-theme="light"] .badge-warning   { background: #FFFBEB !important; color: #B45309 !important; border-color: #FCD34D !important; }
[data-theme="light"] .badge-info      { background: #EFF6FF !important; color: #1D4ED8 !important; border-color: #93C5FD !important; }

[data-theme="light"] .tag-consulta    { background: #E0F2FE !important; color: #0369A1 !important; }
[data-theme="light"] .tag-cirurgia    { background: #FEE2E2 !important; color: #B91C1C !important; }
[data-theme="light"] .tag-exame       { background: #FEF3C7 !important; color: #B45309 !important; }
[data-theme="light"] .tag-avaliacao   { background: #D1FAE5 !important; color: #047857 !important; }
[data-theme="light"] .tag-interconsulta { background: #F3E8FF !important; color: #7E22CE !important; }

/* ═══════════════════════════════════════════════
   DATA TABLE (tabelas de dados)
   ═══════════════════════════════════════════════ */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  background: var(--bg-surface);
  transition: background var(--transition);
}

.data-table tbody tr:hover { background: var(--bg-card); }

/* ═══════════════════════════════════════════════
   ANALYTICS DASHBOARD
   ═══════════════════════════════════════════════ */
.analytics-filters {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.analytics-filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.analytics-metric-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-secondary);
  cursor: pointer;
}

.analytics-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.analytics-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition);
}

.analytics-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.analytics-card-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.analytics-card-value {
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.analytics-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.analytics-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.analytics-chart-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.analytics-chart-wide {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

/* ═══════════════════════════════════════════════
   BTN GROUP
   ═══════════════════════════════════════════════ */
.btn-group {
  display: flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group .btn.active {
  background: var(--brand-secondary);
  color: white;
  border-color: var(--brand-secondary);
}

/* ═══════════════════════════════════════════════
   ADDITIONAL BADGES
   ═══════════════════════════════════════════════ */
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,166,35,0.3); }
.badge-info    { background: var(--info-bg); color: var(--info); border: 1px solid rgba(62,146,204,0.3); }

/* ═══════════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════════ */
.theme-toggle-btns {
  display: flex;
  gap: 0;
}

.theme-toggle-btns .btn {
  border-radius: 0;
  border: 1px solid var(--border-hover);
}

.theme-toggle-btns .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.theme-toggle-btns .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: none;
}

/* ═══════════════════════════════════════════════
   ANAMNESE CARD
   ═══════════════════════════════════════════════ */
.anamnese-card {
  transition: all var(--transition);
}

.anamnese-card .prontuario-section-header {
  cursor: pointer;
  user-select: none;
}

.anamnese-card .prontuario-section-header:hover {
  background: var(--bg-card-hover);
}

.anamnese-body {
  animation: fadeIn 200ms ease;
}

.anamnese-content-display {
  min-height: 60px;
  line-height: 1.8;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  user-select: text;
}

/* ═══════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  gap: var(--space-md);
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   JUSTIFY-END UTIL
   ═══════════════════════════════════════════════ */
.justify-end { justify-content: flex-end; }
.mt-xl { margin-top: var(--space-xl); }
.flex-1 { flex: 1; }

/* ═══════════════════════════════════════════════
   MODULE: MESSAGES
   ═══════════════════════════════════════════════ */

/* Avisos do Sistema */
.msg-urgent-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  color: #FEE2E2;
  font-size: 0.875rem;
  line-height: 1.5;
}
.msg-urgent-warning span { font-size: 1.25rem; flex-shrink: 0; margin-top: 2px; }
.msg-urgent-warning strong { color: #FCA5A5; font-weight: 700; }

.msg-hours-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  color: #FEF3C7;
  font-size: 0.875rem;
  line-height: 1.5;
}
.msg-hours-warning span { font-size: 1.25rem; flex-shrink: 0; margin-top: 2px; }
.msg-hours-warning strong { color: #FCD34D; font-weight: 700; }

[data-theme="light"] .msg-urgent-warning {
  background: #FEF2F2 !important;
  border-color: #FCA5A5 !important;
  color: #991B1B !important;
}
[data-theme="light"] .msg-urgent-warning strong {
  color: #7F1D1D !important;
}

[data-theme="light"] .msg-hours-warning {
  background: #FFFBEB !important;
  border-color: #FCD34D !important;
  color: #92400E !important;
}
[data-theme="light"] .msg-hours-warning strong {
  color: #78350F !important;
}

/* Layout principal */
.messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-lg);
  align-items: start;
  height: calc(100vh - 280px);
  min-height: 500px;
}

@media (max-width: 768px) {
  .messages-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* Painel de Conversas */
.conversations-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.conversations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.conversations-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

#conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  position: relative;
}
.conversation-item:hover { background: var(--bg-card-hover); }
.conversation-item.active {
  background: rgba(10, 36, 99, 0.4);
  border-left: 3px solid var(--brand-secondary);
}

.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-primary-alpha, rgba(10,36,99,0.3));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.conv-info { flex: 1; min-width: 0; }
.conv-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-last-msg {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

/* Thread de mensagens */
.messages-thread-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.messages-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  gap: var(--space-sm);
}

.thread-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.thread-header-info { flex: 1; }
.thread-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}
.thread-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Lista de mensagens */
.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  scroll-behavior: smooth;
}

.messages-no-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: 100%;
  padding: var(--space-3xl);
}

/* Balões de mensagem */
.message-bubble {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: fadeInUp 0.2s ease;
}
.message-bubble.mine {
  align-self: flex-end;
  align-items: flex-end;
}
.message-bubble.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-sender-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  padding-left: 4px;
}

.msg-content {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-bubble.mine .msg-content {
  background: var(--brand-primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.message-bubble.theirs .msg-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* Área de input */
.message-input-area {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.msg-blocked-notice {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  color: #FEF3C7;
  margin-bottom: var(--space-sm);
}

[data-theme="light"] .msg-blocked-notice {
  background: #FFFBEB !important;
  border-color: #FCD34D !important;
  color: #92400E !important;
}

.message-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}
.message-input-row.blocked { opacity: 0.5; }

.msg-textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}

.msg-send-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.msg-input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* Modal de seleção de contatos */
.contact-select-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.contact-select-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Impressão & Marca d'Água MedAngel ─── */
@media print {
  /* Toda a paleta de texto/borda do app é pensada pro tema escuro (tons claros/
     dourados sobre fundo quase preto) — sem isso, texto "claro" em cima de papel
     branco fica ilegível. Redefinindo as variáveis aqui, qualquer elemento que
     usa var(--text-muted) etc. (a imensa maioria do app) automaticamente vira
     preto/cinza escuro de alto contraste na impressão, sem precisar sobrescrever
     elemento por elemento. */
  :root {
    --text-primary: #000000 !important;
    --text-secondary: #1A1A1A !important;
    --text-muted: #4A4A4A !important;
    --text-accent: #000000 !important;
    --text-white: #000000 !important;
    --bg-base: #ffffff !important;
    --bg-surface: #ffffff !important;
    --bg-card: #ffffff !important;
    --bg-card-hover: #ffffff !important;
    --bg-input: #ffffff !important;
    --border: #BBBBBB !important;
    --border-hover: #999999 !important;
    --gold: #7A5A00 !important;
    --gold-light: #7A5A00 !important;
    --gold-pale: #4A4A4A !important;
    --success: #0A6B3D !important;
    --warning: #8A5A00 !important;
    --error: #A31515 !important;
    --info: #0A3D8A !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt !important;
  }

  /* Oculta todos os elementos de navegacao do app */
  .sidebar, .topbar, .btn, .no-print, .filters-bar, .modal-backdrop, .modal-close {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  /* Rede de segurança: além das variáveis CSS acima, vários elementos têm cor
     inline hardcoded (não var()) pensada pro fundo escuro — inline normalmente
     vence CSS externo, então força tudo pra escuro aqui também. */
  .main-content, .main-content * {
    color: #111111 !important;
  }

  /* Padding ZERO — quem define margem e o @page do iframe de impressao */
  .print-document-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .medangel-watermark {
    position: fixed;
    bottom: 5mm;
    right: 8mm;
    font-size: 7pt;
    color: #888888;
    opacity: 0.6;
    font-family: inherit;
    text-align: right;
  }
}

/* ═══════════════════════════════════════════════
   PREMIUM VISUAL ENHANCEMENTS — MedAngel v2
   ═══════════════════════════════════════════════ */

/* ─── Shimmer on Primary Button Hover ─── */
@keyframes btnShimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.btn-primary {
  background: var(--brand-gradient);
  background-size: 200% auto;
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
  background-size: 200% 100%;
  background-position: -200% center;
  transition: background-position 0s;
  pointer-events: none;
  border-radius: inherit;
}

.btn-primary:hover::after {
  animation: btnShimmer 0.55s ease forwards;
}

/* ─── Input Focus Glow Enhanced ─── */
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 150, 46, 0.2);
}

/* ─── Focus visível para teclado (acessibilidade WCAG 2.1 AA) ─── */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Card Micro-Entry Animation ─── */
@keyframes cardEntry {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* NOTA: o bloco de ~195 linhas que ficava aqui (stat-card entry animation,
   card 3D hover, modal header premium, badge glow, toast premium, spinner,
   search bar glow, page-title gradient, table row hover, empty state,
   avatar glow, btn-success shimmer, input autofill override, modal footer,
   glassmorphism card, selection highlight, UX/motion additions e loading
   skeletons) estava duplicado byte-a-byte logo abaixo — removido em
   limpeza de CSS 06/09/2026. A cópia que sobrou (a partir daqui) é a mais
   completa das duas: tinha o único ".spinner" com borda + keyframes de
   rotação; a copia removida só tinha um ".spinner" incompleto (sem
   animação), que o cascade já ignorava mesmo. */

.stat-card {
  animation: cardEntry 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 60ms; }
.stat-card:nth-child(3) { animation-delay: 120ms; }
.stat-card:nth-child(4) { animation-delay: 180ms; }

/* ─── Card Subtle 3D Hover ─── */
.card {
  transform-style: preserve-3d;
  will-change: transform;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px -8px rgba(0,0,0,0.5), 0 0 20px rgba(62,146,204,0.08);
}

/* ─── Modal Premium Header ─── */
.modal-header {
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(10,36,99,0.35) 0%, transparent 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-top: 3px solid transparent;
  border-image: var(--brand-gradient) 1;
}

/* ─── Badge Glow on Hover ─── */
.badge-master:hover, .badge-admin:hover, .badge-active:hover {
  box-shadow: 0 0 14px rgba(62,146,204,0.3);
  transform: scale(1.04);
  transition: all var(--transition);
  cursor: default;
}

/* ─── Toast Premium ─── */
.toast {
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}
[data-theme="light"] .toast {
  background: #FFFFFF !important;
  color: #0F172A !important;
  border-color: rgba(62, 146, 204, 0.3) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12) !important;
}
[data-theme="light"] .toast .toast-title {
  color: #0F172A !important;
  font-weight: 700 !important;
}
[data-theme="light"] .toast .toast-msg {
  color: #334155 !important;
}

/* ─── Spinner Enhanced ─── */
.spinner {
  border-top-color: var(--brand-accent);
  border-right-color: rgba(27,255,219,0.3);
}

/* ─── Search Bar Glow ─── */
.search-bar:focus-within {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(62,146,204,0.18), 0 0 18px rgba(27,255,219,0.07);
}

/* ─── Page Header Title Gradient ─── */
.page-title {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

/* ─── Table Row Hover with Left Accent ─── */
.table tbody tr {
  position: relative;
  transition: background var(--transition), padding-left var(--transition);
}

.table tbody tr:hover td:first-child {
  border-left: 3px solid var(--brand-accent);
  padding-left: calc(18px - 3px);
}

/* ─── Empty State Enhanced ─── */
.empty-state {
  background: radial-gradient(ellipse at center, rgba(62,146,204,0.05) 0%, transparent 70%);
  border-radius: var(--radius-xl);
}

.empty-icon {
  animation: pulse 3s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(62,146,204,0.3));
}

/* ─── Avatar Glow ─── */
.avatar {
  box-shadow: 0 0 0 2px var(--border), 0 4px 14px rgba(62,146,204,0.2);
  transition: box-shadow var(--transition), transform var(--transition);
}

.avatar:hover {
  box-shadow: 0 0 0 2px var(--brand-secondary), 0 0 20px rgba(62,146,204,0.35);
  transform: scale(1.05);
}

/* ─── Btn Success Shimmer ─── */
.btn-success {
  position: relative;
  overflow: hidden;
}

.btn-success::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: rgba(255,255,255,0.12);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
  pointer-events: none;
}

.btn-success:hover::before {
  left: 125%;
}

/* ─── Input Autofill Override ─── */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary) !important;
}

/* ─── Modal Footer Spacing ─── */
.modal-footer .btn {
  min-width: 100px;
}

/* ─── Glassmorphism Card Variant ─── */
.card-glass {
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border) !important;
}

/* ─── Selection Highlight ─── */
::selection {
  background: rgba(184, 150, 46, 0.3);
  color: var(--text-primary);
}

/* UX / Motion additions */
.form-control:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184, 150, 46, 0.16); }
/* Modais com Bezier suavizado */
.modal-backdrop { transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.modal { transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

/* ─── Loading Skeletons ─── */
.skeleton {
  background: var(--bg-input);
  background: linear-gradient(90deg, var(--bg-input) 0%, rgba(255,255,255,0.06) 50%, var(--bg-input) 100%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite linear;
  border-radius: var(--radius-sm);
}
.skeleton.title { height: 28px; width: 60%; margin-bottom: 12px; }
.skeleton.text { height: 16px; width: 100%; margin-bottom: 8px; }
.skeleton.text.short { width: 40%; }
.skeleton.card { height: 120px; width: 100%; border-radius: var(--radius-lg); margin-bottom: 16px; }

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Generic Spinner ─── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spinnerRotate 0.8s linear infinite;
}
@keyframes spinnerRotate {
  to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════
   📱 MOBILE UX / UI OPTIMIZATIONS (App-like feel)
   ══════════════════════════════════════════════════════════════ */

/* Default: hidden on desktop */
.mobile-bottom-nav, .mobile-fab {
  display: none;
}

@media (max-width: 768px) {
  /* ─── Drawer Sidebar (Mobile) ─── */
  .sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    left: -280px; /* Hide off-screen */
    width: 260px;
    height: 100vh;
    z-index: 10000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-surface);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  }
  
  .sidebar.mobile-open {
    left: 0;
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s;
  }
  
  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* Hamburger button is visible on mobile */
  .hamburger-btn {
    display: block !important;
  }

  /* Ajustar o grid principal para não ter margem lateral */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    /* Safe area bottom padding for bottom nav */
    padding-bottom: 90px !important; 
  }

  /* ─── Bottom Navigation Bar ─── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background: rgba(13, 30, 53, 0.85); /* Dark surface with transparency */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.05);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 10px); /* iPhone home indicator safe area */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    flex: 1;
    height: 100%;
    /* Touch target area */
    min-width: 64px;
  }

  .mobile-nav-item.active {
    color: var(--gold-light);
  }

  .mobile-nav-icon {
    font-size: 1.25rem;
    margin-bottom: 2px;
    filter: grayscale(100%) opacity(0.7);
    transition: all 0.2s;
  }

  .mobile-nav-item.active .mobile-nav-icon {
    filter: grayscale(0%) opacity(1);
    transform: translateY(-2px);
  }

  .mobile-nav-label {
    font-size: 0.65rem;
    font-weight: 500;
  }

  /* ─── Floating Action Button (FAB) ─── */
  .mobile-fab {
    display: flex;
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #08090E;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    border: none;
    box-shadow: 0 8px 24px rgba(184, 150, 46, 0.35), 0 0 0 1px rgba(255,255,255,0.1) inset;
    z-index: 998;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
  }

  .mobile-fab:active {
    transform: scale(0.92);
  }

  /* ─── Workflow Active Mode (Full Screen Focus) ─── */
  /* Quando modais como o gravador ou formulários grandes abrem */
  body.workflow-active .mobile-bottom-nav {
    transform: translateY(100%);
  }
  body.workflow-active .mobile-fab {
    transform: translateY(150px);
  }

  /* ─── Touch Target Improvements ─── */
  .btn, .form-control {
    min-height: 44px; /* Apple HIG minimum */
  }
  .table td {
    /* Melhorar legibilidade de nomes longos e área de toque */
    padding: 16px 12px;
    font-size: 0.95rem;
  }
}

/* ─── Analytics KPI Cards ─────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Analytics Print ────────────────────────────────────── */
/* ═══════════════════════════════════════════════
   PREMIUM LAYER — Obsidian Clinic v2
   Elevação visual, tipografia editorial, micro-motions
   ═══════════════════════════════════════════════ */

/* ─── Editorial Page Titles ─── */
.page-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

/* ─── Cards — Gold Accent Always Subtly Visible ─── */
.card::before {
  opacity: 0.25;
}
.card:hover::before {
  opacity: 1;
}

/* ─── Table Rows — Gold Left Indicator on Hover ─── */
.table tbody tr {
  position: relative;
}
.table tbody tr::after {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transform: scaleY(0.6);
  transition: opacity var(--transition), transform var(--transition);
}
.table tbody tr:hover::after {
  opacity: 1;
  transform: scaleY(1);
}

/* ─── Content Entry Animation ─── */
@keyframes contentFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main-content > * {
  animation: contentFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.main-content > *:nth-child(2) { animation-delay: 0.05s; }
.main-content > *:nth-child(3) { animation-delay: 0.1s; }
.main-content > *:nth-child(4) { animation-delay: 0.15s; }

/* ─── Stat Card Gold Shimmer ─── */
@keyframes goldShimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.stat-card::after {
  background: linear-gradient(90deg, transparent, rgba(212, 176, 96, 0.6), transparent);
  background-size: 200% 1px;
  animation: goldShimmer 3s ease-in-out infinite;
}

/* ─── KPI Cards — Premium Edition ─── */
.kpi-card {
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184, 150, 46, 0.5), transparent);
}
.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card), var(--gold-glow);
}

/* ─── Auth Screen Logo Glow ─── */
.auth-brand-logo {
  filter: drop-shadow(0 8px 32px rgba(184, 150, 46, 0.35)) drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

/* ─── Welcome Banner — Premium ─── */
.welcome-banner {
  background: linear-gradient(135deg, #0D0F17 0%, #13151F 50%, #0D0F17 100%);
  border: 1px solid rgba(184, 150, 46, 0.18);
  position: relative;
  overflow: hidden;
}
.welcome-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-light), var(--gold), transparent);
}
.welcome-banner::after {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 300px; height: 300px;
  background: radial-gradient(ellipse, rgba(184, 150, 46, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

@media print {
  .sidebar, .mobile-bottom-nav, .mobile-fab,
  .tabs, #custom-range-inputs,
  .page-header .btn-group, .page-header button {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .card {
    border: 1px solid #ddd !important;
    background: #fff !important;
    page-break-inside: avoid;
    box-shadow: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 16px !important;
  }
  canvas { max-width: 100% !important; }
}

/* ─── Compositor de mensagens ─────────────────────────────────────────────
   O botão Enviar aparecia cortado na borda direita. Causa: num container
   flex, `flex:1` no textarea NÃO permite encolher abaixo do conteúdo mínimo
   (min-width tem valor inicial `auto` em item flex), então o textarea segurava
   sua largura intrínseca e empurrava o botão pra fora. Mesmo defeito do grid
   de preços, que precisou de minmax(0,1fr) pelo mesmo motivo.
   Duas regras resolvem: o campo pode encolher, o botão não pode. */
.message-input-row     { display: flex; gap: var(--space-sm); align-items: stretch; }
.message-input-row > .msg-textarea { flex: 1 1 auto; min-width: 0; resize: vertical; }

.msg-send-btn {
  /* `.btn` traz overflow:hidden (efeito shimmer). Sem uma largura mínima
     amarrada ao conteúdo, o botão encolhe e o overflow ESCONDE o rótulo em vez
     de o layout ceder — que era exatamente o "ENVIA" cortado na borda.
     max-content trava o piso na largura do ícone + texto + padding. */
  flex: 0 0 auto;              /* nunca é espremido pra caber */
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 var(--space-lg);
  white-space: nowrap;         /* "Enviar" não quebra nem some pela metade */
}
.msg-send-btn svg,
.msg-send-btn span[style*="inline-flex"] { flex: 0 0 auto; }

/* Em tela estreita o rótulo sai e fica só o ícone — o botão continua com área
   de toque cheia, em vez de roubar a largura do campo de texto. */
@media (max-width: 560px) {
  .msg-send-btn { padding: 0 var(--space-md); }
  .msg-send-btn .msg-send-label { display: none; }
}
