:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5b6675;
  --border: #e1e5eb;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --ok: #1d7a46;
  --ok-bg: #e4f4ea;
  --warn: #8a5300;
  --warn-bg: #fdf0d9;
  --err: #b3261e;
  --err-bg: #fce8e6;
  --neutral-bg: #eceff3;
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1a2028; --text: #e6e9ee; --muted: #9aa5b4; --border: #2b3440;
    --accent: #6ea8ff; --accent-text: #0b1220;
    --ok: #6fd39a; --ok-bg: #16301f; --warn: #f0b458; --warn-bg: #33270f;
    --err: #ff9088; --err-bg: #3a1c1a; --neutral-bg: #232b36;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1a2028; --text: #e6e9ee; --muted: #9aa5b4; --border: #2b3440;
  --accent: #6ea8ff; --accent-text: #0b1220;
  --ok: #6fd39a; --ok-bg: #16301f; --warn: #f0b458; --warn-bg: #33270f;
  --err: #ff9088; --err-bg: #3a1c1a; --neutral-bg: #232b36;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0; }
.lead { color: var(--muted); margin: 0 0 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono, code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 28px; height: 54px; }
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
nav a:hover { background: var(--neutral-bg); color: var(--text); }
nav a.active { background: var(--neutral-bg); color: var(--text); font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.tile-label { color: var(--muted); font-size: .82rem; }
.tile-value { font-size: 1.9rem; font-weight: 650; line-height: 1.2; }
.tile-sub { color: var(--muted); font-size: .82rem; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  font: inherit; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--neutral-bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--err); border-color: var(--err); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

progress { width: 100%; height: 10px; accent-color: var(--accent); }
#job-running p { margin: .25rem 0; }

.facts { margin: 14px 0 0; display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.facts dt { color: var(--muted); font-size: .82rem; }
.facts dd { margin: 0; word-break: break-word; }

.log { margin-top: 12px; }
.log summary { cursor: pointer; color: var(--muted); }
.log ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; font-size: .85rem; }
.log li { padding: 2px 0; }
.log time { color: var(--muted); margin-right: 6px; }
.lv-warn { color: var(--warn); }
.lv-error { color: var(--err); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .85rem; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
select, input[type="text"], input[type="number"], input[type="password"] {
  font: inherit; padding: 6px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--neutral-bg) 55%, transparent); }
