/* Dashboard DDS FY27 — estilos de la aplicación. Colores en brand.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45;
  color: var(--brand-ink); background: var(--brand-bg);
}
a { color: var(--brand-blue-dark); }
a:hover { color: var(--brand-blue); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }
small, .small { font-size: .82rem; }
.muted { color: var(--brand-muted); }
.nowrap { white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: 2px; }

/* ---------- Encabezado ---------- */
.topbar { background: var(--brand-surface); border-bottom: 4px solid var(--brand-yellow); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: .5rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--brand-ink); }
.brand img { height: 46px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1rem; }
.brand-text span { font-size: .78rem; color: var(--brand-muted); }
.brand-fallback { font-weight: 800; color: var(--brand-blue); border: 2px solid var(--brand-blue); padding: .2rem .5rem; }
.mainnav { display: flex; gap: .2rem; flex-wrap: wrap; margin-left: auto; }
.mainnav a { text-decoration: none; color: var(--brand-ink); padding: .45rem .7rem; border-radius: 6px; font-weight: 600; font-size: .92rem; }
.mainnav a:hover { background: var(--brand-bg); }
.mainnav a.active { background: var(--brand-yellow); }
.tools { display: flex; align-items: center; gap: .5rem; }
.langsel { display: flex; border: 1px solid var(--brand-line); border-radius: 6px; overflow: hidden; }
.langsel a { padding: .3rem .5rem; font-size: .8rem; text-decoration: none; color: var(--brand-ink); font-weight: 600; }
.langsel a.on { background: var(--brand-ink); color: #fff; }
.userbox { font-size: .8rem; color: var(--brand-muted); display: flex; align-items: center; gap: .4rem; }
.userbox form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--brand-blue-dark); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.demo-banner { background: repeating-linear-gradient(-45deg, #C62828, #C62828 14px, #A61F1F 14px, #A61F1F 28px); color: #fff; text-align: center; font-weight: 800; padding: .45rem 1rem; letter-spacing: .02em; }
.demo-tag { display: inline-block; background: #C62828; color: #fff; font-size: .68rem; font-weight: 800; padding: .05rem .35rem; border-radius: 3px; vertical-align: middle; letter-spacing: .03em; }

/* ---------- Contenido ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 1.25rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead .lead { font-size: 1rem; color: var(--brand-ink-2); max-width: 70ch; margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card { background: var(--brand-surface); border-radius: 10px; padding: 1.1rem 1.2rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); border: 1px solid var(--brand-line); min-width: 0; }
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: .2rem; }
.card .insight { font-size: 1.08rem; font-weight: 700; margin: 0 0 .15rem; }
.card .sub { color: var(--brand-muted); font-size: .85rem; margin-bottom: .8rem; }
.grid { display: grid; gap: 1rem; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--brand-ink); background: var(--brand-surface); color: var(--brand-ink); padding: .45rem .85rem; border-radius: 6px; font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-bg); color: var(--brand-ink); }
.btn-primary { background: var(--brand-yellow); border-color: var(--brand-yellow); }
.btn-primary:hover { background: #F5CB00; }
.btn-dark { background: var(--brand-ink); color: #fff; }
.btn-dark:hover { background: #333; color: #fff; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: var(--cls-green-soft); border-color: var(--cls-green); }
.flash-error { background: var(--cls-red-soft); border-color: var(--cls-red); }
.flash-info { background: var(--brand-yellow-soft); border-color: var(--brand-yellow); }
.note { font-size: .8rem; color: var(--brand-muted); font-style: italic; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; background: var(--brand-surface); border: 1px solid var(--brand-line); border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; font-size: .75rem; font-weight: 700; color: var(--brand-muted); text-transform: uppercase; letter-spacing: .03em; gap: .2rem; }
select, input[type=text], input[type=number], input[type=date], input[type=password], input[type=url], textarea {
  font: inherit; font-size: .92rem; padding: .4rem .55rem; border: 1px solid #BDBDBD; border-radius: 6px; background: #fff; color: var(--brand-ink); max-width: 100%;
}
textarea { width: 100%; }
.filters .spacer { flex: 1; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--brand-surface); border: 1px solid var(--brand-line); border-radius: 10px; padding: .9rem 1rem; border-top: 5px solid var(--brand-line); min-width: 0; }
.kpi .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-muted); font-weight: 700; }
.kpi .value { font-size: 2rem; font-weight: 800; line-height: 1.1; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8rem; color: var(--brand-muted); }
.kpi.k-green { border-top-color: var(--cls-green); }
.kpi.k-amber { border-top-color: var(--cls-amber); }
.kpi.k-red { border-top-color: var(--cls-red); }
.kpi.k-none { border-top-color: var(--cls-none); }
.kpi.k-brand { border-top-color: var(--brand-yellow); }
.classmix { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .3rem; }
.classmix .badge { font-size: .78rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; line-height: 1.4; border: 1px solid transparent; }
.badge .ico { font-weight: 900; }
.cls-green { background: var(--cls-green); color: var(--cls-green-fg); }
.cls-amber { background: var(--cls-amber); color: var(--cls-amber-fg); }
.cls-red { background: var(--cls-red); color: var(--cls-red-fg); }
.cls-none { background: var(--cls-none); color: var(--cls-none-fg); }
.st-met { background: var(--cls-green-soft); color: #14582A; border-color: #9CCDAA; }
.st-partial { background: var(--cls-amber-soft); color: #6B4A00; border-color: #E9C86A; }
.st-not_met { background: var(--cls-red-soft); color: #8E1B1B; border-color: #E59A9A; }
.st-na { background: #ECECEC; color: #424242; border-color: #C9C9C9; }
.st-not_evaluated { background: #fff; color: #4A4A4A; border: 1px dashed #8A8A8A; }
.rk-high { background: var(--risk-high); color: #fff; }
.rk-medium { background: #FBE3B5; color: var(--risk-medium); border-color: #E2B861; }
.rk-low { background: #DCE8F4; color: var(--risk-low); border-color: #9DB9D6; }
.fs-open { background: #FFF; color: #8E1B1B; border-color: #E59A9A; }
.fs-in_progress { background: #FFF; color: #6B4A00; border-color: #E9C86A; }
.fs-closed { background: #FFF; color: #14582A; border-color: #9CCDAA; }
.fs-not_applicable { background: #FFF; color: #4A4A4A; border-color: #C9C9C9; }
.crit { display: inline-block; font-family: Consolas, "Cascadia Mono", monospace; font-size: .8rem; font-weight: 700; padding: .05rem .4rem; border-radius: 4px; background: #EFEFEF; border-left: 4px solid #999; white-space: nowrap; }
.crit-prg { border-left-color: #0072CE; }
.crit-fin { border-left-color: #6A3FA0; }
.crit-scm { border-left-color: #00857C; }
.iso { display: inline-block; font-weight: 800; font-size: .72rem; letter-spacing: .04em; background: var(--brand-ink); color: #fff; border-radius: 4px; padding: .05rem .35rem; }
.cov { font-size: .78rem; color: var(--brand-muted); white-space: nowrap; }
.cov-warn { color: #8A3B00; font-weight: 700; }
.kind { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: .1rem .4rem; border-radius: 4px; white-space: nowrap; }
.kind-gap { background: var(--cls-red-soft); color: #8E1B1B; }
.kind-coverage { background: #ECECEC; color: #424242; border: 1px dashed #8A8A8A; }

/* ---------- Ranking (barras CSS) ---------- */
.ranking { list-style: none; margin: 0; padding: 0; }
.rank-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 4.5rem 6.2rem; align-items: center; gap: .6rem; padding: .28rem 0; text-decoration: none; color: inherit; border-radius: 6px; }
a.rank-row:hover { background: var(--brand-bg); }
.rank-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { position: relative; height: 22px; background: #F0F0F0; border-radius: 4px; }
.rank-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; font-size: .75rem; font-weight: 900; }
.rank-ref { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed #555; }
.rank-ref span { position: absolute; top: -1.15rem; left: -1rem; font-size: .66rem; color: #555; width: 2rem; text-align: center; }
.ranking li:not(:first-child) .rank-ref span { display: none; }
.ranking li:first-child .rank-row { margin-top: 1rem; }
.rank-pct { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.rank-row.none .rank-name { color: var(--brand-muted); }
.rank-legend { margin-top: .6rem; display: flex; gap: .8rem; flex-wrap: wrap; font-size: .78rem; color: var(--brand-muted); }
@media (max-width: 640px) { .rank-row { grid-template-columns: 6.5rem minmax(0, 1fr) 3.6rem; } .rank-row .cov { display: none; } }

/* ---------- Tablas y mapas de calor ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .45rem .55rem; border-bottom: 1px solid var(--brand-line); text-align: left; vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--brand-muted); background: #FAFAFA; position: sticky; top: 0; z-index: 1; }
tbody tr:hover td { background: #FCFBF2; }
.heat td, .heat th { text-align: center; vertical-align: middle; }
.heat th:first-child, .heat td:first-child { text-align: left; }
.heat .cell { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 3.9rem; padding: .3rem .25rem; border-radius: 6px; text-decoration: none; font-weight: 800; font-size: .9rem; line-height: 1.15; }
.heat .cell small { font-weight: 600; font-size: .68rem; opacity: .95; }
.heat a.cell:hover { outline: 3px solid var(--brand-ink); }
.heat .cell.cls-none { background: var(--cls-none-soft); color: #4A4A4A; border: 1px dashed #9E9E9E; font-weight: 600; }
.heat .cell.lowcov { box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px #8A3B00; }
.heat td.total { border-left: 2px solid var(--brand-ink); }
.heat-dim .cell { min-width: 3.4rem; font-size: .8rem; }
.heat td, .heat th { padding: .3rem .3rem; }
.heat td:first-child { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.matrix td, .matrix th { padding: .25rem; text-align: center; }
.matrix td:nth-child(-n+2), .matrix th:nth-child(-n+2) { text-align: left; }
.matrix .m { display: inline-block; width: 2.1rem; padding: .15rem 0; border-radius: 4px; font-weight: 900; font-size: .78rem; }
.matrix tr.allfail td:first-child { box-shadow: inset 4px 0 0 var(--cls-red); }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; height: 7rem; vertical-align: bottom; text-transform: none; font-size: .8rem; }
details.area-block { margin-bottom: .8rem; }
details.area-block > summary { cursor: pointer; font-weight: 800; padding: .5rem .2rem; font-size: 1rem; }

/* Barras horizontales simples */
.hbar { display: grid; grid-template-columns: 10rem minmax(0, 1fr) 4.2rem; gap: .5rem; align-items: center; margin: .3rem 0; font-size: .88rem; }
.hbar .track { height: 14px; background: #F0F0F0; border-radius: 3px; overflow: hidden; position: relative; }
.hbar .fill { height: 100%; }
.hbar .fill.coverage { background: repeating-linear-gradient(45deg, #9E9E9E, #9E9E9E 4px, #CFCFCF 4px, #CFCFCF 8px); }
.fill.cls-green { background: var(--cls-green); } .fill.cls-amber { background: var(--cls-amber); } .fill.cls-red { background: var(--cls-red); } .fill.cls-none { background: var(--cls-none); }

/* Listas de oportunidades */
.opps { list-style: none; padding: 0; margin: 0; }
.opps li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .6rem; align-items: start; padding: .55rem 0; border-bottom: 1px solid var(--brand-line); }
.opps .txt { font-size: .88rem; }
.opps .val { font-weight: 800; font-size: 1rem; text-align: right; white-space: nowrap; }
.opps .val small { display: block; font-weight: 600; color: var(--brand-muted); }
.chips { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .2rem; }
.chip { font-size: .7rem; font-weight: 700; padding: .05rem .35rem; border-radius: 4px; background: #EFEFEF; text-decoration: none; color: var(--brand-ink); }
.chip.st-not_met { background: var(--cls-red-soft); } .chip.st-partial { background: var(--cls-amber-soft); }
.showmore > summary { cursor: pointer; color: var(--brand-blue-dark); font-weight: 600; margin-top: .5rem; }

/* ---------- Vista de país ---------- */
.country-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.country-head .flagiso { font-size: 1.4rem; font-weight: 900; background: var(--brand-ink); color: var(--brand-yellow); border-radius: 8px; padding: .4rem .7rem; letter-spacing: .05em; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .88rem; color: var(--brand-ink-2); margin-top: .3rem; }
.meta b { color: var(--brand-ink); }
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--brand-line); margin: 1rem 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--brand-ink); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.on { border-bottom-color: var(--brand-yellow); }
.area-card { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 1rem; align-items: center; }
.gauge { width: 6.5rem; height: 6.5rem; border-radius: 50%; display: grid; place-items: center; position: relative; }
.gauge::before { content: ""; position: absolute; inset: 11px; background: var(--brand-surface); border-radius: 50%; }
.gauge span { position: relative; font-weight: 900; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.counts { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .4rem; }
.crit-table td.text { min-width: 18rem; }
.crit-table tr.hl td { background: var(--brand-yellow-soft); }
.crit-table .details { font-size: .82rem; color: var(--brand-ink-2); }
.crit-table .details div { margin-top: .2rem; }
.crit-table .details b { color: var(--brand-muted); font-weight: 700; }
.field-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tr-note { font-size: .75rem; color: var(--brand-muted); margin-top: .3rem; }
.tr-note summary { cursor: pointer; }
.tr-note[open] { background: #FAFAFA; border-left: 3px solid var(--brand-line); padding: .3rem .5rem; }
@media print { .tr-note { display: none; } }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(760px, 96vw); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 1.2rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label, .stack label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 700; color: var(--brand-ink-2); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 420px; }
.chart-box.short { height: 220px; }

/* ---------- Pie ---------- */
footer.site { max-width: 1440px; margin: 1.5rem auto 0; padding: 1rem 1.25rem 2rem; font-size: .8rem; color: var(--brand-muted); display: flex; gap: 1rem 2rem; flex-wrap: wrap; border-top: 1px solid var(--brand-line); }
footer.site .legend { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(180deg, var(--brand-yellow) 0 38%, var(--brand-bg) 38%); }
.login { width: min(420px, 100%); background: #fff; border-radius: 14px; padding: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.login img { height: 70px; display: block; margin: 0 auto 1rem; }
.login label { display: block; font-weight: 700; font-size: .85rem; margin: .8rem 0 .25rem; }
.login input { width: 100%; }
.login .btn { width: 100%; justify-content: center; margin-top: 1.2rem; padding: .65rem; }

/* ---------- Impresión (PDF desde el navegador) ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 10.5pt; }
  .topbar { position: static; border-bottom-width: 3px; }
  .mainnav, .tools, .filters, .actions, .no-print, .tabs, dialog, .showmore > summary { display: none !important; }
  .showmore[open] > *, .showmore > * { display: block; }
  main { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .grid { gap: .6rem; }
  a { color: inherit; text-decoration: none; }
  .badge, .cell, .rank-bar, .fill, .m, .demo-banner, .gauge, .iso, .flagiso { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chart-box { height: 260px; }
  th { position: static; }
  footer.site { border-top: 1px solid #999; }
}

/* Ajustes tras la revisión visual */
.heat .cell span, .heat .cell small { white-space: nowrap; }
td small.muted { white-space: nowrap; }
.area-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: .8rem; }
@media (min-width: 1200px) { .area-strip { position: sticky; top: 66px; z-index: 5; } }
.area-chip { background: var(--brand-surface); border: 1px solid var(--brand-line); border-radius: 8px; padding: .45rem .7rem; display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: center; font-size: .88rem; }
.area-chip .num { font-weight: 800; font-size: 1.05rem; }
.area-chip:last-child { border: 2px solid var(--brand-ink); }
@media (max-width: 760px) { .area-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { .area-strip { position: static; } }

/* Login con Microsoft */
.login .btn-ms { width: 100%; justify-content: center; gap: .6rem; padding: .65rem; margin-top: .6rem; background: #fff; border: 1px solid #8C8C8C; color: #262626; font-weight: 600; }
.login .btn-ms:hover { background: #F3F3F3; }
.login-sep { display: flex; align-items: center; gap: .6rem; margin: 1.1rem 0 .2rem; color: var(--brand-muted); font-size: .8rem; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; border-top: 1px solid var(--brand-line); }
