:root {
  /* Manual de marca Grupo Ecofam Health IPS */
  --turquesa: #017A82; --verde: #5B9611; --carbon: #3A3939;
  --bg: #F4F7F7; --panel: #FFFFFF; --panel2: #EAF3F3; --line: #D5DCDC; --text: #2E3333; --muted: #5F6A6A;
  --accent: #017A82; --accent-ink: #FFFFFF;
  --ok: #3F6E0B; --ok-bg: #E8F3D3; --warn: #8A5A00; --warn-bg: #FCEFD2; --bad: #B3261E; --bad-bg: #FBE4E1;
  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 15px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 6px; }
.muted, small { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Estructura */
.shell { display: flex; min-height: 100vh; }
.side { width: 230px; flex: none; background: var(--turquesa); color: #fff; padding: 16px 10px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side img { width: 150px; margin: 4px 10px 6px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; padding: 10px 12px 4px; }
.side nav a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 7px; }
.side nav a:hover { background: rgba(255,255,255,.12); }
.side nav a.on { background: #fff; color: var(--turquesa); font-weight: 600; }
.side .yo { font-size: 12px; padding: 0 12px; opacity: .9; }
.side .yo button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 3px 8px; margin-top: 6px; cursor: pointer; font: inherit; }
main { flex: 1; padding: 22px 26px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head .grow { flex: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.cols { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.split { display: grid; gap: 14px; grid-template-columns: 300px 1fr; align-items: start; }
@media (max-width: 1000px) { .cols, .split { grid-template-columns: 1fr; } .side { width: 190px; } }

/* Formularios */
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.f.req span::after { content: ' *'; color: var(--bad); }
label.chk { display: inline-flex; gap: 6px; align-items: center; }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
a.btn { text-decoration: none; display: inline-block; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 7px; padding: 6px 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ok { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.btn.mal { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }

/* Tablas */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 7px 8px; background: var(--panel2); position: sticky; top: 0; }
td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
tr.sel td { background: #DDF0F0; }
.scroll { max-height: 70vh; overflow: auto; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel2); color: var(--muted); }
.chip.URGENTE, .chip.ANULADA, .chip.RECHAZADA { background: var(--bad-bg); color: var(--bad); }
.chip.COMPLETA, .chip.VALIDADO, .chip.TOMADA, .chip.ENTREGADA { background: var(--ok-bg); color: var(--ok); }
.chip.INGRESADO, .chip.APLAZADA, .chip.EN\ PROCESO { background: var(--warn-bg); color: var(--warn); }

/* Resultados */
.res input, .res select { width: 100%; }
.res tr.VALIDADO input, .res tr.VALIDADO select { background: var(--ok-bg); }
.res td.al-A input, .res td.al-B input, .res td.al-A select, .res td.al-B select { color: var(--bad); font-weight: 700; border-color: var(--bad); }
.res td.al-PA input, .res td.al-PB input { color: #fff; background: var(--bad); font-weight: 700; border-color: var(--bad); }
.pac { background: var(--panel2); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.pac b { font-size: 15px; }
.lista-sol { max-height: 75vh; overflow: auto; }
.lista-sol .it { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lista-sol .it:hover { background: var(--panel2); }
.lista-sol .it.on { background: #DDF0F0; border-left: 3px solid var(--accent); }

/* Avisos */
#toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toast div { background: var(--carbon); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 420px; }
#toast div.err { background: var(--bad); }
.aviso { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; }
.modal .card { width: min(560px, 92vw); max-height: 90vh; overflow: auto; }

/* Entrada */
.entrada { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--turquesa), #025B61); }
.entrada .card { width: 360px; }
.entrada img { width: 190px; display: block; margin: 0 auto 14px; }

/* Impresión: informe y etiquetas */
.hoja { background: #fff; color: #000; max-width: 820px; margin: 0 auto; padding: 28px 34px; border: 1px solid var(--line); }
.hoja header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--turquesa); padding-bottom: 10px; margin-bottom: 12px; }
.hoja header img { width: 180px; }
.hoja .datos { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; font-size: 12px; margin-bottom: 12px; }
.hoja h3 { background: var(--panel2); padding: 4px 8px; margin: 14px 0 4px; font-size: 12px; }
.hoja table td, .hoja table th { padding: 3px 6px; font-size: 12px; background: none; position: static; }
.hoja .al { font-weight: 700; }
.hoja .firma { margin-top: 30px; font-size: 12px; }
.hoja footer { margin-top: 24px; border-top: 1px solid #ccc; padding-top: 6px; font-size: 10px; color: #555; }
.etiquetas { display: flex; flex-wrap: wrap; gap: 8px; }
.etq { width: 5cm; height: 2.5cm; border: 1px dashed #bbb; padding: 4px 6px; font-size: 9px; line-height: 1.2; overflow: hidden; background: #fff; color: #000; }
.etq svg { width: 100%; height: 34px; display: block; margin: 2px 0; }
.solo-imp { display: none; }
@media print {
  .side, .no-imp, #toast { display: none !important; }
  main { padding: 0; }
  body { background: #fff; }
  .hoja { border: 0; padding: 0; max-width: none; }
  .etq { border: 0; page-break-inside: avoid; }
  .solo-imp { display: block; }
}
