/* ==========================================================
   Derma Delgadillo — Panel del equipo
   Negro, marfil y champagne (misma línea que la propuesta)
   ========================================================== */
:root {
  --bg: #0A0A09;
  --panel: #11100E;
  --panel-2: #16140F;
  --panel-3: #1C1913;
  --line: #2A251C;
  --line-2: #3D3426;
  --gold: #C4A867;
  --gold-2: #DDC88F;
  --gold-dim: #8A764A;
  --ivory: #F1ECE2;
  --paper: #F4EFE6;
  --ink: #17140F;
  --text: #E7DFD1;
  --soft: #BDB3A4;
  --muted: #958B7C;
  --dim: #6E665A;
  --ok: #93B98C;
  --warn: #DDB862;
  --danger: #E08B76;
  --info: #9DB7C9;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --side: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
a:hover { color: var(--gold-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; color: #F6F1E8; margin: 0; }
p { margin: 0; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
::selection { background: var(--gold); color: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.kicker { font-size: 11px; letter-spacing: 2.6px; text-transform: uppercase; color: var(--gold); font-weight: 500; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; letter-spacing: .2px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s, color .2s; white-space: nowrap; }
.btn:hover { border-color: var(--gold); color: #F8F4EB; }
.btn--gold { background: var(--gold); border-color: var(--gold); color: #0B0A08; }
.btn--gold:hover { background: var(--gold-2); border-color: var(--gold-2); color: #0B0A08; }
.btn--sm { min-height: 32px; padding: 5px 13px; font-size: 12px; }
.btn--danger { border-color: #6B3A2E; color: var(--danger); }
.btn--danger:hover { border-color: var(--danger); color: #F6C6B9; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--soft); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--gold); cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--gold-2); text-decoration: underline; }

/* ---------- Píldoras ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 22px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 11px; color: var(--soft); white-space: nowrap; }
.pill--gold { background: var(--gold); border-color: var(--gold); color: #0B0A08; }
.pill--ok { border-color: #42583F; color: var(--ok); }
.pill--warn { border-color: #6A5728; color: var(--warn); }
.pill--danger { border-color: #6B3A2E; color: var(--danger); }
.pill--info { border-color: #3B4D59; color: var(--info); }
.pill--outline-gold { border-color: var(--gold-dim); color: var(--gold-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.input, .select, .textarea { width: 100%; background: #0D0C0A; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; color: var(--text); min-height: 40px; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(196,168,103,.14); }
.input[readonly], .textarea[readonly] { background: transparent; border-style: dashed; color: var(--soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--soft); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--gold); width: 16px; height: 16px; flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line-2); background: transparent; color: var(--soft); padding: 8px 14px; cursor: pointer; font-size: 12px; min-height: 38px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #0B0A08; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--soft); border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; min-height: 30px; }
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--gold); color: #0B0A08; background: var(--gold); }

/* ---------- Idioma ---------- */
.lang { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; color: var(--soft); border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 500; cursor: pointer; min-height: 30px; }
.lang button[aria-pressed="true"] { background: var(--gold); color: #0A0907; }

/* ==========================================================
   LOGIN
   ========================================================== */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login__media { position: relative; overflow: hidden; border-right: 1px solid var(--line); background: #0E0D0B; }
.login__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.7) contrast(1.06) brightness(.55); }
.login__media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,10,9,.15) 30%, rgba(10,10,9,.92) 100%); }
.login__quote { position: absolute; left: 56px; right: 56px; bottom: 56px; z-index: 1; display: flex; flex-direction: column; gap: 14px; }
.login__quote h2 { font-size: clamp(34px, 3.4vw, 50px); line-height: 1.05; }
.login__quote h2 em { color: var(--gold); }
.login__quote p { color: var(--soft); max-width: 460px; font-weight: 300; }
.login__side { display: flex; flex-direction: column; padding: 28px 48px 32px; gap: 24px; }
.login__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: #F6F1E8; }
.brand img { width: 40px; height: 40px; border-radius: 50%; filter: grayscale(1) sepia(.7) saturate(1.3) brightness(1.18); }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font-family: var(--serif); font-size: 22px; }
.brand__tag { font-size: 9.5px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.login__form { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 18px; }
.login__form h1 { font-size: 44px; line-height: 1.05; }
.login__form .lead { color: var(--soft); font-weight: 300; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 44px; }
.pass-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 36px; height: 36px; cursor: pointer; }
.demo-box { border: 1px dashed var(--line-2); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: rgba(196,168,103,.04); }
.demo-box .chips .chip { font-size: 11.5px; }
.login__legal { font-size: 11.5px; color: var(--dim); line-height: 1.6; max-width: 400px; margin: 0 auto; text-align: center; }
.login__back { font-size: 13px; color: var(--soft); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.login__back:hover { color: var(--gold-2); }
.notice { border: 1px solid #6A5728; color: var(--warn); background: rgba(221,184,98,.06); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* ==========================================================
   PANEL
   ========================================================== */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: #0C0B0A; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px 14px; gap: 18px; z-index: 30; }
.side .brand { padding: 0 6px; }
.branch-select { position: relative; }
.branch-select .select { border-radius: 8px; background-color: transparent; font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav__group { font-size: 10px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--dim); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--soft); font-size: 13.5px; border: 1px solid transparent; }
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav a:hover { color: #F6F1E8; background: var(--panel-2); }
.nav a[aria-current="page"] { background: var(--panel-3); border-color: var(--line-2); color: #F6F1E8; }
.nav a[aria-current="page"] svg { color: var(--gold); opacity: 1; }
.nav .badge { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; background: var(--gold); color: #0B0A08; font-size: 11px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--gold-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; letter-spacing: .5px; flex-shrink: 0; font-weight: 500; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.me__txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me__txt strong { font-weight: 500; font-size: 13px; color: #F6F1E8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__txt span { font-size: 11.5px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.demo-bar { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 7px 16px; font-size: 12px; background: #1A1609; border-bottom: 1px solid #3F3518; color: #E5CF93; text-align: center; }
.topline { display: flex; align-items: center; gap: 12px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: rgba(10,10,9,.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 36px; border-radius: 8px; min-height: 38px; }
.search__results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px; z-index: 40; box-shadow: 0 24px 50px -20px rgba(0,0,0,.9); max-height: 360px; overflow: auto; }
.search__results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px; }
.search__results a:hover, .search__results a:focus { background: var(--panel-3); }
.session-timer { font-size: 11.5px; color: var(--dim); white-space: nowrap; }

.view { padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 38px; line-height: 1.05; }
.page-head .kicker { display: block; margin-bottom: 6px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card__head h2 { font-family: var(--sans); font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase; color: var(--soft); font-weight: 500; }
.card h3 { font-size: 22px; }
.card--paper { background: var(--paper); border-color: #D8CFBE; color: var(--ink); }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.layout-2e { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; transition: border-color .2s; }
.kpi:hover { border-color: var(--gold-dim); color: inherit; }
.kpi strong { font-family: var(--serif); font-size: 40px; font-weight: 500; color: #F6F1E8; line-height: 1; }
.kpi span { font-size: 13px; color: var(--text); }
.kpi small { font-size: 11.5px; color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.is-link { cursor: pointer; }
.tbl tbody tr.is-link:hover td { background: var(--panel-2); }
.tbl td strong { font-weight: 500; color: #F6F1E8; }
.tbl .num { text-align: center; font-variant-numeric: tabular-nums; }

/* Listas */
.list { display: flex; flex-direction: column; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list__item:last-child { border-bottom: 0; }
.list__body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.list__body strong { font-weight: 500; color: #F6F1E8; font-size: 13.5px; }
.list__body span { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; }

/* Paciente */
.pt-head { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.pt-head h1 { font-size: 40px; line-height: 1.05; }
.pt-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; color: var(--soft); text-decoration: none; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: #F6F1E8; }
.tabs a[aria-current="page"] { color: #F6F1E8; border-color: var(--gold); }
.tabs a .lock { opacity: .6; }
dl.dl { display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); }
.section-title { font-size: 10.5px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--gold); font-weight: 500; padding-top: 6px; }
.fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 16px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.fieldset legend { padding: 0 8px; font-size: 10.5px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--gold); }

.note { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.note__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.note__head strong { font-weight: 500; color: #F6F1E8; }
.note__body { padding: 16px 18px; display: grid; gap: 12px; }
.note__soap { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 14px; font-size: 13.5px; }
.note__soap dt { color: var(--gold); font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; padding-top: 2px; }
.note__soap dd { margin: 0; white-space: pre-wrap; }
.note__sign { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-top: 1px dashed var(--line-2); font-size: 12px; color: var(--muted); }
.addendum { margin: 0 18px 14px; padding: 12px 14px; border-left: 2px solid var(--gold-dim); background: var(--panel-2); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.vitals { display: flex; flex-wrap: wrap; gap: 6px; }

.checklist { display: flex; flex-direction: column; }
.checklist__item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.checklist__item:last-child { border-bottom: 0; }
.checklist__icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid currentColor; font-size: 12px; margin-top: 1px; }
.is-ok { color: var(--ok); }
.is-warn { color: var(--warn); }
.is-pending { color: var(--danger); }
.checklist__txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.checklist__txt strong { font-weight: 500; color: #F6F1E8; font-size: 13.5px; }
.checklist__txt span { font-size: 12.5px; color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gold); }

/* Receta */
.rx-editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 20px; align-items: start; }
.med-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.control-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-2); }
.control-grid > div { padding: 12px 14px; border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 4px; }
.control-grid > div:last-child { border-right: 0; }
.control-grid strong { font-family: var(--serif); font-size: 19px; font-weight: 500; line-height: 1.15; color: #F6F1E8; }
.control-grid .gold strong { color: var(--gold-2); }
.paper { background: var(--paper); color: var(--ink); padding: 26px 26px 20px; font-size: 12.5px; line-height: 1.5; border: 1px solid #D8CFBE; position: sticky; top: 80px; }
.paper h3 { color: var(--ink); font-size: 24px; }
.paper .muted { color: #6E6455; }
.paper__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid #D8CFBE; }
.paper__brand { display: flex; gap: 10px; align-items: flex-start; }
.paper__brand img { width: 36px; height: 36px; border-radius: 50%; }
.paper__rx { font-family: var(--serif); font-style: italic; font-size: 30px; color: #9A7C3E; margin: 10px 0 4px; }
.paper ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.paper ol strong { font-weight: 500; }
.paper__foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 12px; margin-top: 14px; border-top: 1px solid #D8CFBE; font-size: 11px; color: #6E6455; }
.paper .seal { font-family: ui-monospace, Menlo, monospace; font-size: 9.5px; word-break: break-all; color: #6E6455; }
.qr { width: 64px; height: 64px; flex-shrink: 0; }

/* Kanban farmacia */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.kanban__col { background: var(--panel); border: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 360px; }
.kanban__col h2 { font-family: var(--sans); font-size: 11px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--soft); font-weight: 500; display: flex; justify-content: space-between; }
.order { border: 1px solid var(--line-2); background: var(--panel-2); padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.order strong { font-weight: 500; color: #F6F1E8; }

/* Firma */
.sigpad { border: 1px dashed var(--line-2); border-radius: 8px; background: #0D0C0A; position: relative; }
.sigpad canvas { width: 100%; height: 140px; display: block; touch-action: none; cursor: crosshair; }
.sigpad__line { position: absolute; left: 20px; right: 20px; bottom: 30px; border-bottom: 1px solid var(--line-2); pointer-events: none; }
.sigpad__hint { position: absolute; left: 20px; bottom: 8px; font-size: 11px; color: var(--dim); pointer-events: none; }
.sig-img { height: 54px; width: auto; background: transparent; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo { border: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; }
.photo img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.photo__ph { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 12px; text-align: center; padding: 10px; background: repeating-linear-gradient(135deg, #12110E 0 10px, #15130F 10px 20px); }
.photo__cap { padding: 8px 10px; font-size: 12px; color: var(--soft); display: flex; flex-direction: column; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; background: rgba(4,4,3,.72); backdrop-filter: blur(3px); overflow-y: auto; }
.modal__box { width: 100%; max-width: 640px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 40px 90px -30px rgba(0,0,0,.95); display: flex; flex-direction: column; }
.modal__box--wide { max-width: 880px; }
/* Formulario grande (alta de paciente): 90 % de la pantalla, sin desplazar la página */
.modal--xl { align-items: center; padding: 5vh 5vw; overflow: hidden; }
.modal__box--xl { max-width: none; width: 90vw; height: 90vh; max-height: 90vh; }
.modal__box--xl .modal__body { flex: 1; min-height: 0; overflow-y: auto; gap: 12px; padding-top: 16px; padding-bottom: 16px; }
.modal__box--xl .grid-4 { gap: 12px 16px; }
.modal__box--xl .section-title { padding-top: 2px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 26px; }
.modal__body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-3); border: 1px solid var(--gold-dim); color: var(--text); padding: 11px 18px; border-radius: 999px; font-size: 13px; z-index: 80; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

.locked { border: 1px dashed var(--line-2); padding: 34px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.locked svg { color: var(--gold); }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 4px 10px; font-size: 12.5px; align-items: center; }
.bar-row .progress { grid-column: 1 / -1; }

.hash-ok { color: var(--ok); }
.hash-bad { color: var(--danger); }

/* ---------- Agenda: selector y vista de mes ---------- */
.seg a { display: inline-flex; align-items: center; border-right: 1px solid var(--line-2); color: var(--soft); padding: 8px 16px; font-size: 12px; min-height: 38px; text-decoration: none; }
.seg a:last-child { border-right: 0; }
.seg a:hover { color: #F6F1E8; }
.seg a[aria-pressed="true"] { background: var(--gold); color: #0B0A08; }
.mcal { gap: 10px; }
.mcal__title { font-family: var(--serif) !important; font-size: 30px !important; letter-spacing: 0 !important; text-transform: none !important; color: #F6F1E8 !important; font-weight: 500 !important; }
.mcal__title::first-letter { text-transform: uppercase; }
.mcal__scroll { position: relative; height: calc(100vh - 300px); min-height: 460px; overflow-y: auto; border: 1px solid var(--line); overscroll-behavior: contain; scroll-behavior: auto; }
.mcal__dow { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--panel-2); border-bottom: 1px solid var(--line-2); }
.mcal__dow span { padding: 8px 10px; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.mcal__week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mcal__day { min-height: 116px; min-width: 0; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 5px; text-align: left; background: var(--panel); color: var(--text); border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; }
.mcal__day:nth-child(7) { border-right: 0; }
.mcal__day--alt { background: #0D0C0A; }
.mcal__day:hover { background: var(--panel-3); }
.mcal__day:focus-visible { outline-offset: -2px; }
.mcal__day.is-past { opacity: .72; }
.mcal__day.is-today { box-shadow: inset 0 0 0 1px var(--gold); opacity: 1; }
.mcal__num { font-size: 12px; color: var(--soft); align-self: flex-start; line-height: 20px; }
.mcal__num--first { color: var(--gold-2); font-weight: 500; text-transform: capitalize; }
.mcal__day.is-today .mcal__num { background: var(--gold); color: #0B0A08; border-radius: 999px; padding: 0 8px; }
.mcal__chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mcal__chip { font-size: 11px; line-height: 1.35; padding: 2px 6px; border-radius: 3px; background: var(--panel-3); border-left: 2px solid var(--gold-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.mcal__chip--desde_app { border-left-color: var(--gold); }
.mcal__chip--en_consulta { border-left-color: var(--info); }
.mcal__chip--atendida { color: var(--muted); }
.mcal__chip--no_asistio { border-left-color: var(--warn); color: var(--muted); }
.mcal__more { font-size: 11px; color: var(--gold); padding-left: 2px; }
@media (max-width: 720px) {
  .mcal__scroll { height: calc(100vh - 260px); }
  .mcal__day { min-height: 68px; padding: 4px; gap: 3px; }
  .mcal__chips { flex-direction: row; flex-wrap: wrap; }
  .mcal__chip { font-size: 0; padding: 0; width: 7px; height: 7px; border-radius: 50%; border: 0; background: var(--gold); }
  .mcal__chip--atendida, .mcal__chip--no_asistio { background: var(--dim); }
  .mcal__more { font-size: 10px; }
  .mcal__dow span { padding: 6px 4px; letter-spacing: 1px; }
}

/* ---------- Vista previa del expediente ---------- */
.modal__body.pv-body { background: #2B2823; padding: 28px 20px; }
.doc-preview { background: #fff; color: #17140F; width: 100%; max-width: 816px; margin: 0 auto; padding: 44px 52px; box-shadow: 0 14px 40px -12px rgba(0,0,0,.7); font-size: 13px; line-height: 1.45; font-family: var(--sans); }
.doc-preview h1 { color: #17140F; font-family: var(--serif); font-size: 26px; margin: 10px 0 2px; }
.doc-preview h2 { color: #17140F; font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; border-bottom: 1px solid #9A8F7C; padding: 18px 0 4px; margin: 0 0 8px; }
.doc-preview table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 4px; }
.doc-preview th, .doc-preview td { border: 1px solid #C9C0AF; padding: 5px 8px; text-align: left; vertical-align: top; color: #17140F; }
.doc-preview th { background: #F4EFE6; font-weight: 500; }
.doc-preview p { margin: 0 0 6px; }
.doc-preview .small { font-size: 11px; color: #4A443A; }
.doc-preview .sig { margin-top: 6px; font-size: 11px; color: #4A443A; }
.doc-preview .note-block { border: 1px solid #C9C0AF; padding: 10px 12px; margin-bottom: 10px; page-break-inside: avoid; break-inside: avoid; }
.doc-preview .mono { font-size: 9.5px; word-break: break-all; color: #6E6455; }
.pv-head { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 10px; border-bottom: 2px solid #C4A867; }
.pv-head img { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.pv-head strong { font-family: var(--serif); font-size: 17px; font-weight: 600; color: #17140F; }
.pv-note { max-width: 420px; }
.doc-preview ul { margin: 0 0 6px; padding-left: 18px; }
.doc-preview li { margin-bottom: 3px; }
.doc-preview .rs-sign { margin-top: 28px; }
.doc-preview .rs-sign td { border: 0; padding: 0 16px 0 0; vertical-align: bottom; }
.rs-line { border-bottom: 1px solid #555; height: 42px; margin-bottom: 4px; }
.dl-option { display: flex; gap: 14px; align-items: flex-start; width: 100%; text-align: left; padding: 16px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; font: inherit; }
.dl-option:hover { border-color: var(--gold); background: var(--panel-3); }
.dl-option svg { color: var(--gold); flex-shrink: 0; margin-top: 2px; }
.dl-option > span { display: flex; flex-direction: column; gap: 4px; }
.dl-option strong { font-weight: 500; color: #F6F1E8; font-size: 14px; }
.dl-option span span { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
@media (max-width: 720px) {
  .doc-preview { padding: 22px 18px; font-size: 12px; }
  .modal__body.pv-body { padding: 12px 8px; }
  .pv-note { display: none; }
}
@media print { .pv-head img { width: 34px; height: 34px; } .pv-head { display: flex; gap: 10pt; border-bottom: 1.5pt solid #C4A867; padding-bottom: 6pt; } }

/* ---------- Impresión ---------- */
/* Entorno de pruebas: barra roja imposible de confundir con producción */
.env-bar { background: #3A1010; border-bottom-color: #7A2A22; color: #FFD2C6; letter-spacing: .3px; position: sticky; top: 0; z-index: 50; }
.env-bar strong { letter-spacing: 2px; }
#printArea { display: none; }
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff !important; color: #111 !important; font-size: 11pt; }
  .app, .modal, .toast, .demo-bar { display: none !important; }
  #printArea { display: block !important; color: #111; }
  #printArea h1, #printArea h2, #printArea h3 { color: #111; }
  #printArea .paper { position: static; border: 0; padding: 0; background: #fff; }
  .print-doc { font-family: var(--sans); }
  .print-doc h1 { font-family: var(--serif); font-size: 22pt; margin-bottom: 4pt; }
  .print-doc h2 { font-family: var(--sans); font-size: 10pt; letter-spacing: 1.5pt; text-transform: uppercase; border-bottom: 1px solid #999; padding: 12pt 0 3pt; margin-bottom: 6pt; }
  .print-doc table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .print-doc td, .print-doc th { border: 1px solid #bbb; padding: 4pt 6pt; text-align: left; vertical-align: top; }
  .print-doc .sig { margin-top: 6pt; font-size: 8.5pt; color: #444; }
  .print-doc .note-block { page-break-inside: avoid; border: 1px solid #bbb; padding: 8pt; margin-bottom: 8pt; }
  .print-doc .mono { font-size: 7.5pt; word-break: break-all; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-2, .rx-editor, .layout-2e { grid-template-columns: minmax(0, 1fr); }
  .paper { position: static; }
}
@media (max-width: 980px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login__media { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 30px 0 60px -20px rgba(0,0,0,.9); }
  .app.is-nav-open .side { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 25; }
  .menu-btn { display: inline-flex; }
  .topline { padding: 10px 16px; }
  .view { padding: 20px 16px 48px; }
  .session-timer { display: none; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .login__side { padding: 20px 16px 24px; }
  .login__form h1 { font-size: 36px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi strong { font-size: 32px; }
  .page-head h1, .pt-head h1 { font-size: 32px; }
  .control-grid { grid-template-columns: minmax(0, 1fr); }
  .control-grid > div { border-right: 0; border-bottom: 1px solid var(--line-2); }
  .note__soap { grid-template-columns: minmax(0, 1fr); }
  dl.dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .med-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .med-row > :nth-child(2) { grid-column: 1; }
  .med-row > :nth-child(3) { grid-row: 1; grid-column: 2; }
  .modal, .modal--xl { padding: 0; }
  .modal__box, .modal__box--xl { min-height: 100vh; max-height: 100vh; width: 100%; border: 0; }
  .search { max-width: none; }
  .topline { gap: 8px; }
  .topline .spacer { display: none; }
  .topline .lang button { padding: 5px 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
