/* ════════════════════════════════════════════════════════════
   HEBREOS Analytics — Design System v2
   "Quiet Executive" · minimalista, culto, introvertido
   Regla 60/30/10 · monocromático + acento oro · WCAG AA
   ════════════════════════════════════════════════════════════ */

:root {
  /* ── Obsidian & Champagne · lujo discreto, cálido ── */
  /* 60% — dominante (fondo y superficies profundas) */
  --bg:        #0B0D11;
  --bg-soft:   #0E1015;
  /* 30% — estructura (tarjetas, barras) */
  --s1:        #14171E;
  --s2:        #1B1F28;
  --s3:        #232834;
  --line:      #242833;
  --line-soft: #1A1D26;

  /* 10% — acento único (oro champagne) */
  --gold:      #C9A24B;
  --gold-dim:  rgba(201,162,75,.14);
  --gold-line: rgba(201,162,75,.34);

  /* marca (uso restringido: wordmark) */
  --red:       #C8102E;

  /* semántica (solo señales: deltas, estados) */
  --up:        #6FA98C;
  --down:      #C7625D;
  --warn:      #D0A85A;
  --up-dim:    rgba(111,169,140,.13);
  --down-dim:  rgba(199,98,93,.13);

  /* texto */
  --txt:       #ECEEF2;
  --txt2:      #98A0AE;
  --txt3:      #5A616E;

  /* forma */
  --r:    10px;
  --r-sm: 6px;
  --r-lg: 14px;

  /* tipografía */
  --display: 'Space Grotesk', system-ui, sans-serif;
  --font:    'Inter', system-ui, sans-serif;
  --mono:    'IBM Plex Mono', ui-monospace, monospace;

  /* sombra */
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);

  /* espaciado base 4/8 */
  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px;
  --sp5: 24px; --sp6: 32px; --sp7: 48px; --sp8: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(201,162,75,.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--txt);
  font-family: var(--font);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv01","ss01";
}

::selection { background: var(--gold-dim); color: var(--gold); }

/* números tabulares para cifras */
.num, .kpi-value, td, .badge, .mono { font-variant-numeric: tabular-nums; }

/* ── Tipografía ── */
h1 { font-family: var(--display); font-size: 1.45rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-family: var(--display); font-size: 1.05rem; font-weight: 500; letter-spacing: -.005em; color: var(--txt); }
h3 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--txt2); }

.eyebrow {
  font-family: var(--mono); font-size: .66rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .18em; color: var(--txt3);
}

/* ── Layout ── */
.app { display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  background: rgba(10,12,16,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo  { font-family: var(--display); font-size: 1.15rem; font-weight: 700; color: var(--red); letter-spacing: .04em; }
.topbar-sep   { width: 1px; height: 18px; background: var(--line); }
.topbar-title { font-size: .78rem; color: var(--txt2); letter-spacing: .01em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.badge {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .04em;
  background: var(--s2); border: 1px solid var(--line);
  color: var(--txt2); padding: 4px 10px; border-radius: 20px;
}
.badge.gold  { background: var(--gold-dim); border-color: var(--gold-line); color: var(--gold); }
#live-badge  { background: var(--up-dim); border-color: var(--up); color: var(--up); }
#live-badge.pulse { animation: livepulse .9s ease; }
@keyframes livepulse { 0%{ box-shadow:0 0 0 0 var(--up-dim);} 100%{ box-shadow:0 0 0 8px transparent;} }
.badge.up    { background: var(--up-dim);   border-color: var(--up);   color: var(--up); }
.badge.down  { background: var(--down-dim); border-color: var(--down); color: var(--down); }

.main { flex: 1; padding: 28px 22px 64px; max-width: 1160px; margin: 0 auto; width: 100%; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 2px; background: var(--s1);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 4px; margin-bottom: 28px; width: fit-content;
}
.tab-btn {
  padding: 8px 18px; border: none; background: transparent;
  color: var(--txt2); font-family: var(--font); font-size: .84rem; font-weight: 500;
  cursor: pointer; border-radius: var(--r-sm); transition: color .15s, background .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--txt); }
.tab-btn.active { background: var(--s3); color: var(--txt); box-shadow: var(--shadow-sm); }

/* ── KPI Cards (bento) ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--sp3);
  margin-bottom: var(--sp6);
}
.kpi-card {
  background: linear-gradient(180deg, var(--s1), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 18px 16px;
  position: relative; overflow: hidden;
  transition: border-color .18s, transform .18s;
}
.kpi-card:hover { border-color: var(--line); transform: translateY(-1px); }
/* acento solo en la card héroe (10%) */
.kpi-card.hero { border-color: var(--gold-line); }
.kpi-card.hero::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--gold);
}

