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

:root {
  --brand: #14535E;
  --brand-accent: #D4AF37;
  --greige: #E8E5DF;
  --ink: #1E293B;
  --muted: #475569;
  --alert: #9B1C1C;
  --gold-deep: #B8860B;
  --gold-soft: #FBF8EF;
  --surface-card: #FAFAF9;
  --surface-mini: #F4F2EC;
  --table-head: #F7F6F3;
  --legend: #94A3B8;
  --ok: #10B981;
  --warn: #D9A441;
  --crit: #9B1C1C;

  --font-title: 'Cinzel', serif;
  --font-body: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--greige);
}

h1, h2, h3, .title {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 8px;
}

h1 { font-size: 28px; letter-spacing: 3px; }
h2 { font-size: 20px; letter-spacing: 2px; }
h3 { font-size: 15px; letter-spacing: 1px; }

a {
  color: var(--brand);
}

.overline {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Cabeçalho institucional */
.institutional-header {
  background: var(--brand);
  color: #fff;
  border-bottom: 3px solid var(--brand-accent);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.institutional-header .brand-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  color: #fff;
  margin: 0;
  line-height: 1.3;
}

.institutional-header .brand-role {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--brand-accent);
  text-transform: uppercase;
  margin: 0;
  line-height: 1.3;
}

.institutional-header .header-meta {
  font-size: 12px;
  color: var(--greige);
  text-align: right;
}

.institutional-header .header-meta a {
  color: var(--brand-accent);
  text-decoration: none;
}

.main-nav {
  display: flex;
  gap: 20px;
}

.main-nav a {
  color: var(--greige);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover,
.main-nav a.active {
  color: #fff;
  border-bottom-color: var(--brand-accent);
}

/* Layout de página autenticada */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 24px;
  max-width: 1040px;
  margin: 0 auto;
  width: 100%;
}

/* Superfície branca que agrupa todo o conteúdo da página (menus, botões,
   busca, seletores...), destacada do fundo greige atrás dela. */
.content-surface {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #E2DFD8;
  box-shadow: 0 2px 14px rgba(20, 83, 94, 0.07);
  padding: 24px;
}

/* Cards com borda-âncora */
.card {
  background: var(--surface-card);
  border: 1px solid #E2DFD8;
  border-left: 3px solid var(--brand-accent);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-mini {
  background: var(--surface-mini);
  border: 1px solid #E2DFD8;
  border-top: 3px solid var(--brand-accent);
  border-radius: 4px;
  padding: 12px 16px;
}

/* Tela de autenticação */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  padding: 24px;
}

.auth-card {
  background: var(--surface-card);
  border-radius: 6px;
  border-top: 4px solid var(--brand-accent);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.auth-card .monogram {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1.5px solid var(--brand-accent);
  overflow: hidden;
  display: block;
  margin: 0 auto 16px;
}

.auth-card .monogram img,
.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--brand-accent);
  overflow: hidden;
  flex-shrink: 0;
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-card h1 {
  text-align: center;
  font-size: 20px;
  letter-spacing: 2px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}

/* Formulários */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #CBC7BE;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(20, 83, 94, 0.15);
}

.field .hint {
  font-size: 11px;
  color: var(--legend);
  margin-top: 4px;
}

/* Grupo de radiobuttons lado a lado (ex.: "colar texto" vs "importar arquivo") */
.radio-inline-group {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.radio-inline-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  margin-bottom: 0;
  cursor: pointer;
}

.radio-inline-group input[type="radio"] {
  width: auto;
  margin: 0;
}

/* Checkbox com legenda em cima, centralizado (ex.: "Favorito" em contatos) */
.checkbox-stacked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.checkbox-stacked label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 0;
}

.checkbox-stacked input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Dropdown de busca (CBO) */
.cbo-search-wrap {
  position: relative;
}

