/* ============================================================================
   DOCLICK CONSULTORIO — Sistema de Diseño Editorial Clínico (v1.0)
   Hereda la identidad de Doclick v3 (#0D4A3A + #F7F5F2 + #C4956A)
   y se adapta dinámicamente al tema del médico activo (Dr. Vegas / Dra. Yurkys)
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #F6F4F0;
  --surface: #FFFFFF;
  --surface-2: #EFECE6;
  --surface-3: #E4E0D8;
  --ink: #0F1F1C;
  --muted: #5F6E68;
  --muted-light: #8C9A94;
  --brand: #0D4A3A;
  --brand-deep: #072E24;
  --brand-soft: #E6F0EC;
  --accent: #C4956A;
  --accent-soft: #F6ECE1;
  --danger: #B42318;
  --danger-bg: #FEF3F2;
  --danger-border: #FECDCA;
  --ok: #067647;
  --ok-bg: #ECFDF3;
  --warn: #B54708;
  --warn-bg: #FFFAEB;
  --info: #175CD3;
  --info-bg: #EFF8FF;
  --border: rgba(15, 31, 28, 0.09);
  --border-strong: rgba(15, 31, 28, 0.16);
  --shadow-sm: 0 1px 3px rgba(15, 31, 28, 0.05);
  --shadow-md: 0 8px 28px -8px rgba(15, 31, 28, 0.09);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: 'Playfair Display', Georgia, serif;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.mono { font-family: 'IBM Plex Mono', monospace; }
p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- LAYOUT GENERAL ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 262px 1fr;
  min-height: 100vh;
}

/* ---------- SIDEBAR EDITORIAL ---------- */
.sidebar {
  background: var(--brand);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 14px;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: #fff;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #16120E;
  display: grid;
  place-items: center;
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  font-size: 16px;
}
.brand-text strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-text span {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.7);
}

/* Tarjeta del Médico Activo */
.doc-switcher-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}
.doc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.doc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.doc-meta strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.2;
}
.doc-meta small {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin-top: 2px;
}
.doc-select {
  width: 100%;
  background: rgba(0,0,0,0.22);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12px;
  cursor: pointer;
}
.doc-select option { color: #111; background: #fff; }

/* Menú de navegación */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.nav-btn:hover {
  background: rgba(255,255,255,0.09);
  color: #fff;
}
.nav-btn.active {
  background: #fff;
  color: var(--brand);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}
.nav-btn .badge-count {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255,255,255,0.16);
  color: inherit;
}
.nav-btn.active .badge-count {
  background: var(--brand-soft);
  color: var(--brand);
}
.nav-btn.hidden-by-role { display: none !important; }

.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.72);
}
.sidebar-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); }

/* ---------- BARRA SUPERIOR ---------- */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Chips de Estado (Offline-First, Rol, BCV) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.status-pill.offline {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #FEDF89;
}
.status-pill.offline .dot { background: var(--warn); }

.role-switch {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
}
.role-switch button {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.role-switch button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.bcv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #6E4720;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(196,149,106,0.35);
  cursor: pointer;
}

/* ---------- CONTENIDO DE PÁGINAS ---------- */
.page-wrap {
  padding: 24px 28px 90px;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
}
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 180ms ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-header .eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 4px;
}
.section-header h1 {
  font-size: 26px;
}
.section-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

