/* Sistema de diseno de Nexoria Gestion.
 *
 * Un solo fichero de tokens y componentes. Regla: ninguna pantalla escribe un
 * color, un radio o una sombra a mano. Si hace falta uno nuevo, se anade aqui.
 * En el producto anterior se acabo con tres paletas parecidas y ninguna igual.
 *
 * Modo claro y oscuro por `prefers-color-scheme`, y `data-tema` para cuando
 * el usuario lo fuerza. El PC de una oficina y la tablet de la nave no tienen
 * el mismo brillo ni la misma luz alrededor.
 */

:root {
  --paper: #F4F6F5;
  --surface: #FFFFFF;
  --surface-2: #F0F3F1;
  --surface-3: #E7EDEA;
  --ink: #0E1714;
  --ink-soft: #54635D;
  --ink-faint: #8A9691;
  --rule: #E4E9E6;
  --rule-soft: #EFF2F0;

  --accent: #0E7C5A;
  --accent-vivo: #0A6247;
  --accent-dim: #E4F4EE;
  --accent-ink: #0A5F45;

  --warn: #8A5D08;
  --warn-dim: #FDF3DF;
  --alert: #C0392B;
  --alert-dim: #FDECEA;
  --calm: #2F6EA8;
  --calm-dim: #E8F1F9;
  --ok: #0E7C5A;
  --ok-dim: #E4F4EE;

  --r-xs: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-full: 999px;

  --s1: 0 1px 2px rgba(14, 23, 20, .05);
  --s2: 0 1px 3px rgba(14, 23, 20, .05), 0 8px 24px -12px rgba(14, 23, 20, .16);
  --s3: 0 2px 6px rgba(14, 23, 20, .06), 0 20px 48px -18px rgba(14, 23, 20, .24);

  --f: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Inter,
       Roboto, Helvetica, Arial, sans-serif;
  --fm: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --lateral: 248px;
  --cabecera: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --paper: #0C110F;
    --surface: #151C19;
    --surface-2: #1B2320;
    --surface-3: #232D29;
    --ink: #E9EFEC;
    --ink-soft: #9DABA5;
    --ink-faint: #71807A;
    --rule: #26302C;
    --rule-soft: #1E2723;
    --accent: #3EC292;
    --accent-vivo: #5AD7A9;
    --accent-dim: #122A22;
    --accent-ink: #7FE0BC;
    --warn: #D9A84E;
    --warn-dim: #2B2416;
    --alert: #E8776A;
    --alert-dim: #2E1B18;
    --calm: #7EAEDC;
    --calm-dim: #15222E;
    --ok: #3EC292;
    --ok-dim: #122A22;
    --s1: 0 1px 2px rgba(0, 0, 0, .4);
    --s2: 0 1px 3px rgba(0, 0, 0, .45), 0 8px 24px -12px rgba(0, 0, 0, .7);
    --s3: 0 2px 6px rgba(0, 0, 0, .5), 0 20px 48px -18px rgba(0, 0, 0, .85);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 650; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: .95rem; font-weight: 650; margin: 0 0 6px; }
p { margin: 0 0 10px; }

.sub { color: var(--ink-soft); font-size: 14px; }
.micro { font-size: 12.5px; color: var(--ink-faint); }
.nada { color: var(--ink-faint); }

/* ------------------------------------------------------------------ armazon */

.marco { display: flex; min-height: 100vh; }

.lateral {
  width: var(--lateral);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--rule-soft);
}
.marca .punto {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent-vivo), var(--accent));
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
}
.marca small { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-faint); }

.granja-actual { padding: 10px 16px 12px; border-bottom: 1px solid var(--rule-soft); }
.granja-actual label {
  display: block; margin-bottom: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-faint);
}
.granja-actual select {
  width: 100%; padding: 6px 8px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-xs);
}
.granja-actual strong { display: block; font-size: 14px; }
.granja-actual a { display: inline-block; margin-top: 6px; font-size: 12.5px; }
.granja-actual a.aqui { font-weight: 600; }

