/* Módulo Contrataciones Públicas · paleta institucional MEF
   Layout: barra superior azul con buscador global → fila de filtros → pestañas → contenido; fichas 360° en panel lateral */
:root {
  --azul: #093158; --celeste: #0097d9; --rojo: #ed3237; --verde: #97bd1e; --naranja: #f39200; --morado: #5a3a8e;
  --bg: #f4f6f9; --panel: #ffffff; --panel2: #eef2f7; --line: #dbe2ea; --line2: #e9eef4;
  --fg: #12233a; --fg2: #47586e; --fg3: #7a8899; --accent: #0a74b0; --accent-soft: #e2f1fa;
  --top: #093158; --top-fg: #ffffff; --top-fg2: #b8c9dc;
  --ok: #3f7d1e; --ok-bg: #eaf4dc; --warn: #a35f00; --warn-bg: #fff1d9; --bad: #c4252a; --bad-bg: #fde6e6; --neu: #5d6b7c; --neu-bg: #edf0f4;
  --c1: #2167ce; --c2: #d98300; --c3: #14a3b8; --c4: #8a5cc2;
  --shadow: 0 1px 2px rgba(9, 49, 88, .06), 0 4px 16px rgba(9, 49, 88, .06);
  --f-disp: "Libre Franklin", "Segoe UI", Arial, sans-serif; --f-body: "Public Sans", "Segoe UI", Arial, sans-serif; --f-mono: "IBM Plex Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0b1522; --panel: #111f30; --panel2: #16273b; --line: #24384f; --line2: #1c2e43;
  --fg: #e6edf5; --fg2: #a9b8c9; --fg3: #7d8ea3; --accent: #48b4ec; --accent-soft: #12324a;
  --top: #06213d; --top-fg: #ffffff; --top-fg2: #9fb6cf;
  --ok: #9fd067; --ok-bg: #1d3216; --warn: #f2b14c; --warn-bg: #3a2a10; --bad: #ff7b7f; --bad-bg: #3d1719; --neu: #a9b8c9; --neu-bg: #1f3045;
  --c1: #4a82dc; --c2: #c27a18; --c3: #27a596; --c4: #a070d8; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0b1522; --panel: #111f30; --panel2: #16273b; --line: #24384f; --line2: #1c2e43;
  --fg: #e6edf5; --fg2: #a9b8c9; --fg3: #7d8ea3; --accent: #48b4ec; --accent-soft: #12324a;
  --top: #06213d; --top-fg: #ffffff; --top-fg2: #9fb6cf;
  --ok: #9fd067; --ok-bg: #1d3216; --warn: #f2b14c; --warn-bg: #3a2a10; --bad: #ff7b7f; --bad-bg: #3d1719; --neu: #a9b8c9; --neu-bg: #1f3045;
  --c1: #4a82dc; --c2: #c27a18; --c3: #27a596; --c4: #a070d8; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; }

.ctr, .ctr * { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; }
.ctr { min-height: 100%; font-variant-numeric: tabular-nums; }
.ctr button, .ctr input, .ctr select { font: inherit; color: inherit; }
.ctr a { color: var(--accent); }
.ctr :focus-visible { outline: 2px solid var(--celeste); outline-offset: 2px; }

/* barra superior */
.c-top { background: var(--top); color: var(--top-fg); padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; position: sticky; top: 0; z-index: 30; }
.c-top-in { max-width: 1440px; margin: 0 auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.c-brand { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.c-brand b { font-family: var(--f-disp); font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.c-brand span { color: var(--top-fg2); font-size: 12px; }
.c-brand .c-sello { display: inline-block; border: 1px solid rgba(255,255,255,.35); border-radius: 3px; padding: 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-left: 6px; color: var(--top-fg); }
.c-search { position: relative; flex: 1 1 380px; max-width: 560px; min-width: 0; }
.c-search input { width: 100%; border: 0; border-radius: 6px; padding: 10px 12px 10px 36px; background: rgba(255,255,255,.12); color: var(--top-fg); }
.c-search input::placeholder { color: var(--top-fg2); }
.c-search input:focus { background: #fff; color: #12233a; outline: none; }
.c-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--top-fg2); stroke-width: 2; }
.c-sres { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 70vh; overflow: auto; z-index: 40; }
.c-sres h6 { margin: 0; padding: 8px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg3); }
.c-sres button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.c-sres button:hover, .c-sres button.on { background: var(--accent-soft); }
.c-sres small { color: var(--fg3); display: block; }

/* filtros y pestañas */
.c-wrap { max-width: 1440px; margin: 0 auto; padding-inline: 16px; padding-block: 14px 40px; }
.c-filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.c-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.c-f > label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--fg3); }
.c-f select, .c-f input { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; max-width: 100%; }
.c-f.ent select { width: min(420px, 86vw); }
.c-limpiar { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
.c-corte { margin-left: auto; font-size: 12px; color: var(--fg3); text-align: right; }
.c-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.c-tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--fg2); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.c-tabs button.on { color: var(--fg); border-bottom-color: var(--celeste); }
.c-tabs .n { font-weight: 500; font-size: 12px; color: var(--fg3); margin-left: 4px; }

