/**
 * Método NES Care — Painel Farmacêutico v2 (layout aprovado)
 */
:root {
  --blue-900: #0C3B6E;
  --blue-700: #0A5578;
  --blue-teal: #0A6E78;
  --blue-teal-2: #0D8070;
  --blue-400: #378ADD;
  --blue-50: #EFF5FC;
  --blue-100: #B5D4F4;
  --blue-800: #185FA5;
  --teal-end: #1D9E75;
  --teal-sidebar: #128A6A;
  --teal-600: #0F6E56;
  --teal-100: #C8EBE0;
  --teal-50: #EEF8F4;
  --teal-accent: #9FE1CB;
  --page-bg: #EFF3F1;
  --gray-50: #F8F9F9;
  --gray-100: #EDEEED;
  --gray-200: #D4D6D4;
  --gray-400: #8F9290;
  --gray-700: #4A4D4B;
  --gray-900: #1E201F;
  --gold-50: #FBF4E8;
  --gold-100: #F0D08A;
  --gold-700: #7A4E0C;
  --danger-50: #FDF4F4;
  --danger-100: #F0BDBD;
  --danger-700: #8B2121;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 14px rgba(12, 59, 110, 0.07);
  --shadow-soft: 0 2px 8px rgba(12, 59, 110, 0.06);
  --shadow-focus: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

#app-screen {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--gray-900);
}

/* ─── TOPBAR ─── */
#app-screen .farm-hero.painel-header.topbar,
#app-screen .nes-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  height: 64px;
  min-height: 64px;
  padding: 0;
  background: linear-gradient(105deg, #0C3B6E 0%, #0A5578 20%, #0A6E78 42%, #0D8070 65%, #1D9E75 100%);
  border: none;
  box-shadow: var(--shadow-soft);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app-screen .farm-hero-inner {
  height: 64px;
  width: 100%;
  max-width: none;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#app-screen .farm-hero-inner > svg:nth-of-type(1) {
  display: none;
}

#app-screen .farm-hero-inner > .mobile-menu-btn {
  flex-shrink: 0;
}

#app-screen .nes-topbar-center {
  flex: 1;
  text-align: center;
  min-width: 0;
}

#app-screen .farm-hero h1,
#app-screen .nes-topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

#app-screen .farm-hero p#farm-nome-logado,
#app-screen .nes-topbar-sub {
  margin: 0;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

#app-screen .farm-hero-actions.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

#app-screen .topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#app-screen .topbar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ─── LAYOUT ─── */
#app-screen .farm-layout.layout.app,
#app-screen .nes-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
  background: var(--page-bg);
}

#app-screen .farm-main.main-content,
#app-screen .nes-main {
  background: var(--page-bg);
  padding: 20px 24px 160px;
  overflow-y: auto;
  min-height: calc(100vh - 64px);
  height: auto;
  max-height: none;
}

/* ─── SIDEBAR (layout aprovado) ─── */
#app-screen .farm-sidebar.sidebar,
#app-screen .nes-sidebar {
  width: 280px;
  min-width: 280px;
  background: linear-gradient(180deg, #0b4a6f 0%, #0f766e 100%);
  color: #fff;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── NUCLEAR: força branco em TUDO dentro da sidebar ── */
#farm-sidebar,
#farm-sidebar *,
.farm-sidebar.sidebar,
.farm-sidebar.sidebar * {
  color: #fff !important;
}

/* Exceção: inputs e selects mantêm contraste próprio */
#farm-sidebar input,
#farm-sidebar select,
.farm-sidebar.sidebar input,
.farm-sidebar.sidebar select {
  color: #fff !important;
  background: rgba(0, 0, 0, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

/* ── Títulos de seção ── */
.nes-sidebar-block-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.88) !important;
  opacity: 1;
  margin: 0 0 6px 4px;
  font-weight: 700;
}

/* ── Logo ── */
.nes-sidebar-logo {
  text-align: center;
  padding: 8px 4px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 8px;
}
.nes-sidebar-logo strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nes-sidebar-logo span {
  font-size: 0.62rem;
  opacity: 0.85;
}

/* ── Blocos ── */
.nes-sidebar-block {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}
.nes-sidebar-block:last-of-type {
  border-bottom: none;
}

/* ── Botões de navegação ── */
#app-screen .sidebar-dash-btn,
#farm-sidebar .sidebar-dash-btn {
  width: 100%;
  margin: 0 0 4px;
  padding: 0.5rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff !important;
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
#app-screen .sidebar-dash-btn svg,
#farm-sidebar .sidebar-dash-btn svg {
  flex-shrink: 0;
  opacity: 0.95;
  stroke: #fff;
}
#app-screen .sidebar-dash-btn:hover,
#app-screen .nes-sidebar-quick-btn:hover,
#farm-sidebar .sidebar-dash-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
#app-screen .sidebar-dash-btn.active,
#app-screen .nes-sidebar-quick-btn.active,
#farm-sidebar .sidebar-dash-btn.active {
  background: rgba(255, 255, 255, 0.22);
  border-left: 3px solid #fff;
  color: #fff !important;
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.1);
}

