/* Horizon Blueprint — design tokens + components */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Brand */
  --ink: #0A1240;          /* night sky (horizonadvisory.es hero) */
  --ink-2: #14226B;
  --sun: #93A5FF;          /* horizon glow */
  --blueprint: #93A5FF;

  /* Light theme */
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface2: #F1F4FA;
  --bg-alt: #F1F4FA;
  --border: #E2E7F0;
  --border-strong: #CDD5E3;
  --text: #0F172A;
  --text-muted: #61708A;
  --accent: #2D3FBF;
  --accent-hover: #1A2BA0;
  --accent-soft: rgba(45, 63, 191, 0.09);
  --primary: var(--accent);
  --success: #12A150;
  --warning: #D98A04;
  --danger: #DC3545;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 64px rgba(11, 27, 63, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0F1E;
    --surface: #111A2E;
    --surface2: #17223A;
    --bg-alt: #17223A;
    --border: #22304C;
    --border-strong: #2E3F62;
    --text: #E7ECF5;
    --text-muted: #8C9AB5;
    --accent: #7D8FFF;
    --accent-hover: #93A5FF;
    --accent-soft: rgba(147, 165, 255, 0.14);
    --success: #34C77B;
    --warning: #F5A524;
    --danger: #F06272;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0F1E; --surface: #111A2E; --surface2: #17223A; --bg-alt: #17223A;
  --border: #22304C; --border-strong: #2E3F62; --text: #E7ECF5; --text-muted: #8C9AB5;
  --accent: #7D8FFF; --accent-hover: #93A5FF; --accent-soft: rgba(147, 165, 255, 0.14);
  --success: #34C77B; --warning: #F5A524; --danger: #F06272;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, 0.02); --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* ── APP SHELL ── */
.app-shell { display: flex; min-height: 100vh; }
.app-shell.hidden, .hidden { display: none !important; }

.sidebar {
  width: var(--sidebar-w);
  background:
    radial-gradient(ellipse 140% 45% at 50% 100%, rgba(147,165,255,0.22), transparent 70%),
    radial-gradient(ellipse at 50% 100%, #14226b 0%, #0a1240 45%, #040919 100%);
  color: #DCE4F5;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 20px 14px;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; text-decoration: none; color: #fff; }
.brand img { height: 30px; width: auto; display: block; }
.brand-name { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; line-height: 1.1; }
.brand-name span { display: block; font-weight: 500; font-size: 11.5px; color: #8EA0C6; letter-spacing: 0.02em; margin-top: 2px; }

.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: #6F80A8; padding: 14px 10px 6px; }
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  color: #B9C5DE;
  text-decoration: none;
  border-radius: 9px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-link.active { color: #fff; background: rgba(147, 165, 255, 0.16); box-shadow: inset 2px 0 0 var(--sun); }
.nav-link.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--sun); color: #0A1240; font-size: 11px; font-weight: 800; border-radius: 20px; padding: 0 7px; line-height: 18px; }

.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 14px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2D3FBF, #93A5FF);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-meta strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { display: block; color: #8EA0C6; font-size: 11.5px; }
.icon-btn {
  background: none; border: none; color: #8EA0C6; cursor: pointer; padding: 6px; border-radius: 8px;
  display: inline-flex;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.icon-btn svg { width: 18px; height: 18px; }

.mobile-bar { display: none; }

/* ── MAIN ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 36px 40px 64px;
}
#app { max-width: 1240px; margin: 0 auto; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 15px; font-weight: 700; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:focus-visible, .form-control:focus-visible, .nav-link:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(45, 63, 191, 0.25), 0 4px 14px rgba(45, 63, 191, 0.18); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.form-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.75; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.form-control { min-height: 120px; resize: vertical; line-height: 1.55; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
tbody tr:hover td { background: var(--surface2); }
tr:last-child td { border-bottom: none; }
td a { font-weight: 600; text-decoration: none; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-active    { background: rgba(18, 161, 80, 0.12);  color: var(--success); }
.badge-draft     { background: var(--surface2);          color: var(--text-muted); }
.badge-paused    { background: rgba(217, 138, 4, 0.13);  color: var(--warning); }
.badge-archived  { background: var(--surface2);          color: var(--text-muted); }
.badge-sent      { background: var(--accent-soft);       color: var(--accent); }
.badge-replied   { background: rgba(18, 161, 80, 0.12);  color: var(--success); }
.badge-bounced   { background: rgba(220, 53, 69, 0.12);  color: var(--danger); }
.badge-pending   { background: var(--surface2);          color: var(--text-muted); }
.badge-scheduled { background: rgba(217, 138, 4, 0.13);  color: var(--warning); }
.badge-skipped   { background: var(--surface2);          color: var(--text-muted); }
.badge-admin     { background: var(--accent-soft); color: var(--accent); }
.badge-significant { background: rgba(18, 161, 80, 0.12); color: var(--success); border: 1px solid var(--success); }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 27, 63, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 2000;
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 240px;
  max-width: 380px;
  animation: slideIn 0.2s ease;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg);
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-info    { border-left-color: var(--accent); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── CSV UPLOAD ── */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.drop-zone p { margin-top: 10px; font-size: 13px; }

/* ── MISC ── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state h3 { margin-bottom: 8px; color: var(--text); font-size: 17px; }
.empty-state .btn { margin-top: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; } .flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.ab-bar-wrap { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.ab-bar { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s; }
.progress-label { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.significance-banner {
  background: rgba(18, 161, 80, 0.08);
  border: 1px solid rgba(18, 161, 80, 0.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}
.significance-banner .sig-icon { font-size: 20px; }
.significance-banner p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 600; margin-bottom: 14px; display: inline-flex; gap: 6px; }
.back-link:hover { color: var(--accent); }
.callout {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid rgba(45, 63, 191, 0.2);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; font-size: 13.5px;
}
.callout.warn { background: rgba(217, 138, 4, 0.1); border-color: rgba(217, 138, 4, 0.35); }
.callout strong { display: block; margin-bottom: 2px; }
.secret-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; font-weight: 600;
  background: var(--surface2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; word-break: break-all;
}
.banner-preview {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: #fff;
  display: flex; align-items: center; justify-content: center; min-height: 80px;
}
.banner-preview img { max-width: 100%; height: auto; display: block; }
.loading { color: var(--text-muted); padding: 24px 0; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(11, 27, 63, 0.4); z-index: 40; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 30;
    background: var(--ink); color: #fff; padding: 10px 16px;
  }
  .mobile-bar .icon-btn { color: #fff; }
  .mobile-bar img { height: 24px; width: auto; }
  .mobile-bar strong { font-size: 15px; }
  .main-content { margin-left: 0; padding: 20px 16px 48px; }
  .page-title { font-size: 22px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  #toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}