.menu { padding: 10px 8px 20px; flex: 1; }
.menu .seccion {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-faint);
  padding: 14px 10px 5px;
}
.menu a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r-xs);
  color: var(--ink); font-size: 14px;
}
.menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu a.aqui { background: var(--accent-dim); color: var(--accent-ink); font-weight: 600; }
.menu a .cuenta { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
.menu a .cuenta.nueva {
  background: var(--alert); color: #fff; font-weight: 700;
  border-radius: 99px; padding: 0 7px; line-height: 18px;
}
.menu .ic { width: 17px; height: 17px; flex: none; opacity: .75; }
.menu a.aqui .ic { opacity: 1; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.cabecera {
  height: var(--cabecera);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.cabecera form.buscar { flex: 1; max-width: 480px; position: relative; }
.cabecera form.buscar input {
  width: 100%; padding: 7px 12px 7px 34px;
  border-radius: var(--r-full);
  border: 1px solid var(--rule);
  background: var(--surface-2);
  color: var(--ink); font: inherit; font-size: 14px;
}
.cabecera form.buscar input:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface); box-shadow: 0 0 0 3px var(--accent-dim);
}
.cabecera form.buscar .lupa {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; opacity: .5; pointer-events: none;
}
.cabecera .quien { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.cabecera .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
}

.cinta {
  padding: 6px 20px; font-size: 13px; font-weight: 600;
  background: var(--warn-dim); color: var(--warn);
  border-bottom: 1px solid var(--rule);
}

.lienzo { padding: 22px; flex: 1; }
.lienzo > header { margin-bottom: 16px; display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.lienzo > header .titulo { flex: 1; min-width: 240px; }

/* ------------------------------------------------------------------ botones */

.boton, button, input[type="submit"] {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: var(--accent); color: #fff;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.boton:hover, button:hover { background: var(--accent-vivo); text-decoration: none; }
.boton.sec, button.sec {
  background: var(--surface); color: var(--ink); border-color: var(--rule);
}
.boton.sec:hover, button.sec:hover { background: var(--surface-2); }
.boton.peligro, button.peligro { background: var(--alert); }
.boton.plano, button.plano {
  background: transparent; color: var(--ink-soft); border-color: transparent;
  padding: 5px 8px; font-weight: 500;
}
.boton.plano:hover, button.plano:hover { background: var(--surface-2); color: var(--ink); }
button:disabled, .boton.apagado { opacity: .5; cursor: not-allowed; }
.botonera { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ tarjetas */

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--s1);
}
.tarjeta > header {
  padding: 12px 16px; border-bottom: 1px solid var(--rule-soft);
  display: flex; align-items: center; gap: 10px;
}
.tarjeta > header h2 { margin: 0; }
.tarjeta > .cuerpo { padding: 16px; }
.rejilla { display: grid; gap: 14px; }
.rejilla.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.rejilla.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.rejilla.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.cifra { padding: 14px 16px; }
.cifra .valor { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.cifra .que { font-size: 12.5px; color: var(--ink-soft); }
.cifra.aviso .valor { color: var(--warn); }
.cifra.mal .valor { color: var(--alert); }

/* ------------------------------------------------------------------- tablas */

.envoltorio-tabla {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); overflow-x: auto;
}
table.datos { width: 100%; border-collapse: collapse; font-size: 14px; }
table.datos th, table.datos td {
  padding: 9px 12px; text-align: left;
  border-bottom: 1px solid var(--rule-soft); white-space: nowrap;
}
table.datos th {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-faint);
  background: var(--surface-2); position: sticky; top: 0;
}
table.datos th a { color: inherit; }
table.datos th a:hover { color: var(--accent); }
table.datos tbody tr:hover { background: var(--surface-2); }
table.datos tbody tr:last-child td { border-bottom: 0; }
table.datos td.num, table.datos th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.datos tfoot td {
  font-weight: 700; background: var(--surface-2);
  border-top: 2px solid var(--rule); border-bottom: 0;
}
table.datos td.ancha { white-space: normal; min-width: 220px; }
table.datos .flecha { opacity: .45; font-size: 10px; }

/* --------------------------------------------------------------- pastillas */

.pastilla {
  display: inline-block; padding: 2px 9px;
  border-radius: var(--r-full); font-size: 12px; font-weight: 650;
  background: var(--surface-3); color: var(--ink-soft); white-space: nowrap;
}
.pastilla.verde { background: var(--ok-dim); color: var(--ok); }
.pastilla.ambar { background: var(--warn-dim); color: var(--warn); }
.pastilla.rojo { background: var(--alert-dim); color: var(--alert); }
.pastilla.azul { background: var(--calm-dim); color: var(--calm); }
.etiqueta {
  display: inline-block; padding: 1px 8px; margin: 0 3px 3px 0;
  border-radius: var(--r-xs); font-size: 12px;
  background: var(--surface-3); color: var(--ink-soft);
}
.si { color: var(--ok); font-weight: 700; }
.no { color: var(--ink-faint); }

/* ------------------------------------------------------------------ avisos */

.aviso {
  padding: 11px 14px; border-radius: var(--r);
  font-size: 14px; margin-bottom: 14px;
  border: 1px solid var(--rule);
  background: var(--surface);
}
.aviso.bien { background: var(--ok-dim); border-color: transparent; color: var(--ok); }
.aviso.ojo { background: var(--warn-dim); border-color: transparent; color: var(--warn); }
.aviso.mal { background: var(--alert-dim); border-color: transparent; color: var(--alert); }
.aviso.info { background: var(--calm-dim); border-color: transparent; color: var(--calm); }
.aviso strong { font-weight: 700; }
.aviso ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------------------------------------------------------------- formulario */

.campos { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 14px; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo.c1 { grid-column: span 1; } .campo.c2 { grid-column: span 2; }
.campo.c3 { grid-column: span 3; } .campo.c4 { grid-column: span 4; }
.campo.c5 { grid-column: span 5; } .campo.c6 { grid-column: span 6; }
.campo.c7 { grid-column: span 7; } .campo.c8 { grid-column: span 8; }
.campo.c9 { grid-column: span 9; } .campo.c10 { grid-column: span 10; }
.campo.c11 { grid-column: span 11; } .campo.c12 { grid-column: span 12; }
@media (max-width: 760px) { .campo { grid-column: span 12 !important; } }

.campo > label {
  font-size: 12.5px; font-weight: 650; color: var(--ink-soft);
  display: flex; align-items: center; gap: 5px;
}
.campo > label .obliga { color: var(--alert); }
.campo input, .campo select, .campo textarea {
  padding: 7px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--rule); border-radius: var(--r-xs);
  background: var(--surface); color: var(--ink); width: 100%;
}
.campo textarea { min-height: 76px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
.campo .ayuda { font-size: 12px; color: var(--ink-faint); }
.campo .mal { font-size: 12.5px; color: var(--alert); font-weight: 600; }
.campo.roto input, .campo.roto select, .campo.roto textarea { border-color: var(--alert); }
.campo .sufijo { font-size: 12px; color: var(--ink-faint); }
.campo.casilla { flex-direction: row; align-items: center; gap: 8px; padding-top: 18px; }
.campo.casilla input { width: auto; }
.campo.casilla label { font-size: 14px; color: var(--ink); font-weight: 500; }

fieldset {
  border: 0; padding: 0; margin: 0 0 22px;
}
fieldset > legend {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-faint);
  padding: 0 0 8px; margin-bottom: 4px; width: 100%;
  border-bottom: 1px solid var(--rule-soft);
}

/* ------------------------------------------------------------------ filtros */

.filtros {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px;
}
.filtros .fila { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filtros .campo { min-width: 150px; flex: 0 1 auto; }
.vistas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.vistas a {
  padding: 5px 12px; border-radius: var(--r-full); font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--rule); color: var(--ink-soft);
}
.vistas a:hover { background: var(--surface-2); text-decoration: none; }
.vistas a.aqui {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

.paginacion {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 12px 2px; font-size: 13.5px; color: var(--ink-soft); flex-wrap: wrap;
}

/* ------------------------------------------------------------------- vacio */

.vacio { text-align: center; padding: 54px 20px; }
.vacio .icono {
  width: 46px; height: 46px; margin: 0 auto 12px;
  opacity: .3;
}
.vacio h2 { margin-bottom: 6px; }
.vacio p { color: var(--ink-soft); max-width: 46ch; margin: 0 auto 16px; }

/* -------------------------------------------------------------- asistente */

.pasos { display: flex; gap: 0; margin-bottom: 22px; flex-wrap: wrap; }
.pasos .paso {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 8px 12px; font-size: 13.5px; color: var(--ink-faint);
  border-bottom: 2px solid var(--rule);
}
.pasos .paso .n {
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-faint);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
}
.pasos .paso.aqui { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 650; }
.pasos .paso.aqui .n { background: var(--accent); color: #fff; }
.pasos .paso.hecho { color: var(--ink-soft); border-bottom-color: var(--accent-dim); }
.pasos .paso.hecho .n { background: var(--accent-dim); color: var(--accent-ink); }

.zona-soltar {
  border: 2px dashed var(--rule); border-radius: var(--r-lg);
  padding: 34px 20px; text-align: center; background: var(--surface);
}
.zona-soltar.encima { border-color: var(--accent); background: var(--accent-dim); }
.zona-soltar input[type="file"] { display: none; }

table.previa td.error { background: var(--alert-dim); color: var(--alert); font-weight: 600; }
table.previa tr.fila-error td { background: var(--alert-dim); }
table.previa tr.fila-omitir { opacity: .55; }

/* -------------------------------------------------------------- interruptor */

.modulo { padding: 14px 16px; border-bottom: 1px solid var(--rule-soft); }
.modulo:last-child { border-bottom: 0; }
.modulo .cab { display: flex; gap: 14px; align-items: flex-start; }
.modulo .txt { flex: 1; min-width: 200px; }
.modulo .txt h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.modulo .txt p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.modulo ul.entrega {
  margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft);
  columns: 2; column-gap: 26px;
}
@media (max-width: 700px) { .modulo ul.entrega { columns: 1; } }

.palanca { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.palanca input { opacity: 0; width: 0; height: 0; position: absolute; }
.palanca i {
  position: absolute; inset: 0; background: var(--surface-3);
  border-radius: var(--r-full); transition: background .18s; cursor: pointer;
}
.palanca i::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: var(--surface); border-radius: 50%; box-shadow: var(--s1);
  transition: transform .18s;
}
.palanca input:checked + i { background: var(--accent); }
.palanca input:checked + i::before { transform: translateX(18px); }
.palanca input:disabled + i { opacity: .4; cursor: not-allowed; }
.palanca input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-dim); }

