/* Guardias Assert: estilos compartidos.
   Identidad: el naranja de Assert marca "de guardia", sobre azul noche. */
:root {
  --baliza: #ec6329;
  --baliza-suave: #fbddd0;
  --baliza-texto: #2a1205;
  --noche: #16213b;
  --noche-2: #22304f;
  --noche-suave: #e3e6ec;
  --acero: #5d6b7e;
  --papel: #f1f2ee;
  --blanco: #fbfbf9;
  --agua: #2f8f7e;
  --agua-suave: #d8ece7;
  --choque: #b3263e;
  --choque-suave: #f6dfe3;

  /* Nombres que usan las pantallas */
  --ink: var(--noche);
  --muted: var(--acero);
  --line: #d9dcd6;
  --canvas: var(--papel);
  --surface: var(--blanco);
  --indigo: var(--noche);
  --indigo-hover: var(--noche-2);
  --indigo-soft: var(--noche-suave);
  --ok: #23705f;
  --ok-soft: var(--agua-suave);
  --warn: #9a3d12;
  --warn-soft: var(--baliza-suave);
  --bad: var(--choque);
  --bad-soft: var(--choque-suave);
  --info: #3a5677;
  --info-soft: #dfe7f0;
  --radius: 10px;
  --radius-lg: 12px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-variation-settings: 'wdth' 100;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.85rem; font-weight: 800; font-variation-settings: 'wdth' 118; letter-spacing: -0.015em; }
