:root {
  --navy: #0F1B2D; --navy2: #17263B; --navy3: #2A3B55; --accent: #C8F25C; --bg: #F4F5F1; --card: #fff;
  --border: #E3E5DE; --ink: #14181F; --muted: #4A5260; --faint: #8A9080;
  --g: #0F7A3D; --gbg: #E3F6EA; --a: #8A5A00; --abg: #FFF1D6; --r: #A3290F; --rbg: #FDE5DF; --n: #3C4452; --nbg: #ECEEE8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1 { font-size: 26px; margin: 2px 0 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row form { margin: 0; }

.top { background: var(--navy); color: #F4EFE6; position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 15px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--navy); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; color: #C9D2DF; font-weight: 600; }
.top nav a:hover { background: var(--navy2); color: #fff; }
.top nav a.on { background: var(--accent); color: var(--navy); }
.salir { display: flex; align-items: center; gap: 10px; color: #B9C3D3; font-size: 13px; margin: 0; }

main.wrap { padding-top: 22px; padding-bottom: 30px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.crumb { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.crumb a { text-decoration: none; }
.crumb.claro { color: #B9C3D3; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.dark { background: var(--navy); color: #F4EFE6; border-color: var(--navy); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pila { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 26px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpi.dark span, .kpi.dark small { color: #B9C3D3; }
.kpi.dark b { color: var(--accent); }
.c-a { color: var(--a); } .c-r { color: var(--r); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
td a { text-decoration: none; }
tfoot td { border-bottom: 0; }
.tabla { overflow-x: auto; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.t-g { background: var(--gbg); color: var(--g); } .t-a { background: var(--abg); color: var(--a); } .t-r { background: var(--rbg); color: var(--r); } .t-n { background: var(--nbg); color: var(--n); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv.claro { border-color: var(--navy3); }
.kv.claro span { color: #B9C3D3; }
.ev { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); }
.ev .sub { width: 100%; }
h2.sep { margin-top: 14px; }
.empty { padding: 22px; text-align: center; color: var(--muted); background: var(--bg); border-radius: 10px; }

.form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #C9CDC2; border-radius: 9px; background: #fff; color: var(--ink); min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: 0; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filtros input, .filtros select { width: auto; min-width: 160px; }
.filtros input[name="q"] { flex: 1 1 260px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; padding: 9px 15px; border-radius: 9px; border: 1px solid #C9CDC2; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; min-height: 40px; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-lg { min-height: 46px; font-size: 15px; }
.btn-dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-accent { background: var(--accent); color: var(--navy); border-color: var(--accent); }
.btn-danger { color: var(--r); border-color: #F0B8A8; }
.btn-ghost { background: transparent; }
.link { font-weight: 700; font-size: 13px; }
.aviso { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.clave { font: 800 24px/1.2 ui-monospace, Consolas, monospace; color: var(--accent); letter-spacing: .04em; word-break: break-all; }
.codigo { background: #0A1220; color: #DCE6F2; padding: 12px; border-radius: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 4px 0 8px; }
.pie { color: var(--faint); font-size: 12px; padding-bottom: 20px; }

body.centro { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); padding: 20px; }
.caja { width: 100%; max-width: 720px; background: var(--bg); border-radius: 18px; padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.caja.angosta { max-width: 420px; }
.caja h2 { margin-top: 8px; }
.marca-grande { display: flex; gap: 14px; align-items: center; }
.marca-grande .logo { width: 46px; height: 46px; font-size: 17px; border-radius: 12px; }
.marca-grande p { margin: 2px 0 0; }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .lateral-primero .col-1 { order: -1; }
  .salir span { display: none; }
  .top-in { gap: 10px; padding-top: 10px; padding-bottom: 0; }
  .top .marca { flex: 1; min-width: 0; }
  .top .marca span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top .salir { order: 2; }
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; justify-content: space-between; gap: 0; padding: 2px 0 10px; overflow-x: auto; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; flex-shrink: 0; padding: 6px clamp(3px, 1vw, 12px); font-size: clamp(11px, 3.15vw, 14px); }
}

/* Fechas en iOS: el control nativo no respeta el ancho del contenedor. */
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
label, .g2 > * { min-width: 0; }

/* Celular: cada fila de tabla se vuelve una ficha con "columna: valor". */
@media (max-width: 700px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  .card { padding: 16px 14px; }
  .tabla { overflow: visible; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp thead { display: none; }
  table.resp tbody tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.resp tbody tr:last-child { border-bottom: 0; }
  table.resp td { border: 0; padding: 3px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: baseline; text-align: right; overflow-wrap: anywhere; }
  table.resp td:not(:first-child):not(.sin-label) > * { grid-column: 2; justify-self: end; }
  table.resp td.vacio { display: none; }
  table.resp td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 4; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  table.resp td:first-child { display: block; text-align: left; padding-bottom: 6px; font-size: 15px; }
  table.resp td:first-child::before { display: none; }
  table.resp td.sin-label { display: block; padding-top: 8px; }
  table.resp td.sin-label::before { display: none; }
  table.resp td.sin-label:empty { display: none; }
  table.resp td.sin-label form, table.resp td.sin-label .btn { width: 100%; }
  table.resp td .sub { text-align: inherit; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 22px; }
  .kpi.dark { grid-column: 1 / -1; }
  table.resp tfoot, table.resp tfoot tr { display: block; width: 100%; }
  table.resp tfoot tr { display: flex; justify-content: space-between; padding-top: 10px; border-top: 2px solid var(--ink); }
  table.resp tfoot td { display: block; width: auto; padding: 0; border: 0; }
}

/* Funciones de la licencia */
fieldset.funciones { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
fieldset.funciones legend { padding: 0 6px; font-weight: 700; }
fieldset.funciones legend b { background: var(--accent); color: var(--navy); padding: 3px 10px; border-radius: 99px; }
.fun-grupo { display: flex; flex-direction: column; gap: 8px; }
.fun-tit { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted, #4A5260); }
label.fun { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 500; }
label.fun input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }
label.fun span { display: flex; flex-direction: column; gap: 2px; }
label.fun small { color: var(--muted, #4A5260); font-weight: 400; font-size: 12.5px; }
label.fun:has(input:checked) { border-color: var(--navy); background: #F7FBEA; }
.precio-sug { font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fun-inv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fun-inv .fun-sub { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--muted, #4A5260); }
@media (max-width: 640px) { .fun-inv { grid-template-columns: 1fr; } }
.legal { max-width: 860px; margin: 0 auto; line-height: 1.6; }
.legal h1 { font-size: 26px; margin: 0 0 4px; }
.legal h2 { font-size: 17px; margin: 22px 0 6px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
.legal .legal-meta { color: var(--muted, #4A5260); font-size: 13px; margin: 0 0 14px; }
.legal-links { text-align: center; font-size: 12.5px; margin-top: 14px; }
.legal-links a { color: inherit; margin: 0 6px; }
