/* ============================================================
   PetroBox · Centro de Inteligencia — Design tokens & UI
   Tema oscuro premium por defecto · acento configurable
   ============================================================ */

:root {
  /* Espaciado (múltiplos de 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  /* Radios */
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px;
  /* Animación */
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
  --t-fast: 180ms; --t-slow: 260ms;
  /* Acento (lo setea JS) */
  --accent: #7C5CFC;
  --accent-2: #7C5CFC;          /* variante para degradados */
  --accent-soft: rgba(124,92,252,.14);
  --accent-rgb: 124,92,252;
  --brand-text: #7C5CFC;        /* acento claro en dark / oscuro en light */
  /* Costos siempre en ámbar */
  --amber: #F9A826;
  --amber-soft: rgba(249,168,38,.14);
  /* Semánticos */
  --green: #2EB872; --green-soft: rgba(46,184,114,.16);
  --red: #E5533D;   --red-soft: rgba(229,83,61,.16);
  --blue: #2D8CFF;  --blue-soft: rgba(45,140,255,.16);
  --gold: #E9B949;  --silver: #B8C0CC; --bronze: #CD7F45;
}

/* ---------- Tema oscuro (default) ---------- */
[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --surface-2: #2A2A2A;
  --surface-3: #14161D;       /* tiles oscuros control center */
  --text: #F3F3F3;
  --text-2: rgba(255,255,255,.70);
  --text-muted: rgba(255,255,255,.38);
  --divider: rgba(255,255,255,.12);
  --shadow: 0 4px 16px rgba(0,0,0,.45);
  --hover: rgba(255,255,255,.04);
  --scrim: rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ---------- Tema claro ---------- */
[data-theme="light"] {
  --bg: #F8F5EE;
  --surface: #FFFFFF;
  --surface-2: #F1ECE1;
  --surface-3: #232733;
  --text: #1A1A1A;
  --text-2: rgba(26,26,26,.66);
  --text-muted: rgba(26,26,26,.40);
  --divider: rgba(26,26,26,.10);
  --shadow: 0 6px 18px rgba(60,50,30,.10);
  --hover: rgba(0,0,0,.03);
  --scrim: rgba(20,16,8,.40);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }   /* el atributo hidden gana a .login/.app/.modal/.side-sheet */
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}
h1, h2, h3, .kpi-val, .logo, .brand-num { font-family: 'Poppins', 'Inter', sans-serif; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
input { font-family: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ============================================================ Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--divider);
  display: flex; flex-direction: column;
  padding: var(--s5) var(--s4);
  position: sticky; top: 0; height: 100vh;
  transition: width var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
  z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s5); }
.logo {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 19px;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.side-brand-txt { overflow: hidden; }
.side-brand-name { font-family: 'Poppins'; font-weight: 700; font-size: 17px; letter-spacing: -.3px; }
.side-brand-sub { font-size: 9.5px; font-weight: 600; letter-spacing: .8px; color: var(--text-muted); white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s2); flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 11px var(--s3); border-radius: var(--r-md);
  color: var(--text-2); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--brand-text); }
.nav-item .ico { flex-shrink: 0; }

.side-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--divider); }
.side-collapse { width: 34px; height: 34px; border-radius: 9px; color: var(--text-muted); display: grid; place-items: center; }
.side-collapse:hover { background: var(--hover); color: var(--text); }
.online { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* Sidebar colapsado (solo iconos) */
.app.collapsed .sidebar { width: 70px; padding-left: var(--s3); padding-right: var(--s3); }
.app.collapsed .side-brand-txt,
.app.collapsed .nav-item span:not(.ico),
.app.collapsed .online-txt { display: none; }
.app.collapsed .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app.collapsed .nav-item { justify-content: center; }
.app.collapsed .side-foot { flex-direction: column; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ============================================================ Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s6);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--divider);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.topbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); }

.chip-select {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--divider);
  color: var(--text-2); font-weight: 600; font-size: 13px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip-select:hover { border-color: var(--accent); color: var(--text); }
.chip-select .caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .6; margin-left: 2px; }

.search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md); color: var(--text-muted); }
.search input { border: none; background: none; outline: none; color: var(--text); font-size: 13px; width: 150px; }
.search input::placeholder { color: var(--text-muted); }

