:root {
  /* Apple HIG System Surfaces & Backgrounds */
  --bg-body: #f5f5f7;
  --bg-card: #ffffff;
  --bg-subtle: #f9f9fb;
  --bg-grouped-secondary: #f2f2f7;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --bg-glass-heavy: rgba(255, 255, 255, 0.9);

  /* Apple Typography Colors */
  --text-main: #1d1d1f;
  --text-secondary: #515154;
  --text-muted: #86868b;

  /* Hairlines & Borders */
  --border-color: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.14);
  --hairline: 1px solid rgba(0, 0, 0, 0.065);

  /* CTI Theme — Apple System Pink / Red (Critical Care) */
  --cti-primary: #e11d48;
  --cti-primary-hover: #be123c;
  --cti-primary-light: rgba(225, 29, 72, 0.09);
  --cti-primary-border: rgba(225, 29, 72, 0.2);
  --cti-surface-tint: #fff8f9;

  /* Internação Theme — Apple System Blue / Teal (Clinical Care) */
  --ward-primary: #0071e3;
  --ward-primary-hover: #0077ed;
  --ward-primary-light: rgba(0, 113, 227, 0.09);
  --ward-primary-border: rgba(0, 113, 227, 0.2);
  --ward-surface-tint: #f5faff;

  /* Active Dynamic Theme Tokens */
  --accent-active: var(--cti-primary);
  --accent-hover: var(--cti-primary-hover);
  --accent-light: var(--cti-primary-light);
  --accent-border: var(--cti-primary-border);
  --accent-surface: var(--cti-surface-tint);

  /* Apple Semantic Colors */
  --success: #1d8348;
  --success-dot: #34c759;
  --success-bg: rgba(52, 199, 89, 0.12);

  --warning: #b25000;
  --warning-dot: #ff9500;
  --warning-bg: rgba(255, 149, 0, 0.14);

  --danger: #d70015;
  --danger-dot: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.12);

  --info: #0066cc;
  --info-dot: #007aff;
  --info-bg: rgba(0, 122, 255, 0.1);

  --indigo: #5856d6;
  --indigo-bg: rgba(88, 86, 214, 0.1);

  /* Apple Continuous Corner Radii */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 980px;

  /* Apple Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);

  --ease-apple: cubic-bezier(0.25, 1, 0.5, 1);
}

body.theme-internacao {
  --accent-active: var(--ward-primary);
  --accent-hover: var(--ward-primary-hover);
  --accent-light: var(--ward-primary-light);
  --accent-border: var(--ward-primary-border);
  --accent-surface: var(--ward-surface-tint);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 4rem;
  transition: background-color 0.3s var(--ease-apple);
}

/* Tabular numerals for clinical precision */
.leito-badge,
.patient-age,
.admission-pill,
.dih-badge,
.kpi-value,
.lab-date-cell,
.metric-pill {
  font-variant-numeric: tabular-nums;
}

/* ================= APPLE TRANSLUCENT TOP NAVIGATION BAR ================= */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.85rem 1.75rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-top {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent-active), #1d1d1f);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  transition: background 0.3s var(--ease-apple);
}

.brand-title h1 {
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ================= SEGMENTED DASHBOARD SWITCHER ================= */
.dashboard-nav-container {
  max-width: 1380px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
}

.dashboard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  background: rgba(118, 118, 128, 0.1);
  padding: 6px;
  border-radius: var(--radius-xl);
  margin-bottom: 1.35rem;
}

.dashboard-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-xl) - 4px);
  padding: 0.95rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.25s var(--ease-apple);
  text-align: left;
  color: var(--text-secondary);
}

.dashboard-tab:hover {
  background: rgba(255, 255, 255, 0.45);
}

.dashboard-tab.active-cti,
.dashboard-tab.active-internacao {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tab-info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.tab-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.25s var(--ease-apple);
}

.dashboard-tab.active-cti .tab-badge-icon,
.dashboard-tab.active-internacao .tab-badge-icon {
  transform: scale(1.03);
}

