/* ============================================================================
   CliniGest (MVP) — style.css
   Identidade visual: verde #077541 · sidebar clara
   ========================================================================== */

:root {
  /* Paleta principal */
  --primary:       #077541;   /* verde — cor de ação principal */
  --primary-dark:  #065B33;   /* hover / estados pressionados */
  --primary-strong:#054B29;   /* texto com ênfase / bordas fortes */
  --primary-light: #E5F3EB;   /* fundos suaves com verde */
  --accent:        #077541;   /* verde — destaque / série do gráfico */
  --accent-soft:   #E5F3EB;   /* fundo suave verde */

  /* Derivadas da cor primária (injetadas dinamicamente) */
  --primary-border: #A9D6BC;  /* borda suave derivada da primária */
  --cor-texto-botao: #FFFFFF; /* texto sobre a cor primária (branco/escuro) */

  /* Neutros */
  --white:       #FFFFFF;
  --bg:          #F8F9FA;     /* fundo da página (branco/quase branco) */
  --bg-soft:     #F5F7FA;     /* chips, hovers em superfícies claras */
  --border:      #E5E7EB;
  --border-soft: #EDEDED;

  /* Sidebar clara (estilo original) */
  --sidebar-bg:    #F5F7FA;
  --sidebar-bg-2:  #EEF1F6;   /* gradiente inferior suave */
  --sidebar-line:  #E5E7EB;
  --sidebar-text:  #424242;   /* texto padrão do menu */
  --sidebar-muted: #9E9E9E;   /* textos secundários */
  --sidebar-icon:  #757575;

  /* Texto */
  --text-dark:   #333333;
  --text-medium: #424242;
  --text-gray:   #9E9E9E;
  --text-muted:  #757575;

  /* Estados */
  --orange:      #FF9800;   /* aviso */
  --orange-dark: #F9A825;
  --red:         #F44336;   /* erro */
  --red-light:   #FFEBEE;
  --green:       #388E3C;   /* sucesso */
  --green-light: #E8F5E9;
  --yellow-light:#FFF3E0;
  --info:        #1976D2;   /* informativo / links */
  --info-light:  #E3F2FD;

  /* Sombras e raios */
  --shadow:      0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.06);
  --shadow-md:   0 6px 18px rgba(0,0,0,.10);
  --shadow-primary: 0 2px 6px rgba(78,205,196,.35), 0 1px 2px rgba(0,0,0,.08);
  --radius:      12px;
  --radius-sm:   8px;

  --sidebar-w:   220px;
  --font:        'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ============================================================================
   Layout geral
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content {
  padding: 24px 28px 40px;
  max-width: 1280px;
  width: 100%;
}

/* ============================================================================
   Sidebar — clara, estilo original
   ========================================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  border-right: 1px solid var(--sidebar-line);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: var(--cor-texto-botao);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}
.brand-logo svg { width: 21px; height: 21px; }

.brand-name { font-size: 15px; font-weight: 700; color: var(--text-dark); line-height: 1.2; letter-spacing: -.2px; }
.brand-sub  { font-size: 10.5px; color: var(--sidebar-muted); }

/* Busca do menu */
.sidebar-search { padding: 12px 12px 6px; }
.search-box { position: relative; }
.search-box > svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--sidebar-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px 8px 34px;
  font-size: 12px;
  color: var(--text-dark);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.search-box input::placeholder { color: var(--sidebar-muted); }
.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(78,205,196,.25);
}

/* Navegação */
.sidebar-nav {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 16px;
}
.sidebar-nav li { margin-bottom: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}
.nav-item svg {
  width: 18px; height: 18px;
  color: var(--sidebar-icon);
  flex-shrink: 0;
  transition: color .12s ease;
}
.nav-label { overflow: hidden; text-overflow: ellipsis; }

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary-strong);
}
.nav-item:hover svg { color: var(--primary-strong); }

/* Item ativo: fundo na cor primária */
.nav-item.active {
  background: var(--primary);
  color: var(--cor-texto-botao);
  box-shadow: 0 2px 6px rgba(78,205,196,.30);
}
.nav-item.active svg { color: var(--cor-texto-botao); }

.nav-caret {
  margin-left: auto;
  display: inline-flex;
  flex-shrink: 0;
  transition: transform .18s ease;
}
.nav-caret svg { width: 15px; height: 15px; color: var(--sidebar-muted); }
.nav-item:hover .nav-caret svg { color: var(--primary-strong); }
.nav-item.active .nav-caret svg { color: var(--cor-texto-botao); }
.nav-item.open .nav-caret { transform: rotate(90deg); }