/* ── Atalhos rápidos ── */
.nes-sidebar-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.nes-sidebar-quick-btn {
  padding: 0.4rem 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff !important;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.nes-sidebar-quick-btn .q-icon {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 1px;
}

#app-screen .sidebar-search input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 0.74rem;
}

#app-screen .sidebar-search input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#app-screen .sidebar-paciente-ativo,
#farm-sidebar .sidebar-paciente-ativo {
  margin: 0 0 8px;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(159, 225, 203, 0.18);
  border: 1px solid rgba(159, 225, 203, 0.35);
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.9) !important;
}
#app-screen .sidebar-paciente-ativo strong,
#farm-sidebar .sidebar-paciente-ativo strong {
  color: #fff !important;
  font-size: 0.75rem;
}

#app-screen .paciente-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  max-height: none;
}

#app-screen .sidebar-pacientes-section,
#app-screen .sidebar-pacientes-section .paciente-list,
#app-screen .sidebar-pacientes-section #pacientesRecentes,
#app-screen #nes-ver-todos-pacientes {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  flex: 0 0 0 !important;
}

#app-screen .patient-item {
  width: 100%;
  text-align: left;
  padding: 0.45rem 6px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 0.45rem;
  align-items: center;
}

#app-screen .patient-item:hover,
#app-screen .patient-item.active {
  background: rgba(255, 255, 255, 0.12);
}

.patient-item-body strong,
.patient-item-text strong {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-item-body span,
.patient-item-text span {
  display: block;
  font-size: 0.62rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-item-text {
  min-width: 0;
}

.patient-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  position: relative;
}

.patient-avatar-sm .active-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-accent);
  border: 2px solid var(--teal-sidebar);
}

.nes-btn-ver-todos {
  width: 100%;
  margin-top: 6px;
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

/* ─── CARDS BASE ─── */
.nes-card {
  background: #fff;
  border: 0.5px solid rgba(93, 202, 165, 0.28);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ─── BARRA PACIENTE (única oficial) ─── */
#paciente-ativo-bar.nes-patient-bar,
#paciente-ativo-bar.patient-bar,
#nes-patient-bar.nes-patient-bar,
#nes-patient-bar.patient-bar {
  display: none;
}

#paciente-ativo-bar.visible,
#nes-patient-bar.visible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  max-height: 160px;
  min-height: 0;
  flex-shrink: 0;
  overflow: hidden;
}

/* Barra legada do prontuário — oculta (dados preservados no DOM) */
#prontuario-clinico-bar.nes-barra-legada-oculta,
.pront-clinico-bar.nes-barra-legada-oculta {
  display: none !important;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Evita terceiro card duplicado na sidebar quando a barra principal está ativa */
body.nes-paciente-bar-ativa #sidebar-paciente-ativo {
  display: none !important;
}

.nes-patient-bar .patient-bar-inner,
#paciente-ativo-bar .patient-bar-inner,
#nes-patient-bar .patient-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: nowrap;
  width: 100%;
  min-height: 0;
  max-height: 140px;
  overflow: hidden;
}

