/* Design system Pampling (wiki guias/estetica) — variables contractuales */
:root {
  --bg-base: #F5F0EB; --bg-card: rgba(255,255,255,0.70); --bg-card-2: rgba(255,255,255,0.90); --bg-input: rgba(255,255,255,0.80);
  --border: rgba(45,42,38,0.08); --border-light: rgba(45,42,38,0.05);
  --text-primary: #2D2A26; --text-secondary: rgba(45,42,38,0.60); --text-muted: rgba(45,42,38,0.35);
  --accent-a: #7947F8; --accent-a-end: #A855F7; --accent-a-grad: linear-gradient(135deg,#7947F8,#A855F7); --accent-a-soft: rgba(121,71,248,0.10);
  --accent-b: #4A9EFF; --accent-b-soft: rgba(74,158,255,0.10);
  --green: #5C8A6C; --green-soft: rgba(92,138,108,0.12); --amber: #C99555; --amber-soft: rgba(201,149,85,0.12); --red: #E05252; --red-soft: rgba(224,82,82,0.12);
  --radius-sm: 8px; --radius: 16px; --radius-lg: 20px;
  --shadow: 0 1px 4px rgba(45,42,38,0.06); --shadow-md: 0 4px 16px rgba(45,42,38,0.08);
  --font: 'Poppins', system-ui, sans-serif; --font-mono: 'JetBrains Mono', monospace; --nav-height: 60px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg-base); color: var(--text-primary); font: 14px/1.45 var(--font); padding-top: var(--nav-height); }
