[hidden] { display: none !important; }
body { margin: 0; }

/* Layout: banda de planta (encabezado oscuro tipo hoja de control) + pestañas por proceso + tablas de trabajo actual vs propuesta */
:root {
  --ground: #f3f5ef; --surface: #ffffff; --ink: #1b1e18; --muted: #5d6656; --line: #dde2d5; --line-strong: #c3cab8;
  --accent: #94c11e; --accent-ink: #4f6a08; --band: #1b1e18; --band-ink: #eef2e6; --band-muted: #a7b199;
  --crit: #c4341f; --crit-bg: #fbe9e5; --warn: #b36b00; --warn-bg: #fff2dc; --minor: #4b6aa8; --minor-bg: #e8eef9; --ok: #3d7a23; --ok-bg: #e7f3df;
  --prop-bg: #f0f7dc; --act-bg: #f4f4f1;
  --f-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --f-body: "Barlow", "Segoe UI", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ground: #121410; --surface: #1a1d17; --ink: #e5e9dd; --muted: #9aa48d; --line: #2c3127; --line-strong: #3d4436;
  --accent: #a6d33a; --accent-ink: #b8e05a; --band: #0b0d09; --band-ink: #eef2e6; --band-muted: #8f9a82;
  --crit: #ff7a62; --crit-bg: #3a1a14; --warn: #f0a640; --warn-bg: #352610; --minor: #8fb0ef; --minor-bg: #1b2538; --ok: #8fd26b; --ok-bg: #1d2e15;
  --prop-bg: #23301a; --act-bg: #20231d; color-scheme: dark } }
:root[data-theme="dark"] {
  --ground: #121410; --surface: #1a1d17; --ink: #e5e9dd; --muted: #9aa48d; --line: #2c3127; --line-strong: #3d4436;
  --accent: #a6d33a; --accent-ink: #b8e05a; --band: #0b0d09; --band-ink: #eef2e6; --band-muted: #8f9a82;
  --crit: #ff7a62; --crit-bg: #3a1a14; --warn: #f0a640; --warn-bg: #352610; --minor: #8fb0ef; --minor-bg: #1b2538; --ok: #8fd26b; --ok-bg: #1d2e15;
  --prop-bg: #23301a; --act-bg: #20231d; color-scheme: dark }

* { box-sizing: border-box; }
body { background: var(--ground); color: var(--ink); font: 15px/1.45 var(--f-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--band); }
.wrap { max-width: 1440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.mono, td.num, .code { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; text-wrap: balance; margin: 0; letter-spacing: .01em; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* banda superior */
.band { background: var(--band); color: var(--band-ink); }
.band .wrap { padding-block: 18px 0; display: grid; gap: 14px; }
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.brand h1 { font-size: 30px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.brand h1 b { color: var(--accent); font-weight: 700; }
.brand p { margin: 0; color: var(--band-muted); font-size: 14px; }
.sources { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.band .wrap > * { min-width: 0; }
.src { overflow: hidden; display: inline-flex; gap: 8px; align-items: center; border: 1px solid #3b4233; border-radius: 4px; padding: 5px 10px; font-size: 13px; color: var(--band-ink); max-width: 100%; min-width: 0; }
.src i { width: 8px; height: 8px; border-radius: 50%; background: var(--band-muted); flex: none; }
.src.on i { background: var(--accent); }
.src span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.src small { color: var(--band-muted); }
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 4px; padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #172003; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--band-ink); border-color: #4a5340; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.tabs button { background: none; border: 0; color: var(--band-muted); padding: 10px 14px 12px; font-family: var(--f-display); font-size: 17px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--band-ink); border-bottom-color: var(--accent); }
nav.tabs button .ct { font-family: var(--f-mono); font-size: 12px; margin-left: 6px; color: var(--accent); }

main .wrap { padding-block: 20px 48px; display: grid; gap: 20px; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: 6px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; background: var(--surface); }
.drop.over { border-color: var(--accent); background: var(--prop-bg); }
.drop p { margin: 0; flex: 1 1 320px; min-width: 0; color: var(--muted); font-size: 14px; }
.drop p strong { color: var(--ink); }
.notice { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 10px 14px; border-radius: 0 4px 4px 0; font-size: 14px; }
.notice.rule { border-left-color: var(--accent); background: var(--prop-bg); }
.notice.err { border-left-color: var(--crit); background: var(--crit-bg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.kpi { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; align-content: start; }
.kpi .v { font-family: var(--f-display); font-size: 30px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi.crit .v { color: var(--crit); }
.kpi.warn .v { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.panel h2 { font-size: 20px; text-transform: uppercase; letter-spacing: .04em; }
.panel h2 small { font-family: var(--f-body); text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.panel .lead { margin: 0; color: var(--muted); font-size: 14px; max-width: 75ch; }

.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr) 54px; gap: 10px; align-items: center; font-size: 13.5px; cursor: pointer; border-radius: 3px; }
.bar:hover .lbl { color: var(--accent-ink); }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .trk { height: 14px; background: var(--act-bg); border-radius: 2px; display: flex; overflow: hidden; }
.bar .trk i { display: block; height: 100%; }
.bar .n { font-family: var(--f-mono); text-align: right; font-size: 13px; }
.sev-CRÍTICO { background: var(--crit); } .sev-REVISAR { background: var(--warn); } .sev-MENOR { background: var(--minor); } .sev-INFO { background: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
@media (max-width: 520px) { .bar { grid-template-columns: minmax(0, 1fr) 44px; } .bar .trk { grid-column: 1 / -1; grid-row: 2; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; min-width: 0; }
.field select, .field input { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; padding: 6px 8px; min-width: 0; max-width: 100%; }
.field input[type="search"] { width: 220px; }
.spacer { flex: 1 1 auto; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { position: sticky; top: 0; background: var(--act-bg); text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; max-width: 46ch; }
td .code { font-size: 13px; }
td.why { min-width: 260px; max-width: 380px; }
td.dec { min-width: 160px; }
.act { background: var(--act-bg); }
.prop { background: var(--prop-bg); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.pill.CRÍTICO { background: var(--crit-bg); color: var(--crit); } .pill.REVISAR { background: var(--warn-bg); color: var(--warn); }
.pill.MENOR { background: var(--minor-bg); color: var(--minor); } .pill.INFO { background: var(--act-bg); color: var(--muted); }
.pill.off { background: var(--crit); color: #fff; }
.chk { font-family: var(--f-display); font-weight: 600; font-size: 14px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.formula { font-family: var(--f-mono); font-size: 12px; color: var(--accent-ink); display: block; margin-top: 3px; }
.up { color: var(--crit); } .down { color: var(--minor); }
.dec select { font-size: 13px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); max-width: 150px; }
.dec select[data-v="AUTORIZADO"] { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.dec select[data-v="RECHAZADO"] { border-color: var(--crit); color: var(--crit); }
.dec select[data-v="APLICADO EN COMPAQ"] { border-color: var(--accent); background: var(--accent); color: #172003; }
.dec input { margin-top: 4px; width: 150px; font-size: 12.5px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--surface); }
.tile b { font-family: var(--f-display); font-size: 22px; font-weight: 600; display: block; }
.tile span { font-size: 12.5px; color: var(--muted); }
.ok-badge { color: var(--ok); font-weight: 600; } .bad-badge { color: var(--crit); font-weight: 600; }
.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--ground) 80%, transparent); display: grid; place-items: center; z-index: 50; }
.busy div { background: var(--surface); border: 1px solid var(--line-strong); padding: 18px 22px; border-radius: 6px; font-weight: 500; }
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 4px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); font-size: 14px; }
ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; border: 1px solid var(--line-strong); border-radius: 3px; padding: 3px 8px; cursor: pointer; background: var(--surface); }
@media (prefers-reduced-motion: no-preference) { .bar .trk i { transition: width .4s ease; } }

/* acceso */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--band); }
.gate-card { width: min(420px, 100%); background: var(--surface); border-radius: 8px; padding: 28px 24px; display: grid; gap: 14px; }
.gate-card h1 { font-size: 30px; text-transform: uppercase; letter-spacing: .04em; }
.gate-card h1 b { color: var(--accent-ink); }
.gate-card p { margin: 0; color: var(--muted); font-size: 14px; }
.gate-form { display: grid; gap: 12px; }
.gate-form .field input { width: 100%; padding: 9px 10px; }
.gate-form .btn { justify-content: center; padding: 10px; }
.gate-links { font-size: 13.5px; }
.gate-links a { color: var(--accent-ink); }
.brand .spacer { flex: 1 1 auto; }
#user .btn.ghost { padding: 4px 10px; font-size: 13px; }

/* grupos de pestañas */
nav.grupos { align-self: start; border-color: #4a5340; }
nav.grupos button { background: transparent; color: var(--band-muted); font-family: var(--f-display); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: 14px; padding: 6px 14px; }
nav.grupos button[aria-pressed="true"] { background: var(--accent); color: #172003; }
.chips + .chips { margin-top: 6px; }
.chips-l { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); align-self: center; margin-right: 4px; }

/* vista tipo Excel */
.gridbox { gap: 10px; }
.grid-title { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.grid-title h2 { font-size: 22px; text-transform: uppercase; letter-spacing: .04em; }
.muted, .grid-help { color: var(--muted); font-size: 13px; margin: 0; }
.grid-count { font-size: 13.5px; color: var(--muted); align-self: center; }
.grid-blocks { flex-wrap: wrap; }
.grid-blocks button { font-size: 13px; }
.grid-wrap { overflow: auto; height: calc(100vh - 230px); min-height: 360px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12.5px; font-family: var(--f-body); }
table.grid td, table.grid th { height: 26px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid td.n { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 12px; }
table.grid thead tr { position: sticky; z-index: 2; }
table.grid thead th, table.grid thead td { background: var(--act-bg); position: sticky; top: 0; }
table.grid thead tr.g-top td, table.grid thead tr.g-top th { background: #fff; position: static; }
table.grid thead tr.g-sub td, table.grid thead tr.g-sub th { background: #eef6d6; font-weight: 600; position: static; }
table.grid thead tr.g-let th { font-size: 10.5px; color: #5d6656; text-align: center; height: 18px; position: static; font-weight: 500; background: #f3f3f1; }
table.grid thead tr.g-hdr th { color: #1b1e18; font-size: 12px; cursor: pointer; text-transform: none; letter-spacing: 0; top: 0; z-index: 3; padding-right: 22px; position: sticky; }
table.grid thead tr.g-hdr th .g-hl { display: block; overflow: hidden; text-overflow: ellipsis; }
.g-fb { position: absolute; right: 2px; top: 4px; width: 18px; height: 18px; border: 1px solid #b9beb2; border-radius: 3px; background: #fff; color: #333; font-size: 11px; line-height: 1; padding: 0; cursor: pointer; display: grid; place-items: center; }
.g-fb:hover { border-color: #217346; }
.g-fb.on { background: #217346; border-color: #217346; color: #fff; }
table.grid .g-rn { position: sticky; left: 0; z-index: 1; background: #f3f3f1; color: #5d6656; font-weight: 500; font-size: 11px; text-align: right; }
table.grid thead .g-rn { z-index: 4; }
table.grid tbody tr:hover td { box-shadow: inset 0 0 0 9999px rgba(33, 115, 70, .10); }
table.grid tbody tr:hover th.g-rn { background: #d6e8dc; color: #1b1e18; }
table.grid tbody td { cursor: default; }
table.grid .g-spacer td { padding: 0; border: 0; height: auto; }
.g-link { border: 0; background: none; color: var(--accent-ink); cursor: pointer; padding: 0 4px 0 0; font-size: 13px; }
@media (max-width: 700px) { .grid-wrap { height: calc(100vh - 160px); } }

/* la cuadrícula siempre se ve como Excel (fondo blanco), también en modo oscuro */
.grid-wrap { background: #fff; color: #1b1e18; color-scheme: light; --line: #e1e3dc; border-color: #c3cab8; }
table.grid td.empty { color: #5d6656; }
.g-ed { border: 0; background: none; color: #217346; cursor: pointer; padding: 0 3px 0 0; font-size: 12px; opacity: 0; }
table.grid tbody tr:hover .g-ed, .g-ed:focus-visible { opacity: 1; }
table.grid td.g-prop { background: #fff2cc; outline: 2px solid #f0a640; outline-offset: -2px; font-weight: 600; }
table.grid td.g-prop.aut { background: #e2f0d9; outline-color: #3d7a23; }
table.grid td.g-prop s { color: #8a8f84; font-weight: 400; margin-right: 2px; }

/* menú de filtro y edición (flotante) */
.g-menu { position: fixed; z-index: 60; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.22); padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; overflow: auto; }
.g-menu input[type=search], .g-menu input:not([type]), .g-menu input[data-ev], .g-menu input[data-en], .g-menu input[data-mc] { width: 100%; font-size: 13.5px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.g-m-sort { display: grid; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.g-m-sort button { text-align: left; border: 0; background: none; padding: 5px 6px; border-radius: 3px; cursor: pointer; color: var(--ink); font-size: 13.5px; }
.g-m-sort button:hover { background: var(--prop-bg); }
.g-m-cond { display: grid; gap: 3px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.g-m-add { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.g-m-list { border: 1px solid var(--line); border-radius: 4px; max-height: 260px; min-height: 120px; overflow: auto; padding: 4px 6px; display: grid; align-content: start; }
.g-m-list label { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 2px 0; cursor: pointer; }
.g-m-list label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-m-list label small { color: var(--muted); font-family: var(--f-mono); font-size: 11px; }
.g-m-list .g-m-all { grid-template-columns: auto 1fr; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 2px; }
.g-m-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.g-m-foot .btn { padding: 5px 10px; font-size: 13px; }
.g-m-foot .btn:disabled { opacity: .5; cursor: default; }
.g-e-h { display: grid; gap: 2px; }
.g-e-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.g-e-cmp > div { padding: 8px; display: grid; gap: 4px; }
.g-e-cmp span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.g-e-cmp b { font-family: var(--f-mono); font-size: 15px; }
.g-e-n { display: grid; gap: 3px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.g-menu p { margin: 0; font-size: 12.5px; }
.g-e-err { color: var(--crit); font-weight: 600; }
