:root {
  /* Paleta de la propuesta v7: verde discreto para acciones, ámbar para plazos cercanos, rojo para vencidos. */
  --fondo: #f5f7f4; --surface-0: #fff; --surface-1: #e9eeea; --border: #dde5de;
  --text-primary: #20372f; --text-secondary: #66736b; --text-muted: #87938b;
  --text-success: #21634e; --text-accent: #21634e; --sobre-marca: #fff; --marca-suave: #e7f0e9;
  --text-warning: #835a16; --ambar-suave: #f7efdf; --text-danger: #a63b39; --rojo-suave: #f9eeec;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #141b19; --surface-0: #1d2723; --surface-1: #28372e; --border: #3b4c42;
    --text-primary: #e5ede7; --text-secondary: #a6b5ac; --text-muted: #7f8f86;
    --text-success: #8ed0b1; --text-accent: #8ed0b1; --sobre-marca: #123827; --marca-suave: #263f31;
    --text-warning: #e9c17c; --ambar-suave: #3f3522; --text-danger: #ffb4aa; --rojo-suave: #432c29;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, sans-serif; font-size: 16px; line-height: 1.4;
  color: var(--text-primary); background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom)); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 22px; margin: 16px 0; }
h2 { font-size: 15px; color: var(--text-secondary); font-weight: 600; margin: 20px 0 8px; }
.muted { color: var(--text-muted); font-size: 14px; }
.error { color: var(--text-danger); min-height: 1.4em; text-align: center; margin: 8px 0; }
.centro { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; }

/* Barra superior */
.barra { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.barra .titulo { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icono-btn { background: none; border: 0; padding: 8px; border-radius: 10px; font-size: 22px; line-height: 1; position: relative; }
.icono-btn:active { background: var(--surface-1); }
.contador { position: absolute; top: 2px; right: 0; background: var(--text-danger); color: var(--surface-0); border-radius: 10px;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; }

/* Avatares */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700;
  flex: none; font-size: 15px; border: 0; padding: 0; }
.avatar.grande { width: 72px; height: 72px; font-size: 26px; }
.equipo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 12px; width: 100%; margin-top: 12px; }
.persona { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; }
.persona:active { background: var(--surface-1); }

/* Teclado del PIN */
.puntos { display: flex; gap: 14px; margin: 8px 0; }
.punto { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-secondary); }
.punto.lleno { background: var(--text-primary); border-color: var(--text-primary); }
.teclado { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; margin-top: 8px; }
.tecla { height: 76px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-1); font-size: 28px; }
.tecla:active { background: var(--border); }
.tecla:disabled { opacity: .3; }
.tecla.borrar { background: none; border: 0; font-size: 22px; }

/* Mosaico de módulos */
.mosaico { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 18px 14px; text-align: left;
  display: flex; flex-direction: column; gap: 10px; min-height: 104px; }
.tile:active { background: var(--border); }
.tile .ico { font-size: 28px; line-height: 1; }
.tile .nom { font-weight: 600; }

/* Listas y formularios */
.lista { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-0); border: 0;
  border-bottom: 1px solid var(--border); text-align: left; width: 100%; }
.fila:last-child { border-bottom: 0; }
.fila .txt { flex: 1; min-width: 0; }
.fila .sub { color: var(--text-secondary); font-size: 14px; }
.fila.no-leido { background: var(--surface-1); }
.fila.inactivo { opacity: .5; }
.marca { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-accent); }
.marca.aviso { background: var(--text-warning); }
.marca.urgente { background: var(--text-danger); }
.vacio { padding: 24px; text-align: center; color: var(--text-muted); }

label.campo { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 14px; color: var(--text-secondary); }
input[type=text], input[type=number], input[type=password], input[type=tel], input[type=date], input[inputmode], select {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-0); font-size: 16px; color: var(--text-primary); width: 100%; }
label.campo textarea { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-0); color: var(--text-primary); font: inherit; }
input.codigo { text-align: center; letter-spacing: 4px; text-transform: uppercase; font-size: 24px; width: 100%; max-width: 280px; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--text-success); }
.colores { display: flex; gap: 10px; flex-wrap: wrap; }
.color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; }
.color.sel { border-color: var(--text-primary); }

.btn { border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 600; background: var(--text-success); color: var(--sobre-marca); width: 100%; margin-top: 12px; min-height: 48px; }
.btn.secundario { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); }
.btn.peligro { background: none; color: var(--text-danger); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; }
.enlace { background: none; border: 0; color: var(--text-accent); padding: 8px; min-height: 44px; font-weight: 550; }

.codigo-grande { font-size: 34px; font-weight: 700; letter-spacing: 6px; font-family: ui-monospace, monospace; }