.tab-cti .tab-badge-icon {
  background: var(--cti-primary-light);
  color: var(--cti-primary);
}

.tab-internacao .tab-badge-icon {
  background: var(--ward-primary-light);
  color: var(--ward-primary);
}

.tab-text h2 {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--text-main);
}

.tab-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.tab-metrics {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.metric-pill {
  background: var(--bg-grouped-secondary);
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.dashboard-tab.active-cti .metric-pill {
  background: var(--cti-primary-light);
  color: var(--cti-primary);
}

.dashboard-tab.active-internacao .metric-pill {
  background: var(--ward-primary-light);
  color: var(--ward-primary);
}

.metric-pill strong {
  font-size: 0.88rem;
  font-weight: 600;
}

/* ================= APPLE HEALTH STYLE KPI CARDS ================= */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

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

.kpi-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-top: 0.1rem;
}

.kpi-sub {
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-muted);
}

/* ================= SPOTLIGHT SEARCH & FILTER TOOLBAR ================= */
.toolbar {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.search-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 260px;
}

.search-input {
  width: 100%;
  max-width: 420px;
  padding: 0.52rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-grouped-secondary);
  font-size: 0.86rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s var(--ease-apple);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--accent-active);
  box-shadow: 0 0 0 3.5px var(--accent-light);
}

.filter-select {
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  background: var(--bg-grouped-secondary);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: all 0.2s var(--ease-apple);
}

.filter-select:hover {
  background: rgba(118, 118, 128, 0.16);
}

.filter-select:focus {
  background: #ffffff;
  border-color: var(--accent-active);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.view-mode-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* ================= APPLE PILL & SYSTEM BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.05rem;
  border-radius: var(--radius-pill);
  font-size: 0.83rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s var(--ease-apple);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-active);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-grouped-secondary);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(118, 118, 128, 0.18);
}

.btn-dark-outline {
  background: rgba(118, 118, 128, 0.1);
  color: var(--text-main);
  border-color: transparent;
}

.btn-dark-outline:hover {
  background: rgba(118, 118, 128, 0.18);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  padding: 0.32rem 0.6rem;
}

.btn-danger-ghost:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 0.34rem 0.75rem;
  font-size: 0.77rem;
}

/* ================= MAIN CONTAINER & SECTOR HEADER ================= */
.main-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.sector-banner {
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.35rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--accent-active);
}

.sector-banner.banner-cti {
  border-left-color: var(--cti-primary);
}

.sector-banner.banner-internacao {
  border-left-color: var(--ward-primary);
}

.sector-banner-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sector-banner-title h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--text-main);
}

.sector-fields-legend {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-grouped-secondary);
  padding: 0.32rem 0.8rem;
  border-radius: var(--radius-pill);
}

/* ================= APPLE INSET GROUPED PATIENT CARDS ================= */
.patients-list {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.patient-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.25s var(--ease-apple), transform 0.25s var(--ease-apple);
}

.patient-card:hover {
  box-shadow: var(--shadow-md);
}

/* Patient Card Header */
.patient-header {
  background: var(--bg-card);
  border-bottom: var(--hairline);
  padding: 1.05rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
}

.patient-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.leito-badge {
  background: var(--accent-light);
  color: var(--accent-active);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.32rem 0.8rem;
  border-radius: var(--radius-pill);
  letter-spacing: -0.01em;
  min-width: 72px;
  text-align: center;
}

.patient-name {
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text-main);
}

.patient-age {
  font-size: 0.83rem;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg-grouped-secondary);
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
}

.patient-admission-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.admission-pill {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: var(--hairline);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
}

.dih-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  background: var(--info-bg);
  color: var(--info);
}

.dih-badge.dih-long {
  background: var(--warning-bg);
  color: var(--warning);
}

