/* =========================================================================
   Sección de Córnea · HUMS — estilos
   Paleta por familias de actividad:
     consulta (azul) · KC (violeta) · preop (ámbar) · quirófano (coral)
     CXL (fucsia) · servicios POLI/Ambulatorio/UFV (esmeralda) · ausencias (rosa)
   ========================================================================= */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e5e9f2;
  --brand: #4f46e5;
  --brand-2: #0ea5e9;
  --danger: #e11d48;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);

  /* Familias: color fuerte (texto/acento) y tinte (fondo) */
  --consulta: #2563eb;  --consulta-bg: #e0ecff;
  --kc: #7c3aed;        --kc-bg: #efe7ff;
  --preop: #d97706;     --preop-bg: #fff1d6;
  --qx: #e8434f;        --qx-bg: #ffe3e5;
  --cxl: #c026d3;       --cxl-bg: #fbe4ff;
  --serv: #059669;      --serv-bg: #d5f7e8;
  --aus: #db2777;       --aus-bg: #ffe4f1;
  --festivo: #1e293b;

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.mono { font-family: ui-monospace, Menlo, monospace; }
.error { color: var(--danger); min-height: 1.2em; margin: .25rem 0; font-size: .9rem; }
.notice { background: #fff8e6; border: 1px solid #fde3a7; color: #7a4b00; padding: .7rem 1rem; border-radius: 10px; margin: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem; padding: .6rem 1.25rem;
  background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; white-space: nowrap; display: flex; align-items: center; gap: .55rem; letter-spacing: -.02em; }