a { color: var(--accent-a); text-decoration: none; }
nav { position: fixed; top: 0; left: 0; width: 100%; height: var(--nav-height); padding: 0 32px; background: rgba(245,240,235,0.85);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); z-index: 100; display: flex; align-items: center; gap: 6px; }
nav .brand { font-weight: 700; margin-right: 18px; display: flex; align-items: center; gap: 8px; }
nav .brand::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-a); display: inline-block; }
nav a.link { font-size: 13px; font-weight: 600; color: var(--text-secondary); padding: 6px 14px; border-radius: var(--radius-sm); }
nav a.link.active { color: var(--accent-a); background: var(--accent-a-soft); }
nav .right { margin-left: auto; font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
main { padding: 24px 32px 48px; max-width: 1500px; margin: 0 auto; }
.section-tag { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--accent-a); margin-bottom: 6px; }
.tag-bar { width: 24px; height: 3px; background: var(--accent-a); border-radius: 2px; }
h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 0 0 4px; }
.page-desc { font-size: 14px; color: var(--text-secondary); margin: 0 0 20px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.active { border-color: var(--accent-a); box-shadow: 0 0 0 2px var(--accent-a-soft); }
.section-title { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.kpi .value { font-size: 26px; font-weight: 800; color: var(--accent-a); letter-spacing: -1px; margin: 4px 0 2px; }
.kpi .aux { font-size: 11px; color: var(--text-primary); }
.delta { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.delta.pos { color: var(--green); background: var(--green-soft); } .delta.neg { color: var(--red); background: var(--red-soft); } .delta.warn { color: var(--amber); background: var(--amber-soft); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
input, select, textarea { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); font: 13px var(--font); color: var(--text-primary); padding: 7px 10px; min-width: 110px; }
input[type=number] { width: 120px; } input[type=checkbox] { accent-color: var(--accent-a); min-width: 0; width: 16px; height: 16px; }
.btn { background: var(--accent-a-grad); color: #fff; font-size: 13px; font-weight: 600; padding: 8px 22px; border: none; border-radius: 999px; cursor: pointer; }
.btn.secondary { background: var(--bg-card-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn.small { padding: 5px 14px; font-size: 12px; } .btn.danger { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
td { font-size: 13px; padding: 9px 10px; border-bottom: 1px solid var(--border-light); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; background: rgba(45,42,38,0.03); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.pill.principal { color: var(--accent-a); background: var(--accent-a-soft); } .pill.capsula { color: var(--amber); background: var(--amber-soft); } .pill.muted { color: var(--text-secondary); background: rgba(45,42,38,0.06); }
.alert-row-red { background: var(--red-soft); } .alert-row-amber { background: var(--amber-soft); } .alert-row-green { background: var(--green-soft); }
.muted { color: var(--text-muted); } .small { font-size: 12px; } .mono { font-family: var(--font-mono); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; } .tab { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer; }
.tab.active { color: var(--text-primary); background: rgba(45,42,38,0.05); }
.scroll { overflow: auto; max-height: 520px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text-primary); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-md); display: none; z-index: 200; }
.hidden { display: none !important; }
.grid-months input { width: 78px; min-width: 0; padding: 4px 6px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--bg-card-2); border: 1px solid var(--border); cursor: pointer; }
.chip.on { border-color: var(--accent-a); color: var(--accent-a); background: var(--accent-a-soft); }
label.f .inline { display: flex; align-items: center; gap: 6px; }
label.f .unit { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: none; letter-spacing: 0; }
.grid-months td.cell-real input { background: var(--accent-b-soft); border-color: rgba(74,158,255,0.35); color: var(--text-primary); }
.grid-months td.cell-proj input { background: var(--bg-input); color: var(--text-primary); }
.legend { display: inline-block; width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--border); vertical-align: middle; }
.legend.cell-real { background: var(--accent-b-soft); border-color: rgba(74,158,255,0.35); } .legend.cell-proj { background: var(--bg-input); }
.grid-months td.cell-mod input { background: rgba(255, 221, 87, 0.35); border-color: rgba(201,149,85,0.45); color: var(--text-primary); }
.legend.cell-mod { background: rgba(255, 221, 87, 0.35); border-color: rgba(201,149,85,0.45); }
.pill.liquidacion { color: var(--red); background: var(--red-soft); }
.pill.fusion { color: #2F6FD6; background: rgba(74,158,255,0.14); }
tr.row-fused td { opacity: 0.8; }
/* Simulador: cuadro de parámetros */
.params-top { display: grid; grid-template-columns: 150px minmax(220px, 1.4fr) minmax(200px, 1.2fr) minmax(220px, 1.2fr) auto; gap: 16px; align-items: end; }
.params-top select, .params-grid input, .params-grid select { width: 100%; min-width: 0; box-sizing: border-box; }
.params-top .btn { height: 38px; align-self: end; }
.params-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.params-grid .inline input { flex: 1; }
.params-suppliers { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); align-items: center; }
@media (max-width: 1100px) { .params-top { grid-template-columns: 1fr 1fr; } .params-top .btn { grid-column: span 2; justify-self: start; } }

/* Simulador v3: rejilla de cobertura con semáforo, entradas y pedidos */
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); align-items: center; }
.legend .swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.legend .swatch.firm { background: rgba(74,158,255,0.35); } .legend .swatch.plan { background: rgba(121,71,248,0.3); }
.dot { display: inline-block; border-radius: 50%; vertical-align: middle; }
.dot.sm { width: 8px; height: 8px; margin-right: 5px; }
.dot.md { width: 12px; height: 12px; margin-right: 2px; }
.dot.lg { width: 18px; height: 18px; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.55); }
.grid-wrap { overflow: auto; max-height: 72vh; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; width: auto; min-width: 100%; }
table.grid th, table.grid td { padding: 4px 7px; border-bottom: 1px solid var(--border); }
table.grid thead th { position: sticky; top: 0; background: #FCFBF9; z-index: 2; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); text-align: center; }
table.grid thead tr:nth-child(2) th { top: 24px; }
table.grid thead th.sub { font-size: 9px; letter-spacing: 0; text-transform: none; }
table.grid td:first-child, table.grid th:first-child { position: sticky; left: 0; background: #FCFBF9; z-index: 1; text-align: left; }
table.grid thead th:first-child { z-index: 3; }
table.grid td.sem { text-align: center; }
table.grid td.sem.warn .dot.lg { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.55), 0 0 0 2px rgba(45,42,38,0.25); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.r-line td { font-weight: 600; background: var(--bg-card-2); }
table.grid tr.r-line td:first-child { background: #F7F5F2; }
table.grid tr.r-color td:first-child { padding-left: 18px; }
table.grid tr.r-sku td:first-child { padding-left: 36px; color: var(--text-secondary); }
table.grid tr.ignored td { opacity: .55; }
table.grid td.firm { background: rgba(74,158,255,0.16); }
table.grid td.plan { background: rgba(121,71,248,0.14); }
table.grid td.firm.plan { background: linear-gradient(90deg, rgba(74,158,255,0.16), rgba(121,71,248,0.14)); }
table.grid th.clickable { cursor: pointer; }
table.grid th.clickable:hover { color: var(--accent-a); }
table.grid th.sel { background: var(--accent-a-soft); color: var(--accent-a); }
table.grid td.sel { box-shadow: inset 0 0 0 1px var(--accent-a); }
table.grid td.need { color: var(--red); font-weight: 600; }
table.grid td.zero { color: var(--text-muted); }
.cov { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; color: #fff; }
.cov.ok { background: #5C8A6C; opacity: .75; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sup { display: inline-flex; align-items: center; gap: 6px; }
.sup input { padding: 3px 6px; font-size: 11px; min-width: 0; }
.sup .desde { width: 100px; } .sup .pct { width: 56px; }
.sup.off input { opacity: .4; pointer-events: none; }
.pbtn { font-size: 11px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card-2); cursor: pointer; }
.pbtn.on { border-color: var(--accent-a); color: var(--accent-a); background: var(--accent-a-soft); }
.tg { display: inline-block; width: 16px; text-align: center; cursor: pointer; color: var(--accent-a); font-weight: 700; user-select: none; margin-right: 3px; font-size: 12px; }
.tg:hover { background: var(--accent-a-soft); border-radius: 3px; }
.tg.leaf { visibility: hidden; cursor: default; }
table.grid td.stk { background: rgba(45,42,38,0.035); }
table.grid td.stk.sub { color: var(--text-secondary); font-weight: 400; }
table.grid th[data-stk] b, #stk-toggle b { color: var(--accent-a); }
/* Paleta: separación de categorías, orden y filtros estilo Excel */
table.grid th.grp-start, table.grid td.grp-start { border-left: 3px solid rgba(45,42,38,0.28); }
table.grid th.grp { background: #EFE9FE; color: var(--accent-a); font-size: 11px; letter-spacing: .5px; }
table.grid th.grp.grp-alt { background: #E5EBE6; color: #3F6B50; }
table.grid td.grp-alt { background: rgba(92,138,108,0.05); }
table.grid th.sub.grp-alt { background: #F6F8F6; }
table.grid .hl { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
table.grid .sortable { cursor: pointer; }
table.grid .sortable:hover { color: var(--accent-a); }
table.grid .fbtn { cursor: pointer; opacity: .45; font-size: 11px; }
table.grid .fbtn:hover, table.grid .fbtn.on { opacity: 1; color: var(--accent-a); }
table.grid th.filtered { color: var(--accent-a); }
.fdrop { position: absolute; z-index: 60; background: #FFFFFF; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; width: 250px; font-size: 12px; }
.fdrop input[type="text"], .fdrop input:not([type]) { width: 100%; box-sizing: border-box; }
.fdrop .list { max-height: 230px; overflow: auto; margin: 6px 0; border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; }
.fdrop .list label { display: block; padding: 2px 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.impact-line { margin-bottom: 16px; }
.impact-line .chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.impact-line .chip-s { font-size: 11px; padding: 3px 10px; border-radius: 999px; background: var(--bg-card-2); border: 1px solid var(--border); }
.impact-line .chip-s b { color: var(--red); }
.fdrop.hover { width: auto; min-width: 380px; max-width: 640px; pointer-events: auto; }
.fdrop.hover table.grid { font-size: 11px; }
table.grid td.hov { cursor: help; }
table.grid td.hov b { color: var(--accent-a); border-bottom: 1px dotted var(--accent-a); }
.impact-summary td.num b { color: var(--red); }
table.grid td.diff.ok { color: #3F6B50; font-weight: 600; }
table.grid td.diff.warn { color: #B07A1E; font-weight: 600; }
table.grid td.diff.bad { color: var(--red); font-weight: 600; }

.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.18); vertical-align: middle; margin-right: 5px; }
input[type="color"].ci { width: 22px; height: 18px; padding: 0; border: 1px solid var(--border); border-radius: 3px; background: none; vertical-align: middle; cursor: pointer; margin-right: 4px; }
.sw.round { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; }
.sw.round:hover { box-shadow: 0 0 0 2px var(--accent-a-soft); }
input.ci-hidden { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
table.grid td.nowrap { white-space: nowrap; }
/* tablero cromático */
.brow { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.brow:last-child { border-bottom: none; }
.blabel { width: 118px; flex: none; font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.bsws { display: flex; flex-wrap: wrap; gap: 8px; }
.bsw { width: 46px; height: 46px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.12); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25); position: relative; transition: transform .1s; }
.bsw:hover { transform: scale(1.12); z-index: 1; }
.bsw.vig { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.22) 0 2px, transparent 2px 6px) !important; background-blend-mode: normal; }
.bsw.vin { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.45); }
.bsw.out { opacity: .35; }
.bsw.out::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 3px; background: var(--red); transform: rotate(-45deg); border-radius: 2px; }
.bsw.new { box-shadow: 0 0 0 3px #5C8A6C; }
.bsw.new::after { content: "+"; position: absolute; right: -6px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: #5C8A6C; color: #fff; font-size: 12px; font-weight: 700; line-height: 16px; text-align: center; }
.bsw-mini { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #9a9a9a; border: 1px solid rgba(0,0,0,0.15); vertical-align: middle; margin-right: 3px; }
.bsw-mini.vig { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.35) 0 1px, transparent 1px 3px); }
.bsw-mini.vin { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5); }
.bsw-mini.out { opacity: .35; }
.bsw-mini.new { box-shadow: 0 0 0 2px #5C8A6C; }
/* cabeceras y primera columna fijas: siempre opacas (la tarjeta es translúcida) */
table.grid thead th { box-shadow: 0 1px 0 var(--border); }
/* paleta: las dos primeras columnas (# y color) fijas al desplazar en horizontal */
table.grid.fix2 tbody td:nth-child(2), table.grid.fix2 thead tr:first-child th:nth-child(2) { position: sticky; left: var(--col1w, 36px); background: #FCFBF9; z-index: 1; box-shadow: 2px 0 0 var(--border); }
table.grid.fix2 thead tr:first-child th:nth-child(2) { z-index: 3; }
table.grid.fix2 tbody tr.row-fused td:nth-child(2) { background: #FCFBF9; }
.bshare { font-size: 14px; font-weight: 700; color: var(--text-primary); letter-spacing: 0; text-transform: none; margin-top: 2px; }
