/* ============================================================================
   Golden Galapagos B2C Reporting Dashboard
   Flowsly light theme: cyan-anchored, derived from flowsly.io brand
   (cyan / void / silver). Spanish-primary labels (English secondary).
   ============================================================================ */

:root {
  /* Flowsly light theme: cyan-anchored, derived from live flowsly.io brand
     (cyan #00d4ff / void #0e0e11 / silver #e8e8ed). Dark-theme tokens
     extrapolated to light surfaces for the dashboard. */
  --bg:            #ffffff;
  --surface:       #ffffff;
  --card:          #ffffff;
  --card-hover:    #f5f5f7;
  --elevated:      #ffffff;
  --fg:            #0e0e11;
  --fg-strong:     #000000;
  --muted:         #5b6068;
  --muted-soft:    #8a8f98;
  --border:        rgba(14, 14, 17, 0.10);
  --border-strong: rgba(14, 14, 17, 0.22);
  --bar-track:     rgba(14, 14, 17, 0.08);

  /* Flowsly brand primaries (lifted from www.flowsly.io :root) */
  --brand-cyan:      #00d4ff;
  --brand-cyan-deep: #00a8d4; /* text/icon variant for AA on white */
  --brand-void:      #0e0e11;
  --brand-silver:    #e8e8ed;

  /* Semantic accents */
  --accent-good:   #00d4ff; /* positive — brand cyan */
  --accent-attn:   #ff5c5c; /* negative — coral red */
  --accent-sand:   #f0a838; /* warning — deeper amber */
  --accent-deep:   #0e0e11; /* strong text */

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --font-body:    'Söhne', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Söhne', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }

/* tabular numerics for every numeric surface */
.num, .kpi-value, .delta, .filter-bar input,
.scorecard .val, .drill-row .amt {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ---- Page shell ---- */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px 64px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 18px;
  gap: 24px;
}
.brand-mark { display: flex; align-items: center; gap: 14px; }
.brand-mark .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-good);
  box-shadow: 0 0 0 5px rgba(0, 212, 255, 0.16), 0 0 18px rgba(0, 212, 255, 0.45);
}
.brand-mark h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand-mark .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.last-sync {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---- Filter bar (sticky) ---- */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(14, 14, 17, 0.04);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 28px;
}
.filter-bar .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-bar label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-bar label .en { opacity: 0.55; font-weight: 500; letter-spacing: 0.04em; }
.filter-bar .field-row { display: flex; gap: 8px; align-items: center; }
.filter-bar input[type="date"] {
  appearance: none;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}
.filter-bar input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }

.multi-select { position: relative; }
.multi-select-btn {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.multi-select-btn:hover { background: var(--card-hover); }
.multi-select-btn .caret { color: var(--muted); font-size: 10px; }
.multi-select-btn .badge {
  background: var(--accent-deep);
  color: var(--accent-sand);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 100px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.multi-select-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 200px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(14, 14, 17, 0.14), 0 2px 6px rgba(14, 14, 17, 0.06);
  padding: 6px;
  max-height: 260px;
  overflow: auto;
  display: none;
  z-index: 60;
}
.multi-select.open .multi-select-pop { display: block; }
.multi-select-pop label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}
.multi-select-pop label:hover { background: var(--card); }
.multi-select-pop input { accent-color: var(--accent-good); }

.btn-reset {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  height: 36px;
  white-space: nowrap;
}
.btn-reset:hover { background: var(--card); border-color: var(--accent-sand); color: var(--accent-sand); }