tr.is-active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
td.nowrap { white-space: nowrap; }
code.path { word-break: break-all; }
code.path.planned { color: var(--muted); }
.empty { padding: 12px 4px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.badge.s-downloaded { background: var(--ok-bg); color: var(--ok); }
.badge.s-missing { background: var(--warn-bg); color: var(--warn); }
.badge.s-unavailable { background: var(--neutral-bg); color: var(--muted); }
.badge.s-error { background: var(--err-bg); color: var(--err); }
.badge.s-downloading { background: var(--warn-bg); color: var(--warn); }

.settings-form { max-width: 760px; }
.grid-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 16px; margin-top: 10px; }
.grid-params input:disabled { opacity: .55; }
.field { display: block; font-weight: 600; margin: 14px 0 4px; }
legend.field { padding: 0; margin-top: 0; }
fieldset { border: 0; margin: 0; padding: 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.check input { margin-top: 5px; }
.notice { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.err { background: var(--err-bg); color: var(--err); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.msg-ok { color: var(--ok); }
.msg-err { color: var(--err); }

@media (max-width: 640px) {
  main { padding: 16px 12px 40px; }
  .tile-value { font-size: 1.5rem; }
}

.topbar-inner .logout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-inner .logout .btn { padding: 4px 12px; }
.login { max-width: 380px; margin: 48px auto 0; }
.login .panel input { width: 100%; }

textarea { font: inherit; padding: 6px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; resize: vertical; }
input[type="search"] { font: inherit; padding: 6px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chip-static { display: inline-block; padding: 1px 9px; margin: 2px 2px 2px 0; border-radius: 999px; background: var(--neutral-bg); font-size: .85rem; }

/* ---- navegador ---- */
.browser { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 16px; align-items: start; }
.tree-pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 6px;
  max-height: calc(100vh - 150px); overflow: auto; position: sticky; top: 12px; }
.tree-pane ul { list-style: none; margin: 0; padding: 0; }
.tree-pane ul ul { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 4px; }
.tn { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tt { width: 22px; flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 0; font-size: .8rem; }
.tl { flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: var(--text); font: inherit; font-size: .9rem;
  padding: 3px 6px; border-radius: 5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl:hover { background: var(--neutral-bg); }
.tl.sel { background: var(--accent); color: var(--accent-text); }
.tc { flex: none; font-size: .78rem; color: var(--muted); padding: 0 6px; }
li.leaf .tl { color: var(--muted); }
li.leaf .tl.sel { color: var(--accent-text); }

.list-pane { min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-bottom: 10px; font-size: .9rem; }
.crumb, .link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-align: left; }
.crumb:hover, .link:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.toolbar input[type="search"] { flex: 1; min-width: 220px; }
.cpv-input { width: 130px; }
.cell-title { min-width: 320px; max-width: 640px; }
.sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.sub .link { font-size: .82rem; }
.link.muted-link { color: var(--muted); }
.vigente { color: var(--ok); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.mono.nowrap { white-space: nowrap; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: -12px 0 30px rgba(0, 0, 0, .18); padding: 16px 20px 32px; overflow: auto; z-index: 10; }
.drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.drawer-head h2 { font-size: 1.1rem; line-height: 1.35; }
.d-sec { margin-top: 18px; }
.d-sec h3 { font-size: .9rem; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; margin: 10px 0; }
.kv dt { color: var(--muted); font-size: .78rem; }
.kv dd { margin: 0; word-break: break-word; }
.doclist { margin: 0; padding-left: 18px; }
.doclist li { margin: 2px 0; word-break: break-word; }
.drawer .badge { margin-left: 8px; }

/* ===== Portales AAPP ===== */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.portal-card { display: block; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  color: var(--text); text-decoration: none; background: var(--bg); }
.portal-card:hover { border-color: var(--accent); background: var(--neutral-bg); }
.portal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.portal-nombre { font-weight: 600; }
.portal-nota { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.portal-url { color: var(--muted); font-size: .78rem; word-break: break-all; }

@media (max-width: 900px) {
  .browser { grid-template-columns: 1fr; }
  .tree-pane { position: static; max-height: 320px; }
}

.wide .topbar-inner, .wide main { max-width: 1680px; }
.drawer th, .drawer td { padding: 6px 8px; }
.drawer td .badge { margin-left: 6px; }

/* ===== Navegador: pantalla compacta, divisor, filtros y cabeceras ordenables ===== */
.wide { font-size: 13px; }
.wide main { padding-top: 14px; padding-bottom: 32px; }
.wide h1 { font-size: 1.2rem; }
.wide .lead { font-size: 12.5px; margin-bottom: 10px; }
.wide th, .wide td { padding: 4px 8px; }
.wide th { font-size: 10.5px; }
.wide .tl { font-size: 12.5px; padding: 2px 5px; }
.wide .tc { font-size: 11px; }
.wide .badge { font-size: 10.5px; padding: 0 7px; }
.wide .crumbs { font-size: 12px; margin-bottom: 6px; }
.wide input, .wide select, .wide .btn { font-size: 12.5px; }
.wide .btn { padding: 4px 10px; }
.wide input[type="search"], .wide input[type="text"], .wide select { padding: 4px 8px; }
.wide .cell-title .link { font-size: 12.5px; line-height: 1.3; }
.wide .sub, .wide .sub .link { font-size: 11px; }
.wide .cell-adj { max-width: 300px; }
.warn-text { color: var(--warn); }

.browser { grid-template-columns: var(--tree-w, 320px) 10px minmax(0, 1fr); gap: 0; }
.list-pane { padding-left: 4px; }
.splitter { position: sticky; top: 12px; height: calc(100vh - 150px); cursor: col-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center; outline: none; }
.splitter::before { content: ""; width: 3px; height: 100%; border-radius: 2px; background: var(--border); transition: background .15s; }
.splitter::after { content: ""; position: absolute; width: 5px; height: 40px; border-radius: 3px; background: var(--muted); opacity: .55; }
.splitter:hover::before, .splitter:focus-visible::before, body.resizing .splitter::before { background: var(--accent); }
.splitter:focus-visible::after, body.resizing .splitter::after { background: var(--accent); opacity: 1; }
body.resizing { cursor: col-resize; user-select: none; }

.fbar { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 6px; }
.frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.frow .grow { flex: 1 1 320px; min-width: 200px; }
.cf { position: relative; display: flex; align-items: center; gap: 6px; flex: 1 1 340px; min-width: 260px; }
.cf-label { flex: none; width: 50px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.cf-box { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-height: 28px;
  padding: 2px 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: text; }
.cf-box:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.cf-box.bad { border-color: var(--err); animation: sacudir .25s; }
.cf-chips { display: contents; }
.tag { display: inline-flex; align-items: center; gap: 2px; max-width: 260px; min-width: 0; padding: 0 3px 0 8px; border-radius: 999px;
  background: var(--neutral-bg); font-size: 11.5px; white-space: nowrap; }
.tag-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tag-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.tag-x:hover { color: var(--err); }
.cf-input { flex: 1 1 120px; min-width: 100px; border: 0 !important; outline: 0; background: transparent !important;
  color: var(--text); padding: 3px 2px !important; font: inherit; }
.cf-mode { flex: none; font-size: 11.5px !important; padding: 2px 4px !important; }
.cf-list { position: absolute; z-index: 20; left: 56px; right: 0; top: calc(100% + 2px); margin: 0; padding: 3px; list-style: none;
  max-height: 290px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.cf-list[hidden] { display: none; }
.cf-list li { display: flex; align-items: baseline; gap: 8px; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.cf-list li:hover, .cf-list li[aria-selected="true"] { background: var(--neutral-bg); }
.o-main { font-weight: 600; white-space: nowrap; }
.o-sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.o-hint { flex: none; margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
@keyframes sacudir { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.help { border: 1px dashed var(--border); border-radius: 8px; padding: 4px 12px; font-size: 12px; color: var(--muted); }
.help[hidden] { display: none; }
.help p { margin: 5px 0; }
.help code { background: var(--neutral-bg); padding: 0 4px; border-radius: 4px; color: var(--text); }

.wide th[data-sort] { padding: 0; }
.th-btn { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 4px 8px; cursor: pointer; font: inherit;
  text-transform: inherit; letter-spacing: inherit; color: inherit; white-space: nowrap; }
.th-btn:hover { color: var(--text); background: color-mix(in srgb, var(--neutral-bg) 70%, transparent); }
.th-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th.num .th-btn { text-align: right; }
.th-btn::after { content: "↕"; margin-left: 4px; opacity: .3; }
th[aria-sort="ascending"] .th-btn::after { content: "▲"; opacity: 1; color: var(--accent); }
th[aria-sort="descending"] .th-btn::after { content: "▼"; opacity: 1; color: var(--accent); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }

@media (max-width: 900px) {
  .browser { grid-template-columns: 1fr; }
  .splitter { display: none; }
}

/* ===== Vistas (licitaciones / adjudicaciones / empresas), rangos, totales y exportación ===== */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.tab { font: inherit; font-size: 12.5px; padding: 6px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
  background: none; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--text); background: var(--neutral-bg); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; background: var(--surface); border-color: var(--border); border-bottom: 1px solid var(--surface); }

.ranges { gap: 6px 14px; align-items: center; }
.rg { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.rg legend { float: left; padding: 0 6px 0 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.rg-sep { color: var(--muted); }
input[type="date"], .wide input[type="date"] { font: inherit; font-size: 12.5px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); }
.rg input[type="text"] { width: 108px; }
.rg input.bad { border-color: var(--err); outline: 1px solid var(--err); }

.totales { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.totales:empty { display: none; }
.stat { display: flex; flex-direction: column; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 84px; }
.stat-v { font-size: 15px; font-weight: 650; line-height: 1.25; white-space: nowrap; }
.stat-l { font-size: 10.5px; color: var(--muted); }
.stat.main { border-color: var(--accent); }
.stat.main .stat-v { color: var(--accent); font-size: 17px; }
.stat.marco { background: var(--warn-bg); border-color: transparent; }
.stat.marco .stat-v, .stat.marco .stat-l { color: var(--warn); }

.resumen { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.resumen p { margin: 0; }
.marco-num { color: var(--muted); font-style: italic; }
td .badge.s-downloading { margin-left: 6px; }
.lote { color: var(--muted); }
.wide .mono, .wide code { font-size: 12px; }
.wide .sub .mono, .wide .sub.mono { font-size: 11px; }

/* ===== Informe de valoración de la oferta técnica ===== */
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.chk input { margin: 0; }
a.badge.informe { text-decoration: none; margin-left: 6px; cursor: pointer; }
a.badge.informe:hover { filter: brightness(.95); text-decoration: underline; }
.valoracion .informes { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.valoracion .btn { text-decoration: none; display: inline-block; }
.link-ext { color: var(--accent); }

/* ===== Organismos: selector de alcance e informe de intereses/aversiones por temas ===== */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; padding: 5px 12px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--neutral-bg); color: var(--text); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.informe-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 760px) { .informe-cols { grid-template-columns: 1fr; } }
details.tema { border: 1px solid var(--border); border-radius: 6px; margin: 6px 0; padding: 0 10px; background: var(--bg); }
details.tema[open] { padding-bottom: 8px; }
details.tema summary { display: grid; grid-template-columns: 1fr 70px auto; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
details.tema .tema-titulo { font-weight: 600; }
details.tema .tema-cifra { color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.barra { display: block; height: 6px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; }
.barra span { display: block; height: 100%; background: var(--accent); }
ul.citas { margin: 2px 0 6px; padding-left: 16px; font-size: .82rem; }
ul.citas li { margin: 1px 0; }

/* ===== Ajustes: rejilla de campos alineados (bloque de Ollama) ===== */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; align-items: end; }
.form-grid .field { margin-top: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-grid input[type="text"], .form-grid input[type="number"], .form-grid select { width: 100%; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .check { margin: 0; min-height: 36px; align-items: center; }
.form-grid .check input { margin-top: 0; }
.subhead { font-size: .95rem; margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-3, .form-grid .span-2, .form-grid .razon { grid-column: 1 / -1; }
}

/* selección bien visible: alcance (segmentado), pestañas y orden del inventario */
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-text); font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--accent); }
.seg button[aria-checked="true"]::before { content: "✓ "; }
.tab[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.badge.alcance-activo { background: var(--accent); color: var(--accent-text); margin: 0 6px 0 0; }
.drawer .badge.alcance-activo { margin-left: 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
a.btn[hidden] { display: none; }
table.inventario td { vertical-align: top; }
table.inventario td.num strong { font-variant-numeric: tabular-nums; }
button.orden { font: inherit; font-weight: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit;
  background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
button.orden:hover { color: var(--text); text-decoration: underline; }
button.orden.activa { color: var(--accent); }

/* botón con un proceso en curso («Regenerar informe», «Procesar»): se distingue de un vistazo */
.btn.en-curso, .btn.en-curso:disabled { opacity: 1; cursor: progress; border-color: var(--accent); color: var(--accent);
  background: var(--neutral-bg); font-weight: 600; }
.btn.ocupado:disabled { cursor: not-allowed; }
.spinner { display: inline-block; width: .9em; height: .9em; margin-right: 6px; vertical-align: -.12em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-right-color: currentColor; opacity: .6; } }