.brand::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 22%, transparent 23%), conic-gradient(from 200deg, var(--brand), var(--brand-2), var(--serv), var(--brand));
  box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
}
.brand span { font-weight: 500; color: var(--ink-3); }
#nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
#nav a { color: var(--ink-2); text-decoration: none; padding: .45rem .85rem; border-radius: 999px; white-space: nowrap; font-weight: 500; font-size: .93rem; }
#nav a:hover { background: #eef1f8; color: var(--ink); }
#nav a.active { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: .75rem; white-space: nowrap; font-size: .9rem; color: var(--ink-2); }
.who-name { font-weight: 600; color: var(--ink); }
.who small { color: var(--brand); font-weight: 600; }
button.link { background: none; border: 0; color: var(--ink-2); cursor: pointer; font: inherit; padding: .3rem .6rem; border-radius: 8px; }
button.link:hover { background: #eef1f8; color: var(--ink); }
.banner-conflict {
  display: flex; align-items: center; gap: .5rem; margin: .75rem auto 0; max-width: 1400px; width: calc(100% - 2rem);
  background: linear-gradient(90deg, #fff1f3, #fff); color: var(--danger); border: 1px solid #fecdd3;
  border-radius: 12px; padding: .7rem 1rem; font-weight: 600; text-decoration: none;
}

/* ---------- Layout y controles ---------- */
main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 1rem; }
.card { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.narrow { max-width: 440px; display: flex; flex-direction: column; gap: .8rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--ink-2); font-weight: 500; }
input, select, textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid #d5dbe7; border-radius: 10px; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
button {
  font: inherit; font-weight: 500; padding: .55rem 1rem; border-radius: 10px; border: 1px solid #d5dbe7;
  background: #fff; color: var(--ink); cursor: pointer; transition: background .15s, transform .05s, box-shadow .15s;
}
button:hover { background: #f3f5fa; }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, var(--brand), #6366f1); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
button.primary:hover { background: linear-gradient(135deg, #4338ca, var(--brand)); }
button.danger { color: var(--danger); border-color: #fecdd3; }
button.danger:hover { background: #fff1f3; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 12px; z-index: 100; box-shadow: var(--shadow); font-weight: 500; }
.toast-error { background: var(--danger); }

/* ---------- Login ---------- */
.center { min-height: 100vh; display: grid; place-items: center; margin: -1.25rem; padding: 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #bae6fd 0, transparent 60%), var(--bg); }
.card.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: .9rem; padding: 2rem; }
.card.login h1 { font-size: 1.6rem; }
.card.login .muted { margin: -.5rem 0 .5rem; }

/* ---------- Listados ---------- */
.table-wrap { overflow-x: auto; }
table.list { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.list th, table.list td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
table.list thead th { color: var(--ink-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.list tbody tr:last-child td, table.list tbody tr:last-child th { border-bottom: 0; }
table.stats td { font-variant-numeric: tabular-nums; font-weight: 600; text-align: center; }
table.stats thead th { text-align: center; text-transform: none; letter-spacing: 0; }
table.stats td.zero { color: var(--ink-3); font-weight: 400; }

/* ---------- Cuadrante: cabecera ---------- */
.cq-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.cq-month { display: flex; align-items: center; gap: .5rem; }
.cq-month h1 { min-width: 12ch; text-align: center; text-transform: capitalize; font-size: 1.7rem; }
.cq-month button.arrow { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 1.2rem; flex: none; }
.cq-actions { display: flex; flex-wrap: nowrap; gap: .6rem; align-items: center; }
.cq-citados { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.cq-open { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cq-open label { display: flex; flex-direction: row; align-items: center; gap: .5rem; }
.cq-legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.lg { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 500; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .7rem .25rem .35rem; }
.lg i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.lg-consulta i { background: var(--consulta); } .lg-kc i { background: var(--kc); } .lg-preop i { background: var(--preop); }
.lg-qx i { background: var(--qx); } .lg-cxl i { background: var(--cxl); } .lg-serv i { background: var(--serv); }
.lg-festivo i { background: var(--festivo); }
.lg-closed i { background: repeating-linear-gradient(135deg, #cbd5e1 0 2px, #fff 2px 5px); border: 1px solid #cbd5e1; }
.lg-conflict i { background: #fff; border: 2px solid var(--danger); }
.lg-citado i { background: #22c55e; }

/* ---------- Cuadrante: tabla semanal ---------- */
.cq-week { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.cq { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; table-layout: fixed; font-size: .84rem; }
table.cq th, table.cq td { padding: 3px 5px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); height: 34px; vertical-align: middle; }
table.cq tr > :last-child { border-right: 0; }
table.cq tbody tr:last-child > * { border-bottom: 0; }

table.cq th.rowhead {
  width: 150px; text-align: left; font-weight: 600; color: var(--ink-2); background: #fafbfe;
  position: sticky; left: 0; z-index: 2; white-space: nowrap; font-size: .8rem;
}
table.cq th.rowhead .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .5rem; vertical-align: 1px; }
table.cq th.corner { color: var(--ink-3); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.dot.k-consulta { background: var(--consulta); } .dot.k-kc { background: var(--kc); } .dot.k-qx { background: var(--qx); }
.dot.k-cxl { background: var(--cxl); } .dot.k-serv { background: var(--serv); } .dot.k-aus { background: var(--aus); }

table.cq thead th { background: #fafbfe; height: 64px; border-bottom: 1px solid var(--line); }
table.cq th.dayhead { text-align: center; line-height: 1.15; }
th.dayhead .dow { display: block; font-size: .7rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
th.dayhead .dnum { display: block; font-size: .95rem; font-weight: 700; color: var(--ink); }
th.dayhead .hname { display: block; font-size: .68rem; font-weight: 500; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th.dayhead.out .dnum, th.dayhead.out .dow { color: #cbd5e1; }
th.dayhead.today .dnum { color: var(--brand); }
th.dayhead .cit { display: inline-block; margin-top: 3px; font-size: .66rem; font-weight: 700; padding: .08rem .45rem; border-radius: 999px; letter-spacing: .02em; }
th.dayhead .cit.si { background: #dcfce7; color: #15803d; }
th.dayhead .cit.no { background: #f1f5f9; color: #64748b; }
th.dayhead.today .cit.si { box-shadow: 0 0 0 1px #86efac; }
th.dayhead.editable { cursor: pointer; }
th.dayhead.editable:hover { background: #f1f4fb; }

/* Selector de vista y botón Hoy */
.cq-title { display: flex; flex-direction: column; align-items: center; min-width: 12ch; }
.cq-sub { font-size: .85rem; color: var(--ink-2); font-weight: 500; }
.seg { display: inline-flex; background: #e8ecf5; border-radius: 999px; padding: 3px; margin-left: .5rem; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: .4rem .95rem; font-size: .88rem; color: var(--ink-2); box-shadow: none; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); font-weight: 600; }
.cq-count { font-size: .85rem; font-weight: 600; color: #15803d; background: #ecfdf3; border: 1px solid #bbf7d0; padding: .4rem .8rem; border-radius: 999px; }
button.cit { border: 0; cursor: pointer; font: inherit; line-height: 1.4; box-shadow: none; }
button.cit.no { outline: 1px dashed #94a3b8; }
button.cit:hover { filter: brightness(.95); transform: scale(1.05); }

/* Días pasados (oscurecidos) y hoy */
table.cq td.past { background-color: #e9edf3; }
table.cq td.past .chip { opacity: .5; filter: grayscale(.55); }
table.cq td.past .aus { opacity: .55; }
th.dayhead.past { background: #e9edf3; }
th.dayhead.past .dnum, th.dayhead.past .dow { color: #94a3b8; }
th.dayhead.past .cit { opacity: .6; }
th.dayhead .hoy { margin-left: .35rem; background: var(--brand); color: #fff; padding: .05rem .4rem; border-radius: 999px; font-size: .62rem; letter-spacing: .04em; }
th.dayhead.today { background: #eef0ff; box-shadow: inset 0 -3px 0 var(--brand); }
table.cq td.today { background-color: #f5f6ff; box-shadow: inset 2px 0 0 #c7cbfa, inset -2px 0 0 #c7cbfa; }

/* Vista semanal: casillas más grandes */
.vista-semana table.cq { font-size: .95rem; }
.vista-semana table.cq th, .vista-semana table.cq td { height: 46px; }
.vista-semana .chip { font-size: .9rem; padding: .3rem .7rem; }

/* Separación mañana / tarde */
table.cq tr.r-pm > * { border-top: 2px dashed #d5dbe7; }
table.cq tr.r-ausencias > * { background: #fffafc; border-top: 1px solid #fbcfe8; }

/* Celdas */
table.cq td { background: #fff; text-align: center; }
table.cq td.out { background: repeating-linear-gradient(135deg, #f8fafc 0 6px, #f1f5f9 6px 12px); }
table.cq td.holiday, table.cq th.holiday { background: var(--festivo); border-color: #334155; }
table.cq th.holiday .dow, table.cq th.holiday .dnum { color: #fff; }
table.cq td.closed { background-image: repeating-linear-gradient(135deg, rgba(148, 163, 184, .13) 0 2px, transparent 2px 8px); }
table.cq td.editable { cursor: pointer; transition: background-color .12s; }
table.cq td.editable:hover { background-color: #eef2ff; }

/* Chip de actividad */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; flex-wrap: wrap; justify-content: center;
  padding: .2rem .55rem; border-radius: 8px; font-weight: 600; font-size: .8rem; line-height: 1.2;
  background: #eef1f8; color: var(--ink); border-left: 3px solid transparent;
}
.chip .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .tag { font-size: .62rem; font-weight: 800; letter-spacing: .05em; padding: .05rem .3rem; border-radius: 4px; color: #fff; }
.chip .note { flex-basis: 100%; font-size: .68rem; font-weight: 500; opacity: .8; }
.chip.k-consulta { background: var(--consulta-bg); color: #1d4ed8; border-left-color: var(--consulta); }
.chip.k-kc       { background: var(--kc-bg);       color: #6d28d9; border-left-color: var(--kc); }
.chip.k-kc .tag  { background: var(--kc); }
.chip.k-preop    { background: var(--preop-bg);    color: #b45309; border-left-color: var(--preop); }
.chip.k-preop .tag { background: var(--preop); }
.chip.k-qx       { background: var(--qx-bg);       color: #c81e3a; border-left-color: var(--qx); }
.chip.k-cxl      { background: var(--cxl-bg);      color: #a21caf; border-left-color: var(--cxl); }
.chip.k-cxl .tag { background: var(--cxl); }
.chip.k-serv     { background: var(--serv-bg);     color: #047857; border-left-color: var(--serv); }
.chip .tag-dia, .chip.k-serv .tag { background: var(--serv); }
.chip.conflict   { background: #fff; color: var(--danger); border: 2px solid var(--danger); animation: pulse 2s ease-in-out infinite; }
.chip.conflict .warn { font-size: .85rem; }
.chip.descitada  { background: #f1f5f9; color: var(--ink-3); text-decoration: line-through; font-weight: 500; border-left-color: #cbd5e1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(225, 29, 72, .15); } }

.aus { display: inline-block; margin: 1px 2px; padding: .12rem .5rem; border-radius: 999px; background: var(--aus-bg); color: var(--aus); font-weight: 700; font-size: .74rem; }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: 18px; padding: 1.5rem; width: min(440px, 94vw); box-shadow: 0 24px 64px rgba(15, 23, 42, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; gap: .85rem; }
dialog .buttons { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: .25rem; }
dialog .buttons .spacer { flex: 1; }

/* ---------- Ausencias ---------- */
.conflict-item { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; border: 1px solid #fecdd3; background: #fff5f7; border-radius: 12px; padding: .75rem 1rem; }
details.card summary { cursor: pointer; font-weight: 600; }

/* ---------- Móvil ---------- */
@media (max-width: 700px) {
  main { padding: .6rem; }
  .center { margin: -.6rem; }
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; }
  #nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .cq-month { flex-wrap: wrap; }
  .cq-month h1 { font-size: 1.3rem; }
  .seg { margin-left: 0; }
  .cq-actions { flex-wrap: wrap; }
  table.cq th.rowhead { width: 112px; font-size: .72rem; }
  .card { padding: 1rem; }
  .cq-week { padding: 0; }
}

/* ---------- Impresión ---------- */
@media print {
  .topbar, #banner, .cq-actions, .cq-month button, .seg, .cq-legend, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .cq-week { break-inside: avoid; page-break-inside: avoid; margin-bottom: 8px; overflow: visible; }
  table.cq { font-size: 8pt; min-width: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chip.conflict { animation: none; }
}
table.cq tr.r-ausencias > td.past { background: #e9edf3; }
@media print { table.cq td.past { background-color: #fff !important; } table.cq td.past .chip { opacity: 1; filter: none; } }
.hint { margin: -.25rem 0 0; font-size: .82rem; color: var(--ink-2); }
@media print { .hint, .cq-citados { display: none !important; } }

/* Fila de ausencias clicable */
table.cq td.aus-cell { cursor: pointer; position: relative; }
table.cq td.aus-cell:hover { background: #ffe4f1; }
.aus-add { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; margin-left: 2px;
  font-weight: 700; font-size: .85rem; color: var(--aus); border: 1px dashed #f9a8d4; opacity: 0; transition: opacity .15s; vertical-align: middle; }
table.cq td.aus-cell:hover .aus-add, table.cq td.aus-cell:empty .aus-add { opacity: 1; }
@media (hover: none) { .aus-add { opacity: .7; } }
.aus-list { display: flex; flex-direction: column; gap: .4rem; background: #fff7fb; border: 1px solid #fbcfe8; border-radius: 12px; padding: .7rem .8rem; }
.aus-row { display: flex; align-items: center; gap: .6rem; }
.aus-row .danger { margin-left: auto; }
button.small { padding: .25rem .6rem; font-size: .8rem; }
@media print { .aus-add { display: none !important; } }

/* ---------- Lista de espera ---------- */
.le-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.le-tabs { display: inline-flex; background: #e8ecf5; border-radius: 999px; padding: 3px; }
.le-tabs button { border: 0; background: transparent; border-radius: 999px; padding: .45rem 1rem; color: var(--ink-2); box-shadow: none; display: inline-flex; gap: .45rem; align-items: center; }
.le-tabs button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.le-tabs .count { font-size: .72rem; background: #eef1f8; color: var(--ink-2); border-radius: 999px; padding: .05rem .45rem; font-weight: 700; }
.le-filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.le-search { min-width: min(340px, 100%); }
.le-card { padding: 0; }
table.le-table { border-collapse: collapse; width: 100%; font-size: .86rem; }
table.le-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding: .65rem .6rem; border-bottom: 1px solid var(--line); background: #fafbfe; position: sticky; top: 0; }
table.le-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.le-row { cursor: pointer; border-left: 4px solid transparent; }
tr.le-row:hover td { background: #f6f8fd; }
tr.le-row.est-llamar td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
tr.le-row.est-prog td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
tr.le-row.est-nodisp td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.le-row.est-nodisp td { color: #94a3b8; }
tr.le-row.sel td { background: #eef0ff; }
.le-name { font-weight: 600; }
.le-obs { max-width: 260px; color: var(--ink-2); }
.le-prog { white-space: nowrap; }
.est { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; white-space: nowrap; }
.est.est-llamar { background: #dcfce7; color: #15803d; }
.est.est-prog { background: #fef3c7; color: #b45309; }
.est.est-nodisp { background: #ffe4e6; color: #be123c; }
.est.est-none { background: #f1f5f9; color: #64748b; }
.le-dup { margin-left: .35rem; font-size: .68rem; font-weight: 700; color: #b45309; background: #fef3c7; padding: .05rem .35rem; border-radius: 6px; }
.le-dup.bil { color: #6d28d9; background: #ede9fe; }
tr.le-detail td { background: #fafbfe; }
tr.le-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .25rem 0; font-size: .82rem; }
tr.le-detail dt { color: var(--ink-2); font-weight: 600; }
tr.le-detail dd { margin: 0; }
.le-check { width: 32px; }
.center-txt { text-align: center; padding: 1.5rem !important; }
@media (max-width: 700px) { table.le-table thead th:nth-last-child(-n+2), tr.le-row td:nth-last-child(-n+2) { display: none; } }

/* ---------- Partes de quirófano ---------- */
a.btn { display: inline-flex; align-items: center; text-decoration: none; padding: .55rem 1rem; border-radius: 10px; font-weight: 500; }
a.btn.primary { background: linear-gradient(135deg, var(--brand), #6366f1); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
.parte-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; margin-top: .5rem; }
.parte-card { display: flex; flex-direction: column; gap: .35rem; text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
.parte-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .1); }
.pc-date { font-weight: 700; font-size: 1.05rem; }
.pc-date::first-letter { text-transform: uppercase; }
.pc-foot { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.back { text-decoration: none; font-size: .9rem; color: var(--ink-2); }
.pe-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.pe-head label { min-width: 180px; }
.pe-head label select, .pe-head label input { width: 100%; }
.pe-head small { flex-basis: 100%; }
.pe-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.pe-bar h2 { margin: 0; }
.pe-list { display: flex; flex-direction: column; gap: .7rem; }
.pe-item { display: grid; grid-template-columns: 96px 1fr auto; gap: .9rem; align-items: start; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--qx); border-radius: 12px; padding: .85rem 1rem; box-shadow: var(--shadow); }
.pe-item.done-realizada { border-left-color: #22c55e; }
.pe-item.done-suspendida { border-left-color: var(--danger); opacity: .8; }
.pe-hora select { font-weight: 700; font-size: 1rem; width: 100%; }
.pe-who { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.pe-ojo { font-weight: 700; color: var(--consulta); background: var(--consulta-bg); padding: .05rem .45rem; border-radius: 6px; font-size: .8rem; }
.pe-tab { font-size: .72rem; color: var(--ink-2); background: #f1f5f9; padding: .05rem .45rem; border-radius: 6px; }
.pe-fields { display: grid; grid-template-columns: 1fr 1fr 200px; gap: .5rem .75rem; }
.pe-fields label { font-size: .75rem; }
.pe-fields .pe-obs { grid-column: 1 / -1; }
.pe-actions { display: flex; flex-direction: column; gap: .3rem; }
dialog.picker { width: min(1200px, 96vw); max-height: 92vh; padding: 1.25rem; }
.picker-inner { display: flex; flex-direction: column; gap: .8rem; }
.picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.picker-head h2 { margin: 0; }
.picker-list { max-height: 64vh; overflow: auto; display: flex; flex-direction: column; gap: .6rem; }
.print-only { display: none; }
@media (max-width: 700px) {
  .pe-item { grid-template-columns: 1fr; }
  .pe-fields { grid-template-columns: 1fr; }
  .pe-actions { flex-direction: row; }
}

/* Parte imprimible (formato del parte del servicio) */
.parte-print { font-family: Arial, Helvetica, sans-serif; color: #000; }
.pp-title { background: #c9c9c9; text-align: center; font-size: 15pt; padding: 6px; border-bottom: 2px solid #000; }
.pp-meta { display: flex; justify-content: space-between; padding: 10px 4px; font-size: 11pt; }
.pp-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
.pp-table th { background: #d9d9d9; border: 1px solid #000; padding: 3px 5px; text-align: center; font-weight: normal; }
.pp-table td { border: 1px solid #000; padding: 4px 6px; text-align: center; }
.pp-table tbody { break-inside: avoid; }
.pp-table .pp-hora { width: 50px; }
.pp-table .pp-nombre { font-weight: bold; }
@media print {
  .no-print-page, .toast { display: none !important; }
  .print-only { display: block !important; }
}

/* ---------- Confirmación de cirugías ---------- */
.banner-cirugias { background: linear-gradient(90deg, #fff7e6, #fff); color: #b45309; border-color: #fde3a7; }
dialog.confirmacion { width: min(900px, 96vw); }
.cf-inner { display: flex; flex-direction: column; gap: .8rem; }
.cf-inner h2 { margin: 0; }
.cf-parte { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cf-head { background: #fafbfe; padding: .55rem .9rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.cf-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.cf-row:last-child { border-bottom: 0; }
.cf-btns { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.cf-btns input { padding: .3rem .5rem; font-size: .85rem; }

/* ---------- Parte de quirófano: editor en formato tabla ---------- */
.pt-sheet { padding: 0; overflow: hidden; }
.pt-title { text-align: center; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 1.05rem; padding: .85rem 1rem;
  background: linear-gradient(135deg, #1e293b, #334155); color: #fff; }
.pt-meta { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: #fafbfe; }
.pt-field { display: flex; flex-direction: column; gap: .3rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.pt-cir { display: flex; gap: .5rem; flex-wrap: wrap; }
.pt-cir select { min-width: 150px; }
.pt-count { margin-left: auto; font-size: .85rem; font-weight: 600; color: var(--ink-2); background: #eef1f8; padding: .35rem .8rem; border-radius: 999px; }
.pt-wrap { overflow-x: auto; }
table.pt-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: .9rem; }
table.pt-table thead th { background: #e8ecf5; color: #334155; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: .5rem .6rem; border: 1px solid #d5dbe7; text-align: center; }
table.pt-table td { border: 1px solid #e1e6f0; padding: 0; vertical-align: middle; background: #fff; }
table.pt-table tbody.pt-pac:nth-of-type(even) td { background: #fbfcff; }
table.pt-table tbody.pt-pac:hover td { background: #f4f6fd; }
table.pt-table tbody.pt-pac { border-top: 2px solid #cbd5e1; }
.pt-c-hora { width: 92px; text-align: center; }
.pt-c-nombre { width: 24%; padding: .5rem .75rem !important; }
.pt-c-nhc { width: 90px; text-align: center; color: var(--ink-2); }
.pt-c-ojo { width: 64px; text-align: center; }
.pt-c-anest { width: 190px; }
.pt-c-act { width: 52px; text-align: center; }
.pt-in { width: 100%; border: 0; border-radius: 0; background: transparent; padding: .55rem .6rem; font: inherit; color: var(--ink); }
.pt-in:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fff; box-shadow: none; }
.pt-in:disabled { color: var(--ink); opacity: 1; }
select.pt-in { cursor: pointer; }
.pt-hora { font-weight: 800; font-size: 1rem; text-align: center; color: var(--brand); }
.pt-missing { color: #b45309; font-style: italic; }
.pt-nombre { font-weight: 700; }
.pt-sub { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .25rem; }
.pt-tab { font-size: .66rem; font-weight: 700; padding: .05rem .4rem; border-radius: 5px; }
.pt-tab.tx { background: var(--qx-bg); color: #c81e3a; }
.pt-tab.cat { background: var(--consulta-bg); color: #1d4ed8; }
.pt-ojo { font-weight: 800; color: var(--consulta); background: var(--consulta-bg); padding: .1rem .45rem; border-radius: 6px; font-size: .82rem; }
.pt-actions { display: flex; flex-direction: column; gap: 3px; align-items: center; padding: 4px; }
.pt-actions button { width: 30px; height: 26px; padding: 0; }
table.pt-table tbody.pt-new td { animation: ptNew 2.2s ease-out; }
@keyframes ptNew { 0% { background: #e0e7ff; } 100% { background: inherit; } }
table.pt-table tbody.pt-realizada td { background: #f0fdf4 !important; }
table.pt-table tbody.pt-suspendida td { background: #fff1f2 !important; }
table.pt-table tfoot td { border: 0; padding: .75rem; background: #fafbfe; text-align: center; }
.pt-add { border-style: dashed !important; }
.pt-empty { text-align: center; color: var(--ink-3); padding: 1.5rem !important; }
.pt-hint { padding: .6rem 1.25rem .9rem; margin: 0; }
@media (max-width: 700px) { .pt-meta { flex-direction: column; align-items: stretch; } .pt-count { margin-left: 0; align-self: flex-start; } }

/* Órdenes de tratamiento y tejido BSTA: fuera del formato del parte */
table.pt-table th.pt-c-extra { background: #fdf4ff; color: #86198f; border-left: 3px solid #e9d5ff; width: 250px; line-height: 1.3; }
table.pt-table td.pt-c-extra { background: #fdfaff !important; border-left: 3px solid #e9d5ff; padding: .35rem .5rem; vertical-align: top; }
.pt-extra-f { display: flex; flex-direction: column; gap: 1px; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #a21caf; }
.pt-extra-f + .pt-extra-f { margin-top: .35rem; }
.pt-extra-f select { border: 1px solid #f0d9fb; border-radius: 8px; background: #fff; padding: .35rem .45rem; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .85rem; }
.banner-seccion { background: linear-gradient(90deg, #fdecef, #fff); color: #9f1239; border-color: #fbcfd8; }

/* Córnea elegida del banco (parte) */
.pt-cornea { margin-top: .4rem; display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; padding: .4rem .5rem; border-radius: 8px; background: #fff; border: 1px solid #f0d9fb; }
.pt-cornea-falta { border-color: #fde3a7; background: #fffbeb; color: #b45309; font-style: italic; }
.pt-cornea-acc { display: flex; gap: .3rem; }
.pt-cornea-acc button { font-style: normal; }
.cornea-picker .small-note { margin: 0; font-size: .82rem; }
table.cn-table td { white-space: nowrap; }
table.cn-table td.cn-avisos { white-space: normal; min-width: 180px; }
tr.cn-ok td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
tr.cn-reservada td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
tr.cn-novalida td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.cn-novalida td { color: #94a3b8; }
.cn-av { font-size: .74rem; line-height: 1.25; }
.cn-av-reservada { color: #b45309; }
.cn-av-novalida { color: var(--danger); }
.cn-av-info { color: var(--ink-2); }
.cn-sub { margin: .2rem 0 0; font-size: .85rem; }
.cn-filtros { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; margin: .6rem 0; }
.cn-filtros label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.cn-filtros label.cn-check { flex-direction: row; align-items: center; gap: .4rem; font-size: .88rem; }
.cn-buscar { min-width: 260px; flex: 1; max-width: 420px; }
.cn-host { padding: 0; overflow: auto; }
.cn-leyenda { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--ink-2); margin-bottom: .3rem; }
.cn-ley::before { content: ''; display: inline-block; width: 4px; height: .9em; margin-right: .4rem; vertical-align: -1px; border-radius: 2px; }
.cn-ley-ok::before { background: #22c55e; }
.cn-ley-res::before { background: #f59e0b; }
.cn-ley-nv::before { background: var(--danger); }

/* Ruleta de ajustes (Mi cuenta, Usuarios) */
.ajustes { position: relative; display: flex; }
.ajustes-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer; transition: transform .25s, background .15s; }
.ajustes-btn:hover { background: #eef1f8; color: var(--ink); transform: rotate(45deg); }
.ajustes-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.ajustes-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .14); padding: .35rem; z-index: 50; display: flex; flex-direction: column; }
.ajustes-menu[hidden] { display: none; }
.ajustes-menu a { color: var(--ink); text-decoration: none; padding: .55rem .75rem; border-radius: 8px; font-size: .92rem; font-weight: 500; }
.ajustes-menu a:hover { background: #eef1f8; }
.ajustes-menu a.active { background: #eef0ff; color: var(--brand); }

/* Quirófano programado o no (según los partes de la aplicación) */
.qx-prog { display: block; margin: .25rem auto 0; font-size: .68rem; font-weight: 700; letter-spacing: .02em; text-decoration: none; padding: .15rem .45rem; border-radius: 999px; width: fit-content; white-space: nowrap; }
.qx-prog.si { background: #dcfce7; color: #15803d; }
.qx-prog.no { background: #f1f5f9; color: #64748b; border: 1px dashed #cbd5e1; }
a.qx-prog:hover { filter: brightness(.95); text-decoration: underline; }
@media print { .qx-prog { display: none; } }

/* Quirófanos juntos: una casilla ancha con las dos personas */
table.cq tr.r-junta td.cell-junta { height: auto; padding: 4px 5px; }
.cell-junta .slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.cell-junta .slot { border-radius: 9px; padding: 1px; }
.cell-junta .slot.editable { cursor: pointer; }
.cell-junta .slot.editable:hover { background: #eef2ff; }
.cell-junta .slot-vacio { min-width: 26px; padding: .1rem .45rem; border: 1px dashed #cbd5e1; color: #94a3b8; font-weight: 700; font-size: .8rem; line-height: 1.3; }
table.cq td.past .slot-vacio { opacity: .5; }
@media print { .cell-junta .slot-vacio { display: none; } }
.cell-junta .slot-vacio { opacity: 0; transition: opacity .12s; }
table.cq td.cell-junta:hover .slot-vacio, .cell-junta .slot-vacio:focus { opacity: 1; }
@media (hover: none) { .cell-junta .slot-vacio { opacity: .55; } }

/* Peonadas (tardes de quirófano extra) */
:root { --peon: #7c4a2d; --peon-bg: #f1e6dc; }
.chip.k-peon { background: var(--peon-bg); color: #6b3d22; border-left-color: var(--peon); }
.chip.k-peon.peon-libre { background: #fff; color: #94a3b8; border: 1px dashed #c9ad98; border-left: 3px solid var(--peon); font-weight: 500; font-style: italic; }
.chip.peon-libre .tag { font-style: normal; }
.lg-peon i, .dot.k-peon { background: var(--peon); }
.peon-nota { font-size: .68rem; color: #6b3d22; margin-top: .15rem; }
button.btn-peon { border-color: #c9ad98; color: #6b3d22; background: #faf5f0; }
button.btn-peon:hover { background: var(--peon-bg); }
dialog.peonada-dlg { width: min(460px, 92vw); box-sizing: border-box; }
.peonada-dlg form { display: flex; flex-direction: column; gap: .6rem; }
.peonada-dlg label { display: flex; flex-direction: column; gap: .25rem; }
.peonada-dlg input, .peonada-dlg select { width: 100%; box-sizing: border-box; }
.peon-tag { font-size: .62rem; font-weight: 800; letter-spacing: .05em; padding: .1rem .35rem; border-radius: 4px; color: #fff; background: var(--peon); }
.slots-peon .slot { padding: 0; }

/* Pestaña Deshacer (historial de cambios) */
.hs-sub { margin: .2rem 0 0; font-size: .85rem; max-width: 820px; }
.hs-list { padding: 0; overflow: hidden; }
.hs-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.hs-item:last-child { border-bottom: 0; }
.hs-siguiente { background: #fff7f8; box-shadow: inset 4px 0 0 var(--danger); }
.hs-desc { font-weight: 600; }
.hs-meta { font-size: .8rem; color: var(--ink-2); margin-top: .15rem; }
.hs-deshecho .hs-desc { text-decoration: line-through; color: var(--ink-3); }

/* Botón ↶ deshacer (editores) */
.undo-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 999px; font-size: 1.25rem; line-height: 1; font-weight: 700; cursor: pointer;
  border: 1px solid #c7cbfa; background: #eef0ff; color: var(--brand); transition: background .15s, transform .15s; }
.undo-btn:hover:not(:disabled) { background: var(--brand); color: #fff; transform: rotate(-20deg); }
.undo-btn:disabled { cursor: default; border-color: var(--line); background: #f1f5f9; color: #cbd5e1; }
.cq-actions .undo-btn { width: 40px; height: 40px; flex: none; }

/* ---- Cuadrante en móvil: edición tras «+» y leyenda tras su botón ---- */
.solo-movil { display: none; }
.cq-edit { display: contents; }
.btn-icono { width: 40px; height: 40px; padding: 0; border-radius: 999px; font-size: 1.4rem; font-weight: 700; line-height: 1; flex: none; }
.cq-actions .btn-mas.on, .cq-actions .btn-mas.on:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-leyenda.on { background: #eef1f8; }
@media (max-width: 700px) {
  .solo-movil { display: inline-grid; place-items: center; }
  .btn-leyenda { padding: 0 .9rem; height: 40px; }
  .cq-actions { flex-wrap: wrap; justify-content: flex-start; }
  /* acciones de edición: ocultas hasta pulsar «+» */
  .cq-edit.editor { display: none; }
  .panel-abierto .cq-edit.editor { display: flex; flex-direction: column; align-items: stretch; gap: .5rem; width: 100%; padding: .6rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
  .panel-abierto .cq-edit.editor button { width: 100%; }
  .cq-open, .hint { display: none !important; }
  .panel-abierto .cq-open { display: flex !important; }
  /* leyenda: oculta hasta pulsar «Leyenda» */
  .cq-legend { display: none; }
  .leyenda-abierta .cq-legend { display: flex; }
}