.patient-bar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-400), var(--teal-end));
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.patient-bar-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.patient-bar-info h3 {
  margin: 0 0 0.1rem;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.74rem;
  color: var(--gray-700);
}

.patient-bar-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  margin-top: 0.15rem;
  max-height: 22px;
  overflow: hidden;
}

.patient-bar-tag,
.nes-badge-ok {
  font-size: 0.65rem;
  padding: 0.12rem 0.45rem;
  border-radius: 99px;
  background: var(--teal-50);
  color: var(--teal-600);
  border: 1px solid var(--teal-100);
}

.patient-bar-actions,
.patient-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

#paciente-ativo-bar .patient-bar-inner {
  width: 100%;
  justify-content: space-between;
}

#paciente-ativo-bar .patient-bar-actions {
  flex-shrink: 0;
}

/* ─── DASHBOARD ─── */
#dashboard-view {
  padding: 0 !important;
}

.dash-header h2 {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.dash-header p {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--gray-400);
}

.nes-stats-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

/* Linha superior premium (cards dashboard, módulos, agenda) */
#app-screen .stat-card.nes-card,
#app-screen .nes-agenda-card.nes-card,
#app-screen #metodo-nes-view .nes-module-card,
#app-screen #dash-module-grid .nes-module-card,
#app-screen .dash-panel-card {
  background: #ffffff;
  border: 1px solid #d8e6e2;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(11, 74, 111, 0.08);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

#app-screen .stat-card.nes-card::before,
#app-screen .nes-agenda-card.nes-card::before,
#app-screen #metodo-nes-view .nes-module-card::before,
#app-screen #dash-module-grid .nes-module-card::before,
#app-screen .dash-panel-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, #0b4a6f, #16a085);
  z-index: 1;
}

.stat-card {
  padding: 1rem 1.1rem;
}

#app-screen .stat-card.nes-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(11, 74, 111, 0.14);
  border-color: #16a085;
}

.stat-card-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
}

.stat-card-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--blue-900);
}

.stat-card-icon {
  float: right;
  font-size: 1.1rem;
}

/* ─── AGENDA ─── */
.nes-agenda-card {
  padding: 20px 22px;
  margin-bottom: 18px;
  border-radius: 20px !important;
}

#app-screen .nes-agenda-card.nes-card:hover {
  border-color: #16a085;
  box-shadow: 0 12px 28px rgba(11, 74, 111, 0.12);
}

.nes-agenda-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.nes-agenda-card-head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.nes-agenda-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.nes-agenda-tab {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.nes-agenda-tab.active {
  background: var(--teal-50);
  border-color: var(--teal-100);
  color: var(--teal-600);
}

.nes-agenda-list-wrap {
  max-height: 380px;
  overflow-y: auto;
}

.nes-agenda-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.nes-agenda-row:last-child {
  border-bottom: none;
}

.nes-agenda-row--vencido {
  background: var(--danger-50);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: var(--radius-sm);
}

.nes-agenda-row--prox3 {
  background: var(--gold-50);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: var(--radius-sm);
}

.nes-agenda-row-time {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue-900);
}

.nes-agenda-row-body strong {
  display: block;
  font-size: 0.78rem;
}

.nes-agenda-row-body span {
  font-size: 0.7rem;
  color: var(--gray-700);
}

.nes-agenda-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.nes-agenda-row-actions .btn,
.nes-agenda-row-actions button {
  font-size: 0.65rem !important;
  padding: 0.2rem 0.45rem !important;
}

/* ─── MÓDULOS ─── */
.dash-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0 0 10px;
}

.nes-module-grid,
.module-grid,
.metodo-nes-grid,
#metodo-nes-grid,
#dash-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 18px;
}

/* Cards hub Método NES */
#app-screen #metodo-nes-view .nes-module-card {
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 200px;
}

#app-screen #metodo-nes-view .nes-module-card:hover {
  transform: translateY(-4px);
  border-color: #16a085;
  box-shadow: 0 14px 32px rgba(11, 74, 111, 0.16);
}

#app-screen #metodo-nes-view .nes-module-card .nes-mod-icon {
  font-size: 28px;
  margin-bottom: 16px;
  display: block;
  line-height: 1;
}