/* ---------- BOTONES ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 140ms ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-deep); }
.btn-accent {
  background: var(--accent);
  color: #1A140E;
  font-weight: 700;
}
.btn-accent:hover { filter: brightness(0.95); }
.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-wa {
  background: #128C7E;
  color: #fff;
}
.btn-wa:hover { background: #0E7266; }
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* ---------- KPI CARDS ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.kpi-val {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
}

/* ---------- TARJETAS Y TABLAS DE AGENDA ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.apt-item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  transition: box-shadow 140ms ease, transform 140ms ease;
}
.apt-item:hover { box-shadow: var(--shadow-md); }
.apt-item.st-en_sala { border-left-color: var(--accent); background: #FFFDF9; }
.apt-item.st-atendida { border-left-color: var(--ok); opacity: 0.86; }
.apt-item.st-pendiente { border-left-color: var(--muted-light); }

.apt-time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--brand);
}
.apt-time small {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 400;
}

.apt-main strong {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.apt-reason {
  color: var(--ink);
  font-size: 13px;
  margin-top: 2px;
}
.apt-bot-note {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.apt-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill-sala { background: var(--accent-soft); color: #7B4D1E; }
.pill-wa { background: var(--ok-bg); color: var(--ok); }
.pill-pend { background: var(--surface-2); color: var(--muted); }
.pill-done { background: #E0F2FE; color: #0369A1; }
.pill-bot { background: #EEF4FF; color: #3538CD; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; }
.pill-allergy {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  font-weight: 700;
}
.pill-ped {
  background: #FEF6EE;
  color: #B93815;
  border: 1px solid #F9DBAF;
}

/* ---------- CABECERA CLÍNICA DE PACIENTE ---------- */
.patient-banner {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.patient-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.patient-banner h2 {
  font-size: 22px;
}
.patient-submeta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
}
.allergy-strip {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.guardian-strip {
  background: #F8F5FF;
  border: 1px solid #E9D7FE;
  color: #53389E;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
}

/* ---------- FORMULARIOS CLÍNICOS ---------- */
.consult-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 16px;
  align-items: start;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color 140ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 74, 58, 0.1);
}
.field textarea { resize: vertical; min-height: 76px; }

.vitals-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  background: var(--surface-2);
  padding: 11px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.vitals-bar .field { margin-bottom: 0; }
.vitals-bar input { padding: 7px 9px; font-family: 'IBM Plex Mono', monospace; font-size: 13px; }

.voice-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: pulseRec 1.1s infinite;
}
@keyframes pulseRec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180,35,24,0.45); }
  50% { box-shadow: 0 0 0 8px rgba(180,35,24,0); }
}