/* ---- Hero KPI strip ---- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}
.kpi-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(14, 14, 17, 0.03), 0 1px 3px rgba(14, 14, 17, 0.04);
  transition: background 120ms, border-color 120ms, transform 120ms, box-shadow 120ms;
}
.kpi-tile:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 14, 17, 0.08), 0 1px 3px rgba(14, 14, 17, 0.04);
}
.kpi-tile .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-tile .en {
  font-size: 11px;
  color: var(--muted-soft);
  font-style: italic;
  margin-bottom: 2px;
}
.kpi-tile .row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.kpi-tile .value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
}
.kpi-tile .delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.delta.up   { color: var(--accent-good); }
.delta.down { color: var(--accent-attn); }
.delta.flat { color: var(--muted); }
.kpi-tile .spark { height: 32px; margin-top: 6px; }

/* ---- Sections ---- */
.section { margin-bottom: 36px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-head .title { display: flex; flex-direction: column; gap: 2px; }
.section-head h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.section-head .en {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.section-head .meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---- Card grid ---- */
.card-grid { display: grid; gap: 16px; }
.card-grid.cols-3   { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-2   { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
.card-grid.cols-1-2 { grid-template-columns: 1fr 2fr; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: 0 1px 0 rgba(14, 14, 17, 0.03), 0 1px 3px rgba(14, 14, 17, 0.04);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.card-head h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: -0.005em;
}
.card-head .en {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.card-head .meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.chart { width: 100%; height: 280px; }
.chart.tall   { height: 360px; }
.chart.short  { height: 180px; }
.chart.xshort { height: 90px; }

/* ---- KPI tile inside a card slot ---- */
.card.kpi-card { gap: 6px; padding: 20px; }
.card.kpi-card .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.card.kpi-card .en {
  font-size: 11px;
  color: var(--muted-soft);
  font-style: italic;
  margin-bottom: 2px;
}
.card.kpi-card .row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card.kpi-card .value {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
  margin-top: 6px;
}
.card.kpi-card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---- Small multiples ---- */
.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}
.scorecard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: background 120ms, transform 120ms, border-color 120ms;
}
.scorecard:hover { background: var(--card-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.scorecard .name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scorecard .avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-deep);
  color: var(--accent-sand);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}
.scorecard .metric {
  display: grid;
  grid-template-columns: 60px 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  margin-bottom: 8px;
}
.scorecard .metric:last-child { margin-bottom: 0; }
.scorecard .metric .lbl {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 600;
}
.scorecard .metric .bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bar-track);
  overflow: hidden;
  position: relative;
}
.scorecard .metric .bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 280ms ease;
}
.scorecard .metric .bar .target {
  position: absolute;
  top: -1px; bottom: -1px;
  width: 1px;
  background: var(--accent-sand);
  opacity: 0.55;
}
.scorecard .metric .val {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  text-align: right;
}

/* ---- Drill-down panel ---- */
.drill-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 17, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
  z-index: 90;
}
.drill-overlay.open { opacity: 1; pointer-events: auto; }
.drill-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -16px 0 48px rgba(14, 14, 17, 0.16), -2px 0 6px rgba(14, 14, 17, 0.08);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(.22,.61,.36,1);
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.drill-panel.open { transform: translateX(0); }

.drill-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drill-head h3 { font-size: 14px; margin: 0 0 4px; font-weight: 600; }
.drill-head .en { font-size: 11px; color: var(--muted); font-style: italic; }
.drill-head .filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-sand);
  margin-top: 8px;
  letter-spacing: 0.04em;
}
.drill-close {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.drill-close:hover { background: var(--card); border-color: var(--accent-attn); color: var(--accent-attn); }

.drill-summary {
  padding: 10px 20px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.drill-summary .count {
  color: var(--accent-sand);
  font-weight: 700;
}
.drill-list { flex: 1; overflow: auto; padding: 4px 12px 16px; }
.drill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 100ms;
}
.drill-row:hover { background: var(--card); }
.drill-row .name { font-weight: 600; font-size: 13px; }
.drill-row .amt {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-sand);
  white-space: nowrap;
}
.drill-row .meta {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.drill-row .meta .pill {
  background: var(--bar-track);
  padding: 1px 8px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--fg);
}
.drill-row .meta .pill.lost { color: var(--accent-attn); }
.drill-row .meta .pill.won  { color: var(--accent-good); }
.drill-row .meta .pill.open { color: var(--accent-sand); }
.drill-row .meta .reason { color: var(--accent-attn); font-style: italic; }
.drill-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13px;
}
.drill-loadmore {
  padding: 12px 20px 20px;
  text-align: center;
}
.drill-loadmore button {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--accent-sand);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.drill-loadmore button:hover { background: var(--card-hover); }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .btn-reset { grid-column: -2 / -1; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .card-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .card-grid.cols-2-1, .card-grid.cols-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .page { padding: 0 16px 40px; }
  .filter-bar { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr; }
  .card-grid.cols-3, .card-grid.cols-2 { grid-template-columns: 1fr; }
  .scorecard-grid { grid-template-columns: 1fr; }
}

/* ---- Per-card error state ---- */
.card-error-msg {
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #8a1f1f;
  background: rgba(255, 92, 92, 0.10);
  border: 1px solid rgba(255, 92, 92, 0.25);
  border-radius: var(--radius-sm);
}
.card[data-state="error"] .chart,
.card[data-state="error"] .scorecard-grid {
  opacity: 0.35;
  filter: grayscale(0.4);
  pointer-events: none;
}
.kpi-strip[data-state="error"] .kpi-error {
  grid-column: 1 / -1;
  padding: 14px 16px;
  font-size: 12px;
  color: #8a1f1f;
  background: rgba(255, 92, 92, 0.10);
  border: 1px solid rgba(255, 92, 92, 0.25);
  border-radius: var(--radius-sm);
}

/* ---- Iframe-only splash ---- */
#iframe-only-splash[hidden] {
  display: none !important;
}
#iframe-only-splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  background: var(--bg);
  text-align: center;
  z-index: 1000;
}
#iframe-only-splash h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--fg-strong);
}
#iframe-only-splash p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  max-width: 440px;
  line-height: 1.5;
}