/* Submenu */
.submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height .22s ease;
}
.submenu.open { max-height: 320px; }
.submenu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 40px;
  font-size: 12.5px;
  color: var(--sidebar-muted);
  border-radius: 6px;
  transition: background .12s ease, color .12s ease;
}
.submenu a::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #BDBDBD;
  flex-shrink: 0;
}
.submenu a:hover { background: var(--primary-light); color: var(--primary-strong); }
.submenu a:hover::before { background: var(--primary); }

/* Rodapé do menu */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-line);
  font-size: 11px;
  color: var(--sidebar-muted);
}

/* ============================================================================
   Header (topbar)
   ========================================================================== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle { display: none; }

.topbar-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -.3px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.breadcrumb a { color: var(--info); font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; color: #C0C4CC; }
.breadcrumb .current { color: var(--text-muted); }

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

.btn-icon {
  position: relative;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-light); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon .badge-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
}

/* Usuário */
.user-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.user-block:hover { background: var(--bg-soft); }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-border));
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; }
.user-meta strong { display: block; font-size: 12.5px; color: var(--text-dark); }
.user-meta span  { display: block; font-size: 11px; color: var(--text-gray); }
.user-caret { width: 15px; height: 15px; color: var(--text-gray); }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: var(--cor-texto-botao);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(78,205,196,.40), 0 1px 3px rgba(0,0,0,.10);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-medium);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-light); }

/* ============================================================================
   Alertas / modo demonstração
   ========================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert strong { font-weight: 700; }

.alert-info {
  background: var(--info-light);
  border: 1px solid #90CAF9;
  color: #1565C0;
}

/* ============================================================================
   Barra de filtros
   ========================================================================== */
.filter-bar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 26px;
}

.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 600;
}
.filter-group input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dark);
  background: #fff;
  width: 150px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.filter-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78,205,196,.15);
}

.filter-actions { display: flex; gap: 8px; }

.filter-range {
  margin-left: auto;
  align-self: center;
}
.period-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  color: var(--text-muted);
}
.period-chip strong { color: var(--text-dark); font-weight: 600; }

/* ============================================================================
   Seções e cards KPI
   ========================================================================== */
.section { margin-bottom: 12px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 13px;
}
.section-title .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-primary { background: var(--primary); }
.dot-orange  { background: var(--orange); }
.dot-red     { background: var(--red); }
.dot-green   { background: var(--green); }

.section + .section { margin-top: 26px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #EEEEEE;
  color: #9E9E9E;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 22px; height: 22px; }

.kpi--primary .kpi-icon { background: var(--primary-light); color: var(--primary-strong); }
.kpi--green   .kpi-icon { background: var(--green-light); color: var(--green); }
.kpi--red     .kpi-icon { background: var(--red-light);   color: var(--red); }
.kpi--orange  .kpi-icon { background: var(--yellow-light); color: var(--orange); }

.kpi-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.kpi-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -.4px;
  line-height: 1.2;
}
.kpi-value.is-positive { color: var(--green); }
.kpi-value.is-negative { color: var(--red); }
.kpi-note {
  display: block;
  font-size: 11px;
  color: var(--text-gray);
  margin-top: 4px;
}

/* ============================================================================
   Card do gráfico
   ========================================================================== */
.chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 28px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.chart-card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-dark); }
.text-muted { font-size: 12px; color: var(--text-gray); }

.chart-legend { margin-left: auto; display: flex; gap: 16px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
  margin-top: 10px;
}
.chart-wrap svg { width: 100%; height: 100%; display: block; }

.chart-tooltip {
  position: absolute;
  display: none;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  pointer-events: none;
  z-index: 5;
  min-width: 150px;
}
.chart-tooltip .tt-title { font-weight: 700; color: var(--text-dark); margin-bottom: 5px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--text-medium); }
.chart-tooltip .tt-row + .tt-row { margin-top: 3px; }
.chart-tooltip .tt-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.chart-tooltip .tt-val { margin-left: auto; font-weight: 700; }

/* ============================================================================
   Rodapé da página
   ========================================================================== */
.page-footer {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-gray);
  text-align: center;
}

/* ============================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }

  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 32px; }
  .user-meta { display: none; }
  .user-caret { display: none; }
  .filter-range { margin-left: 0; width: 100%; }
  .chart-wrap { height: 260px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-group input { width: 100%; }
  .filter-group { flex: 1; min-width: 130px; }
  .topbar-title h1 { font-size: 18px; }
  .chart-legend { margin-left: 0; }
}

/* ============================================================================
   Página de configurações — presets, personalização e pré-visualização
   ========================================================================== */