/* Historial timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tl-item {
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  padding-bottom: 8px;
}
.tl-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}
.tl-diag { font-weight: 700; font-size: 13px; margin: 2px 0; }
.tl-body { font-size: 12.5px; color: var(--muted); }

/* ---------- RÉCIPE VENEZOLANO DUAL (VISTA PREVIA EN VIVO) ---------- */
.ped-calc-box {
  background: linear-gradient(135deg, #FFF9EB 0%, #FEF3C7 100%);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.ped-calc-result {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px dashed #D97706;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
}
.chip-btn:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

/* Hoja Media Carta Horizontal Venezolana */
.recipe-sheet-preview {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  position: relative;
}
.recipe-sheet-preview::after {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 50%;
  border-left: 1.5px dashed rgba(15,31,28,0.22);
}
.rx-half {
  display: flex;
  flex-direction: column;
  min-height: 370px;
}
.rx-header {
  border-bottom: 2px solid var(--brand);
  padding-bottom: 8px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.rx-doc-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
}
.rx-doc-spec {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}
.rx-doc-reg {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}
.rx-tag-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: 4px;
}
.rx-pat-line {
  font-size: 11.5px;
  background: var(--bg);
  padding: 6px 9px;
  border-radius: 6px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.rx-body-list {
  flex: 1;
  font-size: 12.5px;
  padding-left: 18px;
  margin: 4px 0 12px;
}
.rx-body-list li { margin-bottom: 8px; }
.rx-foot {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  color: var(--muted);
}
.rx-qr-box {
  display: flex;
  align-items: center;
  gap: 7px;
}
.rx-sig-box {
  text-align: center;
  min-width: 125px;
}
.rx-sig-box img {
  max-height: 42px;
  margin: 0 auto 2px;
}
.rx-sig-line {
  border-top: 1px solid var(--ink);
  padding-top: 2px;
  font-size: 9.5px;
  color: var(--ink);
}

/* Firma Canvas */
.sig-pad {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: #FCFBF9;
  touch-action: none;
  cursor: crosshair;
  width: 100%;
  max-width: 320px;
  height: 100px;
}

/* ---------- TABLA DE PACIENTES Y CAJA ---------- */
.table-clean {
  width: 100%;
  border-collapse: collapse;
}
.table-clean th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
}
.table-clean td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-clean tr:hover td { background: #FAF9F6; }

/* ---------- MODALES ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 19, 0.52);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 60;
}
.modal-backdrop.open { display: grid; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.24);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 200ms ease;
  z-index: 90;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---------- DOCK MÓVIL (iPhone / Android) ---------- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
  justify-content: space-around;
}
.mobile-nav button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.mobile-nav button.active { color: var(--brand); background: var(--brand-soft); }
.mobile-nav button.hidden-by-role { display: none !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .consult-grid { grid-template-columns: 1fr; }
  .recipe-sheet-preview { grid-template-columns: 1fr; }
  .recipe-sheet-preview::after { display: none; }
  .apt-item { grid-template-columns: 1fr; gap: 8px; }
  .apt-actions { justify-content: flex-start; }
  .page-wrap { padding: 16px 14px 92px; }
  .topbar { padding: 10px 14px; }
  .toast { bottom: 76px; left: 14px; right: 14px; }
  .n8n-canvas { grid-template-columns: repeat(2, 1fr); }
  .wa-grid { grid-template-columns: 1fr; }
}

/* ---------- FASE 2: LIENZO VISUAL N8N & SIMULADOR WHATSAPP ---------- */
.n8n-canvas-wrap {
  background: #141B19;
  background-image: radial-gradient(rgba(255,255,255,0.09) 1px, transparent 1px);
  background-size: 18px 18px;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
}
.n8n-canvas-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.n8n-canvas {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.n8n-node {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 11.5px;
  transition: all 180ms ease;
  position: relative;
}
.n8n-node small {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  color: rgba(255,255,255,0.58);
  margin-bottom: 3px;
}
.n8n-node strong {
  display: block;
  font-size: 12px;
  color: #fff;
}
.n8n-node.node-active {
  background: rgba(16, 185, 129, 0.18);
  border-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  transform: translateY(-2px);
}
.n8n-node.node-danger {
  background: rgba(239, 68, 68, 0.22);
  border-color: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22);
}
.n8n-node.node-warn {
  background: rgba(245, 158, 11, 0.22);
  border-color: #F59E0B;
}

.wa-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
  align-items: start;
}
.wa-phone {
  background: #EFEAE2;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: 540px;
}
.wa-phone-header {
  background: #075E54;
  color: #fff;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wa-phone-header img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.5);
}
.wa-phone-header strong {
  display: block;
  font-size: 13.5px;
}
.wa-phone-header small {
  display: block;
  font-size: 11px;
  color: #D1FAE5;
}
.wa-coex-bar {
  background: #FEF3C7;
  color: #92400E;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #FDE68A;
}
.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.wa-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12.8px;
  line-height: 1.42;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.wa-msg-bot {
  align-self: flex-start;
  background: #FFFFFF;
  border-top-left-radius: 3px;
}
.wa-msg-in {
  align-self: flex-end;
  background: #D9FDD3;
  border-top-right-radius: 3px;
}
.wa-msg-human {
  align-self: flex-start;
  background: #FEF9C3;
  border: 1px solid #FDE047;
}
.wa-msg-alert {
  align-self: flex-start;
  background: #FEF2F2;
  border: 1.5px solid #FCA5A5;
  color: #7F1D1D;
}
.wa-bubble-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.8px;
  color: #047857;
  font-weight: 600;
  margin-bottom: 3px;
}
.wa-msg-alert .wa-bubble-tag { color: #B91C1C; }
.wa-bubble-time {
  font-size: 10px;
  color: #667781;
  text-align: right;
  margin-top: 3px;
}
.wa-input-bar {
  background: #F0F2F5;
  padding: 9px 11px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.wa-input-bar input {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff;
  font-size: 13px;
}
.wa-input-bar input:focus { outline: 2px solid #128C7E; }

/* ---------- IMPRESIÓN MEDIA CARTA VENEZOLANA ---------- */
@media print {
  @page { size: letter landscape; margin: 10mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .mobile-nav, .no-print, .section-header { display: none !important; }
  .app-shell, .main-area, .page-wrap { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .view-section { display: none !important; }
  #view-recipe { display: block !important; }
  .recipe-builder-controls { display: none !important; }
  .recipe-sheet-preview {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: 185mm;
  }
  .recipe-sheet-preview::after { display: block !important; }
}