h2 { font-size: 1.08rem; font-weight: 700; font-variation-settings: 'wdth' 110; }
p { margin: 0; }
a { color: var(--noche); text-decoration-color: var(--baliza); text-decoration-thickness: 2px; text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--baliza); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px; background: var(--noche); color: #fff;
}
.marca { display: block; padding: 4px 10px 4px; text-decoration: none; }
.marca img { display: block; height: 34px; width: auto; }
.producto { display: block; padding: 6px 10px 20px; color: #a3adc0; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.01em; }
.nav .item, .hoja-menu .item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px;
  color: #a3adc0; text-decoration: none; font-weight: 550; font-size: 0.94rem;
}
.nav .item svg, .hoja-menu .item svg { width: 20px; height: 20px; flex: none; }
.nav .item:hover, .hoja-menu .item:hover { background: rgb(255 255 255 / .06); color: #fff; }
.nav .item[aria-current='page'], .hoja-menu .item[aria-current='page'] { background: rgb(255 255 255 / .09); color: #fff; box-shadow: inset 3px 0 0 var(--baliza); }
.nav .item.mas { display: none; font: inherit; border: 0; background: none; cursor: pointer; }
.nav .separador, .hoja-menu .separador { height: 1px; background: rgb(255 255 255 / .08); margin: 8px 10px; }
.yo { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid rgb(255 255 255 / .08); }
.yo div { min-width: 0; flex: 1; }
.yo strong { display: block; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yo button { font: inherit; font-size: 0.82rem; padding: 0; border: 0; background: none; color: #a3adc0; cursor: pointer; text-decoration: underline; }
.yo .avatar { background: var(--noche-2); color: #fff; }

/* Panel "Más" del menú en celular: sube desde abajo. */
.hoja-menu {
  margin: auto 0 0; width: 100%; max-width: none; max-height: 82vh; overflow-y: auto;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); border: 0; border-radius: 18px 18px 0 0;
  background: var(--noche); color: #fff;
}
.hoja-menu::backdrop { background: rgb(10 16 30 / .55); }
.hoja-menu[open] { animation: subir-hoja .18s ease-out; }
@keyframes subir-hoja { from { transform: translateY(24px); opacity: .6; } }
.hoja-menu header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 10px; }
.hoja-menu .cerrar { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .06); color: #fff; cursor: pointer; }
.hoja-menu .cerrar svg { width: 20px; height: 20px; }
.hoja-menu nav { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.hoja-menu .separador { grid-column: 1 / -1; }
.hoja-menu .item { padding: 12px 10px; }
.hoja-menu .yo { margin-top: 12px; }

main { padding: 34px 44px 64px; min-width: 0; max-width: 1240px; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.encabezado .acciones { display: flex; gap: 10px; flex-wrap: wrap; }
.volver { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-weight: 550; font-size: 0.9rem; }
.volver:hover { color: var(--ink); }
.volver svg { width: 18px; height: 18px; }

/* Debajo de 1024 px el menú es una barra fija abajo con los accesos
   principales y "Más" para el resto. */
@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 20;
    flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); overflow: visible;
  }
  .marca, .producto, .nav .yo, .nav .separador, .nav .item:not(.fijo):not(.mas) { display: none; }
  .nav .item, .nav .item.mas { display: flex; flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; font-size: 0.68rem; padding: 6px 4px; }
  .nav .item span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav .item[aria-current='page'], .nav .item.mas[data-actual] { background: rgb(255 255 255 / .09); color: #fff; box-shadow: inset 0 3px 0 var(--baliza); }
  main { padding: 28px 28px 96px; }
}
@media (max-width: 860px) {
  main { padding: 20px 16px 96px; }
  h1 { font-size: 1.45rem; }
}
@media (max-width: 380px) { .hoja-menu nav { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------- piezas */
/* Rol de guardia junto al nombre (Funcional, Desarrollo…). */
.rol-guardia { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--noche-suave); color: var(--noche); font-size: 0.76rem; font-weight: 650; line-height: 1.5; white-space: nowrap; vertical-align: 1px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel + .panel { margin-top: 18px; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.panel > .cuerpo { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 2px solid var(--noche);
  font: inherit; font-weight: 650; font-size: 0.93rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--noche); color: #fff;
}
.btn:hover { background: var(--noche-2); border-color: var(--noche-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn.secundario { background: transparent; color: var(--ink); border-color: var(--noche); }
.btn.secundario:hover { background: var(--noche-suave); }
.btn.peligro { background: transparent; color: var(--bad); border-color: #e6aaa4; }
.btn.peligro:hover { background: var(--bad-soft); }
.btn.bloque { width: 100%; }

.avatar {
  --h: 220;
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: hsl(var(--h) 28% 87%); color: hsl(var(--h) 38% 28%);
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.02em;
}
.avatar.grande { width: 64px; height: 64px; font-size: 1.3rem; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 650; white-space: nowrap; background: #e8eae5; color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.indigo { background: var(--noche-suave); color: var(--noche); }

.aviso { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: var(--info-soft); color: #23384f; margin-bottom: 18px; border-left: 4px solid var(--info); }
.aviso.warn { background: var(--baliza-suave); color: #5c3d00; border-left-color: var(--baliza); }
.aviso svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ------------------------------------------------------- formularios */
.campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 18px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label, .etiqueta { font-weight: 600; font-size: 0.86rem; }
.campo .ayuda { font-size: 0.8rem; color: var(--muted); }
.campo .error { font-size: 0.8rem; color: var(--bad); font-weight: 600; }
input[type='text'], input[type='email'], input[type='password'], input[type='date'], input[type='month'], input[type='time'], input[type='tel'], input[type='search'], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--radius); border: 1.5px solid var(--line);
  font: inherit; color: var(--ink); background: #fff;
}
input:hover, select:hover, textarea:hover { border-color: #b9beb6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--noche); box-shadow: 0 0 0 3px var(--baliza-suave); }
.campo.con-error input, .campo.con-error select { border-color: var(--bad); }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 550; background: #fff; }
.check:has(input:checked) { border-color: var(--noche); background: var(--noche-suave); }
.check input { accent-color: var(--noche); width: 16px; height: 16px; margin: 0; }

.segmentos { display: inline-flex; padding: 3px; background: #e6e8e3; border-radius: var(--radius); }
.segmentos button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 0.88rem; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.segmentos button[aria-pressed='true'] { background: var(--blanco); color: var(--ink); box-shadow: 0 1px 2px rgb(22 33 59 / .12); }

/* ------------------------------------------------------------ listas */
.filas { list-style: none; margin: 0; padding: 0; }
.filas > li { border-top: 1px solid var(--line); }
.filas > li:first-child { border-top: 0; }
.persona { display: flex; align-items: center; gap: 12px; min-width: 0; }
.persona .nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona .sub { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona > :not(.avatar) { min-width: 0; }

.vacio { padding: 48px 20px; text-align: center; color: var(--muted); }
.vacio strong { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: var(--radius);
  background: var(--noche); color: #fff; font-weight: 550; box-shadow: 0 10px 30px rgb(22 33 59 / 0.3);
  border-left: 4px solid var(--baliza);
}
.toast.error { border-left-color: var(--choque); }
@media (max-width: 1023px) { .toast { bottom: 88px; } }

/* ------------------------------------------------------- pantallas sueltas (login) */
.centrado { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.tarjeta { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 36px 32px 32px; }
.tarjeta .logo-tarjeta { display: block; height: 46px; width: auto; margin: 0 auto 22px; }
.tarjeta h1 { text-align: center; font-size: 1.45rem; }
.tarjeta .bajada { text-align: center; color: var(--muted); margin: 6px 0 26px; }
.tarjeta form { display: grid; gap: 16px; }
.tarjeta .error-general { color: var(--bad); font-weight: 600; font-size: 0.9rem; }
