/* =====================================================================
   PARTE Y RUTA — estilos
   Mismo sistema visual que el prototipo que vio el equipo.
   ===================================================================== */

@font-face { font-family: "Archivo"; font-weight: 400; font-display: swap; src: url("fonts/archivo-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 500; font-display: swap; src: url("fonts/archivo-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap; src: url("fonts/archivo-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url("fonts/archivo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --bg: #E7EDEF;
  --surface: #FFFFFF;
  --surface-2: #F1F5F6;
  --surface-3: #E4EBED;
  --ink: #0F1E25;
  --muted: #5A727D;
  --border: #D7E1E5;
  --border-strong: #BACAD0;
  --accent: #0B6E77;
  --accent-soft: #DEEEEF;
  --on-accent: #FFFFFF;
  --warn: #8A5410;
  --warn-soft: #F8EFDE;
  --danger: #96322A;
  --danger-soft: #F8E7E4;
  --ok: #276848;
  --ok-soft: #E1F0E8;
  --shadow: 0 1px 2px rgba(15,30,37,.06), 0 8px 24px rgba(15,30,37,.07);
  --f: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --m: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070E11; --surface: #111D22; --surface-2: #16252B; --surface-3: #1D2F36;
    --ink: #E2ECEF; --muted: #8CA3AC; --border: #22343B; --border-strong: #354A52;
    --accent: #4CBCC3; --accent-soft: #102F32; --on-accent: #05191C;
    --warn: #D2A660; --warn-soft: #2A2214;
    --danger: #E0917F; --danger-soft: #2E1B18;
    --ok: #76C69C; --ok-soft: #12291F;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- cabecera ---------- */

.top { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.top-in { max-width: 72rem; margin: 0 auto; padding: .65rem 1rem; display: flex; align-items: center; gap: .9rem; }
.brand { display: flex; flex-direction: column; gap: .05rem; margin-right: auto; min-width: 0; }
.brand b { font-weight: 700; font-size: .98rem; letter-spacing: -.01em; }
.brand span { font-family: var(--m); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { text-align: right; font-size: .8rem; color: var(--muted); line-height: 1.25; }
.who b { display: block; color: var(--ink); font-weight: 600; font-size: .86rem; }
.salir { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: .35rem .75rem; font-size: .8rem; color: var(--muted); }

.banner { max-width: 72rem; margin: 0 auto; padding: .55rem 1rem; font-size: .84rem; display: flex; gap: .6rem; align-items: center; }
.banner-wrap { border-bottom: 1px solid var(--border); }
.banner-wrap.off { background: var(--danger-soft); color: var(--danger); }
.banner-wrap.install { background: var(--accent-soft); }
.banner .x { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: .1rem .3rem; }

/* ---------- contenedores ---------- */

main { padding: 1rem 1rem 2rem; }
.col { max-width: 30rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.wide { max-width: 72rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.wide > * { min-width: 0; }

.pagehead { display: flex; flex-direction: column; gap: .2rem; }
.pagehead h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.pagehead .sub { font-size: .85rem; color: var(--muted); }

/* ---------- login ---------- */

.login { max-width: 23rem; margin: 8vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; box-shadow: var(--shadow); padding: 1.6rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; }
.login h1 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
.login .lead { margin: 0; color: var(--muted); font-size: .9rem; }
.login .help { font-size: .8rem; color: var(--muted); text-align: center; }
.err { color: var(--danger); background: var(--danger-soft); border-radius: .5rem; padding: .55rem .7rem; font-size: .86rem; }

/* doble factor */
.login.ancho { max-width: 27rem; }
.pasos { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .8rem; font-size: .9rem; }
.pasos li::marker { color: var(--accent); font-weight: 600; }
.pasos details { margin-top: .5rem; font-size: .85rem; }
.pasos summary { cursor: pointer; color: var(--accent); }
.qr { margin: .6rem 0 .2rem; }
.qr img { display: block; width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: .5rem; border: 1px solid var(--border); }
.clave { font-size: .95rem; letter-spacing: .06em; word-break: break-all; background: var(--surface-3); border-radius: .4rem; padding: .5rem .6rem; margin: .4rem 0; user-select: all; }
input.codigo { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }

/* fotos de tickets */
.thumbrow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.thumb { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: .5rem; border: 1px solid var(--border); background: var(--surface-3); }
.ticketimg { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: .5rem; border: 1px solid var(--border); background: #fff; }

/* ---------- piezas ---------- */

.pill { display: inline-flex; align-items: center; gap: .3rem; font-family: var(--m); font-size: .64rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; padding: .2rem .45rem; border-radius: .25rem; white-space: nowrap; }
.pill.entrega { background: var(--accent-soft); color: var(--accent); }
.pill.recogida { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.alert { background: var(--danger-soft); color: var(--danger); }
.pill.wait { background: var(--surface-3); color: var(--muted); }
.pill.amp { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }

.label { font-family: var(--m); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--m); font-size: .82rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.orig { font-size: .78rem; color: var(--muted); }
.warntxt { color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: .5rem; padding: .8rem 1rem; font-weight: 600; font-size: .95rem; width: 100%; text-align: center; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.quiet { background: var(--surface-2); border-color: var(--border); color: var(--ink); font-weight: 500; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: .5rem .8rem; font-size: .84rem; width: auto; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; }
.btnrow > .btn { flex: 1; }
.btnrow.tight { justify-content: flex-end; min-width: 13rem; }
.btnrow.tight > .btn { flex: 0 0 auto; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-size: .86rem; font-weight: 500; text-align: left; }

.box { border: 1px solid var(--border); border-radius: .7rem; background: var(--surface); overflow: hidden; }
.box > .box-head { padding: .6rem .85rem; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.box > .grp { padding: .45rem .85rem; background: var(--surface-2); border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); }
.box > .grp:first-child { border-top: 0; }
.box.accent { background: var(--accent-soft); border-color: var(--accent); }
.box.okbox { background: var(--ok-soft); border-color: var(--ok); }

.row { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row.stack { flex-direction: column; align-items: stretch; gap: .5rem; }

.counter { display: flex; align-items: center; gap: .1rem; }
.counter button { width: 2.2rem; height: 2.2rem; border: 1px solid var(--border-strong); background: var(--surface); border-radius: .4rem; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; color: var(--accent); }
.counter .v { width: 2.2rem; text-align: center; font-family: var(--m); font-size: 1rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.counter .v.zero { color: var(--muted); opacity: .5; }

.toggle { width: 2.9rem; height: 1.7rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-3); position: relative; flex: none; transition: background .15s; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.toggle[aria-pressed="true"]::after { transform: translateX(1.2rem); }

input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], textarea, select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: .5rem; padding: .62rem .7rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 4rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.fields { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .86rem; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: .12rem 0 0; flex: none; accent-color: var(--accent); }

.seg { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: .45rem; padding: .45rem .7rem; font-size: .86rem; color: var(--muted); }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.optlist { display: flex; flex-direction: column; gap: .45rem; }
.opt { text-align: left; width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: .5rem; padding: .6rem .75rem; display: flex; flex-direction: column; gap: .15rem; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt b { font-size: .92rem; font-weight: 600; }
.opt span { font-size: .8rem; color: var(--muted); }

.empty { text-align: center; color: var(--muted); font-size: .9rem; padding: 1.6rem 1rem; border: 1px dashed var(--border-strong); border-radius: .7rem; }
.loading { color: var(--muted); font-size: .9rem; text-align: center; padding: 3rem 1rem; }

/* ---------- hospital ---------- */

.maqrow { display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
.maqrow:last-child { border-bottom: 0; }
.maqnum { font-family: var(--m); font-size: 1.15rem; font-weight: 500; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.maqrow .x { border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: .4rem; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; font-size: 1.05rem; line-height: 1; flex: none; }
.since { font-size: .78rem; color: var(--muted); }
.searchbox { display: flex; flex-direction: column; gap: .5rem; padding: .85rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.hit { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: .5rem; padding: .55rem .7rem; }
.hit .loc { font-size: .78rem; color: var(--muted); margin-left: auto; text-align: right; }
.hit:disabled { opacity: .45; }
.reasons { display: flex; flex-direction: column; gap: .4rem; padding: .85rem; background: var(--warn-soft); border-bottom: 1px solid var(--border); }
.reasons .q { font-size: .88rem; font-weight: 600; }
.reasons button { text-align: left; border: 1px solid var(--border-strong); background: var(--surface); border-radius: .45rem; padding: .6rem .7rem; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { font-family: var(--m); font-size: .85rem; border: 1px solid var(--border); background: var(--surface-2); border-radius: .35rem; padding: .15rem .45rem; }
button.chip { font-size: 1rem; padding: .45rem .7rem; color: var(--ink); cursor: pointer; }
button.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- reparto ---------- */

.tabs { display: flex; border: 1px solid var(--border); border-radius: .7rem; overflow: hidden; background: var(--surface-2); }
.tabs button { flex: 1; border: 0; background: transparent; padding: .6rem .3rem; font-size: .82rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; display: flex; flex-direction: column; align-items: center; gap: .05rem; }
.tabs button b { font-family: var(--m); font-size: 1rem; font-weight: 500; }
.tabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

.stoplist { display: flex; flex-direction: column; gap: .6rem; }
.stop { display: flex; gap: .7rem; padding: .85rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--surface); align-items: flex-start; }
.stop.done { opacity: .66; }
.stop .ord { font-family: var(--m); font-size: .95rem; color: var(--accent); font-variant-numeric: tabular-nums; padding-top: .1rem; flex: none; min-width: 1.2rem; }
.stop .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; border: 0; background: none; padding: 0; text-align: left; }
.stop .shead { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.stop .hora { font-family: var(--m); font-size: .76rem; color: var(--muted); margin-left: auto; }
.stop .name { font-weight: 600; font-size: .96rem; }
.stop .dir { font-size: .84rem; color: var(--muted); }
.stop .foot { display: flex; gap: .5rem; flex-wrap: wrap; font-family: var(--m); font-size: .74rem; color: var(--muted); }
.moves { display: flex; flex-direction: column; gap: .25rem; flex: none; }
.moves button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: .35rem; width: 2rem; height: 1.75rem; display: grid; place-items: center; font-size: .72rem; line-height: 1; }
.moves button:disabled { opacity: .3; }

/* ---------- administración ---------- */

.atabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.atabs::-webkit-scrollbar { display: none; }
.atabs button { border: 0; background: transparent; padding: .7rem .85rem; font-size: .9rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; }
.atabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.kpis { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
.kpi { border: 1px solid var(--border); border-radius: .6rem; padding: .75rem .85rem; background: var(--surface); display: flex; flex-direction: column; gap: .1rem; }
.kpi .n { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi.bad .n { color: var(--danger); }
.kpi .l { font-family: var(--m); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.notice { border: 1px solid var(--danger); background: var(--danger-soft); border-radius: .6rem; padding: .75rem .9rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.notice .txt { flex: 1; font-size: .9rem; min-width: 12rem; }

.section { display: flex; flex-direction: column; gap: .5rem; }
.section > h2 { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem; }
.section > .help { font-size: .84rem; color: var(--muted); margin: 0; }

.tablewrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: .6rem; background: var(--surface); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 46rem; font-size: .86rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
thead th { font-family: var(--m); font-size: .62rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--m); font-size: .82rem; }
td.wrap { white-space: normal; min-width: 14rem; }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { min-width: 9rem; }

.planner { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 54rem) { .planner { grid-template-columns: 1fr; } }
.plancol { border: 1px solid var(--border); border-radius: .7rem; overflow: hidden; min-width: 0; background: var(--surface); }
.plancol .ch { padding: .7rem .9rem; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.plancol .ch h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.plancol .cb { padding: .7rem; display: flex; flex-direction: column; gap: .5rem; }
.task { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); background: var(--surface); border-radius: .55rem; padding: .6rem .7rem; }
.task .tmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.task .tname { font-weight: 600; font-size: .9rem; }
.task .tsub { font-size: .8rem; color: var(--muted); }
.task .tacts { display: flex; flex-direction: column; gap: .3rem; flex: none; }
.taglines { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }

.aviso { display: flex; gap: .8rem; padding: .75rem .85rem; border-bottom: 1px solid var(--border); align-items: flex-start; flex-wrap: wrap; }
.aviso:last-child { border-bottom: 0; }
.aviso .grow { flex: 1; min-width: 14rem; display: flex; flex-direction: column; gap: .15rem; }
.aviso .t { font-weight: 600; font-size: .93rem; }
.aviso .d { font-size: .84rem; color: var(--muted); }
.aviso .w { font-size: .84rem; color: var(--warn); }
.aviso .acts { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- hoja modal ---------- */

.sheet-bg { position: fixed; inset: 0; z-index: 80; background: rgba(6,14,17,.55); display: flex; align-items: flex-end; justify-content: center; padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
@media (min-width: 34rem) { .sheet-bg { align-items: center; } }
.sheet { width: 100%; max-width: 30rem; max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: .9rem; box-shadow: var(--shadow); padding: 1.1rem; display: flex; flex-direction: column; gap: .85rem; }
.sheet h2 { margin: 0; font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.sheet .where { font-size: .84rem; color: var(--muted); }
.sheet .foot { display: flex; gap: .5rem; }
.sheet .foot .btn { flex: 1; }

/* ---------- botón flotante y aviso ---------- */

/* sugerencias: al final de la página, nunca encima de un botón de trabajo */
.fab { display: block; margin: 0 auto 2.5rem; border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); border-radius: 999px; padding: .55rem 1rem; font-weight: 500; font-size: .84rem; }

#toast { position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom)); transform: translate(-50%, 1.5rem); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: .5rem; font-size: .9rem; font-weight: 500; max-width: calc(100vw - 2rem); text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- impresión del listado de ruta ---------- */

#print { display: none; }
@media print {
  body { background: #fff; color: #000; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; font-family: var(--f); font-size: 11pt; }
  #print h1 { font-size: 15pt; margin: 0 0 .3rem; }
  #print table { min-width: 0; font-size: 10pt; }
  #print th, #print td { white-space: normal; border-bottom: 1px solid #999; padding: 4pt 6pt; }
}
