/* Rentabilidad de moldes · identidad Ekuora
   Paleta oficial: #15212F · #2E3A47 · #8296A9 · #D98918 · #FFFFFF
   Tipografía: Montserrat (Light cuerpo · Bold subtítulos · Extra Bold títulos) */
:root {
  --ek-deep: #15212F;
  --ek-corp: #2E3A47;
  --ek-slate: #8296A9;
  --ek-orange: #D98918;
  --ek-white: #FFFFFF;

  --bg: color-mix(in srgb, var(--ek-slate) 9%, var(--ek-white));
  --surface: var(--ek-white);
  --surface-2: color-mix(in srgb, var(--ek-slate) 6%, var(--ek-white));
  --line: color-mix(in srgb, var(--ek-slate) 26%, var(--ek-white));
  --line-strong: color-mix(in srgb, var(--ek-slate) 45%, var(--ek-white));
  --ink: var(--ek-deep);
  --ink-2: var(--ek-corp);
  --ink-3: color-mix(in srgb, var(--ek-slate) 78%, var(--ek-deep));
  --orange-ink: color-mix(in srgb, var(--ek-orange) 55%, var(--ek-deep));
  --orange-wash: color-mix(in srgb, var(--ek-orange) 13%, var(--ek-white));
  --orange-soft: color-mix(in srgb, var(--ek-orange) 7%, var(--ek-white));
  --deep-wash: color-mix(in srgb, var(--ek-deep) 7%, var(--ek-white));
  --slate-wash: color-mix(in srgb, var(--ek-slate) 14%, var(--ek-white));

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px color-mix(in srgb, var(--ek-deep) 6%, transparent), 0 8px 24px color-mix(in srgb, var(--ek-deep) 6%, transparent);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --top-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 300 15px/1.5 var(--font); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: .02em; color: var(--ink); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.print-only { display: none; }
[hidden] { display: none !important; }

/* ---------- Botones y controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: 13px; letter-spacing: .03em; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .row-link:focus-visible, .hl-link:focus-visible, .menu-item:focus-visible, .user-btn:focus-visible, th[data-sort]:focus-visible { outline: 3px solid color-mix(in srgb, var(--ek-orange) 55%, transparent); outline-offset: 2px; }
.btn-primary { background: var(--ek-orange); color: var(--ek-white); }
.btn-primary:hover { background: color-mix(in srgb, var(--ek-orange) 88%, var(--ek-deep)); }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ek-deep); }
.btn-warn { background: var(--orange-wash); color: var(--orange-ink); border-color: color-mix(in srgb, var(--ek-orange) 40%, var(--ek-white)); }
.btn-ghost-light { background: transparent; color: var(--ek-white); border-color: color-mix(in srgb, var(--ek-white) 30%, transparent); }
.btn-ghost-light:hover { background: color-mix(in srgb, var(--ek-white) 10%, transparent); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--ek-deep); color: var(--ek-white); }
.topbar::after { content: ''; position: absolute; right: -60px; top: -90px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid color-mix(in srgb, var(--ek-orange) 22%, transparent); pointer-events: none; }
.topbar { overflow: clip; }
.topbar-inner { position: relative; z-index: 1; max-width: 1440px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand strong { display: block; font-weight: 800; font-size: 16px; letter-spacing: .08em; }
.brand small { display: block; font-weight: 300; font-size: 12px; color: color-mix(in srgb, var(--ek-white) 70%, transparent); }
.mark { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--ek-white); color: var(--ek-deep); font-weight: 800; font-size: 20px; overflow: hidden; flex: 0 0 auto; }
.mark::after { content: ''; position: absolute; right: -12px; bottom: -12px; width: 24px; height: 24px; border-radius: 50%; background: var(--ek-orange); }
.top-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.freshness { font-size: 12px; line-height: 1.35; text-align: right; color: color-mix(in srgb, var(--ek-white) 72%, transparent); }
.freshness strong { color: var(--ek-white); font-weight: 600; }
.freshness.busy::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ek-white) 30%, transparent); border-top-color: var(--ek-orange); animation: spin 1s linear infinite; }
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--ek-white) 30%, transparent); background: transparent; color: var(--ek-white); cursor: pointer; font-size: 13px; font-weight: 600; }
.user-btn:hover { background: color-mix(in srgb, var(--ek-white) 10%, transparent); }
.user-btn .role { font-weight: 300; opacity: .75; }
.menu { position: fixed; right: max(24px, calc((100vw - 1440px) / 2 + 24px)); top: calc(var(--top-h) - 6px); min-width: 250px; background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 6px; z-index: 40; }
.menu-info { display: none; margin: 0 0 4px; padding: 8px 12px 10px; font-size: 11.5px; line-height: 1.45; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.menu-info strong { color: var(--ink); font-weight: 600; }
.menu-item { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 13px; }
.menu-item:hover { background: var(--slate-wash); }
.menu-item[aria-disabled="true"] { opacity: .6; pointer-events: none; }

/* ---------- Estructura ---------- */
.main { max-width: 1440px; margin: 0 auto; padding: 24px 24px 56px; }
.sec-head { margin-bottom: 16px; }
.sec-head h1 { font-size: 24px; letter-spacing: .06em; }
.kicker { display: block; font-weight: 700; font-size: 12px; letter-spacing: .12em; color: var(--ek-orange); text-transform: uppercase; margin-bottom: 4px; }
.subtitle { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 20px 22px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 18px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 14px; letter-spacing: .1em; }
.card-head p { margin: 2px 0 0; font-size: 13px; }
.table-card { margin-top: 18px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.kpi .value { display: block; margin-top: 6px; font-size: 24px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .foot { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.kpi.accent { background: var(--ek-deep); border-color: var(--ek-deep); }
.kpi.accent .label, .kpi.accent .foot { color: color-mix(in srgb, var(--ek-white) 72%, transparent); }
.kpi.accent .value { color: var(--ek-white); }
.meter { height: 8px; border-radius: 8px; background: var(--slate-wash); overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; border-radius: 8px; background: var(--ek-orange); }
.kpi.accent .meter { background: color-mix(in srgb, var(--ek-white) 16%, transparent); }
.neg { color: var(--orange-ink) !important; }

/* ---------- Gráficas ---------- */
.chart-box { position: relative; height: 380px; }
.chart-box.tall { height: 420px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 8px; }
.legend .swatch { width: 18px; height: 0; border-top: 3px solid; border-radius: 3px; }
.legend .swatch.dashed { border-top-style: dashed; }
.chart-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-3); }
.marker-caption { display: none; margin-top: 10px; font-weight: 600; }

.global-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
.highlights { display: grid; gap: 14px; align-content: start; }
.hl { display: block; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); padding: 14px 16px; text-decoration: none; }
.hl .label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.hl .value { display: block; font-size: 20px; font-weight: 800; margin-top: 4px; }
.hl .foot { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.hl-link { transition: border-color .15s, background .15s; }
.hl-link:hover { border-color: var(--ek-deep); background: var(--surface); }
.hl-go { display: block; margin-top: 8px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--orange-ink); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: var(--surface); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .right, .table td.num { text-align: right; white-space: nowrap; }
.table td.num { font-variant-numeric: tabular-nums; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .sort { margin-left: 4px; opacity: .6; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table tbody tr.dim td { color: var(--ink-3); }
.row-link { text-decoration: none; }
.table td.actions { text-align: right; }
.table td.actions form { display: inline-flex; gap: 6px; align-items: center; margin: 3px 0 3px 6px; flex-wrap: wrap; }
.table td.actions input, .table td.actions select { min-height: 32px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 12px; font-size: 12px; background: var(--surface); }

/* Semáforo por molde */
.sem-table th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.sem-table th, .sem-table td { padding-left: 10px; padding-right: 10px; }
.sem-table .mold-cell { min-width: 180px; }
.sem-table .mold-cell strong { display: block; font-weight: 700; color: var(--ink); }
.sem-table .mold-cell small { display: block; color: var(--ink-3); font-size: 12px; }
.sem-table .mold-cell .tag { margin-top: 5px; }
.sem-table .cell-sub { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
.sem-table .m-sub { display: none !important; }
.sem-table tbody tr.is-selected td { background: var(--orange-soft); }
.sem-table tbody tr.is-selected td:first-child { box-shadow: inset 4px 0 0 var(--ek-orange); }
.sem-table tbody tr.is-selected:hover td { background: var(--orange-wash); }
.sem-table .verdict-cell { white-space: nowrap; }

/* ---------- Chips de estado (✓ azul profundo · ✗ naranja) ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.chip-ok { background: var(--ek-deep); color: var(--ek-white); }
.chip-no { background: var(--orange-wash); color: var(--orange-ink); border: 1px solid color-mix(in srgb, var(--ek-orange) 35%, var(--ek-white)); }
.chip-muted { background: var(--slate-wash); color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--slate-wash); color: var(--ink-2); }
.tag-orange { background: var(--orange-wash); color: var(--orange-ink); }

/* ---------- Reporte por molde ---------- */
.sec-mold { position: relative; margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line-strong); }
.sec-mold::before { content: ''; position: absolute; left: 0; top: -1px; width: 36px; height: 18px; border-radius: 0 0 36px 36px; background: var(--ek-orange); }
.mold-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.mold-pick { min-width: 0; }
.pick-wrap { position: relative; display: inline-block; max-width: 100%; margin-top: 2px; }
.pick { appearance: none; -webkit-appearance: none; max-width: 100%; font-weight: 800; font-size: 24px; line-height: 1.2; letter-spacing: .04em; text-transform: uppercase; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 9px 52px 9px 18px; box-shadow: var(--shadow); cursor: pointer; text-overflow: ellipsis; }
.pick:hover { border-color: var(--ek-deep); }
.pick option { text-transform: none; font-size: 15px; font-weight: 600; }
.pick-chevron { position: absolute; right: 18px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--ek-orange); pointer-events: none; }
.mold-pick .subtitle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.verdict-chip { display: flex; flex-direction: column; gap: 2px; padding: 13px 20px; border-radius: 16px; min-width: 250px; }
.verdict-chip .v-text { font-size: 16px; font-weight: 800; letter-spacing: .02em; }
.verdict-chip .v-foot { font-size: 12px; font-weight: 600; opacity: .85; }
.verdict-chip.ok { background: var(--ek-deep); color: var(--ek-white); }
.verdict-chip.no { background: var(--ek-orange); color: var(--ek-deep); }
.verdict-chip.no .v-foot { opacity: 1; }

.report-grid { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 13fr); gap: 18px; align-items: start; }
.report-right { position: sticky; top: calc(var(--top-h) + 16px); }

/* Tablero con la estructura del Dashboard Ejecutivo (A1:D42) */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sheet-bar { display: flex; align-items: center; gap: 10px; margin: 0; padding: 11px 18px; background: var(--ek-deep); color: var(--ek-white); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.sheet-bar::before { content: ''; width: 16px; height: 8px; border-radius: 16px 16px 0 0; background: var(--ek-orange); flex: 0 0 auto; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet-facts { margin-bottom: 12px; }
.sheet-facts th, .sheet-facts td { padding: 8px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.sheet-facts th { width: 48%; font-weight: 600; color: var(--ink-3); }
.sheet-facts td { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.sheet-facts tr:last-child th, .sheet-facts tr:last-child td { border-bottom: 0; }
.sheet-table thead th { padding: 9px 12px; background: var(--ek-corp); color: var(--ek-white); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-align: left; white-space: nowrap; }
.sheet-table thead th.right { text-align: right; }
.sheet-table tbody th { padding: 9px 12px; font-weight: 600; color: var(--ink); text-align: left; border-bottom: 1px solid var(--line); }
.sheet-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet-table th:first-child { padding-left: 18px; }
.sheet-table th:last-child, .sheet-table td:last-child { padding-right: 18px; }
.sheet-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-table tbody tr:last-child th, .sheet-table tbody tr:last-child td { border-bottom: 0; }
.ind-table { margin-bottom: 12px; }
.ind-table tbody th { font-weight: 700; }
.ind-table td.is-ok { font-weight: 700; color: var(--ink); }
.ind-table td.is-below { font-weight: 700; color: var(--orange-ink); }
.below-mark { font-size: 8px; margin-right: 6px; vertical-align: 2px; color: var(--ek-orange); }
.metrics-table td.threshold { color: var(--ink-3); white-space: nowrap; font-size: 12px; }
.metrics-table td.status { width: 1%; white-space: nowrap; }
.metrics-table tr.sub-head th { padding: 7px 18px; background: var(--surface-2); color: var(--ink-3); font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.metrics-table tr.is-gate th { font-weight: 700; }
.th-note { display: none; margin-top: 2px; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.kpi-note { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.tag-plan { background: var(--surface); color: var(--ink-2); border: 1px dashed color-mix(in srgb, var(--ek-orange) 70%, var(--ek-white)); cursor: help; }
.gate-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--ek-orange); vertical-align: 1px; }
.sheet-legend { margin: 0; padding: 10px 18px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.sheet-verdict { padding: 14px 18px 16px; }
.sheet-verdict strong { display: block; font-size: 14px; font-weight: 800; letter-spacing: .02em; }
.sheet-verdict span { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; }
.sheet-verdict.ok { background: var(--deep-wash); color: var(--ink); }
.sheet-verdict.no { background: var(--orange-wash); color: var(--orange-ink); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.stat { border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; min-width: 0; }
.stat .label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--ink-3); }
.stat .value { display: block; font-size: 18px; font-weight: 800; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .foot { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.footnote { margin-top: 22px; font-size: 12px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.recon { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }

/* ---------- Estados ---------- */
.state { display: grid; place-items: center; text-align: center; min-height: 320px; padding: 32px; }
.state h2 { font-size: 18px; letter-spacing: .06em; }
.state p { max-width: 520px; color: var(--ink-3); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--slate-wash); border-top-color: var(--ek-orange); animation: spin 1s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--orange-wash); color: var(--orange-ink); border: 1px solid color-mix(in srgb, var(--ek-orange) 35%, var(--ek-white)); margin-bottom: 18px; font-weight: 600; font-size: 13px; }

/* ---------- Acceso y administración ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ek-deep); position: relative; overflow: hidden; }
.auth-card { position: relative; z-index: 1; width: min(440px, 100%); background: var(--surface); border-radius: 24px; padding: 36px 34px; box-shadow: 0 24px 60px color-mix(in srgb, #000 30%, transparent); }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .mark { background: var(--ek-deep); color: var(--ek-white); }
.brand-kicker { font-weight: 700; font-size: 12px; letter-spacing: .12em; color: var(--ek-orange); text-transform: uppercase; }
.auth-card h1 { font-size: 22px; letter-spacing: .08em; margin: 22px 0 6px; }
.auth-card label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin: 16px 0 6px; }
.auth-card input { width: 100%; min-height: 46px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); font-weight: 400; }
.auth-card .btn { margin-top: 22px; min-height: 48px; font-size: 14px; letter-spacing: .1em; }
.auth-foot { margin: 18px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.7; }
.auth-link { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.auth-card .notice { margin-top: 14px; }
.auth-card a.btn { margin-top: 18px; }
.alert { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--orange-wash); color: var(--orange-ink); font-weight: 600; font-size: 13px; border: 1px solid color-mix(in srgb, var(--ek-orange) 35%, var(--ek-white)); }
.notice { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px; background: var(--deep-wash); color: var(--ink); font-weight: 600; font-size: 13px; border: 1px solid var(--line-strong); }
.auth-shape { position: absolute; border-radius: 50%; pointer-events: none; }
.auth-shape-a { width: 520px; height: 520px; right: -180px; top: -200px; border: 70px solid color-mix(in srgb, var(--ek-orange) 20%, transparent); }
.auth-shape-b { width: 360px; height: 360px; left: -140px; bottom: -160px; background: color-mix(in srgb, var(--ek-slate) 22%, transparent); }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 56px; }
.admin-main .card + .card { margin-top: 18px; }
.conn-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.conn-grid .label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.conn-grid strong { display: block; margin-top: 4px; font-weight: 700; overflow-wrap: anywhere; }
.ping-out { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--ink-2); }
.field input, .field select { min-height: 42px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 14px; background: var(--surface); font-weight: 400; font-size: 14px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .global-grid { grid-template-columns: minmax(0, 1fr); }
  .highlights { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .report-grid { grid-template-columns: minmax(0, 1fr); }
  .report-right { position: static; }
}
@media (max-width: 1100px) {
  .hide-md { display: none !important; }
}
@media (max-width: 900px) {
  .hide-tab { display: none !important; }
  .freshness { display: none; }
  .menu-info { display: block; }
  .conn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .marker-caption { display: flex; }
}
@media (max-width: 640px) {
  :root { --top-h: 60px; }
  .hide-sm { display: none !important; }
  .topbar-inner { padding-top: 10px; padding-bottom: 10px; }
  .topbar-inner, .main, .admin-main { padding-left: 16px; padding-right: 16px; }
  .menu { right: 16px; }
  .brand small { display: none; }
  .brand strong { font-size: 14px; }
  .user-btn .role { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 19px; }
  .highlights { grid-template-columns: minmax(0, 1fr); }
  .chart-box, .chart-box.tall { height: 300px; }
  .card { padding: 16px; }
  .sec-head h1 { font-size: 20px; }
  .sem-table .mold-cell { min-width: 0; }
  .sem-table .m-sub { display: block !important; margin-top: 2px; }
  .sem-table td, .sem-table th { padding-left: 8px; padding-right: 8px; }
  .mold-head { align-items: stretch; }
  .mold-pick, .pick-wrap, .pick { width: 100%; }
  .pick { font-size: 17px; letter-spacing: .01em; text-transform: none; padding: 10px 46px 10px 14px; }
  .verdict-chip { min-width: 0; width: 100%; }
  .sheet-facts th, .sheet-facts td { padding: 8px 14px; }
  .sheet-facts th { width: 50%; }
  .sheet-table th:first-child { padding-left: 14px; }
  .sheet-table th:last-child, .sheet-table td:last-child { padding-right: 14px; }
  .sheet-table thead th { font-size: 10px; letter-spacing: .04em; white-space: normal; }
  .sheet-table tbody th, .sheet-table td { padding-top: 8px; padding-bottom: 8px; font-size: 12.5px; }
  .metrics-table .col-th { display: none; }
  .metrics-table .th-note { display: block; }
  .metrics-table tbody th, .metrics-table td { padding-left: 8px; padding-right: 8px; }
  .metrics-table tbody th:first-child, .metrics-table thead th:first-child { padding-left: 14px; }
  .metrics-table td:last-child { padding-right: 14px; }
  .metrics-table .chip { padding: 3px 8px; font-size: 10px; letter-spacing: .02em; }
  .sheet-bar { padding: 10px 14px; }
  .sheet-legend { padding-left: 14px; padding-right: 14px; }
  .sheet-verdict { padding: 14px; }
  .stats { gap: 10px; }
  .stat .value { font-size: 16px; }
}
@media (max-width: 420px) {
  .metrics-table .chip { padding: 3px 7px; font-size: 10px; letter-spacing: .02em; }
}

/* ---------- Impresión (A4 horizontal: portafolio en la hoja 1, molde en la hoja 2) ---------- */
@media print {
  @page { size: A4 landscape; margin: 7mm; }
  html, body { background: #FFFFFF !important; }
  body { font-size: 9.5px; }
  .topbar { position: static; }
  .topbar::after { display: none; }
  .topbar-inner { padding: 6px 10px; }
  .top-actions, .no-print, .banner, .marker-caption, .pick-wrap, .hl-go, #viewLoading, #viewError { display: none !important; }
  .print-only { display: block; }
  .main { padding: 6px 0 0; max-width: none; }
  .card, .kpi, .stat, .hl, .sheet, .pick { box-shadow: none !important; }
  .card { padding: 9px 11px; border-radius: 10px; }
  .kicker { font-size: 8.5px; margin-bottom: 0; }
  .subtitle { font-size: 9px; margin-top: 1px; }
  .card-head { margin-bottom: 4px; }
  .card-head h2 { font-size: 10px; }
  .card-head p, .chart-note, .footnote { font-size: 8px; }
  .legend { font-size: 8.5px; }
  .brand strong { font-size: 12px; }
  .brand small { font-size: 9px; }
  .mark { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
  canvas { max-width: 100% !important; height: auto !important; }

  /* Hoja 1 · Portafolio */
  .sec-global { break-after: page; }
  .sec-head { margin-bottom: 6px; }
  .sec-head h1 { font-size: 15px; }
  .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
  .kpi { padding: 7px 9px; border-radius: 10px; }
  .kpi .label, .kpi .foot { font-size: 7.5px; }
  .kpi .value { font-size: 13px; margin-top: 2px; }
  .meter { height: 5px; margin-top: 5px; }
  .global-grid { grid-template-columns: minmax(0, 1fr) 190px; gap: 6px; }
  .highlights { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .hl { padding: 7px 9px; }
  .hl .label, .hl .foot { font-size: 7.5px; }
  .hl .value { font-size: 11px; margin-top: 1px; }
  .chart-box { height: 205px; }
  .table-card { margin-top: 6px; }
  .table { font-size: 8px; }
  .table th { font-size: 7px; letter-spacing: .04em; padding: 3px 5px; }
  .table td { padding: 2.5px 5px; }
  .sem-table .mold-cell small, .sem-table .cell-sub { font-size: 7px; }
  .sem-table .mold-cell .tag { display: none; }
  .sem-table tbody tr.is-selected td { background: transparent; }
  .sem-table tbody tr.is-selected td:first-child { box-shadow: none; }

  /* Hoja 2 · Reporte por molde */
  .sec-mold { margin-top: 0; padding-top: 0; border-top: 0; }
  .sec-mold::before { display: none; }
  .mold-head { margin-bottom: 6px; align-items: center; }
  #mPrintTitle { font-size: 16px; letter-spacing: .04em; text-transform: uppercase; }
  .verdict-chip { min-width: 0; padding: 6px 12px; border-radius: 10px; }
  .verdict-chip .v-text { font-size: 11px; }
  .verdict-chip .v-foot { font-size: 8px; }
  .report-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 8px; }
  .report-right { position: static; }
  .sheet { border-radius: 10px; }
  .sheet table { font-size: 8.5px; }
  .sheet-bar { padding: 4px 10px; font-size: 8.5px; }
  .sheet-bar::before { width: 10px; height: 5px; }
  .sheet-facts { margin-bottom: 4px; }
  .sheet-facts th, .sheet-facts td { padding: 2.2px 10px; }
  .sheet-table thead th { padding: 3px 6px; font-size: 7.5px; letter-spacing: .04em; }
  .sheet-table tbody th, .sheet-table td { padding: 2.2px 6px; }
  .sheet-table th:first-child { padding-left: 10px; }
  .sheet-table th:last-child, .sheet-table td:last-child { padding-right: 10px; }
  .ind-table { margin-bottom: 4px; }
  .metrics-table td.threshold { font-size: 8px; }
  .metrics-table tr.sub-head th { padding: 2px 10px; font-size: 7px; }
  .sheet-legend { padding: 3px 10px; font-size: 7.5px; }
  .sheet-verdict { padding: 5px 10px 6px; }
  .sheet-verdict strong { font-size: 9px; }
  .sheet-verdict span { font-size: 8px; margin-top: 1px; }
  .chip { padding: 1px 6px; font-size: 7.5px; letter-spacing: .02em; }
  .gate-dot { width: 5px; height: 5px; margin-right: 5px; }
  .chart-box.tall { height: 300px; }
  .stats { margin-top: 6px; gap: 6px; }
  .stat { padding: 5px 8px; }
  .stat .label, .stat .foot { font-size: 7.5px; }
  .stat .value { font-size: 11px; margin-top: 1px; }
  .footnote { margin-top: 4px; }
  /* Ajuste fino para que cada sección quepa en una hoja */
  body { line-height: 1.3; }
  .chart-box { height: 200px; }
  .sem-table .mold-cell small, .sem-table .cell-sub, .sem-table .m-sub { display: none !important; }
  .sem-table .mold-cell { min-width: 0; }
  .sem-table th, .sem-table td { padding: 1.6px 5px; }
  .sem-table th { white-space: nowrap; }
  .chip { padding: 0 5px; font-size: 7px; line-height: 1.55; }
  .sheet table { font-size: 8px; }
  .sheet-facts th, .sheet-facts td { padding: 1.3px 10px; }
  .sheet-table tbody th, .sheet-table td { padding: 1.3px 6px; }
  .sheet-table thead th { padding: 2.4px 6px; }
  .sheet-bar { padding: 3px 10px; }
  .th-note { display: none !important; }
  .kpi-note { font-size: 7px; margin-top: 0; }
  .chart-box.tall { height: 270px; }
  .sec-mold { break-inside: avoid; }
  .verdict-chip, .sheet-bar, .sheet-table thead th, .sheet-verdict, .chip, .kpi.accent, .topbar, .mark, .meter > span, .gate-dot, .tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
