/* ============================================================
   SVA Mexfon — Internal terminal aesthetic
   Dark, dense, financial. JetBrains Mono + Fraunces display.
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --line: #1f1f1f;
  --line-bright: #2a2a2a;
  --text: #e8e6e1;
  --text-dim: #8a8782;
  --text-faint: #555048;
  --accent: #d4ff3a;        /* electric lime, accent */
  --accent-dim: #8aa820;
  --warm: #ff9b3a;          /* MXN warm */
  --cool: #6db9ff;          /* EUR cool */
  --pos: #4ade80;
  --neg: #f87171;
  --neutral: #8a8782;
  --shadow-deep: 0 1px 0 rgba(255,255,255,0.02), 0 2px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  position: relative;
  overflow-x: hidden;
}

/* Grain overlay for texture */
.bg-grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg-vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at top, transparent 30%, rgba(0,0,0,0.4) 100%);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 12px;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.logo-mark {
  display: flex; align-items: baseline; gap: 8px;
  font-family: 'Fraunces', serif;
}
.logo-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 12px rgba(212,255,58,0.6);
  animation: pulse 2.5s ease-in-out infinite;
  align-self: center;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}
.logo-text {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
.logo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 500;
}

.topbar-right { display: flex; gap: 12px; align-items: center; }

.status {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s;
}
.status-dot.live { background: var(--pos); box-shadow: 0 0 8px rgba(74,222,128,0.5); }
.status-dot.error { background: var(--neg); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent-dim); }
.btn-icon:active { transform: scale(0.95); }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  padding: 0 18px;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 56px;
  z-index: 9;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  white-space: nowrap;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.tab:hover:not(.active) { color: var(--text-dim); }

/* ============================================================
   MAIN
   ============================================================ */
.main {
  position: relative;
  z-index: 2;
  padding: 18px 18px 80px;
  max-width: 720px;
  margin: 0 auto;
}

.view { display: none; animation: fadeUp 0.4s ease-out; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   META ROW
   ============================================================ */
.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 18px;
  border-radius: 4px;
  overflow: hidden;
}
.meta-block {
  background: var(--bg-elevated);
  padding: 10px 14px;
}
.meta-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 4px;
}
.meta-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* ============================================================
   HERO TOTALS
   ============================================================ */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 26px;
}
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--line-bright);
  border-radius: 6px;
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 32px; height: 1px;
  background: currentColor;
}
.hero-mxn { color: var(--warm); }
.hero-eur { color: var(--cool); }

.hero-eyebrow {
  font-size: 9px;
  letter-spacing: 0.15em;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.9;
}
.hero-amount {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  font-feature-settings: "tnum";
}
.hero-delta {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 500;
}
.hero-delta.pos { color: var(--pos); }
.hero-delta.neg { color: var(--neg); }

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-style: italic;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 22px 0 10px;
  font-variation-settings: "opsz" 9;
}
.section-rule {
  height: 1px;
  width: 14px;
  background: var(--accent);
  display: inline-block;
}
.section-hint {
  font-family: 'JetBrains Mono', monospace;
  font-style: normal;
  font-weight: 400;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0;
  margin-left: 4px;
}

/* ============================================================
   DATA TABLE (custom layout, not real <table>)
   ============================================================ */
.data-table {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: "tnum";
  transition: background 0.1s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-hover); }

.row-name {
  color: var(--text);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.01em;
}
.row-num {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row-num.dim { color: var(--text-dim); font-size: 11px; }
.row-delta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: right;
  min-width: 50px;
}
.row-delta.pos { color: var(--pos); }
.row-delta.neg { color: var(--neg); }
.row-delta.neutral { color: var(--text-faint); }

.row.header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line-bright);
  padding: 8px 14px;
}
.row.header > * {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 600;
  text-transform: uppercase;
}

.row.total {
  background: var(--bg-elevated);
  border-top: 1px solid var(--line-bright);
  border-bottom: 1px solid var(--line-bright);
}
.row.total .row-name {
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.row.total .row-num {
  color: var(--accent);
  font-weight: 700;
}

.row.subtotal .row-name {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.row.subtotal .row-num { color: var(--text); }

.row.eur-row .row-num,
.row.eur-row.total .row-num,
.row.eur-row.total .row-name { color: var(--cool); }

.loading-row, .empty-row, .error-row {
  padding: 24px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.error-row { color: var(--neg); }

/* Pronostico table has 5 columns */
.row.pron {
  grid-template-columns: 1fr auto auto auto auto;
}
.row.pron.header > * { font-size: 9px; }

/* ============================================================
   FILTERS
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-group {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group.full { flex-basis: 100%; }
.filter-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--text-faint);
  font-weight: 600;
}

.select {
  background: var(--bg-card);
  border: 1px solid var(--line-bright);
  color: var(--text);
  padding: 9px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  border-radius: 4px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%238a8782' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
input.select { background-image: none; padding-right: 10px; }
.select:focus { border-color: var(--accent-dim); }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-dim);
  transition: all 0.15s;
  user-select: none;
}
.checkbox-pill input { display: none; }
.checkbox-pill.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
}

/* ============================================================
   CHART
   ============================================================ */
.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 12px 8px;
  margin-bottom: 12px;
  position: relative;
}

/* ============================================================
   CUSTOM PULL
   ============================================================ */
.custom-info {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-dim);
  border-radius: 4px;
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.15em;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}
.btn-primary:hover { box-shadow: 0 0 24px rgba(212,255,58,0.3); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled {
  background: var(--bg-hover);
  color: var(--text-faint);
  cursor: wait;
}

.custom-results {
  margin-top: 18px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  position: relative;
  z-index: 2;
  padding: 14px 18px 20px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  margin-top: 30px;
}