/* bloques */
.c-grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.c-card h3 { margin: 0 0 2px; font-family: var(--f-disp); font-size: 15px; font-weight: 700; text-wrap: balance; }
.c-card .sub { margin: 0 0 10px; color: var(--fg3); font-size: 12px; }
.s12 { grid-column: span 12; } .s8 { grid-column: span 8; } .s7 { grid-column: span 7; } .s6 { grid-column: span 6; } .s5 { grid-column: span 5; } .s4 { grid-column: span 4; }
@media (max-width: 980px) { .s8, .s7, .s6, .s5, .s4 { grid-column: span 12; } }

.c-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.c-kpi { padding: 12px 16px; border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2); min-width: 0; }
.c-kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--fg3); }
.c-kpi .v { font-family: var(--f-disp); font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.c-kpi .d { font-size: 12px; color: var(--fg2); }
.c-kpi.alerta .v { color: var(--bad); }

.c-aviso { border-left: 3px solid var(--celeste); background: var(--accent-soft); padding: 9px 12px; border-radius: 0 6px 6px 0; font-size: 13px; color: var(--fg2); margin-bottom: 14px; }

/* pills */
.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-ok { background: var(--ok-bg); color: var(--ok); } .p-warn { background: var(--warn-bg); color: var(--warn); }
.p-bad { background: var(--bad-bg); color: var(--bad); } .p-neu { background: var(--neu-bg); color: var(--neu); }
.sev { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.sev.alta { color: var(--bad); } .sev.media { color: var(--warn); } .sev.baja { color: var(--neu); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* tablas */
.c-tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.c-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.c-t th { position: sticky; top: 0; background: var(--panel2); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg2); padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
.c-t th.num, .c-t td.num { text-align: right; }
.c-t th .ord { color: var(--celeste); }
.c-t td { padding: 7px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.c-t tr.click { cursor: pointer; } .c-t tr.click:hover td { background: var(--accent-soft); }
.c-t td .t2 { color: var(--fg3); font-size: 12px; display: block; }
.c-t td.wrap { min-width: 240px; max-width: 460px; }
.c-tbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 8px; }
.c-tbar input { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 9px; min-width: 0; flex: 1 1 260px; max-width: 420px; }
.c-tbar .meta { color: var(--fg3); font-size: 12px; }
.c-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 11px; cursor: pointer; font-size: 13px; }
.c-btn:hover { border-color: var(--celeste); }
.c-btn.pri { background: var(--azul); color: #fff; border-color: var(--azul); }
.c-pag { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 8px 0 0; font-size: 12px; color: var(--fg3); }

/* gráficos */
.c-chart { width: 100%; overflow-x: auto; }
.c-chart svg { display: block; width: 100%; height: auto; }
.c-chart text { fill: var(--fg2); font-size: 11px; font-family: var(--f-body); }
.c-chart .lbl { fill: var(--fg); font-weight: 600; }
.c-chart .grid { stroke: var(--line2); stroke-width: 1; }
.c-chart .base { stroke: var(--line); stroke-width: 1; }
.c-chart .hit:hover { fill: var(--accent-soft); }
.c-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--fg2); margin: 0 0 6px; }
.c-tip { position: fixed; z-index: 60; pointer-events: none; background: var(--panel); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 6px; padding: 7px 9px; font-size: 12px; max-width: 280px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.hbar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .nm button { all: unset; cursor: pointer; color: var(--fg); } .hbar .nm button:hover { color: var(--accent); text-decoration: underline; }
.hbar .tr { height: 12px; background: var(--panel2); border-radius: 0 3px 3px 0; overflow: hidden; }
.hbar .br { height: 100%; background: var(--c1); border-radius: 0 3px 3px 0; }
.hbar .vl { text-align: right; color: var(--fg2); font-size: 12px; white-space: nowrap; }

/* panel lateral (fichas 360°) */
.c-velo { position: fixed; inset: 0; background: rgba(9, 25, 45, .45); z-index: 45; }
.c-ficha { position: fixed; top: 0; right: 0; bottom: 0; width: min(980px, 100%); background: var(--bg); z-index: 50; overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.c-fh { background: var(--panel); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 14px; position: sticky; top: 0; z-index: 2; }
.c-fh .tipo { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--celeste); font-weight: 700; }
.c-fh h2 { margin: 3px 0 4px; font-family: var(--f-disp); font-size: 20px; line-height: 1.25; text-wrap: balance; padding-right: 80px; }
.c-fh .de { color: var(--fg2); font-size: 13px; }
.c-fh .acc { position: absolute; right: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); display: flex; gap: 6px; }
.c-fb { padding: 16px 20px 40px; display: grid; gap: 14px; }
.c-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.c-dl > div { padding: 9px 12px; border-bottom: 1px solid var(--line2); border-right: 1px solid var(--line2); min-width: 0; }
.c-dl dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg3); }
.c-dl dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.c-sec h4 { margin: 0 0 8px; font-family: var(--f-disp); font-size: 14px; }
.c-ciclo { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.c-ciclo div { flex: 1 1 120px; padding: 9px 12px; border-right: 1px solid var(--line2); position: relative; min-width: 0; }
.c-ciclo div:last-child { border-right: 0; }
.c-ciclo b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg3); }
.c-ciclo span { font-weight: 600; font-size: 13px; }
.c-ciclo div.on { background: var(--accent-soft); }
.c-ciclo div.off span { color: var(--fg3); font-weight: 400; }
.c-link { all: unset; cursor: pointer; color: var(--accent); }
.c-link:hover { text-decoration: underline; }
.c-vacio { padding: 24px; text-align: center; color: var(--fg3); }
.c-mono { font-family: var(--f-mono); font-size: 12px; }
.c-met h3 { font-family: var(--f-disp); margin: 18px 0 6px; }
.c-met p, .c-met li { max-width: 78ch; line-height: 1.55; color: var(--fg2); }
.c-carga { padding: 60px 16px; text-align: center; color: var(--fg2); }
@media (max-width: 640px) { .c-kpi .v { font-size: 20px; } .c-corte { margin-left: 0; text-align: left; } .c-fh h2 { font-size: 17px; } .hbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; } }
@media (prefers-reduced-motion: no-preference) { .c-ficha { animation: entra .18s ease-out; } @keyframes entra { from { transform: translateX(24px); opacity: .6; } } }

