:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #1f1f1f;
  --color-muted: #6b6b6b;
  --color-border: #e5e5e5;
  --color-accent: #f2982c;
  --color-ok: #2563eb;
  --color-warn: #f59e0b;
  --color-crit: #dc2626;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar__brand {
  font-weight: 600;
  font-size: 16px;
}

.topbar__nav {
  display: flex;
  gap: 16px;
  align-items: center;
  color: var(--color-muted);
}

.content {
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.login {
  max-width: 420px;
  margin: 96px auto;
  background: var(--color-surface);
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-align: center;
}

.login h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

.login__hint {
  margin: 0 0 24px;
  color: var(--color-muted);
  font-size: 13px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

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

.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.flash {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 8px;
}

.flash--error {
  background: #fef2f2;
  color: var(--color-crit);
  border: 1px solid #fecaca;
}

.flash--success {
  background: #eff6ff;
  color: var(--color-ok);
  border: 1px solid #bfdbfe;
}

.nav__user {
  font-size: 13px;
}

.nav__logout {
  margin: 0;
}

.btn--link {
  background: transparent;
  border: none;
  color: var(--color-muted);
  padding: 0;
  cursor: pointer;
  font-size: 13px;
}

.btn--link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.empty {
  max-width: 640px;
  margin: 64px auto;
  text-align: center;
}

.empty h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.empty p {
  margin: 8px 0;
  color: var(--color-muted);
}

.empty__hint {
  font-size: 13px;
  margin-top: 24px;
}

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

.nav__link {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 13px;
}
.nav__link:hover { color: var(--color-text); }

.wizard { max-width: 720px; margin: 0 auto; }
.wizard h1 { margin: 8px 0 24px; font-size: 22px; }
.wizard-form fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 16px;
  background: var(--color-surface);
}
.wizard-form legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.wizard-form label {
  display: block;
  margin: 8px 0;
  font-size: 13px;
}
.wizard-form input[type="text"],
.wizard-form input[type="date"],
.wizard-form select {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
  margin-top: 4px;
}
.wizard-form select[multiple] { min-height: 96px; }
.hint { color: var(--color-muted); font-size: 12px; margin: 4px 0 12px; }
.slot { margin: 12px 0; }
.slot__label { font-weight: 600; }
.sync-form { display: flex; gap: 12px; align-items: center; margin: 0 0 20px; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px; font-size: 13px; }
.flash--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.lines {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lines th, .lines td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
.lines th {
  background: #f4f4f4;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
}
.lines tr:last-child td { border-bottom: none; }

.panel-scroll { overflow-x: auto; }
.panel {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12px;
}
.panel th, .panel td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.panel th {
  background: #f4f4f4;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10px;
}
.panel td.num, .panel th.num { text-align: right; font-variant-numeric: tabular-nums; }
.panel td.total { font-weight: 600; }
.panel tr:hover td { background: #fafafa; }

.semaphore {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.semaphore--verde     { background: #dcfce7; color: #14532d; }
.semaphore--amarillo  { background: #fef3c7; color: #78350f; }
.semaphore--rojo_hot  { background: #fee2e2; color: #7f1d1d; }
.semaphore--rojo_cold { background: #fee2e2; color: #7f1d1d; }

/* Panel v2 — pacing hero */
.panel--v2 { border-collapse: separate; border-spacing: 0; }
.panel--v2 td { vertical-align: middle; border-bottom: 1px solid var(--color-border); }
.panel--v2 th { border-bottom: 1px solid var(--color-border); }
.panel--v2 .muted { color: var(--color-muted); }

.line-name { font-size: 13px; }
.line-name strong { font-weight: 600; }
.line-name__sep { color: var(--color-muted); margin: 0 4px; }
.line-period { font-size: 11px; color: var(--color-muted); margin-top: 2px; }

.pacing-col { min-width: 340px; }
.pacing-cell { padding-right: 90px !important; }

/* Cliente/Línea sticky al scroll horizontal */
.panel--v2 th:first-child,
.panel--v2 td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--color-surface);
  box-shadow: 1px 0 0 var(--color-border);
  min-width: 220px;
}
.panel--v2 tr:hover td:first-child { background: #fafafa; }
.panel--v2 .errors-row td:first-child { background: #fef2f2; }

.pacing-bar {
  position: relative;
  width: 240px;
  height: 22px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: visible;
}
.pacing-bar__fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 4px 0 0 4px;
  transition: width 200ms ease;
}
.pacing-bar__fill--verde     { background: linear-gradient(90deg, #16a34a, #4ade80); }
.pacing-bar__fill--amarillo  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.pacing-bar__fill--rojo_hot  { background: linear-gradient(90deg, #dc2626, #f87171); }
.pacing-bar__fill--rojo_cold { background: linear-gradient(90deg, #dc2626, #f87171); }

.pacing-bar__marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #1f2937;
  border-radius: 2px;
}
.pacing-bar__marker::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -3px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #1f2937;
}

.pacing-bar__label {
  position: absolute;
  top: 0; bottom: 0;
  right: -68px;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}
.pacing-bar__gap {
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 56px;
  text-align: center;
}
.pacing-bar__gap--verde     { background: #dcfce7; color: #14532d; }
.pacing-bar__gap--amarillo  { background: #fef3c7; color: #78350f; }
.pacing-bar__gap--rojo_hot  { background: #fee2e2; color: #7f1d1d; }
.pacing-bar__gap--rojo_cold { background: #fee2e2; color: #7f1d1d; }

.pacing-bar__legend {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 4px;
}

.errors-row td.errors {
  background: #fef2f2;
  color: #7f1d1d;
  font-size: 11px;
  padding: 8px 14px;
}
.errors-row .errors div { margin: 2px 0; }

/* Wizard v2 — slot builder */
.slot-block { margin: 16px 0; padding: 12px; border: 1px solid #e5e7eb; border-radius: 6px; }
.slot-block legend { font-weight: 600; padding: 0 8px; }
.slot-block > label { display: block; margin: 8px 0; }
.slot-block > label > select, .slot-block > label > input { display: block; margin-top: 4px; min-width: 320px; }

.campaign-block { margin-top: 12px; padding: 8px; background: #f9fafb; border-radius: 4px; }
.campaign-list { margin-top: 8px; }
.campaign-search { width: 100%; padding: 4px 8px; margin-bottom: 6px; }
.campaign-checks { max-height: 240px; overflow-y: auto; background: #fff; border: 1px solid #e5e7eb; padding: 4px; }
.camp-row { display: block; padding: 2px 6px; font-size: 13px; }
.camp-row .hint { color: #94a3b8; font-size: 11px; margin-left: 6px; }

.ga4-filters-block { margin-top: 12px; padding: 8px; background: #f9fafb; border-radius: 4px; }
.ga4-filters-block h4 { margin: 0 0 8px; font-size: 14px; }
.clauses { margin: 8px 0; }
.clause-row { display: grid; grid-template-columns: 90px 220px 120px 1fr 32px; gap: 6px; align-items: center; margin: 6px 0; }
.clause-row select, .clause-row input { padding: 4px 8px; font-size: 13px; margin-top: 0; }
.clause-row input.clause-value { min-width: 0; width: 100%; background: #fff; border: 1px solid var(--color-border); border-radius: 4px; }
.clause-del { background: #fee2e2; color: #7f1d1d; border: none; padding: 4px 8px; cursor: pointer; border-radius: 4px; }
.clause-del:hover { background: #fecaca; }

.ga4-actions { display: flex; gap: 8px; margin: 8px 0; }
.ga4-explore-panel { margin-top: 8px; padding: 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; }
.ga4-explore-rows { max-height: 320px; overflow-y: auto; }
.ga4-row { display: grid; grid-template-columns: 24px 32px 1fr 100px 120px 80px; gap: 8px; padding: 4px 6px; font-size: 12px; align-items: center; border-bottom: 1px solid #f1f5f9; }
.ga4-row:hover { background: #f8fafc; }
.ga4-rank { color: #94a3b8; }
.ga4-num { text-align: right; font-family: monospace; }

.line-link { color: inherit; text-decoration: none; }
.line-link:hover { color: var(--color-accent); }

.budget-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.budget-edit-icon { color: var(--color-accent); opacity: 0; font-size: 14px; transition: opacity 120ms ease; }
.budget-cell:hover .budget-edit-icon { opacity: 1; }
.budget-link:hover { color: var(--color-accent); }

.panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.panel-header__actions { display: flex; gap: 12px; align-items: center; }
.btn--refresh { background: var(--color-accent); color: #fff; border-color: var(--color-accent); font-size: 12px; padding: 6px 14px; font-weight: 600; }
.btn--refresh:hover { opacity: 0.9; }

/* --- Tramos de inversión (wizard) --- */
.tramos-block { grid-column: 1 / -1; margin-top: 8px; padding: 10px 12px; border: 1px dashed #d8dee6; border-radius: 8px; background: #fafbfc; }
.tramos-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.tramos-title .hint { font-weight: 400; color: #6b7280; }
.tramo-row { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 4px 0; }
.tramo-row input[type="date"] { width: 150px; }
.tramo-row input[type="number"] { width: 80px; }
.tramo-del { border: none; background: transparent; color: #9ca3af; cursor: pointer; font-size: 13px; }
.tramo-del:hover { color: #dc2626; }
.btn-mini { margin-top: 6px; padding: 4px 10px; font-size: 12px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; }
.btn-mini:hover { border-color: #f29c38; color: #f29c38; }


/* --- Selector de campañas estilo Dashbo --- */
.btn-add-camps { margin: 8px 0; }
.camp-selected { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; font-size: 13px; }
.camp-selected th { text-align: left; background: #eef0f3; padding: 8px 10px; font-weight: 600; }
.camp-selected td { padding: 7px 10px; border-top: 1px solid #f0f1f3; }
.camp-selected tr:nth-child(even) td { background: #fafbfc; }
.camp-selected .camp-del { border: none; background: transparent; cursor: pointer; font-size: 15px; color: #6b7280; }
.camp-selected .camp-del:hover { color: #dc2626; }
.camp-selected .camp-status { color: #94a3b8; font-size: 11px; margin-left: 6px; }
.camp-selected .empty td { color: #94a3b8; font-style: italic; }
.camp-note { margin-top: 6px; }
.extra-account { margin-top: 10px; padding: 8px 10px; background: #fff7ed; border: 1px dashed #fdba74; border-radius: 6px; font-size: 13px; }
.camp-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.camp-modal[hidden] { display: none; }
.camp-modal__box { background: #fff; width: min(640px, 100%); max-height: 88vh; display: flex; flex-direction: column; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.camp-modal__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eef0f3; }
.camp-modal__head h3 { margin: 0; font-size: 18px; font-weight: 500; }
.camp-modal__close { border: none; background: none; font-size: 18px; cursor: pointer; color: #6b7280; }
.camp-modal__sync { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: #f7f7f8; font-size: 13px; }
.camp-modal__filters { display: flex; gap: 12px; align-items: center; padding: 10px 18px; }
.camp-modal__search { flex: 1; padding: 6px 10px; }
.camp-modal__toggle { font-size: 13px; color: #6b7280; white-space: nowrap; }
.camp-modal__list { overflow-y: auto; padding: 0 18px; flex: 1; min-height: 160px; }
.camp-opt { display: flex; justify-content: space-between; padding: 9px 8px; border-bottom: 1px solid #eef0f3; cursor: pointer; font-size: 14px; }
.camp-opt:hover { background: #fafbfc; }
.camp-opt.is-selected { background: #fff1e6; color: #c2410c; font-weight: 600; }
.camp-opt.is-already { color: #9ca3af; cursor: default; }
.camp-opt .camp-status { color: #94a3b8; font-size: 11px; font-weight: 400; }
.camp-modal__bulk { padding: 10px 18px; border-top: 1px dashed #e5e7eb; font-size: 13px; }
.camp-modal__bulk .sep { color: #f29c38; margin: 0 8px; }
.linklike { border: none; background: none; color: #ea580c; cursor: pointer; padding: 0; font-size: 13px; }
.camp-modal__foot { display: flex; justify-content: flex-end; padding: 12px 18px; background: #f7f7f8; border-radius: 0 0 10px 10px; }

.slot-account { padding: 10px 0; }
.slot-account + .slot-account { border-top: 1px dashed #d8dee6; margin-top: 8px; }
.slot-account__head { display: flex; gap: 12px; align-items: flex-end; }
.slot-account__head label { flex: 1; }
.btn-del-account { white-space: nowrap; margin-bottom: 8px; }
.btn-add-account { margin-top: 8px; }

/* --- Recordatorio de campañas en otras líneas --- */
.reminder { display: flex; justify-content: center; padding: 32px 16px; }
.reminder__card { background: #fff; max-width: 640px; width: 100%; border: 1px solid #fed7aa; border-left: 4px solid #f29c38; border-radius: 10px; padding: 22px 24px; box-shadow: 0 8px 24px rgba(0,0,0,.06); }
.reminder__card h1 { font-size: 20px; margin: 0 0 8px; }
.reminder__line { margin: 14px 0; padding: 10px 12px; background: #fafbfc; border: 1px solid #eef0f3; border-radius: 8px; }
.reminder__line-name { font-weight: 600; margin-bottom: 6px; }
.reminder__camp { display: flex; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
.reminder__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