.alert-success {
  background: var(--green-light);
  border: 1px solid #A5D6A7;
  color: #1B5E20;
}
.alert-error {
  background: var(--red-light);
  border: 1px solid #EF9A9A;
  color: #B71C1C;
}

.config-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.config-side { position: sticky; top: 20px; }

/* ---------- Cards de preset ---------- */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.preset-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.preset-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}
.preset-card-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}
.preset-desc {
  font-size: 11.5px;
  color: var(--text-gray);
  font-family: Consolas, 'Courier New', monospace;
}
.preset-swatches {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.12);
  display: inline-block;
}
.btn-block { width: 100%; justify-content: center; }

/* ---------- Formulário de personalização ---------- */
.custom-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.color-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.color-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-medium);
}
.color-field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.text-color-row {
  display: flex;
  gap: 8px;
}
.text-color-row input[type="color"] {
  width: 54px;
  flex-shrink: 0;
}
.text-color-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: Consolas, 'Courier New', monospace;
  color: var(--text-dark);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.text-color-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
}

/* ---------- Pré-visualização ---------- */
.preview-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.preview-hint {
  font-size: 12px;
  color: var(--text-gray);
  line-height: 1.5;
}
.badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  background: var(--primary-light);
  color: var(--primary-strong);
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
}
.preview-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: var(--cor-texto-botao);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(78,205,196,.30);
}
.preview-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.preview-icon svg { width: 18px; height: 18px; }
.preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Responsivo da página de configurações ---------- */
@media (max-width: 1100px) {
  .config-layout { grid-template-columns: 1fr; }
  .config-side { position: static; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .color-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .preset-grid { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   Autenticação — login.php
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 480px at 8% -8%, var(--primary-light), transparent 60%),
    radial-gradient(900px 480px at 108% 108%, var(--primary-light), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px 24px;
}

.auth-brand { text-align: center; margin-bottom: 22px; }

.auth-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: var(--cor-texto-botao);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
}
.auth-logo svg { width: 26px; height: 26px; }

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -.4px;
}
.auth-subtitle {
  font-size: 13px;
  color: var(--text-gray);
  margin-top: 3px;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-medium);
}
.auth-field input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  color: var(--text-dark);
  background: #fff;
  width: 100%;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.auth-field input::placeholder { color: var(--text-gray); }

.auth-submit {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 14px;
  margin-top: 4px;
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.auth-alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.auth-alert-error {
  background: var(--red-light);
  border: 1px solid #EF9A9A;
  color: #B71C1C;
}
.auth-alert-info {
  background: var(--info-light);
  border: 1px solid #90CAF9;
  color: #1565C0;
}

.auth-links {
  margin-top: 18px;
  text-align: center;
}
.auth-links a {
  font-size: 12.5px;
  color: var(--info);
  font-weight: 500;
}
.auth-links a:hover { text-decoration: underline; }

.auth-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 11px;
  color: var(--text-gray);
}

/* ============================================================================
   Botão Sair do header
   ========================================================================== */
.btn-logout {
  padding: 8px 12px;
  font-size: 12.5px;
}

/* ============================================================================
   Página 403 — Acesso negado
   ========================================================================== */
.error-403 {
  max-width: 520px;
  margin: 40px auto;
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 28px;
}
.error-403-code {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.error-403-icon {
  width: 52px;
  height: 52px;
  margin: 14px auto 16px;
  border-radius: 50%;
  background: var(--red-light);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-403-icon svg { width: 24px; height: 24px; }
.error-403 h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}
.error-403 p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 22px;
}
.error-403 p strong { color: var(--text-dark); }

/* ============================================================================
   Módulo Pacientes — listagem, formulário e ficha
   ========================================================================== */

/* ---------- Barra de filtros: select ---------- */
.filter-group select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dark);
  background: #fff;
  min-width: 150px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.filter-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78,205,196,.15);
}
.filter-group-search input { width: 260px; }

/* ---------- Barra de ações da página ---------- */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-toolbar-title h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}

/* ---------- Tabela ---------- */
.table-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 700;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-medium);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-soft); }

.th-actions { text-align: right; }
.th-actions { width: 140px; }

.table-primary {
  display: inline-block;
  color: var(--text-dark);
  font-weight: 600;
}
a.table-primary:hover { color: var(--info); text-decoration: underline; }
.table-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-gray);
  margin-top: 2px;
}