/* Botón "Descargar" (menú) en el encabezado */
.c-desc { display: flex; align-items: center; }
.c-desc .menu-desc { position: relative; }
.c-desc .btn { border: 1px solid #0097d9; background: #0097d9; color: #fff; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.c-desc .menu-desc-lista { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; background: #fff; color: #1f2a33; border: 1px solid #d8e2ec; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 280px; padding: 4px; display: grid; }
.c-desc .menu-desc-lista[hidden] { display: none; }
.c-desc .menu-desc-lista button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 6px; font: inherit; font-size: 14px; color: inherit; cursor: pointer; display: grid; gap: 2px; }
.c-desc .menu-desc-lista button:hover:not(:disabled) { background: #f2f6fa; }
.c-desc .menu-desc-lista button:disabled { color: #8a97a3; cursor: not-allowed; }
.c-desc .menu-desc-lista small { color: #5e6b76; font-size: 12px; }
.c-carga .c-desc .menu-desc-lista { left: 0; right: auto; }

/* Gráficos y controles en HTML (misma lib que el resto de la plataforma, con los colores del módulo) */
.hb { display: grid; grid-template-columns: minmax(90px, 1.2fr) minmax(0, 2.4fr) auto; gap: 5px 10px; align-items: center; font-size: 13px; }
.hb-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-b { display: flex; height: 16px; min-width: 0; gap: 1px; }
.hb-b i { display: flex; align-items: center; justify-content: center; height: 100%; min-width: 0; overflow: hidden; border-radius: 2px; }
.hb-b i b { color: #fff; font-size: 10px; font-weight: 700; line-height: 1; white-space: nowrap; padding: 0 3px; text-shadow: 0 0 2px rgba(0,0,0,.35); }
.hb-v { text-align: right; white-space: nowrap; color: var(--fg2); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--fg2); margin: 0 0 8px; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.c-seg { margin: 0 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; vertical-align: middle; }
.seg button { border: 0; background: var(--panel); color: var(--fg2); font: inherit; font-size: 12px; font-weight: 600; padding: 5px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--azul); color: #fff; }
.fm { position: relative; display: grid; gap: 3px; min-width: 0; }
.fm-l { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--fg3); }
.fm-b { display: flex; justify-content: space-between; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; color: var(--fg); cursor: pointer; min-width: 150px; max-width: min(420px, 86vw); text-align: left; }
.fm-b .fm-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm.activo .fm-b { border-color: var(--celeste); font-weight: 600; }
.fm-p[hidden] { display: none; }
.fm-p { position: absolute; z-index: 40; top: 100%; left: 0; min-width: 100%; max-width: min(420px, 90vw); max-height: 280px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; display: grid; margin-top: 4px; }
.fm-o { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--fg); cursor: pointer; }
.fm-o:hover { background: var(--panel2); }
.fm-o.cero { color: var(--fg3); }
.fm-o small { color: var(--fg3); font-variant-numeric: tabular-nums; }
.fm-o input { margin: 0; }
.c-aplicados { margin: -4px 0 10px; font-size: 12px; color: var(--fg2); }
.c-tw.alta { max-height: 70vh; overflow: auto; scroll-padding: 40px 0 44px; }
.c-t tfoot td { position: sticky; bottom: 0; background: var(--panel2); font-weight: 700; border-top: 2px solid var(--line); z-index: 1; padding: 8px 10px; }
@media (max-width: 760px) { .hb { grid-template-columns: minmax(70px, 1fr) minmax(0, 1.6fr) auto; font-size: 12px; } .fm-b { min-width: 120px; } }