.icon-btn { width: 38px; height: 38px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--divider); color: var(--text-2); display: grid; place-items: center; position: relative; transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.bell-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--surface); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }

/* ============================================================ Content */
.content { padding: var(--s6); max-width: 1480px; width: 100%; margin: 0 auto; }
.block { margin-bottom: var(--s8); }
.block-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.block-title { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.block-line { flex: 1; height: 1px; background: var(--divider); }

.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-kpi { grid-template-columns: repeat(5, 1fr); }
.span-2 { grid-column: span 2; }

/* ============================================================ DashCard */
.card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--s5);
}
.card-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s4); }
.card-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.card-htxt h2 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.card-htxt p { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-top: 1px; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: var(--s3); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.kpi-delta { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.kpi-delta.up { color: var(--green); background: var(--green-soft); }
.kpi-delta.down { color: var(--red); background: var(--red-soft); }
.kpi-val { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.kpi-title { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ============================================================ Chart línea */
.linechart { width: 100%; height: 240px; display: block; }
.lc-tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #0c0c0c; color: #fff; border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); transform: translate(-50%, -120%); white-space: nowrap;
}
.lc-tooltip .lc-t-lbl { color: rgba(255,255,255,.6); font-size: 11px; font-weight: 500; }
.lc-axis { fill: var(--text-muted); font-size: 11px; font-weight: 600; font-family: 'Inter'; }
.lc-line { stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: lcDraw 1.2s var(--ease) forwards; }
@keyframes lcDraw { to { stroke-dashoffset: 0; } }
.lc-area { opacity: 0; animation: lcAreaIn .85s var(--ease) .35s forwards; }
@keyframes lcAreaIn { to { opacity: 1; } }
.lc-dot { opacity: 0; animation: lcDotIn .35s var(--ease) forwards; transition: r .15s var(--ease); }
@keyframes lcDotIn { to { opacity: 1; } }
.lc-hit { cursor: pointer; }

/* ============================================================ Leaderboard */
.lb-row { display: flex; align-items: center; gap: var(--s3); padding: 10px 0; }
.lb-row + .lb-row { border-top: 1px solid var(--divider); }
.lb-medal { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #1a1a1a; flex-shrink: 0; }
.lb-av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0; }
.lb-mid { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-meta { font-size: 11.5px; color: var(--text-muted); }
.lb-bar { height: 4px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.lb-bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: barGrow .9s var(--ease); }
@keyframes barGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.lb-right { text-align: right; flex-shrink: 0; }
.lb-val { font-weight: 700; font-size: 13.5px; }
.lb-grow { font-size: 11.5px; font-weight: 700; }
.lb-grow.up { color: var(--green); } .lb-grow.down { color: var(--red); }

/* ============================================================ Donut */
.donut-wrap { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut svg { animation: donutPop .6s var(--ease); transform-origin: center; }
@keyframes donutPop { from { transform: scale(.94); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.donut-seg { opacity: 0; animation: segIn .55s var(--ease) forwards; transition: stroke-width .15s var(--ease); }
@keyframes segIn { to { opacity: 1; } }
.donut-seg:hover { stroke-width: 21; cursor: pointer; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.05; gap: 2px; }
.donut-center b { font-size: 24px; font-family: 'Poppins'; font-weight: 800; display: block; }
.donut-center span { font-size: 10.5px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.legend { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text-2); }
.legend-pct { font-weight: 700; }
.legend-amt { color: var(--text-muted); font-size: 12px; min-width: 78px; text-align: right; }

/* ============================================================ Lista clave-valor / planes */
.kv-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 13.5px; }
.kv-row + .kv-row { border-top: 1px solid var(--divider); }
.kv-key { color: var(--text-2); display: flex; align-items: center; gap: 9px; }
.kv-val { font-weight: 700; }
.dotc { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.plan-row { display: flex; align-items: center; gap: var(--s3); padding: 10px 0; }
.plan-row + .plan-row { border-top: 1px solid var(--divider); }
.plan-mid { flex: 1; }
.plan-name { font-weight: 600; font-size: 13.5px; }
.plan-meta { font-size: 11.5px; color: var(--text-muted); }
.plan-mrr { font-weight: 700; color: var(--brand-text); }

/* ============================================================ Heatmap */
.heat { display: grid; grid-template-columns: 54px repeat(4, 1fr); gap: 6px; align-items: center; }
.heat-h { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-align: center; text-transform: uppercase; letter-spacing: .4px; }
.heat-day { font-size: 12px; font-weight: 600; color: var(--text-2); }
.heat-cell { height: 30px; border-radius: 7px; background: var(--accent); transition: transform var(--t-fast) var(--ease); }
.heat-cell:hover { transform: scale(1.06); }
.heat-legend { display: flex; align-items: center; gap: 7px; justify-content: flex-end; margin-top: var(--s4); font-size: 11px; color: var(--text-muted); }
.heat-legend i { width: 16px; height: 12px; border-radius: 3px; }

/* ============================================================ Alertas */
.alert-card { display: flex; gap: var(--s3); padding: var(--s4); border-radius: var(--r-md); border: 1px solid var(--divider); background: var(--surface-2); }
.alert-card + .alert-card { margin-top: var(--s3); }
.alert-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.alert-lvl-alto { border-left: 3px solid var(--red); }
.alert-lvl-medio { border-left: 3px solid var(--amber); }
.alert-lvl-bajo { border-left: 3px solid var(--blue); }
.alert-title { font-weight: 700; font-size: 13.5px; }
.alert-detail { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* ============================================================ Centro de decisiones */
.dec-grid { grid-template-columns: repeat(4, 1fr); }
.dec-card { border-radius: var(--r-lg); padding: var(--s5); color: #fff; position: relative; overflow: hidden; min-height: 116px; display: flex; flex-direction: column; justify-content: space-between; }
.dec-card .dec-ico { position: absolute; top: var(--s4); right: var(--s4); opacity: .35; }
.dec-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; opacity: .85; }
.dec-val { font-size: 21px; font-weight: 800; font-family: 'Poppins'; letter-spacing: -.3px; margin: 6px 0 2px; }
.dec-detail { font-size: 12px; opacity: .85; }

/* ============================================================ Feed tiempo real */
.feed-row { display: flex; align-items: flex-start; gap: var(--s3); padding: 11px 0; }
.feed-row + .feed-row { border-top: 1px solid var(--divider); }
.feed-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.feed-mid { flex: 1; }
.feed-txt { font-size: 13.5px; }
.feed-txt b { font-weight: 700; }
.feed-time { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================ Ventas/Costos — selector negocio */
.biz-search { margin-bottom: var(--s4); }
.biz-grid { grid-template-columns: repeat(3, 1fr); }
.biz-card { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); border-radius: var(--r-md); border: 1px solid var(--divider); background: var(--surface); cursor: pointer; transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); position: relative; }
.biz-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.biz-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.biz-av { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.biz-name { font-weight: 600; font-size: 13.5px; }
.biz-meta { font-size: 11.5px; color: var(--text-muted); }
.biz-check { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: none; place-items: center; }
.biz-card.sel .biz-check { display: grid; }

.period-chips { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.pchip { padding: 7px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--divider); font-size: 13px; font-weight: 600; color: var(--text-2); }
.pchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.total-card { display: flex; align-items: center; justify-content: space-between; padding: var(--s5); border-radius: var(--r-lg); margin-bottom: var(--s4); color: #fff; }
.total-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; opacity: .85; }
.total-val { font-size: 30px; font-weight: 800; font-family: 'Poppins'; letter-spacing: -.5px; margin-top: 2px; }
.total-sub { font-size: 12px; opacity: .85; }

.mov-row { display: flex; align-items: center; gap: var(--s3); padding: 12px 0; cursor: pointer; }
.mov-row + .mov-row { border-top: 1px solid var(--divider); }
.mov-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.mov-mid { flex: 1; min-width: 0; }
.mov-title { font-weight: 600; font-size: 13.5px; }
.mov-meta { font-size: 11.5px; color: var(--text-muted); }
.mov-right { display: flex; align-items: center; gap: var(--s3); }
.mov-amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.mov-chev { color: var(--text-muted); }

.pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill-green { color: var(--green); background: var(--green-soft); }
.pill-amber { color: var(--amber); background: var(--amber-soft); }
.pill-blue { color: var(--blue); background: var(--blue-soft); }

/* ============================================================ Control center */
.eco-grid { grid-template-columns: repeat(4, 1fr); }
.eco-tile { background: var(--surface-3); border: 1px solid var(--divider); border-radius: var(--r-lg); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.eco-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.eco-num { font-size: 30px; font-weight: 800; font-family: 'Poppins'; color: #fff; line-height: 1; }
.eco-lbl { font-size: 12.5px; color: rgba(255,255,255,.6); font-weight: 600; }

.health-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.health-row + .health-row { border-top: 1px solid var(--divider); }
.health-name { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); }
.health-state { font-size: 12px; font-weight: 700; }

.audit-row { display: flex; align-items: flex-start; gap: var(--s3); padding: 10px 0; }
.audit-row + .audit-row { border-top: 1px solid var(--divider); }
.audit-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.audit-txt { flex: 1; font-size: 13px; }
.audit-time { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* ============================================================ Configuración */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: 13px 0; }
.set-row + .set-row { border-top: 1px solid var(--divider); }
.set-name { font-weight: 600; font-size: 14px; }
.set-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--divider); position: relative; flex-shrink: 0; transition: background var(--t-fast) var(--ease); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(18px); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--divider); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--accent); color: #fff; }

.accent-dots { display: flex; gap: var(--s3); }
.accent-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 2px solid transparent; }
.accent-dot.active { border-color: var(--text); }
.accent-dot .ck { color: #fff; opacity: 0; }
.accent-dot.active .ck { opacity: 1; }

/* ============================================================ Popover / sheets */
.popover { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md); box-shadow: 0 12px 36px rgba(0,0,0,.4); padding: 6px; min-width: 170px; }
.pop-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.pop-item:hover { background: var(--hover); color: var(--text); }
.pop-item.active { color: var(--brand-text); background: var(--accent-soft); }

.sheet-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 90; backdrop-filter: blur(2px); }
.side-sheet { position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--divider); z-index: 95; padding: var(--s5); overflow-y: auto; animation: slideIn var(--t-slow) var(--ease); }
.bottom-sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 480px; max-width: 96vw; background: var(--surface); border: 1px solid var(--divider); border-bottom: none; border-radius: var(--r-xl) var(--r-xl) 0 0; z-index: 95; padding: var(--s6); animation: slideUp var(--t-slow) var(--ease); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideUp { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s5); }
.sheet-head h3 { font-size: 18px; font-weight: 700; }
.sheet-x { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--text-muted); }
.sheet-x:hover { background: var(--hover); color: var(--text); }
.detail-amt { font-size: 32px; font-weight: 800; font-family: 'Poppins'; letter-spacing: -.5px; margin: var(--s2) 0 var(--s4); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4) var(--s5); }
.detail-k { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.detail-v { font-size: 14px; font-weight: 600; margin-top: 3px; }

/* ============================================================ Iconos */
.ico { display: inline-flex; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================ Login */
.login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--s6);
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-xl); box-shadow: 0 24px 60px rgba(0,0,0,.4); padding: 40px 32px; text-align: center; animation: fade var(--t-slow) var(--ease); }
.login-logo { width: 58px; height: 58px; border-radius: 17px; margin: 0 auto var(--s4); background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-family: 'Poppins'; font-weight: 800; font-size: 27px; display: grid; place-items: center; box-shadow: 0 8px 24px var(--accent-soft); }
.login-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.login-sub { font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; color: var(--text-muted); margin-top: 5px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: var(--s6); padding: 13px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--divider); font-weight: 600; font-size: 14px; color: var(--text); transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn-google:hover:not([disabled]) { border-color: var(--accent); transform: translateY(-1px); }
.btn-google[disabled] { opacity: .5; cursor: not-allowed; }
.btn-google .g { width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #4285F4; font-weight: 800; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.login-hint { font-size: 12px; color: var(--text-muted); margin-top: var(--s4); }
.login-error { font-size: 12.5px; color: var(--red); margin-top: var(--s3); background: var(--red-soft); padding: 9px 12px; border-radius: 10px; }

/* Menú de usuario (popover) */
.pop-user { padding: 10px 12px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; }
.pop-user-name { font-weight: 700; font-size: 13px; }
.pop-user-mail { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.pop-user-rol { font-size: 11px; color: var(--brand-text); font-weight: 600; margin-top: 3px; }
.avatar { cursor: pointer; transition: transform var(--t-fast) var(--ease); }
.avatar:hover { transform: scale(1.05); }

.only-mobile { display: none; }
.fade-in { animation: fade var(--t-slow) var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.empty { text-align: center; padding: var(--s8); color: var(--text-muted); font-size: 13.5px; }

/* ============================================================ Operativo: pills, botones, utilidades */
.pill-red { color: var(--red); background: var(--red-soft); }
.muted { color: var(--text-muted); }
.small { font-size: 11.5px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px; }
.kpi-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--divider); color: var(--text); font-weight: 600; font-size: 13px; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn .ico { width: 16px; height: 16px; }
.btn.sm { padding: 7px 11px; font-size: 12.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { background: transparent; border-color: var(--red); color: var(--red); }
.btn.block { display: flex; width: 100%; justify-content: center; padding: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- Tablas ---- */
.table-card { padding: 0; overflow: hidden; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.table-head-actions { display: flex; gap: var(--s2); }
.filtros { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--divider); font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: all var(--t-fast) var(--ease); }
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.table-scroll { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dtable thead th { text-align: left; padding: 12px var(--s5); font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); cursor: pointer; white-space: nowrap; user-select: none; }
.dtable thead th:hover { color: var(--text-2); }
.dtable thead th.num, .dtable td.num { text-align: right; }
.dtable .arrow { color: var(--brand-text); }
.dtable tbody td { padding: 12px var(--s5); border-top: 1px solid var(--divider); }
.dtable tbody tr.clickable { cursor: pointer; transition: background var(--t-fast) var(--ease); }
.dtable tbody tr.clickable:hover { background: var(--hover); }
.dt-biz { display: flex; align-items: center; gap: var(--s3); }
.dt-bn { font-weight: 600; }
.dt-bo { font-size: 11.5px; color: var(--text-muted); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s5); border-top: 1px solid var(--divider); font-size: 12.5px; }
.pager-ctrls { display: flex; align-items: center; gap: var(--s3); }

/* ---- Toasts ---- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1a1a1a; color: #fff; border: 1px solid rgba(255,255,255,.14); padding: 11px 18px; border-radius: 12px; font-size: 13px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: slideUp var(--t-slow) var(--ease); transition: opacity var(--t-fast), transform var(--t-fast); }
.toast.ok { border-color: var(--green); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: var(--scrim); backdrop-filter: blur(3px); padding: var(--s5); }
.modal-card { width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-xl); box-shadow: 0 24px 60px rgba(0,0,0,.5); padding: var(--s6); animation: fade var(--t-slow) var(--ease); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s5); }
.modal-head h3 { font-size: 18px; font-weight: 700; }

/* ---- Form ---- */
.form { display: flex; flex-direction: column; gap: var(--s3); }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.form .frow { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.form input, .form select, .cfg-edit input, .d-qr-row input, .d-qr-row select, .date-input {
  padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--divider); background: var(--surface-2); color: var(--text); font-size: 14px; outline: none; transition: border-color var(--t-fast) var(--ease); }
.form input:focus, .form select:focus, .date-input:focus, .cfg-edit input:focus { border-color: var(--accent); }

/* ---- QR ---- */
.qr-wrap { text-align: center; }
.qr-wrap p { color: var(--text-2); font-size: 13.5px; margin-bottom: var(--s4); }
.qr { width: 220px; height: 220px; border-radius: var(--r-md); background: #fff; padding: 10px; }
.token { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-muted); word-break: break-all; margin: var(--s3) 0; }

/* ---- Asistente (wizard) ---- */
.wz-steps { list-style: none; display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.wz-step { display: flex; align-items: center; gap: var(--s3); padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--divider); background: var(--surface-2); }
.wz-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--text-muted); background: var(--surface); flex-shrink: 0; }
.wz-step.ok .wz-ic { color: #fff; background: var(--green); }
.wz-step.error .wz-ic { color: #fff; background: var(--red); }
.wz-step.run .wz-ic { color: var(--brand-text); }
.wz-lbl { font-weight: 600; font-size: 13.5px; flex: 1; }
.wz-msg { font-size: 11.5px; color: var(--text-muted); width: 100%; flex-basis: 100%; padding-left: 38px; }
.wz-step { flex-wrap: wrap; }
.spin { width: 14px; height: 14px; border: 2px solid var(--divider); border-top-color: var(--brand-text); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wz-error { color: var(--red); background: var(--red-soft); padding: 12px 14px; border-radius: var(--r-md); font-size: 13px; margin-bottom: var(--s3); }

/* ---- Barras verticales ---- */
.bars { display: flex; align-items: flex-end; gap: var(--s3); height: 200px; padding-top: var(--s4); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-val { font-size: 11px; font-weight: 700; color: var(--text-2); }
.bar-track { width: 100%; max-width: 46px; flex: 1; display: flex; align-items: flex-end; }
.bar-track > i { width: 100%; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--accent), var(--accent-soft)); display: block; animation: barUp .8s var(--ease); transform-origin: bottom; }
@keyframes barUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar-lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; }
/* MRR a todo el ancho: barras más altas y anchas */
.bars-mrr { height: 270px; gap: var(--s5); padding-top: var(--s5); }
.bars-mrr .bar-track { max-width: 96px; }
.bars-mrr .bar-track > i { border-radius: 12px 12px 5px 5px; }
.bars-mrr .bar-val { font-size: 13px; }
.bars-mrr .bar-lbl { font-size: 12.5px; }

/* ---- Barras horizontales ---- */
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 38px; align-items: center; gap: var(--s3); font-size: 13px; }
.hbar-k { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 9px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.hbar-track > i { display: block; height: 100%; border-radius: 5px; animation: barGrow .8s var(--ease); transform-origin: left; }
.hbar-n { text-align: right; font-weight: 700; }

/* ---- Detalle de negocio (panel lateral) ---- */
.side-sheet.wide { width: 460px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--r-md); padding: 4px; margin-bottom: var(--s4); }
.tab { flex: 1; padding: 8px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.tab.active { background: var(--surface); color: var(--brand-text); box-shadow: var(--shadow); }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.d-box { background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--r-md); padding: 12px 14px; }
.d-box.d-block { grid-column: span 2; margin-top: var(--s3); }
.d-l { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.d-v { font-size: 17px; font-weight: 700; margin-top: 3px; word-break: break-word; }
.d-qr-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.d-qr-row input { width: 76px; }
.dev-card { border: 1px solid var(--divider); border-radius: var(--r-md); padding: 14px; margin-bottom: 10px; background: var(--surface-2); }
.dev-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.dev-name { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.dev-name .ico { width: 15px; height: 15px; }
.dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px; font-size: 12.5px; }
.dv-row { display: flex; justify-content: space-between; gap: 10px; }
.dv-row span:last-child { font-weight: 600; text-align: right; }
.dev-actions { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }
.sheet-actions { display: flex; gap: var(--s2); margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--divider); }

/* ---- Config ---- */
.cfg-edit { display: flex; gap: 8px; align-items: center; }
.cfg-edit input { width: 100px; }

/* ---- Reportes ---- */
.rep-head { gap: var(--s3); }
.rep-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================ Responsive */
@media (max-width: 1240px) {
  .grid-kpi { grid-template-columns: repeat(3, 1fr); }
  .dec-grid { grid-template-columns: repeat(2, 1fr); }
  .biz-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1040px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 39; opacity: 0; pointer-events: none; transition: opacity var(--t-slow) var(--ease); }
  .app.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
@media (max-width: 920px) { .only-wide { display: none; } }
@media (max-width: 760px) {
  .content { padding: var(--s4); }
  .topbar { padding: var(--s3) var(--s4); }
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .eco-grid { grid-template-columns: repeat(2, 1fr); }
  .biz-grid { grid-template-columns: 1fr; }
  .dec-grid { grid-template-columns: 1fr; }
  .topbar-title h1 { font-size: 18px; }
}
@media (max-width: 460px) {
  .grid-kpi { grid-template-columns: 1fr; }
}
.scrim { display: none; }