/* ---------- Botões de ação na tabela ---------- */
.table-actions { display: flex; gap: 6px; white-space: nowrap; justify-content: flex-end; }
.form-excluir { display: inline-flex; margin: 0; }
.btn-action {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .12s ease;
}
.btn-action svg { width: 16px; height: 16px; }
.btn-action:hover { transform: translateY(-1px); }
.btn-action-view:hover { border-color: var(--info); color: var(--info); background: var(--info-light); }
.btn-action-edit:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-light); }
.btn-action-delete:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }

/* ---------- Badges (convênios e status) ---------- */
.badge-primary {
  background: var(--primary-light);
  color: var(--primary-strong);
  border: 1px solid var(--primary-border);
}
.badge-gray {
  background: #F0F0F0;
  border-color: #D6D6D6;
  color: #616161;
}
.badge-blue {
  background: var(--info-light);
  border-color: #90CAF9;
  color: #1565C0;
}
.badge-teal {
  background: #E0F2F1;
  border-color: #80CBC4;
  color: #00695C;
}
.badge-green {
  background: var(--green-light);
  border-color: #A5D6A7;
  color: #1B5E20;
}
.badge-red {
  background: var(--red-light);
  border-color: #EF9A9A;
  color: #B71C1C;
}
.badge-orange {
  background: var(--yellow-light);
  border-color: #FFCC80;
  color: #E65100;
}
.badge-purple {
  background: #F3E5F5;
  border-color: #CE93D8;
  color: #6A1B9A;
}
.badge-indigo {
  background: #E8EAF6;
  border-color: #9FA8DA;
  color: #283593;
}

/* ---------- Paginação ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--text-gray); }
.pagination-info strong { color: var(--text-dark); }
.pagination-links { display: flex; gap: 6px; align-items: center; }
.page-link {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-medium);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.page-link svg { width: 15px; height: 15px; }
.page-link:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-light); }
.page-link.active {
  background: var(--primary);
  color: var(--cor-texto-botao);
  border-color: var(--primary);
  pointer-events: none;
}
.page-link.disabled { opacity: .45; pointer-events: none; }

/* ---------- Estado vazio ---------- */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { width: 44px; height: 44px; color: #D0D3D8; margin-bottom: 10px; }
.empty-state h3 { font-size: 15px; color: var(--text-dark); margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; line-height: 1.6; }

/* ---------- Formulário de paciente ---------- */
.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 18px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field-full { grid-column: 1 / -1; }
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-medium);
}
.form-field label .required { color: var(--red); }
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--text-dark);
  background: #fff;
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-field input.is-invalid,
.form-field select.is-invalid { border-color: var(--red); }
.form-field textarea { min-height: 96px; resize: vertical; }
.form-hint { font-size: 11.5px; color: var(--text-gray); }
.field-error { font-size: 11.5px; color: var(--red); min-height: 16px; }

/* ---------- Campo de check/checkbox ---------- */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-medium);
  cursor: pointer;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  user-select: none;
}
.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Botão de perigo ---------- */
.btn-danger {
  background: var(--red-light);
  border: 1px solid #EF9A9A;
  color: var(--red);
}
.btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ---------- Ficha do paciente ---------- */
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  align-items: start;
}
.detail-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.detail-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 3px; }
.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 600;
}
.detail-value { font-size: 13.5px; color: var(--text-dark); }
.detail-text { white-space: pre-line; line-height: 1.6; }

/* ---------- Responsivo do módulo ---------- */
@media (max-width: 900px) {
  .filter-group-search input { width: 180px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .filter-group select { width: 100%; min-width: 0; }
  .filter-group-search input { width: 100%; }
  .pagination { flex-direction: column; align-items: flex-start; }
}

/* ============================================================================
   Módulo Agenda (Fase 4) — grade semanal/dia/mês, blocos, modais
   ========================================================================== */

/* ---------- Barra de filtros da agenda ---------- */
.agenda-filters { align-items: center; gap: 18px; }
.agenda-filters .filter-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.agenda-filters .filter-form .filter-group select { min-width: 180px; }

/* Navegação de período */
.agenda-nav { display: inline-flex; align-items: center; gap: 8px; }
.agenda-nav .page-link { min-width: 30px; padding: 0; }
.agenda-periodo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 170px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Toggle Semana | Dia | Mês */
.agenda-view-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.agenda-view-toggle a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .12s ease, color .12s ease;
}
.agenda-view-toggle a:hover { color: var(--primary-strong); }
.agenda-view-toggle a.active {
  background: var(--primary);
  color: var(--cor-texto-botao);
  box-shadow: var(--shadow-primary);
}

.agenda-hoje { white-space: nowrap; }

/* "Ir para" */
.filter-ir-para input { width: 140px; }