#app-screen #metodo-nes-view .nes-module-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0b2f4a;
  margin: 0 0 6px;
  line-height: 1.35;
}

#app-screen #metodo-nes-view .nes-module-card p {
  font-size: 14px;
  line-height: 1.5;
  color: #546b7a;
  margin: 0 0 14px;
  flex: 1;
}

#app-screen #metodo-nes-view .nes-module-card.nes-mod-ready {
  border-left: none;
}

/* Cards módulos no dashboard (render JS) */
#app-screen #dash-module-grid .nes-module-card {
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 200px;
}

#app-screen #dash-module-grid .nes-module-card:hover {
  transform: translateY(-4px);
  border-color: #16a085;
  box-shadow: 0 14px 32px rgba(11, 74, 111, 0.16);
}

#app-screen #dash-module-grid .nes-module-card .mod-icon,
#app-screen #dash-module-grid .nes-module-card .nes-mod-icon {
  font-size: 28px;
  margin-bottom: 16px;
  display: block;
}

#app-screen #dash-module-grid .nes-module-card h4,
#app-screen #dash-module-grid .nes-module-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0b2f4a;
  margin: 0 0 6px;
}

#app-screen #dash-module-grid .nes-module-card p {
  font-size: 14px;
  line-height: 1.5;
  color: #546b7a;
  margin: 0 0 12px;
  flex: 1;
}

#app-screen #dash-module-grid .nes-module-card .mod-body {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dash-module-badge,
.nes-module-badge,
#app-screen .nes-badge,
#app-screen #dash-module-grid .nes-badge,
#app-screen #metodo-nes-view .nes-badge {
  background: #e6f7f2;
  color: #0f766e;
  border: 1px solid #bfe8dd;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  margin-bottom: 12px;
}

/* Botão Abrir — hub e dashboard */
#app-screen .nes-mod-btn-abrir,
#app-screen #metodo-nes-view .nes-module-card .btn-primary,
#app-screen #dash-module-grid .nes-module-card .nes-btn-primary {
  background: linear-gradient(135deg, #0b4a6f, #16a085);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 9px 22px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 6px 14px rgba(22, 160, 133, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: auto;
  align-self: flex-start;
}

#app-screen .nes-mod-btn-abrir:hover,
#app-screen #metodo-nes-view .nes-module-card .btn-primary:hover,
#app-screen #dash-module-grid .nes-module-card .nes-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(22, 160, 133, 0.35);
  color: #fff;
}

/* ─── BOTÕES ─── */
.nes-btn-primary {
  background: linear-gradient(135deg, var(--teal-end), var(--teal-600));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 500;
  cursor: pointer;
}

.nes-btn-secondary {
  background: #fff;
  color: var(--blue-800);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ─── BADGES ─── */
.nes-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
}

.nes-badge-info {
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid var(--blue-100);
}

.nes-badge-warning,
.nes-agenda-status--proximo {
  background: var(--gold-50);
  color: var(--gold-700);
  border: 1px solid var(--gold-100);
}

.nes-badge-danger,
.nes-agenda-status--vencido {
  background: var(--danger-50);
  color: var(--danger-700);
  border: 1px solid var(--danger-100);
}

.nes-badge-ok,
.nes-agenda-status--realizado {
  background: var(--teal-50);
  color: var(--teal-600);
  border: 1px solid var(--teal-100);
}

/* ─── RODAPÉ ─── */
.nes-footer-grid,
.dash-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.dash-panel-card {
  background: #fff;
  border: 0.5px solid rgba(93, 202, 165, 0.28);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.dash-panel-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 700;
  font-size: 0.82rem;
}

.dash-panel-body {
  padding: 0.75rem 1rem;
}

.nes-progress,
.adesao-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--gray-100);
  overflow: hidden;
}

.nes-progress-fill,
.adesao-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1D9E75, #378ADD);
}

.adesao-row {
  margin-bottom: 0.7rem;
}

.adesao-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.activity-row {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.74rem;
}

/* Método NES hub */
#metodo-nes-view {
  padding: 0 !important;
  background: var(--page-bg);
}

#metodo-nes-view .nes-module-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

