:root {
  --bg: #14171a; --panel: #1a1f22; --panel-2: #20241f; --line: #2c3439; --line-soft: #23292d;
  --border: #3a444b;
  --ink: #e9efe8; --muted: #93a293; --muted-2: #7d8a8c;
  --green: #3f8f5c; --green-2: #4fa76d; --green-ink: #9bd8ab;
  --field: #181b17; --field-line: #3a423a;
  --danger: #ef7a7a; --danger-line: #3a2426; --blue: #8fb0d0; --warn: #e8c170;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--blue); }

/* Campos */
.inp { background: var(--field); border: 1px solid var(--field-line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; color: var(--ink); min-width: 0; }
.inp:focus { outline: none; border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(63,143,92,.22); }
.inp:disabled { opacity: .75; }
.inp.num { text-align: right; font-variant-numeric: tabular-nums; }
textarea.inp { resize: vertical; }
label.fld { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; min-width: 0; }
label.fld > .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
label.fld > .ayuda { font-size: 11.5px; color: var(--muted-2); }
label.fld > .ayuda.alerta { color: var(--warn); }
label.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); align-self: end; padding-bottom: 9px; }

/* Botones */
.btn { background: linear-gradient(180deg, var(--green-2), var(--green)); border: 0; border-radius: 8px;
  color: #fff; font-weight: 600; font-size: 13px; padding: 8px 15px; cursor: pointer; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled, .btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; font-size: 13px; padding: 7px 13px; cursor: pointer; }
.btn-ghost:hover { color: var(--ink); border-color: var(--green-2); }
.btn-danger { background: none; border: 1px solid var(--danger-line); color: var(--danger);
  border-radius: 8px; font-size: 12.5px; padding: 6px 12px; cursor: pointer; }
.btn-xs { font-size: 11.5px; padding: 3px 9px; border-radius: 6px; }
.lnk { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-size: 12.5px; }
.lnk.rojo { color: var(--danger); }

/* Acceso (login / activación) */
.acceso { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2620, #101311); padding: 16px; }
.card-acceso { width: 100%; max-width: 400px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: 0 24px 60px -22px rgba(0,0,0,.75); }
.card-acceso .brand { text-align: center; margin-bottom: 22px; }
.card-acceso .logo { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(160deg, var(--green-2), #2b6a44); display: grid; place-items: center; font-size: 26px; }
.card-acceso h1 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -.02em; color: var(--green-ink); }
.card-acceso .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.card-acceso form { display: flex; flex-direction: column; gap: 14px; }
.card-acceso .inp { width: 100%; }
.err { color: var(--danger); font-size: 13px; }
.err:empty { display: none; }

/* Estructura */
header.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: #12161a; }
header.top .title { font-size: 20px; }
header.top .spacer { flex: 1; }
header.top .who { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; }
header.top .who:hover { color: var(--ink); }
header.top #btn-admin.active { background: var(--green); border-color: var(--green); color: #fff; }
header.top .ctx { display: flex; flex-direction: column; gap: 1px; line-height: 1.15; min-width: 0; }
header.top .ctx-emp { font-weight: 750; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
header.top .ctx-sub { font-size: 11.5px; color: var(--muted-2); }
.shell { display: flex; align-items: stretch; min-height: calc(100vh - 62px); }
nav.sidebar { width: 190px; flex-shrink: 0; background: #12161a; border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
nav.sidebar button { display: block; width: 100%; text-align: left; background: transparent;
  border: 1px solid transparent; border-radius: 8px; color: var(--muted); padding: 9px 12px; font-size: 13.5px; cursor: pointer; }
nav.sidebar button:hover { color: var(--ink); background: var(--panel); }
nav.sidebar button.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
main.body { flex: 1; min-width: 0; padding: 18px 22px 60px; }
@media (max-width: 700px) {
  .shell { flex-direction: column; }
  nav.sidebar { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  nav.sidebar button { width: auto; }
}

/* Páginas */
.page-h { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.page-h h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; max-width: 1040px; }
.card h3 { margin: 0 0 10px; font-size: 14.5px; }
.section-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 16px 0 8px; }
.muted { color: var(--muted); } .muted2 { color: var(--muted-2); }
.nota { color: var(--muted); font-size: 12.5px; max-width: 820px; line-height: 1.5; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wrap-x { overflow-x: auto; max-width: 100%; }

/* Formularios en grilla */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; max-width: 1000px; }
.fgrid .c2 { grid-column: span 2; } .fgrid .full { grid-column: 1 / -1; }
.fsec { grid-column: 1 / -1; margin-top: 8px; font-size: 11px; color: var(--green-ink); text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line-soft); padding-bottom: 4px; }
@media (max-width: 520px) { .fgrid .c2 { grid-column: auto; } }

/* Pestañas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 13px; cursor: pointer; font-size: 13.5px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--green-ink); border-bottom-color: var(--green-2); font-weight: 600; }

/* Tablas */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.grid tr.click { cursor: pointer; }
table.grid tr.click:hover td { background: rgba(63,143,92,.10); }
table.grid tr.vig td { background: rgba(63,143,92,.08); }
table.grid tr.sub td { background: #171b1e; font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Etiquetas */
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--green-ink); border-color: #2f5e40; background: rgba(63,143,92,.12); }
.badge.warn { color: var(--warn); border-color: #5a4a26; background: rgba(232,193,112,.08); }
.badge.bad { color: var(--danger); border-color: var(--danger-line); background: rgba(239,122,122,.06); }

/* Ficha: pares clave/valor */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 16px; }
.kv .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kv .v { font-size: 14px; margin-top: 2px; }

/* Modales y avisos */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9998;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow: auto; }
.modal { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; width: 100%;
  box-shadow: 0 24px 60px -22px rgba(0,0,0,.8); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .acciones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .err { margin-top: 10px; }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all;
  background: var(--field); border: 1px solid var(--field-line); padding: 8px 10px; border-radius: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #22303a;
  border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 9999; }
.drop { border: 1.5px dashed var(--field-line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); max-width: 640px; }
.drop.over { border-color: var(--green-2); background: rgba(63,143,92,.08); }
.cambios { margin: 0; padding-left: 16px; font-size: 12.5px; }
.cambios li { margin: 1px 0; }
.cambios .antes { color: var(--muted-2); text-decoration: line-through; }
