:root {
  --bg: #f8f5f0; --panel: #fff; --ink: #231a15; --ink-2: #4a3b32; --muted: #7a6a5f; --line: #ebe3d8; --line-2: #f3eee7;
  --accent: #8a4b2a; --accent-2: #6f3b20; --accent-soft: #f7ece3; --accent-ring: rgba(138, 75, 42, .2);
  --good: #059669; --good-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --bad: #dc2626; --bad-soft: #fef2f2;
  --fc: #c98a12; --side: #1e1411; --side-2: #2e201a; --side-ink: #e3d6cb;
  --radius: 12px; --shadow: 0 1px 2px rgba(35, 26, 21, .04), 0 1px 3px rgba(35, 26, 21, .06);
  --shadow-lg: 0 10px 30px -10px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
.hidden { display: none !important; }
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.02em; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 16px; letter-spacing: -.01em; font-weight: 600; margin: 24px 0 12px; }
a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); max-width: 820px; margin: 0; }
.small { font-size: 12.5px; color: var(--muted); }
.error { color: var(--bad); white-space: pre-line; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); background: var(--line-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- logo ---------- */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .06em; font-size: 17px; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #b8733f, #6f3b20); box-shadow: 0 4px 12px -2px rgba(138, 75, 42, .5); }
.logo-mark svg { width: 20px; height: 20px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { position: relative; overflow: hidden; color: #fff; padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 0% 0%, #5a3320 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #3d2618 0%, transparent 55%), var(--side); }
.login-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: linear-gradient(180deg, #000, transparent 85%); }
.login-hero > * { position: relative; z-index: 1; }
.hero-copy h1 { font-size: 38px; letter-spacing: -.03em; line-height: 1.15; margin-bottom: 16px; max-width: 520px; }
.hero-copy p { color: #e6d3c2; font-size: 16px; max-width: 480px; margin: 0 0 28px; }
.beneficios { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.beneficios li { display: flex; gap: 10px; align-items: center; color: #f1e7dd; }
.beneficios svg { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: rgba(201, 138, 18, .2); color: #e8b64c; }
.hero-pie { color: #a8978a; font-size: 13px; margin: 0; }
.login-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--panel); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.login-card h2 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.login-card .muted { margin-top: -10px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.login-card input { padding: 10px 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 14px; gap: 20px; }
.sidebar .logo { color: #fff; padding: 2px 8px 6px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-sec { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #9c8a7d; padding: 14px 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s; }
nav a span { flex: 1; }
nav a em { font-style: normal; font-size: 11px; font-weight: 600; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: rgba(200, 180, 165, .12); color: #a8978a; }
nav a:hover { background: var(--side-2); color: #fff; }
nav a.active { background: linear-gradient(90deg, rgba(184, 115, 63, .34), rgba(184, 115, 63, .12)); color: #fff; box-shadow: inset 2px 0 0 #d9a066; }
nav a.active em { background: #b8733f; color: #fff; }
.user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(200, 180, 165, .14); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, #c98a12, #8a4b2a); flex: none; }
.user-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.user-txt b { color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-txt span { font-size: 12px; color: #a8978a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { border: 0; background: none; color: #a8978a; padding: 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--side-2); color: #fff; }

main { padding: 32px 40px 72px; min-width: 0; max-width: 1480px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1 1 420px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card > b:first-child { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.grow { flex: 1; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.acciones { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-weight: 500; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600; box-shadow: var(--shadow); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn:hover { border-color: #d6c9bb; background: #fcfaf7; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 2px rgba(15,23,42,.1), 0 4px 12px -4px rgba(138, 75, 42, .5); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 4px; box-shadow: none; }
.btn:disabled { opacity: .65; cursor: wait; }
input, select { font: inherit; color: var(--ink); padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: #d6c9bb; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }

.dropzone { display: flex; gap: 16px; align-items: center; padding: 22px; border: 1.5px dashed #d8cbbd; border-radius: 10px; flex-wrap: wrap; background: #fdfbf8; margin-bottom: 12px; }
.dz-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--good-soft); color: var(--good); flex: none; }
.dz-icon svg { width: 26px; height: 26px; }
.dz-txt { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 220px; }
.dz-txt input[type=file] { border: 0; padding: 0; background: none; font-size: 13px; color: var(--muted); }
.dz-txt input[type=file]::file-selector-button { font: inherit; font-weight: 600; margin-right: 10px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.card > .small { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 0 0 20px; }
.kpi { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); overflow: hidden; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .v.sm { font-size: 18px; padding: 4px 0 2px; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.kpi .v.good { color: var(--good); } .kpi .v.warn { color: var(--warn); } .kpi .v.bad { color: var(--bad); }

.filtros { display: flex; gap: 16px; align-items: center; margin: 20px 0 12px; flex-wrap: wrap; }
.buscar { position: relative; display: inline-flex; align-items: center; width: 340px; max-width: 100%; }
.buscar svg { position: absolute; left: 11px; color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.buscar input { width: 100%; padding-left: 34px; }
.check { color: var(--ink-2); cursor: pointer; }

.tabla-wrap { overflow: auto; max-height: 580px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 16px; box-shadow: var(--shadow); }
.tabla-wrap:empty { display: none; }
.tabla-wrap > h2 { margin: 0; padding: 16px 16px 12px; font-size: 14px; }
.tabla-wrap > .muted { padding: 20px !important; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #faf7f3; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); z-index: 1; border-bottom: 1px solid var(--line); }
td { color: var(--ink-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #fbf8f4; }
tr.clic { cursor: pointer; }
tr.sel { background: var(--accent-soft) !important; box-shadow: inset 3px 0 0 var(--accent); }
td input.final { width: 78px; text-align: right; padding: 5px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
td input.final.editado { border-color: #f59e0b; background: var(--warn-soft); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f3eee8; color: var(--muted); line-height: 1.6; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
p.tag { margin: 0 0 16px; }

.grafica { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow); }
.grafica > b { font-size: 15px; font-weight: 600; }
.grafica > .muted { display: block; margin: 2px 0 12px; font-size: 13px; }
.grafica svg { width: 100%; height: auto; display: block; }
.leyenda { display: flex; gap: 20px; font-size: 12.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.leyenda i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 7px; }
details.card { padding: 0; margin-bottom: 8px; }
details.card summary { padding: 14px 20px; cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before { content: "›"; font-size: 18px; color: var(--muted); transition: transform .15s; width: 10px; }
details.card[open] summary::before { transform: rotate(90deg); }
details.card table { border-top: 1px solid var(--line); }
.explica { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.explica .card { padding: 0; overflow: hidden; }
.explica .card > b:first-child { padding: 16px 16px 0; }
.explica .card p { margin: 4px 0; }
.card ul { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 20; box-shadow: var(--shadow-lg); font-weight: 500; animation: sube .2s ease-out; max-width: calc(100vw - 32px); }
@keyframes sube { from { opacity: 0; transform: translate(-50%, 8px); } }
.barra { height: 8px; background: #f0eae2; border-radius: 4px; overflow: hidden; width: 140px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.barra > span { display: block; height: 100%; background: var(--good); border-radius: 4px; }
.barra.bad > span { background: #f59e0b; }

/* ---------- compra al CEDIS ---------- */
.parametros { margin-bottom: 20px; }
.param-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.param-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.param-grid .small { font-weight: 400; }
.ajuste-global { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.ajuste-global > div:first-child { flex: 1 1 320px; }
.ajuste-global b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 5px 10px; border-radius: 999px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pct-input { display: inline-flex; align-items: center; gap: 4px; }
.pct-input input { width: 78px; text-align: right; padding: 5px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
.pct-input input.editado { border-color: #f59e0b; background: var(--warn-soft); }
.sube { color: var(--good); font-weight: 600; } .baja { color: var(--bad); font-weight: 600; }
.ddi { font-variant-numeric: tabular-nums; }
.ddi.bajo { color: var(--bad); font-weight: 600; } .ddi.alto { color: var(--warn); font-weight: 600; }
.siguiente { display: flex; justify-content: flex-end; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 20px 32px; gap: 28px; }
  .hero-copy h1 { font-size: 28px; }
  .hero-pie { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px; }
  .sidebar .logo { padding: 0; flex: 1; }
  .user { order: 2; border: 0; padding: 0; }
  .user-txt { display: none; }
  nav { order: 3; flex: 1 1 100%; flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .nav-sec { display: none; }
  nav a { padding: 7px 10px; white-space: nowrap; flex: none; }
  nav a em { display: none; }
  nav a.active { box-shadow: none; }
  main { padding: 20px 16px 60px; }
  h1 { font-size: 21px; }
  .page-head { margin-bottom: 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; } .kpi .v { font-size: 21px; }
  .buscar { width: 100%; }
}

/* ---------- más fácil de leer (pruebas) ---------- */
.lead { color: var(--ink-2); font-size: 15px; margin: 0; max-width: 760px; }
details.como { margin-top: 8px; max-width: 760px; }
details.como summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; list-style: none; }
details.como summary::-webkit-details-marker { display: none; }
details.como summary::before { content: "?"; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--accent-soft); color: var(--accent); }
details.como > div { margin-top: 8px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; color: var(--ink-2); font-size: 13.5px; }
.oculto { display: none; }
.dropzone { transition: border-color .15s, background .15s; }
.dropzone.sobre { border-color: var(--accent); background: var(--accent-soft); }
.vacio { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 40px 20px; }
.vacio b { font-size: 15px; color: var(--ink); }
.vacio span { color: var(--muted); max-width: 440px; margin-bottom: 10px; }
nav a.hecho em { background: rgba(5, 150, 105, .22); color: #6ee7b7; font-size: 0; }
nav a.hecho em::before { content: "✓"; font-size: 12px; }
nav a.active.hecho em { background: #059669; color: #fff; }
.leyenda-ddi { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.flecha { color: #c4b5a8; margin: 0 2px; }
.corto { font-style: normal; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 6px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; cursor: help; }
.barra { width: 80px; }
th[title] { cursor: help; text-decoration: underline dotted #c4b5a8; text-underline-offset: 3px; }
td.extra, th.extra { background: #fcfaf6; }
details.parametros > summary { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; cursor: pointer; list-style: none; }
details.parametros > summary::-webkit-details-marker { display: none; }
details.parametros > summary b { font-size: 14px; font-weight: 600; }
details.parametros > summary::after { content: "Cambiar"; margin-left: auto; color: var(--accent); font-weight: 600; font-size: 13px; }
details.parametros[open] > summary { margin-bottom: 14px; }
details.parametros[open] > summary::after { content: "Ocultar"; }
.grupos { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grupo { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grupo h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.grupo h2 a { color: var(--accent); }
.grupo .kpis { margin: 0; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.grupo .kpi { box-shadow: none; background: #fcfaf7; padding: 14px; }
.grupo .kpi .v { font-size: 22px; }
h2 .tag { margin-left: 8px; vertical-align: middle; }
@media (max-width: 980px) { .leyenda-ddi { margin-left: 0; } }
.sin-datos .filtros, .sin-datos .leyenda-ddi { display: none; }
details.card.parametros { margin-bottom: 20px; }
.inicio { margin-top: 4px; }