#metodo-nes-view .nes-module-card {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  padding: 14px;
}

#nes-agenda-hub.nes-card {
  margin-bottom: 14px;
}

/* ─── RESPONSIVO ─── */
@media (max-width: 1100px) {
  .nes-stats-grid,
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .nes-module-grid,
  .module-grid,
  #dash-module-grid,
  #metodo-nes-view .nes-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  #app-screen .farm-main,
  #app-screen .nes-main {
    padding: 14px;
  }

  #paciente-ativo-bar.visible,
  #nes-patient-bar.visible {
    flex-direction: column;
    align-items: flex-start;
  }

  #paciente-ativo-bar .patient-bar-actions {
    width: 100%;
  }

  #paciente-ativo-bar .patient-bar-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .nes-stats-grid,
  .stats-grid,
  .nes-module-grid,
  .module-grid,
  .nes-footer-grid,
  .dash-footer-grid {
    grid-template-columns: 1fr;
  }

  .nes-module-card,
  .dash-module-card {
    grid-template-columns: 36px 1fr;
  }

  .nes-module-card .btn,
  .dash-module-card .btn {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
  }

  .patient-bar-actions .btn,
  .nes-agenda-row-actions .btn,
  button.nes-btn-primary,
  button.nes-btn-secondary {
    width: 100%;
    min-height: 44px;
  }
}

/* ─── BOTÃO HOME (sidebar) ─── */
#farm-sidebar .nes-sidebar-home-btn,
#app-screen .nes-sidebar-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.55rem 0.5rem;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.15);
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background .15s;
}
#farm-sidebar .nes-sidebar-home-btn:hover,
#app-screen .nes-sidebar-home-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
#farm-sidebar .nes-sidebar-home-btn svg,
#app-screen .nes-sidebar-home-btn svg {
  flex-shrink: 0;
  stroke: #fff;
}

/* ─── PÁGINA SERVIÇOS E FORMULÁRIOS ─── */
#servicos-formularios-view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-8);
}
#servicos-formularios-view.active,
#servicos-formularios-view.visible {
  display: block;
}