.kpi-label { font-family: var(--mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .14em; color: var(--txt3); margin-bottom: 10px; }
.kpi-value { font-family: var(--display); font-size: 1.85rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.kpi-value.sm { font-size: 1.4rem; }
.kpi-sub   { font-size: .74rem; color: var(--txt2); margin-top: 8px; }
.kpi-pct   { font-size: .82rem; font-weight: 600; margin-top: 6px; font-family: var(--mono); }
.kpi-pct.ok   { color: var(--up); }
.kpi-pct.warn { color: var(--warn); }
.kpi-pct.bad  { color: var(--down); }

/* delta chip (▲▼ vs período anterior) */
.delta { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono);
  font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 20px; margin-top: 8px; }
.delta.up   { background: var(--up-dim);   color: var(--up); }
.delta.down { background: var(--down-dim); color: var(--down); }
.delta.flat { background: var(--s2);       color: var(--txt3); }

/* ── Sections ── */
.section { margin-bottom: var(--sp6); }
.section-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: var(--sp4); padding-bottom: var(--sp3);
  border-bottom: 1px solid var(--line);
}
.section-header h2 { display: flex; align-items: center; gap: 10px; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--s1); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  background: var(--bg-soft); color: var(--txt2);
  padding: 11px 14px; text-align: center;
  font-family: var(--mono); font-size: .64rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em;
  white-space: nowrap; border-bottom: 1px solid var(--line);
}
thead th:first-child { text-align: left; }
tbody tr { border-bottom: 1px solid var(--line-soft); transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--s2); }
tbody td { padding: 11px 14px; text-align: center; color: var(--txt); }
tbody td:first-child { text-align: left; font-weight: 500; }
tbody tr.total-row td { background: var(--gold-dim); font-weight: 700; border-top: 1px solid var(--gold-line); }

/* ── Progress bar ── */
.prog-wrap { display: flex; align-items: center; gap: 8px; justify-content: center; }
.prog-bar  { flex: 1; height: 5px; background: var(--s3); border-radius: 3px; overflow: hidden; max-width: 84px; }
.prog-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.prog-fill.ok   { background: var(--up); }
.prog-fill.warn { background: var(--warn); }
.prog-fill.bad  { background: var(--down); }
.prog-pct { font-family: var(--mono); font-size: .76rem; font-weight: 600; min-width: 38px; }
.prog-pct.ok   { color: var(--up); }
.prog-pct.warn { color: var(--warn); }
.prog-pct.bad  { color: var(--down); }

/* ── Buttons (5 estados) ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--r-sm);
  font-family: var(--font); font-size: .84rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn-gold  { background: var(--gold); color: #1A1205; font-weight: 600; }
.btn-gold:hover { background: #D8B468; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--txt2); }
.btn-ghost:hover { border-color: var(--txt3); color: var(--txt); background: var(--s1); }
.btn-red   { background: var(--red); color: #fff; }
.btn-red:hover { background: #a50d24; }
.btn-sm    { padding: 7px 13px; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Upload / Carga ── */
.drop-zone {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 44px 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--s1);
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--gold-line); background: var(--gold-dim); }
.drop-zone .icon { font-size: 2.2rem; margin-bottom: 12px; opacity: .85; }
.drop-zone p { color: var(--txt2); font-size: .9rem; }
.drop-zone strong { color: var(--gold); font-weight: 600; }

/* ── Cards ── */
.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }

/* ── Login ── */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: linear-gradient(180deg, var(--s1), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 38px 34px; width: 100%; max-width: 384px; box-shadow: var(--shadow);
}
.login-logo { font-family: var(--display); font-size: 1.7rem; font-weight: 700; color: var(--red); letter-spacing: .04em; margin-bottom: 6px; }
.login-sub  { color: var(--txt2); font-size: .82rem; margin-bottom: 28px; }