.dih-badge.dih-critical {
  background: var(--danger-bg);
  color: var(--danger);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Patient Card Grid Body */
.patient-body {
  padding: 1.25rem 1.4rem 1.4rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.9rem;
}

.field-box {
  background: var(--bg-subtle);
  border: var(--hairline);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-box.col-12 { grid-column: span 12; }
.field-box.col-8 { grid-column: span 8; }
.field-box.col-6 { grid-column: span 6; }
.field-box.col-4 { grid-column: span 4; }
.field-box.col-3 { grid-column: span 3; }

/* Subtle Apple Tinted Surface Cards */
.field-box.highlight-trs {
  background: #fff8f9;
  border-color: rgba(225, 29, 72, 0.14);
}

.field-box.highlight-ward {
  background: #f5faff;
  border-color: rgba(0, 113, 227, 0.14);
}

.field-box.highlight-pendencia {
  background: #fffcf5;
  border-color: rgba(255, 149, 0, 0.2);
}

.field-box.highlight-objetivo {
  background: #f6f9ff;
  border-color: rgba(0, 122, 255, 0.15);
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.field-box.highlight-trs .field-label { color: var(--cti-primary); }
.field-box.highlight-ward .field-label { color: var(--ward-primary); }
.field-box.highlight-pendencia .field-label { color: var(--warning); }
.field-box.highlight-objetivo .field-label { color: var(--info); }

.field-content {
  font-size: 0.9rem;
  line-height: 1.52;
  color: var(--text-main);
  white-space: pre-line;
}

.field-empty {
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* Badges inside fields */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.1rem;
}

.atb-tag {
  background: var(--indigo-bg);
  color: var(--indigo);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.24rem 0.7rem;
  border-radius: var(--radius-pill);
}

.trs-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  width: fit-content;
  text-transform: none;
  letter-spacing: 0;
}

.trs-active {
  background: var(--cti-primary-light);
  color: var(--cti-primary);
}

.trs-inactive {
  background: var(--bg-grouped-secondary);
  color: var(--text-secondary);
}

/* ================= APPLE NUMBERS STYLE LAB EVOLUTION TABLE ================= */
.lab-section {
  grid-column: span 12;
  background: var(--bg-card);
  border: var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 0.15rem;
}

.lab-header {
  background: var(--bg-subtle);
  padding: 0.7rem 1.05rem;
  border-bottom: var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lab-header-title {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.lab-table-wrapper {
  overflow-x: auto;
}

.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.lab-table th,
.lab-table td {
  padding: 0.6rem 1.05rem;
  border-bottom: var(--hairline);
  text-align: left;
}

.lab-table th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lab-table tr:last-child td {
  border-bottom: none;
}

.lab-table tr:hover td {
  background: var(--bg-subtle);
}

.lab-date-cell {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  width: 145px;
}

.lab-biomarker-cell {
  font-weight: 500;
  color: var(--text-main);
}

.lab-trend-up {
  color: var(--danger);
  font-weight: 600;
}

.lab-trend-down {
  color: var(--info);
  font-weight: 600;
}

.lab-trend-normal {
  color: var(--success);
  font-weight: 500;
}

/* ================= COMPACT SUMMARY TABLE VIEW ================= */
.summary-table-container {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.summary-table th,
.summary-table td {
  padding: 0.85rem 1rem;
  border-bottom: var(--hairline);
  vertical-align: top;
  text-align: left;
}

.summary-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

/* ================= APPLE SHEET MODALS & MAXIMIZED EDITOR ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
  animation: appleFadeIn 0.22s var(--ease-apple);
}

@keyframes appleFadeIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

/* Maximized full-screen layout for Patient Edit / Create Modal & Medico Profile Modal */
#patient-modal.modal-backdrop,
.modal-backdrop.modal-maximized {
  padding: 0 !important;
  background: var(--bg-body);
}

#patient-modal .modal-dialog,
.modal-backdrop.modal-maximized .modal-dialog {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: var(--bg-body);
}

#patient-form,
#form-cadastro-medico-proprio {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#patient-modal .modal-header,
.modal-backdrop.modal-maximized .modal-header {
  background: var(--bg-glass-heavy);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text-main);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 1rem 2.5rem;
}

#patient-modal .modal-close,
.modal-backdrop.modal-maximized .modal-close {
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-grouped-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background 0.15s;
}

#patient-modal .modal-close:hover,
.modal-backdrop.modal-maximized .modal-close:hover {
  background: rgba(118, 118, 128, 0.22);
}

#patient-modal .modal-body,
.modal-backdrop.modal-maximized .modal-body {
  flex: 1;
  padding: 1.5rem 2.5rem;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
}

#patient-modal .form-grid,
.modal-backdrop.modal-maximized .form-grid {
  background: var(--bg-card);
  padding: 1.25rem 1.4rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.modal-header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-maximize-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--bg-grouped-secondary);
  color: var(--text-main);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s var(--ease-apple);
}

.modal-maximize-btn:hover {
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
  border-color: rgba(0, 113, 227, 0.3);
}

#patient-modal textarea.form-control {
  min-height: 115px;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1.1rem 1.5rem;
  background: var(--bg-card);
  color: var(--text-main);
  border-bottom: var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.018em;
}

.modal-close {
  background: var(--bg-grouped-secondary);
  border: none;
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.form-group.col-12 { grid-column: span 12; }
.form-group.col-8 { grid-column: span 8; }
.form-group.col-6 { grid-column: span 6; }
.form-group.col-5 { grid-column: span 5; }
.form-group.col-4 { grid-column: span 4; }
.form-group.col-3 { grid-column: span 3; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.008em;
}

.form-control {
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-subtle);
  transition: all 0.18s var(--ease-apple);
}

.form-control:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent-active);
  box-shadow: 0 0 0 3.5px var(--accent-light);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.calculated-days-preview {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--info);
  margin-top: 0.15rem;
}