/* ---------- Grade ---------- */
.agenda-scroll {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.agenda-grid {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(130px, 1fr));
  min-width: 1050px;
}
.agenda-grid--dia {
  grid-template-columns: 64px minmax(320px, 1fr);
  min-width: 0;
}

/* Coluna de horários */
.agenda-timecol { background: var(--bg-soft); border-right: 1px solid var(--border); }
.agenda-timeslot {
  height: 30px;
  line-height: 30px;
  padding: 0 10px;
  font-size: 11px;
  color: var(--text-gray);
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
}
.agenda-timeslot:last-child { border-bottom: none; }

/* Colunas de dia */
.agenda-day { display: flex; flex-direction: column; border-right: 1px solid var(--border-soft); min-width: 0; }
.agenda-day:last-child { border-right: none; }
.agenda-day-head {
  padding: 9px 8px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.agenda-day-head .ad-nome {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 700;
}
.agenda-day-head .ad-dia {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
}
.agenda-day-head.is-today .ad-nome { color: var(--primary-strong); }
.agenda-day-head.is-today .ad-dia {
  background: var(--primary);
  color: var(--cor-texto-botao);
  box-shadow: var(--shadow-primary);
}

/* Corpo do dia (área clicável para novo agendamento) */
.agenda-day-body {
  position: relative;
  height: 660px;               /* 660 min = 08:00–19:00 */
  overflow: hidden;
  cursor: pointer;
}
.agenda-day-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 29px,
    var(--border-soft) 29px,
    var(--border-soft) 30px
  );
  pointer-events: none;
}
.agenda-day-body:hover { background: var(--bg-soft); }