/* Una tarjeta que se puede elegir entera (el sector). Es un <label>, asi que
   se pincha en cualquier sitio y no hay que acertarle al interruptor. */
.modulo.elegible {
  display: block; cursor: pointer; border-radius: var(--r);
  transition: background .14s;
}
.modulo.elegible:hover { background: var(--surface-2); }
.modulo.elegible.puesto { background: var(--accent-dim); }
.modulo.elegible:has(input:disabled) { cursor: not-allowed; opacity: .62; }

.precio {
  font-size: 11.5px; font-weight: 700; padding: 2px 9px;
  border-radius: var(--r-full); background: var(--accent-dim); color: var(--accent-ink);
}
.precio.pago { background: var(--warn-dim); color: var(--warn); }
.precio.camino { background: var(--surface-3); color: var(--ink-faint); }

/* ------------------------------------------------------------------ entrada */

.entrada {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: var(--paper);
}
.entrada .caja {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: var(--s3); padding: 30px 28px;
}
.entrada .caja .marca { border: 0; padding: 0 0 18px; }
.entrada .campos { grid-template-columns: 1fr; }
.entrada button { width: 100%; justify-content: center; margin-top: 6px; }

/* ------------------------------------------------------------------ ficha */

.ficha-cab { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.ficha-cab .quien { flex: 1; min-width: 240px; }
.ficha-cab .inicial {
  width: 46px; height: 46px; border-radius: var(--r);
  background: var(--accent-dim); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 18px; font-weight: 700; flex: none;
}
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.pestanas a {
  padding: 8px 14px; font-size: 14px; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pestanas a:hover { color: var(--ink); text-decoration: none; }
.pestanas a.aqui { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 650; }

dl.datos { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 20px; }
dl.datos dt { font-size: 12px; color: var(--ink-faint); font-weight: 650; }
dl.datos dd { margin: 0 0 2px; font-size: 14.5px; word-break: break-word; }

.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li {
  padding: 10px 0 10px 22px; border-left: 2px solid var(--rule-soft);
  position: relative; margin-left: 6px;
}
.linea-tiempo li::before {
  content: ""; position: absolute; left: -5px; top: 16px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-dim); border: 2px solid var(--accent);
}
.linea-tiempo .cuando { font-size: 12px; color: var(--ink-faint); }

/* ------------------------------------------------------------------- pie */

.pie {
  padding: 18px 22px; font-size: 12.5px; color: var(--ink-faint);
  border-top: 1px solid var(--rule); display: flex; gap: 14px; flex-wrap: wrap;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .marco { flex-direction: column; }
  .lateral {
    width: 100%; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--rule);
  }
  .menu { display: none; }
  .menu.abierto { display: block; }
  .lienzo { padding: 16px 14px; }
}

@media print {
  .lateral, .cabecera, .botonera, .filtros, .paginacion { display: none !important; }
  body { background: #fff; }
}
