:root {
  --ink: #17233d;
  --teal: #0e7c72;
  --teal-bright: #16b8a6;
  --paper: #f3f0e8;
  --card: #fffcf7;
  --line: #d9d3c7;
  --warn: #8a4b12;
  --warn-bg: #f6e7d4;
  --danger: #8d2b2b;
  --danger-bg: #f8e4e4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--teal); }
a:hover { color: var(--ink); }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  background: var(--ink);
  color: #f6f3ec;
  padding: 0.7rem 1.25rem;
}

.marca, .marca-sola {
  color: #f6f3ec;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.marca-sola { color: var(--ink); font-size: 1.1rem; margin: 0; }

.top nav { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.top nav a { color: #d7deea; text-decoration: none; font-weight: 500; }
.top nav a[aria-current="page"] { color: var(--teal-bright); }
.salir { margin-left: auto; display: flex; gap: 0.6rem; align-items: center; }
.salir span { color: #c5cedd; font-size: 0.85rem; }
.salir button, button, .boton {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.primario, .boton.primario {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  font-weight: 600;
}
.salir button { background: transparent; color: #f6f3ec; border-color: #3d4d6e; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
h1 { font-size: 1.55rem; letter-spacing: -0.03em; margin: 0.2rem 0 0.6rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 0.4rem; }

.nota, .aviso, .error, .flash {
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}
.nota { background: var(--card); border: 1px solid var(--line); }
.nota p { margin: 0.3rem 0; }
.aviso { background: var(--warn-bg); color: var(--warn); }
.error, .flash { background: var(--card); border: 1px solid var(--teal-bright); }
.error { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.ayuda { color: #4d5870; font-size: 0.92rem; }
.miga { margin: 0; color: #4d5870; }
.cabeza, .acciones, .linea { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }
.cabeza { justify-content: space-between; align-items: baseline; }
.estado { margin: 0; color: #4d5870; }
.pill {
  display: inline-block;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  margin-right: 0.35rem;
}

table { width: 100%; border-collapse: collapse; background: var(--card); margin: 0.8rem 0 1rem; }
th, td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; color: #4d5870; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; }
.sub { display: block; color: #4d5870; font-size: 0.78rem; }
.tabla-scroll { overflow-x: auto; max-width: 100%; }
.tabla-scroll table { min-width: 640px; }
.tabla-scroll input { width: 6.5rem; }

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}
.grilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; align-items: start; }
.ancho { grid-column: 1 / -1; }
.grilla button, .linea button { justify-self: start; }
.login { max-width: 26rem; margin: 8vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.3rem; }
.login form { display: grid; gap: 0.8rem; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.liquido { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.totales { font-variant-numeric: tabular-nums; }
pre { background: var(--ink); color: #f6f3ec; padding: 1rem; overflow: auto; border-radius: 12px; font-size: 0.82rem; }
details { margin-top: 1rem; }

:root { --navy: #17233d; --side-w: 220px; }

body.staff-shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}
html.nav-ready body.staff-shell { transition: grid-template-columns 0.22s ease; }
html.nav-collapsed body.staff-shell { grid-template-columns: 0 minmax(0, 1fr); }
html.nav-collapsed body.staff-shell > .side {
  width: 0;
  max-width: 0;
  overflow: hidden;
  visibility: hidden;
}
.side {
  background: var(--navy);
  color: #fff;
  min-height: 100vh;
  width: var(--side-w);
  max-width: var(--side-w);
  position: sticky;
  top: 0;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 2;
}
html.nav-ready .side { transition: width 0.22s ease, max-width 0.22s ease; }
.side .brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  padding: 1rem 0.9rem 0.4rem;
}
.side nav { padding: 0.2rem 0.45rem 1rem; overflow-y: auto; flex: 1 1 auto; }
.side-group h2 {
  margin: 0.85rem 0.45rem 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-bright);
  font-weight: 600;
}
.side-link {
  display: block;
  padding: 0.32rem 0.45rem;
  border-radius: 6px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
.side-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.side-link.on { background: rgba(22, 184, 166, 0.18); color: var(--teal-bright); }
.side-user {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: 0.75rem 0.85rem 0.9rem;
}
.role-chip {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(22, 184, 166, 0.22);
  color: #d7fff8;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}
.side-user-name {
  display: block;
  margin: 0.35rem 0 0.45rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.side-logout {
  background: transparent;
  color: #f6f3ec;
  border-color: #3d4d6e;
  border-radius: 999px;
}
.workspace { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1rem;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 5;
}
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 8px;
  padding: 0;
}
.buscar { flex: 1 1 auto; margin: 0; }
.buscar input {
  width: 100%;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}
.buscar input::placeholder { color: rgba(255,255,255,0.55); }
body.staff-shell main { margin: 0; max-width: 1100px; }
.usuario { margin: 0 0 0.8rem; }
.usuario .acciones form, .resultados form { display: inline; }
.resultados { list-style: none; padding: 0; }
.resultados li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
fieldset { border: 1px solid var(--line); border-radius: 12px; }
legend { font-size: 0.82rem; padding: 0 0.3rem; }
body.solo-lectura form[method="post"]:not(.salir) button,
body.solo-lectura form[method="post"]:not(.salir) input[type="submit"] { display: none; }
textarea { width: 100%; }

@media (max-width: 800px) {
  .grilla, .dos { grid-template-columns: 1fr; }
  .salir { margin-left: 0; width: 100%; }
  .top { padding: 0.7rem; }
  main { padding: 1rem 0.7rem 2rem; }
  h1 { font-size: 1.3rem; }
}

@media (max-width: 960px) {
  body.staff-shell,
  html.nav-collapsed body.staff-shell { grid-template-columns: 1fr; }
  body.staff-shell > .side,
  html.nav-collapsed body.staff-shell > .side,
  html.nav-ready body.staff-shell > .side {
    display: flex;
    position: fixed;
    z-index: 20;
    top: 3.4rem;
    height: calc(100vh - 3.4rem);
    min-height: 0;
    max-height: none;
    width: min(280px, 88vw);
    max-width: min(280px, 88vw);
    visibility: visible;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  html.nav-open body.staff-shell > .side { transform: none; }
}