/* ---------- Blocos de agendamento ---------- */
.agenda-block {
  position: absolute;
  left: 2px;
  width: calc(100% - 4px);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, .08);
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  transition: box-shadow .12s ease, transform .12s ease;
  z-index: 2;
}
.agenda-block:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); z-index: 4; }
.agenda-block:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.agenda-block .ab-hora { display: block; font-weight: 700; font-size: 10.5px; opacity: .85; }
.agenda-block .ab-nome {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-block .ab-prof {
  display: block;
  font-size: 10px;
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fase 10b: chip de especialidade dentro do bloco (herda a cor do status
 * e usa um fundo translúcido para continuar legível em blocos pequenos) */
.agenda-block .ab-esp {
  display: inline-block;
  max-width: 100%;
  margin-top: 2px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .6);
  font-size: 9.5px;
  line-height: 1.4;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-block--bs .ab-esp { display: none; }

/* Cores por status */
.agenda-block.status-agendada   { background: var(--info-light); border-color: #90CAF9; color: #1565C0; }
.agenda-block.status-confirmada { background: #E0F2F1;          border-color: #80CBC4; color: #00695C; }
.agenda-block.status-realizada  { background: var(--green-light); border-color: #A5D6A7; color: #1B5E20; }
.agenda-block.status-cancelada  { background: var(--red-light);  border-color: #EF9A9A; color: #B71C1C; text-decoration: line-through; opacity: .78; }
.agenda-block.status-faltou     { background: var(--yellow-light); border-color: #FFCC80; color: #E65100; }

/* Bloqueio de sala (observações contendo [BS]) */
.agenda-block--bs { background: #EEEEEE; border-color: #D6D6D6; color: #616161; }
.agenda-block--bs .ab-nome { font-weight: 700; }

/* Checkbox de ação em lote (visão dia) */
.ag-chk {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
  z-index: 5;
}

/* Chip "+N" (mais de 2 no mesmo horário) */
.agenda-mais {
  position: absolute;
  left: 2px;
  width: calc(100% - 4px);
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--bg-soft);
  color: var(--text-medium);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.agenda-mais:hover { background: var(--primary-light); color: var(--primary-strong); border-color: var(--primary-border); }

/* ---------- Ações em lote ---------- */
.agenda-lote {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.agenda-lote span { font-size: 12.5px; color: var(--text-medium); margin-right: auto; }

/* ---------- Visão Mês ---------- */
.agenda-mes {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.agenda-mes-head {
  padding: 9px 8px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 700;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.agenda-mes-day {
  min-height: 96px;
  border: 1px solid var(--border-soft);
  padding: 6px;
  position: relative;
  transition: background .12s ease;
}
.agenda-mes-day:hover { background: var(--primary-light); }
.agenda-mes-day--blank { background: var(--bg-soft); }
.agenda-mes-day.is-today { background: var(--primary-light); }
.agenda-mes-day a { display: block; height: 100%; }
.agenda-mes-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}
.agenda-mes-day.is-today .agenda-mes-num { background: var(--primary); color: var(--cor-texto-botao); box-shadow: var(--shadow-primary); }
.agenda-mes-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
  background: var(--info-light);
  border: 1px solid #90CAF9;
  color: #1565C0;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 700;
}
.agenda-mes-count.verde    { background: var(--green-light); border-color: #A5D6A7; color: #1B5E20; }
.agenda-mes-count.vermelho { background: var(--red-light);  border-color: #EF9A9A; color: #B71C1C; }

/* ---------- Modais ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 200;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-dark); }
.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-gray);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text-dark); }
.modal-body { padding: 18px; }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.modal-actions .btn { font-size: 12.5px; padding: 8px 12px; }
.modal-actions .btn[hidden] { display: none; }

/* Lista "+N" no modal */
.modal-lista { display: flex; flex-direction: column; gap: 8px; }
.modal-lista-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color .12s ease, background .12s ease;
}
.modal-lista-item:hover { border-color: var(--primary); background: var(--primary-light); }
.modal-lista-item .ml-hora { font-weight: 700; font-size: 12.5px; }
.modal-lista-item .ml-nome { font-size: 12.5px; font-weight: 600; color: var(--text-dark); }
.modal-lista-item .ml-sub { display: block; font-size: 11px; color: var(--text-gray); }
.modal-lista-item .ml-status { margin-left: auto; }

/* ---------- Responsivo da agenda ---------- */
@media (max-width: 900px) {
  .agenda-filters { flex-direction: column; align-items: stretch; }
  .agenda-filters .filter-form,
  .agenda-filters .agenda-nav,
  .agenda-filters .agenda-view-toggle,
  .agenda-filters .agenda-hoje,
  .agenda-filters .filter-ir-para { align-self: flex-start; }
}
@media (max-width: 640px) {
  .agenda-periodo { min-width: 0; }
  .agenda-mes-day { min-height: 64px; }
}

/* ============================================================================
   Módulo Prontuário Eletrônico (Fase 5)
   ========================================================================== */

/* ---------- Abas ---------- */
.pront-tabs {
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.pront-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .12s ease, color .12s ease;
}
.pront-tab:hover { color: var(--primary-strong); background: var(--primary-light); }
.pront-tab.active {
  background: var(--primary);
  color: var(--cor-texto-botao);
  box-shadow: var(--shadow-primary);
}
.pront-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  font-size: 11px;
  font-weight: 700;
}
.pront-tab.active .pront-tab-count { background: rgba(255,255,255,.25); }

/* ---------- Lista de evoluções (expansíveis) ---------- */
.evol-list { display: flex; flex-direction: column; gap: 10px; }

.evol-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.evol-item summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  flex-wrap: wrap;
  transition: background .12s ease;
}
.evol-item summary::-webkit-details-marker { display: none; }
.evol-item summary:hover { background: var(--bg-soft); }

.evol-badge { flex-shrink: 0; }
.evol-titulo { font-size: 13.5px; font-weight: 700; color: var(--text-dark); }
.evol-meta { font-size: 12px; color: var(--text-gray); margin-left: auto; }
.evol-chevron {
  display: inline-flex;
  color: var(--text-gray);
  transition: transform .18s ease;
  flex-shrink: 0;
}
.evol-chevron svg { width: 16px; height: 16px; }
.evol-item[open] .evol-chevron { transform: rotate(180deg); }

.evol-detalhe {
  padding: 16px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.evol-conteudo-livre {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-medium);
  white-space: normal;
}
.evol-conteudo-campos { display: flex; flex-direction: column; gap: 12px; }
.evol-campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}
.evol-campo-rotulo {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 700;
}
.evol-campo-valor {
  font-size: 13.5px;
  color: var(--text-dark);
  line-height: 1.6;
  white-space: normal;
}
.evol-acoes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  gap: 8px;
}
.evol-acoes .btn { font-size: 12.5px; padding: 7px 12px; }

/* ---------- Campos dinâmicos ---------- */
.pront-campos-dinamicos {
  grid-column: 1 / -1;
  gap: 14px 18px;
  margin-top: 4px;
}
.pront-campos-dinamicos[hidden] { display: none; }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-group .checkbox-field { align-self: flex-start; }

/* ---------- Fase 10 — grades de checkboxes (especialidades/unidades) ---------- */
/* Lista multi-coluna para vínculos N:N no formulário do profissional.        */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 18px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface-alt, #f8fafc);
}
.checkbox-grid .checkbox-field { align-self: start; margin: 0; }

/* ---------- Paciente fixo (não editável nos formulários) ---------- */
.paciente-fixo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px dashed var(--primary-border);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.paciente-fixo .table-primary { font-size: 14px; }

/* ---------- Página de impressão A4 ---------- */
.print-body { background: var(--bg); }

@media (max-width: 900px) {
  .pront-tabs { width: 100%; }
  .evol-item summary { gap: 8px; }
  .evol-meta { margin-left: 0; width: 100%; }
}

/* ============================================================================
   Módulo Financeiro (Fase 6) — contas, fluxo de caixa e DRE
   ========================================================================== */

/* ---------- Grade de 4 cards KPI ---------- */
.kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Alinhamento de números em tabelas ---------- */
.num { text-align: right; white-space: nowrap; }
.th-num { text-align: right; }

/* ---------- Botão "Marcar paga" na tabela ---------- */
.btn-action-pagar:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

/* ---------- Linha de agrupamento (fluxo de caixa) ---------- */
.table-group-row td {
  background: var(--bg-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.table-group-row td .table-group-info { font-weight: 500; color: var(--text-gray); text-transform: none; letter-spacing: 0; }

/* ---------- Relatório DRE ---------- */
.report-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 8px;
}
.report-head h2 { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.report-head .report-periodo { font-size: 12.5px; color: var(--text-gray); }

.report-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.report-table td { padding: 10px 8px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.report-table .rep-label { color: var(--text-medium); width: 40%; }
.report-table .rep-val { text-align: right; font-weight: 600; color: var(--text-dark); white-space: nowrap; width: 22%; }
.report-table .rep-info { text-align: right; font-size: 11.5px; color: var(--text-gray); width: 38%; }

.report-table tr.rep-sub td { padding-left: 26px; color: var(--text-medium); }
.report-table tr.rep-sub .rep-label { font-weight: 500; }
.report-table tr.rep-divider td { border-top: 1px dashed var(--border); }

.report-table tr.rep-total td {
  font-weight: 700;
  color: var(--text-dark);
  background: var(--bg-soft);
  border-bottom: none;
  padding: 12px 8px;
}
.report-table tr.rep-total .rep-label { text-transform: uppercase; letter-spacing: .5px; font-size: 12.5px; }
.report-table tr.rep-total .rep-val { font-size: 15px; }

.report-table .rep-resultado { font-weight: 800; font-size: 15px; }
.report-table .rep-lucro { color: var(--green); }
.report-table .rep-prejuizo { color: var(--red); }

.report-legend {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-gray);
  line-height: 1.6;
}

/* ---------- Gráfico de barras do fluxo de caixa ---------- */
.fluxo-bars { width: 100%; height: 300px; display: block; }

/* ---------- Responsivo financeiro ---------- */
@media (max-width: 1100px) {
  .kpi-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpi-grid--4 { grid-template-columns: 1fr; }
  .report-card { padding: 16px; }
  .report-table .rep-info { display: none; }
  .report-table .rep-label { width: 55%; }
  .report-table .rep-val { width: 45%; }
}

/* ============================================================================
   Fase 7 — Lista de espera e Painel de chamadas
   ========================================================================== */

/* ---------- Submenu ativo na sidebar ---------- */
.submenu a.active {
  background: var(--primary-light);
  color: var(--primary-strong);
  font-weight: 600;
}
.submenu a.active::before { background: var(--primary); }

/* ---------- Marcação "Lista de espera" na grade da agenda ---------- */
.ab-lista {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--yellow-light);
  border: 1px solid #FFCC80;
  color: #E65100;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
  vertical-align: middle;
  line-height: 1.4;
}
.agenda-block--lista { border-style: dashed; }

/* ---------- Ações extras da lista de espera ---------- */
.btn-action-calendar:hover { border-color: var(--info); color: var(--info); background: var(--info-light); }
.btn-action-check:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }
.btn-action-undo:hover { border-color: var(--orange); color: var(--orange-dark); background: var(--yellow-light); }

/* ---------- Botão compacto (painel de chamadas) ---------- */
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.btn-sm svg { width: 13px; height: 13px; }

/* ---------- Painel de chamadas: destaque "painel de TV" ---------- */
.painel-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--cor-texto-botao);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 30px;
  margin-bottom: 18px;
  min-height: 118px;
  transition: background .3s ease;
}
.painel-hero.is-empty {
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  color: var(--text-gray);
  box-shadow: var(--shadow);
}
.painel-hero-numero {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  flex-shrink: 0;
  min-width: 120px;
}
.painel-hero-info { flex: 1; min-width: 0; }
.painel-hero-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: .8;
  margin-bottom: 5px;
}
.painel-hero-nome {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
}
.painel-hero-meta {
  font-size: 13px;
  opacity: .9;
  margin-top: 5px;
}
.is-empty .painel-hero-label { color: var(--text-gray); }
.is-empty .painel-hero-nome { font-size: 22px; color: var(--text-medium); }
.is-empty .painel-hero-meta { color: var(--text-gray); }

/* ---------- Painel de chamadas: contadores ---------- */
.painel-counters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.painel-counter {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.painel-counter .pc-num { font-size: 24px; font-weight: 800; color: var(--text-dark); line-height: 1; }
.painel-counter .pc-label { font-size: 11.5px; color: var(--text-gray); text-transform: uppercase; letter-spacing: .5px; }
.painel-counter--pendente .pc-num { color: var(--orange); }
.painel-counter--chamado  .pc-num { color: var(--info); }
.painel-counter--concluido .pc-num { color: var(--green); }

/* ---------- Painel de chamadas: número na fila ---------- */
.painel-numero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--primary-strong);
  font-weight: 800;
  font-size: 13px;
}
.painel-linha-chamado td { background: var(--info-light); }

/* ---------- Responsivo do painel ---------- */
@media (max-width: 900px) {
  .painel-hero-numero { font-size: 44px; min-width: 96px; }
  .painel-hero-nome { font-size: 24px; }
  .painel-counters { grid-template-columns: 1fr; }
}

/* ============================================================================
   Fase 8 — Controle de Estoque
   ========================================================================== */

/* ---------- Checkbox de filtro ("estoque baixo") ---------- */
.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-medium);
  cursor: pointer;
  user-select: none;
  height: 36px;
}
.filter-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--orange);
  cursor: pointer;
}

