/* ---------------------------------------------------------------------------
   Dashboard de campaña · hoja única
   Paleta de series validada para daltonismo en ambos modos (slots 1-3).
--------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #eeeeeb;
  --border: #dcdcd6;
  --border-strong: #c3c2b7;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #86857f;

  --series-1: #2a78d6; /* enviados */
  --series-2: #eb6834; /* aperturas */
  --series-3: #1baf7a; /* clics */

  --danger: #c02a2a;
  --warning: #9a6400;
  --accent: #2a78d6;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface-0: #111110;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #33332f;
    --border-strong: #4a4a45;

    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e85;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    --danger: #e66767;
    --warning: #eda100;
    --accent: #3987e5;

    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px rgb(0 0 0 / 25%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-0);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- Acceso --------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login__brand { margin-bottom: 24px; }
.login__brand strong { display: block; font-size: 20px; letter-spacing: -0.01em; }
.login__brand span { color: var(--text-muted); font-size: 13px; }

.field { margin-bottom: 16px; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input, .select {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.input:focus-visible, .select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- Botones -------------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: progress; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn--block { width: 100%; display: block; }

/* --- Estructura ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar__title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.topbar__meta { font-size: 12px; color: var(--text-muted); }
.topbar__spacer { flex: 1; }

.main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card__title {
  font-size: 14px;
  font-weight: 650;
  margin: 0 0 4px;
}

.card__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: 20px;
}

.grid .card { margin-bottom: 0; }

/* --- Filtros -------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filters .field { margin: 0; flex: 1 1 150px; min-width: 130px; }
.filters .field--search { flex: 2 1 220px; }

/* --- Indicadores ---------------------------------------------------------- */

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 20px;
}

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat__value {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat__foot { font-size: 12px; color: var(--text-muted); }

/* --- Barras --------------------------------------------------------------- */

.bars { display: flex; flex-direction: column; gap: 10px; }

.bar__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

.bar__name { color: var(--text-primary); }

.bar__value {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar__track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  gap: 2px; /* separación entre segmentos contiguos */
}

.bar__fill { border-radius: 0 5px 5px 0; min-width: 2px; }
.bar__fill--1 { background: var(--series-1); }
.bar__fill--2 { background: var(--series-2); }
.bar__fill--3 { background: var(--series-3); }

/* --- Leyenda -------------------------------------------------------------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.legend__item { display: flex; align-items: center; gap: 6px; }

.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

/* --- Gráfico temporal ----------------------------------------------------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__axis { fill: var(--text-muted); font-size: 11px; }
.chart__line { fill: none; stroke-width: 2; }
.chart__dot { stroke: var(--surface-1); stroke-width: 2; }
.chart__hit { fill: transparent; cursor: crosshair; }
.chart__crosshair { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 5;
}

.tooltip__title { font-weight: 650; margin-bottom: 4px; }
.tooltip__row { display: flex; align-items: center; gap: 6px; }
.tooltip__value { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* --- Tabla ---------------------------------------------------------------- */

.table__wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; color: var(--text-secondary); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.tag--enviado::before { background: var(--series-1); }
.tag--abierto::before { background: var(--series-2); }
.tag--clic::before { background: var(--series-3); }

/* --- Avisos --------------------------------------------------------------- */

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  margin-bottom: 16px;
}

.alert--danger { border-color: var(--danger); color: var(--danger); }
.alert--warning { border-color: var(--warning); color: var(--warning); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.footnote { font-size: 12px; color: var(--text-muted); margin-top: 12px; }

@media (max-width: 640px) {
  .main, .topbar { padding-left: 14px; padding-right: 14px; }
  .card { padding: 16px; }
}
