:root {
  --bg: #141518;
  --bg-2: #1b1d21;
  --surface: #22252b;
  --surface-2: #2b2f36;
  --border: #363a42;
  --text: #f5f4ef;
  --muted: #a5a9b2;
  --accent: #ffcc00;
  --accent-2: #ffe066;
  --on-accent: #17181a;
  --good: #3ddc97;
  --bad: #ff6b5b;
  --warn: #ffb020;
  --oct: #5e6470;
  --font-head: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Barlow", system-ui, sans-serif;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --radius: 14px; --radius-sm: 10px; --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  --dur-fast: 120ms; --dur: 220ms; --dur-slow: 520ms;
  --ease-out: cubic-bezier(.2,.8,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  background:
    radial-gradient(900px 420px at 110% -10%, rgba(255,204,0,.16), transparent 60%),
    radial-gradient(700px 380px at -20% 30%, rgba(255,204,0,.06), transparent 60%),
    var(--bg);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: .01em; margin: 0; line-height: 1.05; }
.wrap { max-width: 1180px; margin: 0 auto; padding: var(--s-4); }

/* Cabecera */
.hero { padding: var(--s-5) 0 var(--s-4); display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.logo { height: 26px; width: auto; display: block; }
.hero h1 { font-size: clamp(34px, 9vw, 64px); }
.hero h1 span { color: var(--accent); }
.hero p { margin: 0; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: var(--s-2); padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; color: var(--muted); box-shadow: var(--shadow-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(61,220,151,.18); }

/* Navegación entre vistas */
.nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; padding: 6px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); max-width: 460px; }
.nav a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-family: var(--font-head); font-size: 18px; font-weight: 700; text-align: center; line-height: 1.1; transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
@media (hover: hover) { .nav a:hover { color: var(--text); background: var(--surface-2); } }
.nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav a:active { transform: scale(.98); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4);
  border-radius: var(--radius-sm); font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
  text-decoration: none; color: var(--text);
}
.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-big { min-height: 56px; font-size: 18px; width: 100%; font-family: var(--font-head); letter-spacing: .02em; font-size: 22px; }
@media (hover: hover) {
  .btn:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
  .btn-accent:hover { background: var(--accent-2); }
}
.btn:focus-visible, .opt:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active, .opt:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn svg, .opt svg { width: 18px; height: 18px; }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-4); box-shadow: var(--shadow); }
.card h2 { font-size: 26px; margin-bottom: var(--s-3); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.card h2 small { font-family: var(--font-body); font-weight: 500; font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
.grid > *, .pair > *, .kpis > *, .opts > * { min-width: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3) var(--s-4); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi.hot { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.kpi.hot .kpi-label, .kpi.hot .kpi-sub { color: rgba(23,24,26,.72); }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--font-head); font-size: clamp(30px, 8vw, 44px); font-weight: 700; line-height: 1.05; margin: 2px 0; }
.kpi-sub { font-size: 13px; color: var(--muted); display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.delta { font-weight: 700; padding: 1px 8px; border-radius: 999px; font-size: 13px; }
.delta.up { background: rgba(61,220,151,.16); color: var(--good); }
.delta.down { background: rgba(255,107,91,.16); color: var(--bad); }
.kpi.hot .delta.up { background: rgba(23,24,26,.12); color: #0d6b45; }
.kpi.hot .delta.down { background: rgba(23,24,26,.12); color: #a3271b; }
.live { position: absolute; top: 10px; right: 12px; font-size: 11px; font-weight: 700; color: var(--good); }

/* Barras */
.bars { display: grid; gap: var(--s-3); }
.bar-row { display: grid; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; gap: var(--s-2); font-size: 14px; }
.bar-head b { font-weight: 600; }
.bar-head span { color: var(--muted); white-space: nowrap; }
.track { height: 12px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.fill { height: 100%; border-radius: 999px; background: var(--accent); transform-origin: left; animation: grow var(--dur-slow) var(--ease-out) both; }
.fill.oct { background: var(--oct); }
.fill.bad { background: var(--bad); }
.legend { display: flex; gap: var(--s-4); font-size: 13px; color: var(--muted); margin-bottom: var(--s-3); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Columnas del gráfico por línea */
.cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); align-items: end; height: 220px; padding-top: var(--s-4); }
.col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: var(--s-2); }
.col-bars { display: flex; align-items: flex-end; justify-content: center; gap: 6px; height: 100%; }
.col-bar { width: 38%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: var(--accent); transform-origin: bottom; animation: growY var(--dur-slow) var(--ease-out) both; position: relative; }
.col-bar.oct { background: var(--oct); }
.col-bar em { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.col-name { text-align: center; font-size: 13px; color: var(--muted); line-height: 1.2; }
.col-name b { display: block; color: var(--text); font-family: var(--font-head); font-size: 18px; }

/* Alertas */
.alerts { display: grid; gap: var(--s-2); }
.alert { display: grid; grid-template-columns: 32px 1fr; gap: var(--s-3); align-items: start; padding: var(--s-3); border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); }
.alert .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,107,91,.16); color: var(--bad); }
.alert.warn .ic { background: rgba(255,176,32,.16); color: var(--warn); }
.alert.ok .ic { background: rgba(61,220,151,.16); color: var(--good); }
.alert b { display: block; }
.alert span { color: var(--muted); font-size: 14px; }

/* Tablas simples */
.rows { display: grid; gap: 2px; }
.r { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.r:last-child { border-bottom: 0; }
.r small { display: block; color: var(--muted); font-size: 13px; }
.num { font-family: var(--font-head); font-size: 20px; font-weight: 600; text-align: right; }

/* Estados */
.state { text-align: center; padding: var(--s-5) var(--s-3); color: var(--muted); }
.state b { display: block; color: var(--text); font-family: var(--font-head); font-size: 22px; }
.skeleton { height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; margin: 10px 0; }
.err { color: var(--bad); font-size: 14px; }
.err:empty { display: none; }

/* Formularios */
.opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
.opts.three { grid-template-columns: repeat(3, 1fr); }
.opt {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: var(--shadow-sm); font-weight: 600; line-height: 1.15;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
@media (hover: hover) { .opt:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); } }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.opt:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.field { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.field > label, .field > .lbl { font-weight: 700; font-size: 14px; color: var(--muted); letter-spacing: .02em; }
input, select, textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: inherit; font-size: 17px; min-width: 0; max-width: 100%;
}
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
textarea { min-height: 80px; resize: vertical; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.quick { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.quick .opt { min-height: 40px; padding: 0 14px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); background: var(--bg-2); padding: 6px; border-radius: var(--radius); border: 1px solid var(--border); }
.tabs .opt { min-height: 48px; font-family: var(--font-head); font-size: 20px; }

.done { text-align: center; padding: var(--s-6) var(--s-4); }
.done .big { width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; margin: 0 auto var(--s-4); animation: pop var(--dur-slow) var(--ease-out) both; }
.done .big svg { width: 40px; height: 40px; }
.done h2 { font-size: 34px; justify-content: center; }
.done p { color: var(--muted); }

.foot { color: var(--muted); font-size: 13px; text-align: center; padding: var(--s-6) 0 var(--s-7); }

/* Entrada */
.rise { animation: rise var(--dur-slow) var(--ease-out) both; }
.stagger > * { animation: rise var(--dur-slow) var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 60ms; } .stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; } .stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; } .stagger > *:nth-child(n+7) { animation-delay: 340ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Escritorio */
@media (min-width: 760px) {
  .wrap { padding: var(--s-5); }
  .kpis { grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
  .grid.two { grid-template-columns: 1.3fr 1fr; align-items: start; }
  .grid.two-eq { grid-template-columns: 1fr 1fr; align-items: start; }
  .opts { grid-template-columns: repeat(4, 1fr); }
  .opts.motivos { grid-template-columns: repeat(5, 1fr); }
  .logo { height: 32px; }
}
@media (min-width: 1100px) {
  .kpis { grid-template-columns: repeat(6, 1fr); }
}