/* ---------- Validade na tabela ---------- */
.validade-vencida  { color: var(--red); font-weight: 700; }
.validade-vencendo { color: var(--orange-dark); font-weight: 600; }

/* ---------- Quantidade do histórico (+/-) ---------- */
.mov-qtd { font-weight: 700; white-space: nowrap; }
.mov-qtd--entrada { color: var(--green); }
.mov-qtd--saida   { color: var(--red); }
.mov-qtd--ajuste  { color: var(--orange-dark); }

/* ---------- Botão de ação "movimentar" ---------- */
.btn-action-move:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
  background: var(--yellow-light);
}

/* ---------- Cards de quantidade na ficha do item ---------- */
.estoque-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.estoque-mini-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.estoque-mini-card .em-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-gray);
  font-weight: 600;
  margin-bottom: 3px;
}
.estoque-mini-card .em-value {
  display: block;
  font-size: 19px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}
.estoque-mini-card--alerta  .em-value { color: var(--orange); }
.estoque-mini-card--critico .em-value { color: var(--red); }

/* ---------- Aviso de vencimento em destaque na ficha ---------- */
.venc-aviso {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--yellow-light);
  border: 1px solid #FFCC80;
  color: #E65100;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  margin-top: 6px;
}
.venc-aviso--vencido {
  background: var(--red-light);
  border-color: #EF9A9A;
  color: #B71C1C;
}