.cbo-dropdown {
  display: none;
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.cbo-option {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.cbo-option:hover {
  background: var(--surface-mini, #F4F2EC);
}

/* Ficha do paciente — banner + menu lateral + conteúdo, sem content-surface geral */
.patient-hero {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.patient-banner-top {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.patient-banner-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.patient-mode-switch {
  display: flex;
  gap: 4px;
}

.patient-mode-switch a {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
}

.patient-mode-switch a:hover {
  color: var(--brand);
}

.patient-mode-switch a.active {
  color: var(--brand);
  border-bottom-color: var(--brand-accent);
  background: var(--surface-mini, #F4F2EC);
}

.patient-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 12px;
}

.patient-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #E2DFD8;
  border-radius: 8px;
  padding: 8px;
  position: sticky;
  top: 12px;
}

.patient-sidebar a {
  display: block;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 4px;
  margin-bottom: 2px;
}

.patient-sidebar a:hover {
  background: var(--surface-mini, #F4F2EC);
}

.patient-sidebar a.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.patient-content {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid #E2DFD8;
  border-radius: 8px;
  padding: 20px;
}

@media (max-width: 800px) {
  .patient-layout { flex-direction: column; }
  .patient-sidebar { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .patient-sidebar a { flex: 1 1 auto; text-align: center; }
}

/* Grid de 2 cards por linha (aba Resumo) */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.summary-grid .card {
  margin-bottom: 0;
}

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

.btn {
  display: inline-block;
  width: 100%;
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn:hover {
  background: #0f414a;
}

.btn-accent {
  background: var(--brand-accent);
  color: var(--brand);
}

.alert {
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid var(--alert);
  background: #FBEAEA;
  color: var(--alert);
}

/* Pílulas de status */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.pill-ok { background: rgba(16, 185, 129, 0.15); color: #0a7a5c; }
.pill-warn { background: rgba(217, 164, 65, 0.2); color: #8a5c10; }
.pill-crit { background: rgba(155, 28, 28, 0.15); color: var(--alert); }

/* Minicards de indicadores */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.indicator-grid .label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.indicator-grid .value {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.totp-secret {
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 2px;
  background: var(--surface-mini);
  border: 1px dashed var(--brand-accent);
  padding: 12px;
  border-radius: 4px;
  text-align: center;
  word-break: break-all;
  margin-bottom: 12px;
}

/* Formulários em grade */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 16px;
}

.form-grid .field-span-2 { grid-column: span 2; }
.form-grid .field-span-3 { grid-column: span 3; }

.field-error {
  color: var(--alert);
  font-size: 11px;
  margin-top: 4px;
}

.field input.has-error, .field select.has-error, .field textarea.has-error {
  border-color: var(--alert);
}

.field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #CBC7BE;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-sm {
  width: auto;
  padding: 7px 14px;
  font-size: 12px;
}

.btn-secondary {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.btn-danger {
  background: transparent;
  color: var(--alert);
  border: 1px solid var(--alert);
}

/* Tabelas */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  text-align: left;
  background: var(--table-head);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid #E2DFD8;
}

table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #EFEDE8;
  vertical-align: middle;
}

table.data-table tr:hover td {
  background: var(--surface-mini);
}

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  padding: 11px 12px;
  border: 1px solid #CBC7BE;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 14px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.allergy-banner {
  background: #FBEAEA;
  border: 1px solid var(--alert);
  color: var(--alert);
  padding: 10px 14px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 16px;
}

.patient-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.patient-banner .name {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--brand);
}

.patient-banner .meta {
  color: var(--muted);
  font-size: 13px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 12px;
}

/* Cabeçalho de card com botão para abrir formulário oculto — título à esquerda, ação à direita */
.card-toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.card-toggle-header h3,
.card-toggle-header h4 {
  margin: 0;
}

.btn-toggle {
  width: auto;
  white-space: nowrap;
  border: none;
  background: var(--brand-accent);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-toggle:hover {
  filter: brightness(0.96);
}

.toggle-form {
  display: none;
  background: var(--surface-mini, #F4F1EA);
  border: 1px solid #E2DFD8;
  border-left: 3px solid var(--brand-accent);
  border-radius: 6px;
  padding: 16px;
  margin-top: 12px;
}

.toggle-form.open {
  display: block;
}

.inline-form.toggle-form.open {
  display: flex;
}

/* Menu de configurações — agrupado por categoria, com ícone e descrição */
.config-group {
  margin-bottom: 28px;
}

.config-group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #E2DFD8;
}

.config-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.config-menu-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface-card);
  border: 1px solid #E2DFD8;
  border-left: 3px solid var(--brand-accent);
  border-radius: 4px;
  padding: 16px;
  text-decoration: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.config-menu-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.config-menu-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.config-menu-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-menu-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}

.config-menu-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Formulário oculto dentro de uma linha de tabela (ex.: editar regime inline) */
.toggle-form-row {
  background: var(--surface-mini, #F4F1EA);
}

.toggle-form-row.open {
  display: table-row;
}

/* Editor rich text (documentos de texto livre — relatório/laudo/plano terapêutico) */
.richtext-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--border, #E2DFD8);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--surface-mini, #F4F1EA);
}

.richtext-toolbar button {
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.richtext-toolbar button:hover {
  background: var(--surface-mini, #F4F1EA);
}

.richtext-toolbar input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
}

.richtext-editor {
  min-height: 220px;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 0 0 6px 6px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.5;
  background: #fff;
  overflow-y: auto;
}

.richtext-editor:focus {
  outline: 2px solid var(--accent, #14535E);
  outline-offset: -1px;
}

/* Abas */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid #E2DFD8;
}

.tab-btn {
  appearance: none;
  display: inline-block;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  text-decoration: none;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--brand);
}

.tab-btn.tab-btn-active {
  color: var(--brand);
  border-bottom-color: var(--brand-accent);
}

.inline-form .field {
  margin-bottom: 0;
  min-width: 140px;
  flex: 1;
}

/* Agenda semanal */
.week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.week-day {
  background: var(--surface-card);
  border: 1px solid #E2DFD8;
  border-top: 3px solid var(--brand-accent);
  border-radius: 4px;
  padding: 10px;
  min-height: 160px;
}

.week-day.is-today {
  border-top-color: var(--ok);
}

.week-day h3 {
  font-size: 11px;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.appointment-slot {
  background: var(--surface-mini);
  border-left: 3px solid var(--brand);
  border-radius: 3px;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.appointment-slot .time {
  font-weight: 700;
  color: var(--brand);
}

.appointment-slot form {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

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

footer.page-footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--legend);
}

@media (max-width: 640px) {
  .page-body { padding: 16px; }
  .content-surface { padding: 16px; }
  .institutional-header { padding: 10px 16px; }
  .auth-card { padding: 28px 20px; }
}

/* Consulta */
.encounter-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid #E2DFD8;
}

.encounter-tabs a {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.encounter-tabs a:hover {
  color: var(--brand);
  border-bottom-color: var(--brand-accent);
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.vitals-grid .field input {
  text-align: center;
}

.vitals-grid .field.readonly-imc .value-box {
  padding: 11px 12px;
  border-radius: 4px;
  background: var(--surface-mini);
  border: 1px dashed var(--brand-accent);
  text-align: center;
  font-weight: 700;
  color: var(--brand);
}

.finalize-box {
  background: var(--gold-soft);
  border: 1px solid var(--brand-accent);
  border-radius: 4px;
  padding: 16px;
  margin-top: 24px;
}

.print-only { display: none; }

/* Modais (<dialog>) — chrome padrão da marca em vez do default do navegador */
dialog {
  border: none;
  border-radius: 6px;
  border-left: 3px solid var(--brand-accent);
  padding: 24px;
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  background: var(--surface-card, #fff);
}

dialog::backdrop {
  background: rgba(20, 18, 14, 0.45);
}

dialog h3 {
  margin: 0 0 16px;
  font-family: var(--font-title);
  color: var(--brand);
}

dialog form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  width: 100%;
}

dialog .modal-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

dialog form > .field, dialog .modal-row .field {
  flex: 1 1 200px;
  min-width: 160px;
  margin-bottom: 0;
}

dialog form > .field-full {
  flex: 1 1 100%;
}

dialog form > h3, dialog form > .modal-actions, dialog form > p.hint, dialog form > div:last-child {
  flex: 1 1 100%;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.kebab-btn.btn-sm-icon {
  font-size: 13px;
  padding: 2px 6px;
}

/* Menu kebab (⋮) e dropdown com submenu — ações por linha / "+ Adicionar" */
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kebab-menu, .dropdown-menu {
  position: relative;
  display: inline-block;
}

.kebab-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  color: var(--muted);
  border-radius: 4px;
}

.kebab-btn:hover { background: var(--surface-mini, #F4F2EC); }

.kebab-menu .menu-panel, .dropdown-menu .menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 30;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
}

.kebab-menu.open .menu-panel, .dropdown-menu.open .menu-panel { display: block; }

.menu-panel button, .menu-panel a, .menu-panel .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink, #2b2b2b);
  text-decoration: none;
  position: relative;
}

.menu-panel button:hover, .menu-panel a:hover, .menu-panel .menu-item:hover { background: var(--surface-mini, #F4F2EC); }

.menu-item.has-submenu .submenu-panel {
  display: none;
  position: absolute;
  left: 100%;
  top: -4px;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
}

.menu-item.has-submenu:hover .submenu-panel { display: block; }

.filter-toggle-btn {
  background: none;
  border: 1px solid var(--border, #E2DFD8);
  border-radius: 4px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
}

.filter-input {
  width: 100%;
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid #CBC7BE;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 8px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(20, 83, 94, 0.15);
}

.value-out-of-range {
  color: var(--crit, #b3261e);
  font-weight: 700;
}

.ref-range-hint {
  color: var(--muted);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Toggle switch (ex.: catálogo/avulso na prescrição) */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #CBC7BE;
  border-radius: 20px;
  transition: background .15s;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
}

.switch input:checked + .switch-slider {
  background: var(--brand);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

@media print {
  .institutional-header, .page-footer, .no-print { display: none !important; }
  .page-body { padding: 0; max-width: none; }
  .content-surface { padding: 0; border: none; box-shadow: none; border-radius: 0; }
  body { background: #fff; }
  .card { border: none; padding: 8px 0; box-shadow: none; }
  .print-only { display: block; }
  a[href]::after { content: ""; }
}