.sf-header {
  margin-bottom: 1.5rem;
}
.sf-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy-900, #0f172a);
  margin: 0 0 0.25rem;
}
.sf-header p {
  font-size: 0.84rem;
  color: var(--navy-500, #64748b);
  margin: 0;
}
.sf-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1.5px solid var(--navy-200, #e2e8f0);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.sf-search-bar svg { flex-shrink: 0; color: var(--navy-400, #94a3b8); }
.sf-search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--navy-900, #0f172a);
  background: transparent;
}
.sf-search-bar input::placeholder { color: var(--navy-400, #94a3b8); }

.sf-category {
  margin-bottom: 2rem;
}
.sf-category-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--navy-500, #64748b);
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--navy-100, #f1f5f9);
}
.sf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.sf-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 0.75rem 0.9rem;
  background: #fff;
  border: 1.5px solid var(--navy-100, #e2e8f0);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.sf-card:hover {
  border-color: #0b4a6f;
  box-shadow: 0 4px 16px rgba(11,74,111,0.12);
  transform: translateY(-2px);
}
.sf-card[data-sf-hidden="1"] { display: none; }
.sf-card-icon {
  font-size: 1.75rem;
  line-height: 1;
}
.sf-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy-800, #1e293b);
  line-height: 1.25;
}
.sf-card-desc {
  font-size: 0.66rem;
  color: var(--navy-400, #94a3b8);
  line-height: 1.3;
}
.sf-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--navy-200, #e2e8f0);
  background: #fff;
  color: var(--navy-700, #334155);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s;
}
.sf-back-btn:hover { background: var(--navy-50, #f8fafc); }

@media (max-width: 760px) {
  #servicos-formularios-view {
    padding: 1rem;
  }
  .sf-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* ── Card Próximo Atendimento ───────────────────────────────────────────── */
#dash-proximo-atend-card .nes-agenda-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
#dash-proximo-atend-card .nes-agenda-card-head h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy-700, #334155);
  margin: 0;
}

.npa-body { padding: .25rem 0; }

.npa-vazio {
  color: var(--gray-400, #94a3b8);
  font-size: .875rem;
  padding: .5rem 0;
  margin: 0;
}

.npa-dados {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .35rem .75rem;
  margin-bottom: 1rem;
}

.npa-linha {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.npa-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-400, #94a3b8);
}

.npa-valor {
  font-size: .9rem;
  color: var(--navy-800, #1e293b);
  font-weight: 500;
}

.npa-nome {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-900, #0f172a);
}

.npa-acoes {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.npa-btn-wa {
  text-decoration: none;
}

@media (max-width: 600px) {
  .npa-dados { grid-template-columns: 1fr 1fr; }
  .npa-acoes { flex-direction: column; }
  .npa-acoes .btn { width: 100%; justify-content: center; }
}

/* ── Banner LGPD ──────────────────────────────────────────────────────── */
#nes-lgpd-banner,
.nes-banner-lgpd,
.nes-consentimento-alerta.erro {
  background: #8b0000 !important;
  color: #ffffff !important;
  border: 2px solid #ffb4b4 !important;
}

#nes-lgpd-banner *,
.nes-banner-lgpd *,
.nes-consentimento-alerta.erro * {
  color: #ffffff !important;
}

#nes-lgpd-banner p,
.nes-banner-lgpd p,
.nes-consentimento-alerta.erro p {
  color: #ffd5d5 !important;
}

#nes-lgpd-banner button:first-of-type,
.nes-banner-lgpd .btn-lgpd-primary {
  background: #ffffff !important;
  color: #8b0000 !important;
  font-weight: 700 !important;
  border: none !important;
}

#nes-lgpd-banner button:first-of-type:hover,
.nes-banner-lgpd .btn-lgpd-primary:hover {
  background: #ffe5e5 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   A11Y — Operação Polimento NES · Sprint 3 (Fatia Segura)  ·  2026-07-09
   Bloco puramente ADITIVO. NÃO altera layout estrutural, fluxo de navegação,
   conceito do Dashboard, Hub Clínico, banco, RLS, API, auth, Patient Store nem
   motor clínico. Nenhum componente legado é removido.
   Usa min-width/min-height: são RESTRIÇÕES e vencem qualquer height fixo
   definido depois na cascata, garantindo o alvo de toque sem tocar as regras
   originais. Escopo restrito a #app-screen (Dashboard + Painel Clínico).
   ═══════════════════════════════════════════════════════════════════════════ */

/* (2) Ocultar "Diagnóstico E2E" da interface de produção (controle de dev). */
#app-screen #btn-nes-e2e-diagnostico { display: none !important; }

/* (1) Alvos de toque >= 44px (WCAG 2.5.5). Só ampliam área clicável. */
#app-screen .topbar-icon-btn      { min-width: 44px; min-height: 44px; }
#app-screen .sidebar-hamburger    { min-width: 44px; min-height: 44px; }
#app-screen #btn-sidebar-home     { min-height: 44px; }
#app-screen #farm-sidebar .sidebar-dash-btn { min-height: 44px; }
#app-screen .nes-sidebar-quick-btn           { min-height: 44px; }
#app-screen #paciente-ativo-bar .btn         { min-height: 44px; }
#app-screen #nes-btn-trocar-paciente         { min-height: 44px; }
#app-screen #pront-quick-rail .btn           { min-height: 44px; }
#app-screen .nes-mod-btn-abrir               { min-height: 44px; }

/* (3) Foco visível por teclado (WCAG 2.4.7) — anel consistente e nítido.
       :focus-visible aparece só na navegação por teclado, sem poluir o mouse. */
#app-screen a:focus-visible,
#app-screen button:focus-visible,
#app-screen input:focus-visible,
#app-screen select:focus-visible,
#app-screen textarea:focus-visible,
#app-screen [tabindex]:focus-visible {
  outline: 3px solid #0f6e56;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Superfícies escuras (topbar em gradiente verde + sidebar): anel claro para
   contraste adequado sobre fundo escuro. */
#app-screen .farm-hero-actions .topbar-icon-btn:focus-visible,
#app-screen .sidebar-hamburger:focus-visible,
#app-screen #farm-sidebar button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}