/* Ventana de confirmación */
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: end center; padding: 16px; z-index: 10; }
.dialogo { background: var(--surface-0); border-radius: 18px; padding: 20px; width: 100%; max-width: 480px; }
.dialogo p { margin: 0 0 8px; font-size: 17px; text-align: center; }
.dialogo .detalle { color: var(--text-secondary); font-size: 14px; text-align: center; margin-bottom: 8px; }
.dialogo .botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text-primary); color: var(--surface-0); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; }

/* Temperaturas */
.ok { color: var(--text-success); } .warn { color: var(--text-warning); } .bad { color: var(--text-danger); }
.sub-cab { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.usb { border: 2px solid var(--text-warning); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.usb .btn { margin-top: 8px; padding: 10px; }
.hecho-dia { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 18px 12px;
  margin-bottom: 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.hecho-dia .hecho-ico { font-size: 30px; }
.hecho-dia .muted { font-size: 14px; }
.incidencia-hoy { margin-top: 10px; font-size: 14px; }
.incidencia-hoy .en-linea { justify-content: center; margin-top: 4px; }
.tpunto { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.tpunto-cab { display: flex; align-items: center; gap: 8px; font-size: 17px; margin-bottom: 4px; }
.tpunto-cab .ico { font-size: 24px; }
.fila-cap, .fila-val { display: grid; grid-template-columns: 1fr 58px 58px 58px 24px; gap: 6px; align-items: center; }
.fila-cap { font-size: 12px; color: var(--text-secondary); text-align: center; }
.fila-val { padding: 4px 0; }
.etq { font-size: 14px; display: flex; flex-direction: column; }
.etq small { color: var(--text-secondary); font-size: 11px; }
input.num { width: 100%; text-align: center; font-size: 18px; padding: 8px 2px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-0); color: var(--text-primary); }
.estado { text-align: center; font-size: 18px; font-weight: 700; }
.incidencia { margin-top: 8px; padding: 10px; border: 1px dashed var(--text-danger); border-radius: 10px; color: var(--text-danger); font-size: 14px; }
.aviso-suave { margin-top: 6px; font-size: 13px; color: var(--text-warning); }
.opciones { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opcion { padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); color: var(--text-primary); }
.opcion.sel { border: 2px solid var(--text-accent); color: var(--text-accent); font-weight: 600; }
.nav-mes { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.nav-mes .enlace { font-size: 24px; }
.seg { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: none; font-size: 14px; }
.seg button.sel { border-color: var(--text-accent); color: var(--text-accent); }
.tabla-scroll { overflow-x: auto; margin-bottom: 10px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist th, table.hist td { padding: 6px 2px; text-align: center; border-top: 1px solid var(--border); }
table.hist th { color: var(--text-secondary); font-weight: 500; }
table.hist td small { display: block; font-size: 11px; color: var(--text-secondary); }
table.hist td.d { text-align: left; color: var(--text-secondary); }
table.hist td.vacio { color: var(--text-muted); }
.nota { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.dl { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; font-size: 15px; border-top: 1px solid var(--border); }
.dl:first-child { border-top: none; }
.bloqueado { text-align: center; font-size: 14px; color: var(--text-secondary); }
.corr { background: var(--surface-1); border-left: 3px solid var(--text-warning); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.fi { padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; }
.tachado { text-decoration: line-through; color: var(--text-secondary); }
tr.abre { cursor: pointer; }
.nota a { text-decoration: none; }
.en-linea { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.en-linea input.num { width: 80px; font-size: 16px; }
.botones-fila { display: flex; gap: 10px; }
.botones-fila .btn { text-align: center; text-decoration: none; display: block; }

/* Encargos (v7) */
.acc { color: var(--text-accent); }
.enc-cab { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.enc-cab h1 { font-size: 28px; margin: 0; letter-spacing: -.5px; }
.enc-fecha { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: .6px; text-transform: uppercase; color: var(--text-secondary); }
.btn.enc-nuevo { width: auto; margin: 0; padding: 12px 18px; }
.enc-pestanas { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; }
.enc-pestanas button { border: 0; background: none; color: var(--text-secondary); min-height: 46px; padding: 0 0 10px;
  display: flex; align-items: center; gap: 8px; font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.enc-pestanas button.sel { color: var(--text-accent); border-color: var(--text-accent); font-weight: 650; }
.enc-num { background: var(--surface-1); color: var(--text-secondary); border-radius: 8px; padding: 1px 7px; font-size: 12px; }
.enc-alerta { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px;
  margin-bottom: 14px; padding: 12px 14px; border: 0; border-left: 3px solid var(--text-danger); border-radius: 5px 12px 12px 5px;
  background: var(--rojo-suave); color: var(--text-danger); font-weight: 550; text-align: left; }
.enc-buscar { display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-0); color: var(--text-secondary); }
.enc-buscar input { border: 0; background: none; min-height: 46px; width: 100%; font-size: 16px; color: var(--text-primary); outline: none; }
.enc-filtros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-top: 12px; padding: 3px; border-radius: 12px; background: var(--surface-1); }
.enc-filtros button { border: 0; background: none; border-radius: 9px; min-height: 52px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 12px; color: var(--text-secondary); padding: 4px 2px; }
.enc-filtros button strong { font-size: 16px; color: var(--text-primary); }
.enc-filtros button.sel { background: var(--surface-0); box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--text-accent); }
.enc-lista-cab { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.enc-lista-cab h2 { margin: 0; color: var(--text-primary); font-size: 15px; }
.enc-tarjeta { background: var(--surface-0); border: 1px solid var(--border); border-radius: 18px; padding: 16px; margin-bottom: 10px; }
.enc-tarjeta.roja { border-left: 3px solid var(--text-danger); }
.enc-tarjeta h3 { font-size: 17px; margin: 6px 0 4px; font-weight: 600; }
.enc-ceja { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-accent); }
.enc-ceja .muted { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 13px; }
.enc-ceja.bad { color: var(--text-danger); } .enc-ceja.warn { color: var(--text-warning); }
.enc-meta { margin: 0; font-size: 14px; color: var(--text-secondary); }
.enc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.enc-tag { font-size: 12px; background: var(--surface-1); color: var(--text-secondary); border-radius: 7px; padding: 2px 8px; }
.enc-plazo { margin: 8px 0 0; font-size: 14px; }
.enc-pie { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.enc-pie .enlace { padding-left: 0; }
.btn-acc { border: 0; border-radius: 12px; min-height: 44px; padding: 10px 16px; background: var(--marca-suave); color: var(--text-accent); font-weight: 650; }
.enc-tarjeta.roja .btn-acc { background: var(--rojo-suave); color: var(--text-danger); }
.btn.suave { background: var(--marca-suave); color: var(--text-accent); }
.enc-volver { display: block; padding-left: 0; text-align: left; }
.enc-producto { font-size: 24px; color: var(--text-primary); margin: 6px 0 4px; letter-spacing: -.3px; }
.enc-pasos { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.enc-pasos li { font-size: 12px; text-align: center; color: var(--text-secondary); padding-top: 9px; border-top: 4px solid var(--surface-1); }
.enc-pasos li.hecho { border-color: var(--text-accent); color: var(--text-primary); }
.enc-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.enc-datos dt { font-size: 12px; color: var(--text-secondary); }
.enc-datos dd { margin: 2px 0 0; font-size: 16px; font-weight: 550; overflow-wrap: anywhere; }
.enc-tarjeta.detalle > .enlace { display: block; margin-top: 6px; padding-left: 0; }
.enc-actividad, .enc-proximos, .enc-paciente { margin: 12px 0; }
.enc-actividad summary, .enc-proximos summary, .enc-paciente summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.enc-actividad ul { list-style: none; padding: 0; margin: 4px 0; }
.enc-actividad li { display: flex; flex-direction: column; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.enc-seccion { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--text-primary); font-size: 15px; margin: 22px 0 10px; }
.enc-seccion .muted { font-weight: 400; font-size: 13px; }
.enc-seccion:first-child { margin-top: 0; }
.enc-lote-cab { display: flex; justify-content: space-between; align-items: baseline; }
.enc-lote-cab h3 { margin: 0 0 4px; font-size: 18px; }
.enc-fila { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.enc-fila:last-of-type { border-bottom: 0; }
.enc-nota { font-size: 13px; color: var(--text-secondary); text-align: center; margin: 8px 0 0; }
.enc-resumen { text-align: left; margin: 0 0 8px; padding-left: 20px; color: var(--text-primary); }
.enc-opciones { display: flex; flex-direction: column; gap: 4px; }
.enc-opciones .btn { margin-top: 6px; }
.enc-mensaje { margin: 12px 0 0; padding: 14px; border-radius: 14px 14px 14px 2px; background: var(--marca-suave); color: var(--text-primary);
  text-align: left; line-height: 1.6; }
.enc-form .campo { color: var(--text-primary); font-weight: 550; }
.enc-form .campo small { font-weight: 400; }
.enc-foto { display: flex; flex-direction: column; gap: 8px; padding: 14px; margin: 12px 0; border: 1px dashed var(--border);
  border-radius: 12px; font-weight: 550; color: var(--text-primary); }
.enc-foto .btn { margin: 0; display: block; text-align: center; cursor: pointer; }
.enc-foto-vista img { display: block; max-width: 100%; max-height: 160px; border-radius: 8px; margin-top: 10px; }
.enc-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.enc-dos .campo { margin: 12px 0 0; }
.casilla { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.casilla input { width: 22px; height: 22px; accent-color: var(--text-accent); flex: none; }
.deshacer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; margin-bottom: 12px;
  border-radius: 12px; background: var(--marca-suave); color: var(--text-accent); font-size: 14px; }
.form-modal { text-align: left; color: var(--text-primary); }
.form-modal textarea { width: 100%; }
label.campo textarea { width: 100%; }