.section-divider {
  padding-top: 0.4rem;
}

.section-divider-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  padding: 0 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#modal-lab-list {
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.lab-editor-row {
  display: grid;
  grid-template-columns: 165px 1fr 170px auto;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.lab-editor-row:last-child {
  margin-bottom: 0;
}

.modal-footer {
  padding: 1rem 2.5rem;
  background: var(--bg-glass-heavy);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .dashboard-tabs {
    grid-template-columns: 1fr;
  }
  .field-box.col-8,
  .field-box.col-6,
  .field-box.col-4,
  .field-box.col-3,
  .form-group.col-8,
  .form-group.col-6,
  .form-group.col-5,
  .form-group.col-4,
  .form-group.col-3 {
    grid-column: span 12;
  }
  .lab-editor-row {
    grid-template-columns: 1fr;
    border-bottom: var(--hairline);
    padding-bottom: 0.75rem;
  }
  #patient-modal .modal-header,
  #patient-modal .modal-body,
  .modal-footer {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* Print Layout (Passômetro / Passagem de Plantão - Margens de 1 cm) */
@page {
  size: A4 portrait;
  margin: 1cm;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 1cm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 9.5pt;
  }

  .no-print,
  .app-header .header-actions,
  .dashboard-tabs,
  .toolbar,
  .card-actions,
  .kpi-strip {
    display: none !important;
  }

  .app-header {
    position: static;
    background: #ffffff !important;
    color: #000000 !important;
    border-bottom: 1.5px solid #000000;
    padding: 0 0 6px 0;
    box-shadow: none;
    margin-bottom: 10px;
  }

  .brand-icon {
    display: none;
  }

  .brand-subtitle {
    color: #334155 !important;
  }

  .main-container,
  .dashboard-nav-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .sector-banner {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #0f172a !important;
    padding: 6px 10px;
    margin-bottom: 8px;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .patient-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    margin-bottom: 10px;
  }

  .patient-header {
    padding: 6px 10px;
    background: #f8fafc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .patient-body {
    padding: 8px 10px;
    gap: 6px;
  }

  .field-box {
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
  }

  .lab-table th,
  .lab-table td {
    padding: 3px 6px;
    font-size: 8.5pt;
  }
}

/* Modo Outros (Consulta / Sem Edição) */
body.role-viewer .card-actions {
  display: none !important;
}
body.role-viewer button[onclick*="abrirModalPaciente"],
body.role-viewer button[onclick*="abrirModalRapidoLab"],
body.role-viewer button[onclick*="excluirPaciente"],
body.role-viewer button[onclick*="restaurarDadosExemplo"] {
  display: none !important;
}
/* ================= BALANCO HIDRICO DIARIO & DIURESE 24H SECTION ================= */
.bh-section {
  grid-column: span 12;
  background: var(--bg-card);
  border: 1.5px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 0.35rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.bh-header {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08) 0%, rgba(14, 165, 233, 0.03) 100%);
  padding: 0.75rem 1.05rem;
  border-bottom: 1px solid rgba(2, 132, 199, 0.16);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bh-header-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0369a1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bh-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
  padding: 0.95rem 1.05rem;
  background: var(--bg-card);
}

.bh-metric-card {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.2s ease;
}

/* Destaque 1: Diurese de 24 horas */
.bh-metric-card.diurese-highlight {
  background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1.5px solid #38bdf8;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.12);
}

/* Destaque 2: Balanco Hidrico Diario */
.bh-metric-card.bh-highlight-negativo {
  background: linear-gradient(145deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px solid #4ade80;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.12);
}

.bh-metric-card.bh-highlight-positivo {
  background: linear-gradient(145deg, #f8fafc 0%, #eff6ff 100%);
  border: 1.5px solid #60a5fa;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
}

.bh-metric-card.bh-highlight-alerta {
  background: linear-gradient(145deg, #fff7ed 0%, #ffedd5 100%);
  border: 1.5px solid #fb923c;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.12);
}

.bh-metric-card.detalhes-highlight {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.bh-metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.diurese-highlight .bh-metric-label { color: #0369a1; }
.bh-highlight-negativo .bh-metric-label { color: #15803d; }
.bh-highlight-positivo .bh-metric-label { color: #1d4ed8; }
.bh-highlight-alerta .bh-metric-label { color: #c2410c; }
.detalhes-highlight .bh-metric-label { color: var(--text-secondary); }

.bh-metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.bh-metric-number {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.diurese-highlight .bh-metric-number { color: #0284c7; }
.bh-highlight-negativo .bh-metric-number { color: #16a34a; }
.bh-highlight-positivo .bh-metric-number { color: #2563eb; }
.bh-highlight-alerta .bh-metric-number { color: #ea580c; }
.detalhes-highlight .bh-metric-number { color: var(--text-main); font-size: 1.15rem; }

.bh-metric-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.bh-metric-footer {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 0.3rem;
  padding-top: 0.35rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.bh-status-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.pill-diurese-normal { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.pill-diurese-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.pill-diurese-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.pill-diurese-polyuria { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

.pill-bh-negativo { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.pill-bh-positivo { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.pill-bh-alerta { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.pill-bh-neutro { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* Interactive Calculator inside Quick Modal */
.bh-calculator-preview {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 0.35rem;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.bh-calc-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.bh-calc-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
}

.bh-calc-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.bh-calc-val-final {
  font-size: 1.45rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #0284c7;
}

.bh-calc-divider {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-muted);
}

.highlight-calc-final {
  background: #ffffff;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid #38bdf8;
  box-shadow: 0 2px 4px rgba(14, 165, 233, 0.08);
}

.bh-input-highlight-in {
  border-color: #7dd3fc !important;
  background-color: #f0f9ff !important;
}

.bh-input-highlight-diurese {
  border-color: #38bdf8 !important;
  background-color: #e0f2fe !important;
  font-weight: 700 !important;
  color: #0369a1 !important;
}

.badge-mini-calc {
  font-size: 0.72rem;
  font-weight: 700;
  background: #0284c7;
  color: #ffffff;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

/* History table */
.bh-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.bh-history-table th,
.bh-history-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: var(--hairline);
  text-align: left;
}

.bh-history-table th {
  background: var(--bg-subtle);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.bh-history-table tr:hover td {
  background: var(--bg-subtle);
}

/* Badges for summary table */
.table-bh-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.table-diurese-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

/* Hide action buttons in read-only mode (global viewer or per-patient specialty reader) */
body.role-viewer button[onclick*="abrirModalRapidoBH"],
body.role-viewer button[onclick*="excluirBalancoHidrico"],
.patient-card.card-readonly .card-actions,
.patient-card.card-readonly button[onclick*="abrirModalRapidoBH"],
.patient-card.card-readonly button[onclick*="excluirBalancoHidrico"],
.patient-card.card-readonly button[onclick*="abrirModalRapidoLab"],
.patient-card.card-readonly button[onclick*="removerLinhaLabCard"],
.summary-row-readonly button[onclick*="abrirModalPaciente"] {
  display: none !important;
}

/* ================= EQUIPES MÉDICAS & ESPECIALIDADES (APPLE HIG) ================= */
.medical-team-bar {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
  border: var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.medical-team-bar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: var(--hairline);
}

.medico-active-profile {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.medico-avatar-pill {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #1d4ed8);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.medico-identity-details {
  display: flex;
  flex-direction: column;
}

.medico-identity-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.medico-identity-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.role-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.role-pill-admin {
  background: rgba(124, 58, 237, 0.14);
  color: #6d28d9;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.role-pill-chefe {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.role-pill-editor {
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
  border: 1px solid rgba(0, 113, 227, 0.28);
}

.role-pill-leitor {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border: 1px solid rgba(13, 148, 136, 0.28);
}

.role-pill-pendente {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.specialty-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.specialty-filter-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.specialty-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-grouped-secondary);
  color: var(--text-secondary);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s var(--ease-apple);
}

.specialty-pill-btn:hover {
  background: rgba(0, 113, 227, 0.08);
  color: var(--text-main);
}

.specialty-pill-btn.active {
  background: var(--text-main);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.specialty-pill-btn .sp-role-dot {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: #1d1d1f;
  font-weight: 700;
}

.specialty-pill-btn.active .sp-role-dot {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.specialty-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.specialty-check-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-subtle);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.18s var(--ease-apple);
}

.specialty-check-card:hover {
  border-color: #0071e3;
  background: #ffffff;
}

.specialty-check-card.checked {
  border-color: #0071e3;
  background: rgba(0, 113, 227, 0.07);
  color: #0071e3;
}

.admin-specialty-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}

.admin-specialty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.8rem;
}

.specialty-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.8rem;
}

.specialty-admin-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow-xs);
}

.patient-specialty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  border: 1px solid rgba(0, 113, 227, 0.22);
}

.patient-access-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 700;
}

.patient-access-editor {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.patient-access-leitor {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

/* Modo Minimizado do Quadro Equipe / Especialidade */
.medical-team-bar {
  transition: all 0.22s var(--ease-apple);
}

.medical-team-bar.is-minimized {
  padding: 0.45rem 0.95rem;
  margin-bottom: 0.75rem;
  border-radius: 14px;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.medical-team-bar.is-minimized .medical-team-bar-top {
  padding-bottom: 0;
  border-bottom: none;
  gap: 0.5rem;
  flex: 1 1 auto;
}

.medical-team-bar.is-minimized .medico-avatar-pill {
  width: 28px;
  height: 28px;
  font-size: 0.8rem;
}

.medical-team-bar.is-minimized .medico-identity-name {
  font-size: 0.84rem;
}

.medical-team-bar.is-minimized .medico-identity-sub {
  display: none;
}

.medical-team-bar.is-minimized .specialty-pills-row {
  width: auto;
  padding-left: 0.65rem;
  border-left: var(--hairline);
}

.specialty-minimized-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.specialty-compact-select {
  appearance: auto;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-grouped-secondary);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  max-width: 280px;
  transition: all 0.18s var(--ease-apple);
}

.specialty-compact-select:hover,
.specialty-compact-select:focus {
  border-color: #0071e3;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.specialty-expand-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  border: 1px solid rgba(0, 113, 227, 0.24);
  cursor: pointer;
  transition: all 0.18s var(--ease-apple);
}

.specialty-expand-pill:hover {
  background: rgba(0, 113, 227, 0.18);
}

.specialty-expand-pill:active,
.team-bar-minimize-btn:active {
  transform: scale(0.975);
}

.specialty-checkbox-grid.is-minimized {
  display: none !important;
}

@media (max-width: 900px) {
  .medical-team-bar.is-minimized .specialty-pills-row {
    width: 100%;
    padding-left: 0;
    border-left: none;
    padding-top: 0.35rem;
    border-top: var(--hairline);
  }
}

/* ================= QUADRO DO PACIENTE MINIMIZADO (LINK DO NOME + EDIÇÃO) ================= */
.patients-list {
  gap: 0.7rem;
}

.patient-name-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #0071e3;
  padding: 0.25rem 0.5rem;
  margin-left: -0.35rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s var(--ease-apple);
}

.patient-name-link .patient-name {
  color: #0071e3;
  text-decoration: underline;
  text-decoration-color: rgba(0, 113, 227, 0.35);
  text-underline-offset: 3px;
  font-size: 1.08rem;
  font-weight: 700;
}

.patient-name-link:hover {
  background: rgba(0, 113, 227, 0.08);
}

.patient-name-link:hover .patient-name {
  color: #005bb5;
  text-decoration-color: #005bb5;
}

.patient-name-link:active {
  transform: scale(0.98);
}

.patient-expand-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
  font-size: 0.7rem;
  font-weight: 800;
  transition: transform 0.2s var(--ease-apple), background 0.2s var(--ease-apple);
}

.patient-expanded-only-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.patient-card.is-minimized {
  border-radius: 14px;
}

.patient-card.is-minimized .patient-header {
  padding: 0.65rem 1.15rem;
  border-bottom: none;
}

.patient-card.is-minimized .patient-body,
.patient-card.is-minimized .patient-expanded-only-meta,
.patient-card.is-minimized .patient-expanded-only-btn {
  display: none !important;
}

.patient-card.is-expanded {
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-md);
}

@media print {
  .patient-card.is-minimized .patient-body {
    display: grid !important;
  }
  .patient-card.is-minimized .patient-expanded-only-meta {
    display: inline-flex !important;
  }
}

/* ================= CONTROLE DE SAÍDA DO PACIENTE (ALTA, ÓBITO, MUDANÇA, OUTRA) ================= */
.saida-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.24rem 0.72rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.saida-badge-alta {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.32);
}

.saida-badge-obito {
  background: rgba(30, 41, 59, 0.14);
  color: #1e293b;
  border: 1px solid rgba(30, 41, 59, 0.35);
}

.saida-badge-mudanca {
  background: rgba(0, 113, 227, 0.14);
  color: #005bb5;
  border: 1px solid rgba(0, 113, 227, 0.32);
}

.saida-badge-outra {
  background: rgba(217, 119, 6, 0.15);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.34);
}

.field-box.highlight-saida {
  background: #f0fdf4;
  border-color: #86efac;
}

.field-box.highlight-saida-obito {
  background: #f8fafc;
  border-color: #94a3b8;
}

.field-box.highlight-saida-mudanca {
  background: #eff6ff;
  border-color: #93c5fd;
}

.field-box.highlight-saida-outra {
  background: #fffbeb;
  border-color: #fcd34d;
}

body.role-viewer button[onclick*="abrirModalSaidaPaciente"],
.patient-card.card-readonly button[onclick*="abrirModalSaidaPaciente"] {
  display: none !important;
}



/* ==========================================================================
   DARK MODE OVERRIDES (APPLE HIG DEEP SLATE)
   ========================================================================== */
[data-theme="dark"],
html.dark,
body.dark {
  --bg-body: #090d16;
  --bg-card: #111827;
  --bg-subtle: #1e293b;
  --bg-grouped-secondary: #172033;
  --bg-glass: rgba(17, 24, 39, 0.85);
  --bg-glass-heavy: rgba(17, 24, 39, 0.95);
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --hairline: 1px solid rgba(255, 255, 255, 0.08);
  --cti-surface-tint: #1c1318;
  --ward-surface-tint: #0f172a;
}

/* ==========================================================================
   BARRA DO CALENDÁRIO DE PLANTÃO & HISTÓRICO TEMPORAL (APPLE HIG)
   ========================================================================== */
.passometro-calendar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 18px;
  margin-bottom: 14px;
  background: var(--bg-card);
  border: var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.calendar-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.calendar-badge-icon {
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(0, 113, 227, 0.08);
  border: 1px solid rgba(0, 113, 227, 0.18);
}

.calendar-title-group {
  display: flex;
  flex-direction: column;
}

.calendar-label-sup {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calendar-date-display {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.calendar-status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calendar-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.calendar-status-pill.status-hoje {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52, 199, 89, 0.3);
}

.calendar-status-pill.status-passado {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(255, 149, 0, 0.35);
}

.calendar-status-pill.status-futuro {
  background: var(--indigo-bg);
  color: var(--indigo);
  border: 1px solid rgba(88, 86, 214, 0.35);
}

.calendar-copiado-badge {
  font-size: 11px;
  font-weight: 600;
  color: #0284c7;
  background: rgba(2, 132, 199, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(2, 132, 199, 0.25);
}

.calendar-bar-center {
  display: flex;
  align-items: center;
}

.calendar-nav-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--bg-grouped-secondary);
  border-radius: var(--radius-pill);
  border: var(--hairline);
}

.btn-cal-nav,
.btn-cal-today {
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s var(--ease-apple);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.btn-cal-nav:hover,
.btn-cal-today:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-main);
}

[data-theme="dark"] .btn-cal-nav:hover,
[data-theme="dark"] .btn-cal-today:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-cal-nav:active,
.btn-cal-today:active {
  transform: scale(0.96);
}

.btn-cal-today {
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 700;
  color: var(--ward-primary);
  border: var(--hairline);
}

.calendar-picker-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.calendar-input-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border: var(--hairline);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.15s ease;
}

.calendar-input-trigger:hover {
  border-color: var(--ward-primary);
  color: var(--ward-primary);
}

.calendar-native-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.calendar-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-cal-action {
  appearance: none;
  border: var(--hairline);
  background: var(--bg-grouped-secondary);
  color: var(--text-main);
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease-apple);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-cal-action:hover {
  background: var(--bg-subtle);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .btn-cal-action:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-cal-action:active {
  transform: scale(0.97);
}

.btn-cal-action-recopiar {
  color: #0369a1;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.22);
}

.btn-cal-action-recopiar:hover {
  background: rgba(2, 132, 199, 0.16);
  border-color: rgba(2, 132, 199, 0.35);
}

/* Modal de Histórico de Plantões */
.modal-historico-card {
  max-width: 860px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal-historico-body {
  overflow-y: auto;
  max-height: calc(88vh - 140px);
  padding: 16px 20px;
}

.historico-top-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-grouped-secondary);
  border-radius: var(--radius-sm);
  border: var(--hairline);
  margin-bottom: 16px;
}

.historico-summary-pill {
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.historico-summary-pill strong {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.historico-dias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.historico-dia-card {
  background: var(--bg-card);
  border: var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s var(--ease-apple);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}

.historico-dia-card:hover {
  border-color: var(--ward-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.historico-dia-card.dia-card-ativo {
  border: 2px solid var(--ward-primary);
  background: var(--ward-primary-light);
}

.dia-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.dia-card-date {
  display: flex;
  flex-direction: column;
}

.dia-card-date strong {
  font-size: 15px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.dia-card-extenso {
  font-size: 11px;
  color: var(--text-muted);
}

.dia-card-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.dia-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.dia-tag.tag-hoje {
  background: var(--success-bg);
  color: var(--success);
}

.dia-tag.tag-ativo {
  background: var(--ward-primary);
  color: #fff;
}

.dia-tag.tag-copia {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
}

.dia-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-grouped-secondary);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
}

.dia-metric-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dia-metric-label {
  color: var(--text-secondary);
}

.dia-metric-val strong {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.dia-card-footer {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
}

.historico-empty-msg {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  grid-column: 1 / -1;
}

/* Utilidades de Exibição e Login */
.hidden {
  display: none !important;
}

.pep-login-divider-toggle {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.pep-login-divider-toggle:hover span {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

