:root {
  --bg: #f6f4f2; --panel: #fff; --texto: #1f1b1a; --suave: #6b6461; --borde: #e3ddd9;
  --acento: #a8231c; --acento-hover: #8b1a14; --acento-suave: #fbeae8;
  --ok: #1e7b45; --ok-suave: #e5f4ea; --error: #b3261e; --error-suave: #fde8e6; --aviso: #8a5a00; --aviso-suave: #fff3d6;
  --radio: 10px; --sombra: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161312; --panel: #211d1c; --texto: #f1ece9; --suave: #a59c97; --borde: #3a3331;
    --acento: #e0574e; --acento-hover: #ef6c63; --acento-suave: #3a1f1d;
    --ok: #5cc98a; --ok-suave: #193325; --error: #ff8a80; --error-suave: #3d1d1b; --aviso: #f0c060; --aviso-suave: #3a2f12;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--texto); }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.suave { color: var(--suave); }
.chico { font-size: .85rem; }

/* Estructura */
.app { display: flex; min-height: 100vh; }
/* El menú queda fijo a la izquierda (alto de la ventana): en páginas largas no se mueve y "Salir" siempre se ve */
.lateral { width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--borde); padding: 1rem .75rem; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marca { font-weight: 800; font-size: 1.2rem; color: var(--acento); padding: .25rem .6rem 1rem; letter-spacing: -.01em; text-align: center; }
.marca small { display: block; font-weight: 500; font-size: .75rem; color: var(--suave); }
.marca img.logo { display: block; max-width: 100%; max-height: 90px; object-fit: contain; margin: 0 auto .3rem; }
.login .marca img.logo { width: 220px; max-width: 100%; max-height: 160px; margin: 0 auto .5rem; }
.lateral a { color: var(--texto); padding: .45rem .6rem; border-radius: 8px; }
.lateral a:hover { background: var(--acento-suave); text-decoration: none; }
.lateral a.activo { background: var(--acento-suave); color: var(--acento); font-weight: 600; }
.lateral .grupo { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); padding: .9rem .6rem .25rem; }
.lateral .pie { margin-top: auto; padding: .6rem 0 0; position: sticky; bottom: -1rem; padding-bottom: 1rem; background: var(--panel); border-top: 1px solid var(--borde); display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.lateral .pie-nombre { padding: .2rem .6rem; color: var(--suave); font-weight: 600; }
.lateral .pie form { display: block; width: 100%; margin-top: .3rem; }
.lateral .pie .salir { display: block; width: 100%; text-align: center; font-weight: 700; background: #c62828; border-color: #c62828; color: #fff; }
.lateral .pie .salir:hover { background: #a61f1f; border-color: #a61f1f; color: #fff; }
.lateral a.boton-panel { border: 2px solid var(--acento); color: var(--acento); text-align: center; font-weight: 700; margin: .2rem 0 .3rem; }
.lateral a.boton-panel:hover { background: var(--acento-suave); }
.lateral a.boton-panel.activo { background: var(--acento); color: #fff; }
.lateral .boton-caja { background: var(--acento); color: #fff; text-align: center; font-weight: 700; margin-bottom: .5rem; }
.lateral .boton-caja:hover { background: var(--acento-hover); color: #fff; }
.contenido { flex: 1; padding: 1.5rem 2rem; min-width: 0; max-width: 1300px; }
@media (max-width: 800px) {
  .app { flex-direction: column; }
  .lateral { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--borde);
    position: static; height: auto; overflow: visible; }
  .lateral .grupo { display: none; }
  .contenido { padding: 1rem; }
}

/* Componentes */
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.2rem; box-shadow: var(--sombra); }
.grilla { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grilla-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }
.dato .etiqueta { color: var(--suave); font-size: .85rem; }
.dato .valor { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.barra { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.barra .espacio { flex: 1; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--borde); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--acento-suave) 50%, transparent); }
.tabla { border: 1px solid var(--borde); border-radius: var(--radio); overflow: auto; box-shadow: var(--sombra); }
tfoot td { font-weight: 700; border-top: 2px solid var(--borde); }
.inactivo td { opacity: .5; }

button, .boton { font: inherit; cursor: pointer; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); padding: .45rem .9rem; border-radius: 8px; display: inline-block; }
button:hover, .boton:hover { border-color: var(--suave); text-decoration: none; }
.primario { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 600; }
.primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); }
.peligro { color: var(--error); }
.enlace { border: 0; background: none; padding: 0; color: var(--acento); }

input, select, textarea { font: inherit; color: var(--texto); background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; padding: .45rem .6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: -1px; }
.form { display: grid; gap: .9rem; max-width: 560px; }
.form label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; }
.form .ayuda { font-weight: 400; color: var(--suave); font-size: .8rem; }
.form-linea { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.form-linea label { display: grid; gap: .2rem; font-size: .85rem; font-weight: 600; }
input.precio { width: 130px; text-align: right; }

.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.msg.ok { background: var(--ok-suave); color: var(--ok); }
.msg.error { background: var(--error-suave); color: var(--error); }
.etiq { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: var(--borde); }
.etiq.ok { background: var(--ok-suave); color: var(--ok); }
.etiq.error { background: var(--error-suave); color: var(--error); }
.etiq.aviso { background: var(--aviso-suave); color: var(--aviso); }

/* Login */
.centro { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 360px; }
.login .marca { font-size: 1.8rem; text-align: center; padding-bottom: 1.2rem; }
