/* Expediente Médico — imagen elegante: dorado del logo + azul */
:root {
  --accent: #2563eb;
  --accent-2: #3b82f6;
  --accent-soft: #eff6ff;
  --accent-dark: #1e40af;
  --gold: #c9a227;
  --gold-soft: #f7ecd0;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #eef2f7;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .07);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1100px 480px at 50% -10%, rgba(201, 162, 39, .10), rgba(201, 162, 39, 0) 60%),
    radial-gradient(900px 460px at 88% -12%, rgba(37, 99, 235, .09), rgba(37, 99, 235, 0) 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
h1, h2, h3 { font-family: var(--serif); color: var(--ink); margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .35rem 0; }
a { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---------- Botones (sistema azul elegante) ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 11px;
  padding: .65rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
  transition: background .18s ease, box-shadow .18s ease, filter .18s ease, transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(30, 64, 175, .35), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 6px 18px rgba(30, 64, 175, .42), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-accent2 {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 55%, #60a5fa 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .30), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-accent2:hover { filter: brightness(1.07); }
.btn-gold {
  background: #dbeafe;
  color: var(--accent-dark);
  border: 1px solid #bfdbfe;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .14);
}
.btn-gold:hover { background: #bfdbfe; }
.btn-danger { background: linear-gradient(135deg, #b91c1c, #dc2626); color: #fff; box-shadow: 0 4px 14px rgba(185, 28, 28, .28); }
.btn-danger:hover { filter: brightness(1.07); }
.btn-ghost { background: #fff; color: var(--accent-dark); border: 1px solid #bfdbfe; box-shadow: 0 1px 3px rgba(30, 64, 175, .08); }
.btn-ghost:hover { background: var(--accent-soft); border-color: #93c5fd; }
.btn-small { padding: .4rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Acceso ---------- */
.access-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background:
    radial-gradient(820px 420px at 50% -6%, rgba(201, 162, 39, .16), rgba(201, 162, 39, 0) 62%),
    radial-gradient(760px 420px at 90% 0%, rgba(37, 99, 235, .12), rgba(37, 99, 235, 0) 58%),
    linear-gradient(180deg, #fdfaf1 0%, var(--bg) 60%);
}
.access-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(94, 76, 18, .16), 0 3px 12px rgba(15, 23, 42, .06);
  padding: 1.8rem 1.5rem;
  text-align: center;
}
.access-logo { width: 185px; height: auto; margin: 0 auto .4rem; display: block; }
.access-clinic { font-family: var(--serif); color: var(--gold); font-weight: 700; letter-spacing: .04em; margin: 0 0 .35rem; }
.access-sub { color: var(--muted); margin: 0 0 1rem; }
.access-note { text-align: left; font-size: .92rem; color: var(--muted); background: var(--gold-soft); border-radius: 10px; padding: .7rem .8rem; }
.access-error { color: var(--danger); font-weight: 600; font-size: .92rem; }
.access-foot { font-size: .8rem; color: var(--muted); margin-top: 1.1rem; }
.app-version { font-size: .75rem; color: var(--muted); opacity: .7; margin-top: .4rem; }

/* ---------- Cabecera y navegación ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  background: #fff;
  border-bottom: 3px solid var(--gold);
  padding: .6rem .9rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.header-logo { width: 52px; height: auto; flex-shrink: 0; }
.header-title { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { font-size: .8rem; color: var(--muted); }
.app-nav {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .55rem .7rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 63px;
  z-index: 19;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: .45rem .85rem;
  font-size: .88rem;
  font-weight: 600;
}
.nav-btn.active { background: linear-gradient(135deg, #1e40af, #2563eb); border-color: #1e40af; color: #fff; box-shadow: 0 3px 10px rgba(30, 64, 175, .30); }

.view { max-width: 980px; margin: 0 auto; padding: 1rem .9rem 4rem; }

/* ---------- Tarjetas y formularios ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 { border-bottom: 2px solid #eadfae; padding-bottom: .4rem; }
.view > h2 { border-bottom: 2px solid #eadfae; padding-bottom: .45rem; margin-bottom: .9rem; }
.field { display: block; margin-bottom: .8rem; text-align: left; }
.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .7rem;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.field textarea { min-height: 90px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 .8rem; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .8rem; flex-wrap: wrap; }
.row-between { display: flex; gap: .6rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .85rem; }
.divider { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- Listas ---------- */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding: .75rem .2rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #f8fafc; }
.list-item .item-title { font-weight: 700; }
.list-item .item-sub { font-size: .85rem; color: var(--muted); }

/* ---------- Insignias ---------- */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-gold { background: var(--gold-soft); color: #8a6d1b; }

/* ---------- Estadísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.stat .stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .stat-value { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; margin-top: .15rem; }
.stat .stat-value.green { color: var(--ok); }
.stat .stat-value.red { color: var(--danger); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  margin: auto 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}
.modal-small { max-width: 440px; }
.modal-wide { max-width: 760px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1rem;
  border-bottom: 2px solid var(--gold-soft);
}
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--muted); padding: 0 .3rem; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-note { font-size: .92rem; color: var(--muted); }

/* ---------- Firma (lienzo) ---------- */
.sign-canvas {
  width: 100%;
  height: 200px;
  border: 2px dashed var(--gold);
  border-radius: 10px;
  background: #fffdf5;
  touch-action: none;
  display: block;
}
.sign-thumb { max-width: 220px; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- Fotos ---------- */
.photo-grid { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.photo-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.photo-thumb-large { width: 100%; max-width: 420px; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- Recibo / documentos ---------- */
.doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.doc-letterhead { text-align: center; border-bottom: 3px solid var(--gold); padding-bottom: .7rem; margin-bottom: .9rem; }
.doc-letterhead img { width: 110px; height: auto; }
.doc-letterhead .doc-clinic { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--gold); }
.doc-letterhead .doc-sub { font-size: .85rem; color: var(--muted); }
.folio-red { color: var(--danger); font-weight: 800; }
.doc-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.doc-table td { padding: .3rem .2rem; vertical-align: top; }
.doc-table td:first-child { font-weight: 600; color: var(--muted); width: 38%; }
.doc-amount { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; text-align: right; }
.doc-qr { text-align: center; margin: .9rem 0; }
.doc-qr canvas, .doc-qr img { width: 160px; height: 160px; }
.doc-legal { font-size: .8rem; color: var(--muted); text-align: center; border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .8rem; }
.doc-sig { margin-top: 1.2rem; text-align: center; }
.doc-sig img { max-width: 220px; max-height: 90px; }
.doc-sig .sig-line { border-top: 1px solid var(--ink); width: 240px; margin: .4rem auto 0; padding-top: .2rem; font-size: .85rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 99;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Utilidades ---------- */
.empty { text-align: center; color: var(--muted); padding: 1.4rem .5rem; }
.alert-box { border-radius: 10px; padding: .7rem .9rem; font-size: .92rem; margin-bottom: .8rem; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--accent-soft); color: var(--accent-dark); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tab-btn { border: 1px solid #d7e3f5; background: #fff; border-radius: 999px; padding: .4rem .8rem; font-size: .88rem; font-weight: 600; color: var(--accent-dark); transition: background .18s ease, box-shadow .18s ease; }
.tab-btn:hover { background: var(--accent-soft); }
.tab-btn.active { background: linear-gradient(135deg, #1e40af, #2563eb 60%, #3b82f6); border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(30, 64, 175, .32); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

@page { margin: 0; }

@media print {
  body { background: #fff; }
  .app-header, .app-nav, .btn, .modal-overlay, .toast, .no-print { display: none !important; }
  .view { max-width: 100%; padding: 0; }
  .card, .doc { border: none; box-shadow: none; }
}

/* ===== Versión 2026-11-10: barra lateral, rejilla de horas, gráficas ===== */
.app-shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 250px; flex: 0 0 250px; background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 45%, #1e3a8a 100%);
  color: #fff; display: flex; flex-direction: column; gap: .6rem; padding: 1rem .7rem;
  position: sticky; top: 0; height: 100dvh; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: .6rem; }
.side-logo { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: #fff; }
.side-clinic { font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: 1.02rem; }
.side-sub { font-size: .75rem; opacity: .85; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; overflow-y: auto; }
.side-btn {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  background: transparent; border: 0; color: #fff; padding: .55rem .75rem; border-radius: 999px;
  font-size: .95rem; cursor: pointer;
}
.side-btn:hover { background: rgba(255,255,255,.16); }
.side-btn.active { background: rgba(255,255,255,.30); font-weight: 700; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 2px 8px rgba(15, 23, 42, .18); }
.side-group-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: rgba(255,255,255,.78); padding: 0 .75rem; margin: .45rem 0 .1rem;
  border-top: 1px solid rgba(255,255,255,.22); padding-top: .6rem;
}
.side-group-label:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.side-ico { width: 1.4rem; text-align: center; }
.side-foot { border-top: 1px solid rgba(255,255,255,.25); padding-top: .6rem; }
.side-user { font-size: .8rem; opacity: .9; margin-bottom: .4rem; }
.side-collapse {
  color: #fff; align-self: flex-start; font-weight: 700;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .28);
}
.side-collapse:hover { background: rgba(255, 255, 255, .30); }
.side-collapse .collapse-ico { font-size: 1.05rem; line-height: 1; margin-right: .2rem; }
body.sidebar-collapsed .side-collapse { align-self: center; }
body.sidebar-collapsed .side-collapse .collapse-ico { margin-right: 0; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
body.sidebar-collapsed .sidebar { width: 74px; flex-basis: 74px; align-items: center; }
body.sidebar-collapsed .side-label, body.sidebar-collapsed .side-brand-txt, body.sidebar-collapsed .side-user, body.sidebar-collapsed .side-group-label { display: none; }
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .topbar { display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; background: #fff; border-bottom: 2px solid #c9a227; position: sticky; top: 0; z-index: 30; }
  .topbar-title { font-family: "Playfair Display", Georgia, serif; font-weight: 700; color: #8a6d1f; }
}
.access-tabs { display: flex; gap: .4rem; margin: 1rem 0; }
.access-tab { flex: 1; padding: .55rem; border-radius: .6rem; border: 1.5px solid #2563eb; background: #fff; color: #1d4ed8; cursor: pointer; font-weight: 600; transition: background .18s ease, box-shadow .18s ease; }
.access-tab:hover { background: var(--accent-soft); }
.access-tab.active { background: linear-gradient(135deg, #1e40af, #2563eb 60%, #3b82f6); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(30, 64, 175, .32); }
.badge-green { background: #e6f4ea; color: #2e7d32; }
.badge-red { background: #fdecea; color: #c0392b; }
.badge-amber { background: #fff4e0; color: #a05a00; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.hero { display: flex; gap: 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-bottom: 3px solid var(--gold); border-radius: 1rem; box-shadow: var(--shadow); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.hero-logo { width: 78px; height: 78px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.hero h1 { margin: 0; font-size: 1.35rem; color: #8a6d1f; }
.next-card { background: linear-gradient(120deg, #3b82f6 0%, #2563eb 55%, #1e3a8a 100%); color: #fff; border: none; }
.next-card h3 { color: #fff; border-bottom: 2px solid rgba(255,255,255,.35); }
.next-name { font-size: 1.3rem; font-weight: 700; margin: .2rem 0; }
.big-num { font-size: 1.6rem; font-weight: 700; margin: .2rem 0; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.patient-row { cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.patient-head h2 { margin-bottom: .3rem; }
.appt-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid #eee7d3; flex-wrap: wrap; }
.mini-card { border: 1px solid #eee7d3; border-radius: .6rem; padding: .5rem .7rem; margin: .4rem 0; }
.photo-row { display: flex; gap: .4rem; flex-wrap: wrap; margin: .4rem 0; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: .5rem; border: 1px solid #ddd; }
.card-danger { border: 1.5px solid #c0392b; }
.adverse { color: #c0392b; font-weight: 600; }
.hour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .45rem; margin: .4rem 0; }
.hour-btn { display: flex; flex-direction: column; align-items: center; padding: .5rem .2rem; border-radius: .6rem; border: 1.5px solid #2563eb; background: #fff; color: #1d4ed8; cursor: pointer; font-weight: 600; transition: background .18s ease, box-shadow .18s ease; }
.hour-btn:hover { background: var(--accent-soft); }
.hour-btn small { font-weight: 400; font-size: .72rem; }
.hour-btn.selected { background: linear-gradient(135deg, #1e40af, #2563eb 60%, #3b82f6); border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(30, 64, 175, .30); }
.hour-btn:disabled { border-color: #ccc; color: #999; background: #f4f4f4; cursor: not-allowed; text-decoration: line-through; }
.chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid #d8d2bd; border-radius: 999px; padding: .25rem .6rem; margin: .15rem; font-size: .85rem; background: #fff; }
.chart { width: 100%; height: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 .2rem; }
.dot-a { background: #2563eb; } .dot-b { background: #c0392b; }
.perm-row { padding: .35rem 0; border-bottom: 1px solid #f0ead6; }
.prest-row { gap: .6rem; padding: .25rem 0; }
.sig-preview { max-height: 48px; border: 1px solid #ddd; border-radius: .4rem; background: #fff; }
.money-in { text-align: right; }
.doc-head { text-align: center; margin-bottom: 1rem; }
.doc-logo { height: 60px; }
.doc-head-name { font-family: "Playfair Display", Georgia, serif; font-size: 1.4rem; font-weight: 700; color: #8a6d1f; }
.doc-head-line { font-size: .8rem; color: #666; }
.doc-gold-rule { height: 3px; background: linear-gradient(90deg, #c9a227, #2563eb); margin: .6rem 0; }
.doc-sign { margin-top: 2rem; text-align: center; width: 46%; display: inline-block; vertical-align: top; }
.doc-sign-line { border-top: 1.5px solid #333; margin: 0 1rem .3rem; }
.doc-sign-img { max-height: 54px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem .9rem; }
.alert-amber { background: #fff4e0; border: 1px solid #e0a83c; color: #6b4e00; padding: .7rem .9rem; border-radius: .7rem; margin-bottom: 1rem; }
.portal-mode .sidebar, .portal-mode .topbar { display: none; }
.portal-mode .main-col { margin: 0 auto; max-width: 860px; width: 100%; }
/* Ronda de cierre: línea de tiempo, comparador, vista semanal */
.timeline { border-left: 3px solid #d8d2bd; margin: .5rem 0 .5rem .4rem; padding-left: 1rem; }
.timeline-item { position: relative; padding: .35rem 0; }
.timeline-dot { position: absolute; left: -1.36rem; top: .55rem; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d8d2bd; }
.compare-wrap { position: relative; max-width: 560px; margin: .6rem auto; background: #f6f3ea; border-radius: .7rem; overflow: hidden; }
.compare-img { display: block; width: 100%; }
.compare-top { position: absolute; inset: 0; height: 100%; object-fit: cover; }
.compare-line { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.5); transform: translateX(-1.5px); pointer-events: none; }
.compare-tag { position: absolute; top: .5rem; background: rgba(0,0,0,.55); color: #fff; font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; pointer-events: none; }
.compare-tag-a { left: .5rem; } .compare-tag-b { right: .5rem; }
.compare-range { width: 100%; max-width: 560px; display: block; margin: .2rem auto; accent-color: #2563eb; }
.week-grid { overflow-x: auto; }
.week-grid table { border-collapse: collapse; width: 100%; min-width: 640px; }
.week-grid th, .week-grid td { border: 1px solid #eee7d3; padding: .3rem .4rem; font-size: .8rem; vertical-align: top; }
.week-grid th { background: #f6f3ea; text-align: center; }
.week-grid td.busy { background: #fdecea; }
.week-grid .wk-appt { display: block; margin: .1rem 0; }
.zone-map-svg { max-width: 320px; width: 100%; height: auto; display: block; margin: 0 auto; }
.progress-wrap { background: #f0ead6; border-radius: 999px; height: 14px; overflow: hidden; margin: .3rem 0; }
.progress-bar { background: linear-gradient(90deg, #c9a227, #2563eb); height: 100%; }

/* ===== Alineación visual con la versión de Muse: pestañas desplegables =====
   Cabecera tipo Fold: título serif, explicación corta, distintivo con conteo y flecha. */
.fold-head { align-items: flex-start; }
.fold-head h3 { margin: 0; border-bottom: none; padding-bottom: 0; }
.fold-sub { margin: .2rem 0 0; max-width: 560px; }
.fold-arrow { font-size: 1rem; line-height: 1; }

/* ===== Actualización 8: existencias contra stock mínimo ===== */
.stock-box { margin-top: .5rem; }
.stock-box .progress-wrap { position: relative; overflow: visible; }
.stock-box .progress-bar { border-radius: 999px; }
.stock-tick { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: #1f2937; border-radius: 2px; }

/* Dashboard estilo panel (v11) */
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 .8rem; }
.stat-card { padding-top: .8rem; }
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1.05; margin: 0; color: #263238; }
.stat-label { font-weight: 700; margin: .1rem 0 0 0; }
.stat-sub { color: #607d8b; font-size: .85rem; margin: .15rem 0 0 0; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 0 .8rem; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } .dash-stats { grid-template-columns: repeat(2, 1fr); } }
.avatar-ini { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: #e3f2fd; color: #1565c0; font-weight: 700; font-size: .8rem; margin-right: .5rem; flex: none; }
.agenda-table { width: 100%; border-collapse: collapse; }
.agenda-table th { text-align: left; font-size: .78rem; letter-spacing: .04em; color: #8a6d1b; border-bottom: 2px solid #eadfae; padding: .3rem; }
.agenda-table td { padding: .45rem .3rem; border-bottom: 1px solid #f0e9d6; vertical-align: middle; }
.qa-list .btn { width: 100%; margin-bottom: .5rem; justify-content: flex-start; }
.qa-list .btn:last-child { margin-bottom: 0; }
.anuncio { border-left: 3px solid #c9a85c; background: #fffdf4; padding: .35rem .6rem; margin-bottom: .55rem; border-radius: 0 6px 6px 0; }
.anuncio p { margin: .15rem 0; }

.pac-cell { display: inline-flex; align-items: center; }
.an-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; flex-wrap: nowrap; }
.an-head strong { flex: 1; }

.proof-img { max-width: 100%; border-radius: 10px; }
.py-item-row { margin-bottom: .45rem; }
.py-item-row .pyi-concepto { flex: 1; }

.sf-prest-val { flex: 0 1 200px; max-width: 200px; }

/* v14: buscador CIE-10 */
.cie-res{display:flex;flex-direction:column;align-items:flex-start;gap:.35rem;margin-top:.4rem}

/* v16: WhatsApp, semáforo IMC, alertas críticas y consulta SOAP */
.btn-wa { background: linear-gradient(135deg, #2bd46b, #11a24c); color: #fff; border: 1px solid #0e8a3e; box-shadow: 0 2px 8px rgba(18, 161, 76, .35); }
.btn-wa:hover { filter: brightness(1.06); }
.wa-ico { width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; margin-right: 3px; }
.imc-chip { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.imc-verde { background: #dcfce7; color: #15803d; }
.imc-amarillo { background: #fef9c3; color: #a16207; }
.imc-rojo { background: #fee2e2; color: #b91c1c; }
.alertas-panel { background: #fef2f2; border: 1px solid #fecaca; border-left: 5px solid #dc2626; border-radius: 12px; padding: .7rem .9rem; margin: .6rem 0; color: #7f1d1d; }
.alertas-panel h4 { color: #b91c1c; margin: 0 0 .35rem; font-size: .82rem; letter-spacing: .05em; }
.modal:has(.soap-grid) { max-width: 1180px; }
.soap-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1020px) { .soap-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .soap-grid { grid-template-columns: 1fr; } }
.soap-col { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: .8rem; }
.soap-col h4 { margin: 0 0 .6rem; font-size: .8rem; letter-spacing: .04em; color: #1d4ed8; border-bottom: 2px solid #bfdbfe; padding-bottom: .35rem; }
.vital-row { display: grid; grid-template-columns: 1fr 86px 58px; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.vital-row > span:first-child { font-size: .82rem; color: #334155; }
.vital-row input { width: 100%; }
.vital-alert { background: #fee2e2; color: #b91c1c; border-radius: 999px; padding: .08rem .45rem; font-size: .7rem; font-weight: 700; text-align: center; display: inline-block; }

/* v17: signos con color, cronómetro, interrogatorio y diseño unificado */
.vital-ok-chip { background: #dcfce7; color: #15803d; border-radius: 999px; padding: .08rem .45rem; font-size: .7rem; font-weight: 700; display: inline-block; white-space: nowrap; }
.vital-ok { border-color: #22c55e !important; background: #f0fdf4; }
.vital-bad { border-color: #ef4444 !important; background: #fef2f2; }
.att-bar { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: 10px; padding: .45rem .8rem; margin-bottom: .7rem; font-size: .92rem; }
.radio-line { display: inline-flex; align-items: center; gap: .4rem; margin-right: 1.1rem; font-weight: 400; }
.int-row { display: grid; grid-template-columns: 118px 1fr; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.int-row > span { font-size: .82rem; color: #334155; }
#cf-imc-display .imc-chip { font-size: .98rem; padding: .35rem .9rem; }

/* Diseño unificado: todas las secciones comparten el lenguaje del expediente del paciente */
#view > h2 { border-bottom: 2px solid #eadfae; padding-bottom: .4rem; }
.mini-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: .7rem .9rem; }
.modal-body .form-grid { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: .9rem; }
#view table { width: 100%; border-collapse: collapse; }
#view table th { background: #f1f5f9; color: #334155; text-align: left; font-size: .8rem; letter-spacing: .03em; padding: .45rem .6rem; border-bottom: 2px solid #e2e8f0; }
#view table td { padding: .45rem .6rem; border-bottom: 1px solid #eef2f7; vertical-align: top; }

/* v18: apariencia alineada a la versión de Muse (azul clínico, fondo gris-azul claro, títulos sans pesada, filetes azules) */
body { background: #eef2f7; }
.access-screen { background: linear-gradient(180deg, #dbeafe 0%, #eef2f7 65%); }
.access-card { border-top: 4px solid var(--accent); }
.access-clinic { font-family: var(--sans); color: var(--ink); }
h1, h2, h3 { font-family: var(--sans); font-weight: 800; letter-spacing: -.01em; }
.card h2, .card h3 { border-bottom: 2px solid #bfdbfe; }
#view > h2 { border-bottom: 2px solid #bfdbfe; }
.header-title, .stat .stat-value, .modal-head h2 { font-family: var(--sans); font-weight: 800; }
.side-clinic { font-family: var(--sans); font-weight: 800; }

/* Mapas corporales interactivos */
.map-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.map-tab { border: 1.5px solid #93c5fd; background: #fff; color: #1d4ed8; border-radius: 999px; padding: .35rem .8rem; font-weight: 600; cursor: pointer; }
.map-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.map-stage { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: .6rem; }
.bodymap { width: 100%; max-width: 290px; display: block; margin: 0 auto; }
.map-base, .map-base-rect { fill: #f1f5f9; stroke: #94a3b8; stroke-width: 1.2; }
.map-region { cursor: pointer; }
.map-region > * { fill: #dbeafe; stroke: #2563eb; stroke-width: 1; }
.map-region:hover > * { fill: #bfdbfe; }
.map-region.on > * { fill: #2563eb; stroke: #1e40af; }
.map-chips { margin-top: .5rem; min-height: 1.6rem; }

/* Mapas anatómicos con regiones superpuestas (v21) */
.map-wrap { position: relative; max-width: 430px; margin: 0 auto; }
.map-wrap.wide { max-width: 640px; }
.map-img { width: 100%; display: block; border-radius: 8px; }
.map-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.dp-stage { position: relative; }
.dp-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.dp-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.dp-group { display: inline-flex; gap: 6px; align-items: center; }
.dp-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; cursor: pointer; padding: 0; }
.dp-color.active { box-shadow: 0 0 0 2px #1e40af; }
.dp-tool { border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.dp-tool.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Carnet del paciente (portal) */
.carnet{background:#fff;border:1px solid #dbe3ee;border-top:4px solid #c9a227;border-radius:14px;padding:1rem 1.1rem;margin-bottom:1rem;box-shadow:0 2px 10px rgba(15,42,74,.06)}
.carnet-top{display:flex;align-items:center;gap:.8rem;border-bottom:1px solid #eef2f7;padding-bottom:.7rem;margin-bottom:.7rem}
.carnet-logo{width:52px;height:52px;object-fit:contain}
.carnet-brand{display:flex;flex-direction:column;flex:1}
.carnet-brand strong{font-size:1.05rem;color:#0f2a4a}
.carnet-brand span{font-size:.78rem;letter-spacing:.18em;text-transform:uppercase;color:#b08d1e;font-weight:700}
.carnet-qr{width:84px;height:84px;flex:none}
.carnet-qr img,.carnet-qr canvas{width:84px;height:84px}
.carnet-body{display:flex;gap:.9rem;align-items:center}
.carnet-avatar{width:64px;height:64px;border-radius:50%;background:linear-gradient(145deg,#1d4e79,#2563eb);color:#fff;display:flex;align-items:center;justify-content:center;font-size:1.35rem;font-weight:800;flex:none}
.carnet-data p{margin:.1rem 0;font-size:.92rem}
.carnet-nombre{font-size:1.08rem;font-weight:800;color:#0f2a4a}

.cloud-status{font-size:.72rem;color:#64748b;padding:.1rem .9rem .4rem;}