/* ── Form ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--txt2); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 11px 13px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--txt); border-radius: var(--r-sm);
  font-family: var(--font); font-size: 1rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus { border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-dim); }
.field select { cursor: pointer; }

/* ── Preview table (upload) ── */
.preview-box { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-top: 16px; font-size: .82rem; }
.preview-box h4 { font-family: var(--mono); color: var(--gold); margin-bottom: 12px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

/* ── State ── */
.empty   { color: var(--txt2); text-align: center; padding: 40px 24px; font-size: .88rem; }
.empty .icon { font-size: 1.6rem; display: block; margin-bottom: 10px; opacity: .6; }
.loading { color: var(--gold); text-align: center; padding: 40px; font-size: .88rem; }
.error-msg   { color: var(--down); font-size: .84rem; margin-top: 8px; }
.success-msg { color: var(--up); font-size: .84rem; margin-top: 8px; }

/* ── Report history ── */
.reporte-item { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line-soft); }
.reporte-item:last-child { border-bottom: none; }
.reporte-tipo { font-family: var(--mono); font-size: .64rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 5px; }
.reporte-tipo.diario          { background: var(--s3); color: var(--txt2); }
.reporte-tipo.semanal         { background: var(--gold-dim); color: var(--gold); }
.reporte-tipo.ventas_producto { background: var(--up-dim); color: var(--up); }
.reporte-fecha { font-size: .85rem; flex: 1; }
.reporte-asesor { font-size: .74rem; color: var(--txt2); }
.reporte-at    { font-family: var(--mono); font-size: .72rem; color: var(--txt3); }

/* ── Chart container ── */
.chart-box { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.chart-box canvas { max-height: 240px; }

/* ── Filter select (inline) ── */
.inline-select {
  background: var(--s2); color: var(--txt); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 13px; font-family: var(--font); font-size: .84rem;
  cursor: pointer; outline: none; transition: border-color .15s;
}
.inline-select:focus { border-color: var(--gold-line); }

/* ── Metodología ── */
.flow { display: flex; flex-direction: column; gap: 2px; }
.flow-step { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--s1); border: 1px solid var(--line); }
.flow-step:first-child { border-radius: var(--r) var(--r) 0 0; }
.flow-step:last-child  { border-radius: 0 0 var(--r) var(--r); }
.flow-step + .flow-step { border-top: none; }
.flow-n {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid var(--gold-line); color: var(--gold);
  font-family: var(--mono); font-size: .8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.flow-step b { font-size: .92rem; }
.flow-step p { color: var(--txt2); font-size: .83rem; line-height: 1.55; margin-top: 3px; }

.formula {
  background: var(--bg); border: 1px solid var(--line); border-left: 2px solid var(--gold);
  border-radius: var(--r-sm); padding: 12px 14px; margin-top: 10px;
  font-size: .86rem; color: var(--txt); line-height: 1.6;
}
.formula .f-name { display: block; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--txt2); margin-bottom: 6px; }
.formula .f-rule { font-family: var(--mono); font-size: .78rem; color: var(--gold); }
.formula code { font-family: var(--mono); font-size: .85rem; color: var(--txt); background: var(--s2); padding: 2px 7px; border-radius: 4px; }
.formula .hl { color: var(--gold); }
.formula .beta { font-family: var(--font); font-size: .62rem; color: var(--txt3); text-transform: none; letter-spacing: 0; }

/* ── Insight strip (Resumen) ── */
.insight {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--s1); border: 1px solid var(--line); border-left: 2px solid var(--gold);
  border-radius: var(--r); padding: 14px 16px; margin-bottom: var(--sp4);
}
.insight .ic { font-size: 1.1rem; line-height: 1.4; }
.insight .tx { font-size: .85rem; color: var(--txt); line-height: 1.5; }
.insight .tx b { color: var(--gold); font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .topbar { padding: 11px 14px; }
  .main { padding: 18px 14px 48px; }
  .kpi-value { font-size: 1.55rem; }
  .topbar-title { display: none; }
  .tabs { width: 100%; overflow-x: auto; }
  h1 { font-size: 1.2rem; }
}

/* ── Print (PDF via Ctrl+P) ── */
@media print {
  body { background: white; color: #000; }
  .topbar, .tabs, .btn, .no-print, .inline-select { display: none !important; }
  .kpi-card, .card, .chart-box { border: 1px solid #ccc; background: white; box-shadow: none; }
  table { border: 1px solid #ccc; }
  thead th { background: #16243A; -webkit-print-color-adjust: exact; color: white; }
  tbody tr.total-row td { background: #FFF3CC; -webkit-print-color-adjust: exact; }
}
