:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --border: #e2e8e6;
  --text: #10151c;
  --text-muted: #64748b;
  --sidebar-bg: #ffffff;
  --accent: #10b981;
  --accent-weak: #d1fae5;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius: 12px;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2b;
  --border: #1f2937;
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --sidebar-bg: #0d1424;
  --accent: #34d399;
  --accent-weak: rgba(52, 211, 153, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 10px 22px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  flex-shrink: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.nav-link:hover { background: var(--accent-weak); color: var(--text); }

.nav-link.active {
  background: var(--accent);
  color: #06231a;
  font-weight: 600;
}

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: 14px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  display: inline-block;
}
.logout-form { display: inline; margin: 0; }
.nowrap { white-space: nowrap; }

.leads-count {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.leads-count-zero {
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
}

.content { padding: 28px; }

.page-title { font-size: 22px; font-weight: 700; margin: 0 0 2px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card-label { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.card-value { font-size: 28px; font-weight: 700; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow-x: auto;
}

.panel-title { font-weight: 700; font-size: 15px; margin: 0 0 16px; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.bar-label { width: 180px; flex-shrink: 0; color: var(--text-muted); }
a.bar-label { text-decoration: none; }
a.bar-label:hover { text-decoration: underline; color: var(--accent); }
.bar-track { flex: 1; height: 10px; background: var(--accent-weak); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-count { width: 34px; text-align: right; flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.filters button {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #06231a;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.campaign-form { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.form-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.campaign-form input[type="text"],
.campaign-form input[type="email"] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  min-width: 280px;
}
.campaign-form textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  width: 420px;
  max-width: 100%;
  font-family: inherit;
  resize: vertical;
}
.sender-fields { display: flex; gap: 18px; flex-wrap: wrap; }
.oferta-preview {
  display: inline-block;
  max-width: 260px;
  font-size: 13px;
  color: var(--text);
}
.sender-preview { font-size: 12px; color: var(--text-muted); }
.empty-state-inline { font-size: 12px; color: var(--text-muted); font-style: italic; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.chip-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-label {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  user-select: none;
}
.chip-label:hover { border-color: var(--accent); }
.chip-checkbox:checked + .chip-label {
  background: var(--accent);
  border-color: var(--accent);
  color: #06231a;
  font-weight: 600;
}
.chip-checkbox:focus-visible + .chip-label { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-remove {
  margin-left: 6px;
  font-weight: 700;
  opacity: 0.6;
}
.chip-remove:hover { opacity: 1; }

.campaign-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  min-width: 280px;
}
.campaign-form select:disabled { color: var(--text-muted); cursor: not-allowed; }

.add-rubro-row { display: flex; gap: 8px; align-items: center; }
.add-rubro-row input[type="text"] { min-width: 220px; }
.campaign-form button[type="submit"] {
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #06231a;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.campaign-form button[type="submit"]:hover { filter: brightness(1.08); }

.status-pill-off { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background .15s;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch.off { background: var(--border); }
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.toggle-switch.on .toggle-knob { transform: translateX(20px); }

.check-ok { color: var(--accent); font-weight: 600; }
.check-missing { color: #ef4444; font-weight: 600; }

.empty-state { color: var(--text-muted); font-size: 14px; padding: 12px 0; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 320px;
  text-align: center;
  box-shadow: var(--shadow);
}
.google-btn {
  display: block;
  margin-top: 20px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #06231a;
  font-weight: 600;
}

/* --- v2: linaje, elegibilidad, outbox --- */
.table-scroll { overflow-x: auto; }
.hint { font-size: 12px; color: var(--text-muted); margin: -6px 0 14px; }
.small { font-size: 12px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.plain { list-style: none; margin: 0; padding: 0; }
.reasons { margin: 4px 0 0; padding-left: 16px; font-size: 12px; color: var(--text-muted); }
.alert { border-color: #ef4444; color: #b91c1c; }
.panel-subtitle { font-weight: 600; font-size: 13px; margin: 16px 0 8px; }
.pager { display: flex; gap: 10px; margin-top: 12px; }
.status-eligible, .status-succeeded { background: var(--accent-weak); color: var(--accent); }
.status-blocked, .status-failed, .status-permanently_failed { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.status-suppressed { background: rgba(100, 116, 139, 0.18); color: var(--text-muted); }
.sender-verified, .sender-operational { background: var(--accent-weak); color: var(--accent); }
.sender-not_eligible, .sender-not_requested { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.locations-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.location-row { display: flex; gap: 8px; flex-wrap: wrap; }
.location-row input, .campaign-form select, .campaign-form input[type="text"] {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); min-width: 220px;
}
a.card { color: inherit; text-decoration: none; }

/* --- v9: banda de modo de operación --- */
.mode-banner {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
  padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.mode-chip { font-size: 12px; color: var(--text-muted); }
.mode-chip + .mode-chip { border-left: 1px solid var(--border); padding-left: 8px; }