/* ---------- Responsivo do módulo ---------- */
@media (max-width: 900px) {
  .estoque-mini-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .estoque-mini-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   Relatórios / BI (Fase 9) — grade de gráficos lado a lado
   ========================================================================== */
.grid-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.chart-card--half { margin-top: 28px; min-width: 0; }
.chart-card--half .chart-wrap { height: 260px; }

/* Donut — layout rosca (SVG) + legenda (HTML) lado a lado.
   A legenda em HTML usa tamanho de fonte real (sem escala do SVG),
   truncagem com reticências e swatches coloridos alinhados. */
.donut-layout {
  display: flex;
  align-items: stretch;
  gap: 18px;
  height: 100%;
  min-height: 0;
}
.donut-svg-wrap {
  flex: 1 1 55%;
  min-width: 0;
  min-height: 0;
}
.donut-legend {
  flex: 1 1 45%;
  min-width: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  overflow-y: auto;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.3;
  min-width: 0;
  cursor: default;
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name {
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.legend-value {
  margin-left: auto;
  font-weight: 700;
  color: var(--text-medium);
  flex-shrink: 0;
}

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

@media (max-width: 640px) {
  .donut-layout { flex-direction: column; align-items: stretch; gap: 10px; height: auto; }
  .donut-svg-wrap { flex: none; height: 180px; }
  .donut-legend { flex: none; justify-content: flex-start; max-height: 220px; }
}

.toolbar-text {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.privacy-note {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #FBFBFB;
  font-size: 12px;
  color: var(--text-gray);
  line-height: 1.5;
}

.nowrap { white-space: nowrap; }
