/* ╔══════════════════════════════════════════════════════════════════════════╗
   ║  AI SALES AGENT — Admin Panel · Modern Dark UI                          ║
   ║  Inspired by Linear / Vercel — minimalist, monochromatic, focused       ║
   ╚══════════════════════════════════════════════════════════════════════════╝ */

@import url('https://rsms.me/inter/inter.css');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --bg:              #0a0a0b;
  --surface:         #111113;
  --surface-2:       #18181b;
  --surface-3:       #1f1f23;
  --surface-hover:   #1c1c20;

  /* Borders */
  --border:          rgba(255, 255, 255, 0.06);
  --border-strong:   rgba(255, 255, 255, 0.12);

  /* Text */
  --text:            #fafafa;
  --text-muted:      rgba(255, 255, 255, 0.55);
  --text-dim:        rgba(255, 255, 255, 0.35);

  /* Brand & semantic */
  --accent:          #5e6ad2;
  --accent-hover:    #6e78d9;
  --accent-glow:     rgba(94, 106, 210, 0.18);

  --blue:            #3b82f6;
  --blue-light:      rgba(59, 130, 246, 0.12);
  --purple:          #a855f7;
  --purple-light:    rgba(168, 85, 247, 0.12);
  --green:           #10b981;
  --green-light:     rgba(16, 185, 129, 0.12);
  --red:             #ef4444;
  --red-light:       rgba(239, 68, 68, 0.12);
  --orange:          #f59e0b;
  --orange-light:    rgba(245, 158, 11, 0.12);

  /* Semantic for leads */
  --hot:  #ff5e57;
  --warm: #ffb84d;
  --cold: #4dabff;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.hidden { display: none !important; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* ╔══════════ LOGIN ══════════╗ */

.login-bg {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at top, rgba(94, 106, 210, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
    var(--bg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

.login-logo { text-align: center; margin-bottom: 32px; }

.logo-icon {
  display: inline-flex;
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  border-radius: 10px;
  font-size: 22px;
  box-shadow: 0 0 24px var(--accent-glow);
}

.login-logo h1 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Forms ── */

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0;
}

.form-group input,
.filter-select,
.search-input,
.data-table input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.form-group input::placeholder { color: var(--text-dim); }

.form-group input:focus,
.filter-select:focus,
.search-input:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-msg {
  background: var(--red-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ff8a8a;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Buttons ── */

.btn-primary,
.btn-secondary,
.btn-logout {
  display: inline-flex;
  align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-full { width: 100%; justify-content: center; padding: 11px; font-weight: 500; }

.btn-logout {
  width: 32px; height: 32px;
  padding: 0; justify-content: center;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-logout:hover { color: var(--red); border-color: rgba(239,68,68,.3); background: var(--red-light); }

/* ╔══════════ DASHBOARD LAYOUT ══════════╗ */

.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px;
  position: sticky; top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.brand-dot {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item svg { opacity: .7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.user-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Main content ── */

.main-content {
  padding: 28px 32px;
  max-width: 1280px;
  width: 100%;
}

.section { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Stats grid ── */

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.green  { background: var(--green-light);  color: var(--green); }
.stat-icon.red    { background: var(--red-light);    color: var(--red); }

.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── Chart wrap ── */

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.chart-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}
.chart-svg { width: 100%; display: block; }

/* ── Cards row ── */

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.005em;
}

/* ── Lead breakdown ── */

.lead-rows { display: flex; flex-direction: column; gap: 10px; }
.lead-row {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center; gap: 12px;
}
.lead-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.lead-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.lead-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.lead-fill.hot  { background: linear-gradient(90deg, var(--hot), #ff8c8c); }
.lead-fill.warm { background: linear-gradient(90deg, var(--warm), #ffd178); }
.lead-fill.cold { background: linear-gradient(90deg, var(--cold), #7ec3ff); }

.lead-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Pipeline ── */

.pipeline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 140px;
}
.pipeline-empty {
  margin: auto;
  font-size: 13px;
  color: var(--text-dim);
}

.pipeline-step {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  gap: 6px;
  height: 100%;
}

.pipeline-bar-track {
  width: 100%;
  height: 90px;
  background: var(--surface-3);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.pipeline-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  border-radius: 3px;
  transition: height .6s cubic-bezier(.4, 0, .2, 1);
  min-height: 2px;
}
.pipeline-step.won  .pipeline-bar { background: linear-gradient(180deg, var(--green), #34d399); }
.pipeline-step.lost .pipeline-bar { background: linear-gradient(180deg, var(--red), #f87171); }

.pipeline-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pipeline-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: capitalize;
  text-align: center;
}

/* ╔══════════ CONVERSATIONS ══════════╗ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  width: auto;
  min-width: 150px;
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.search-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  min-width: 240px;
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-wrap svg { color: var(--text-dim); flex-shrink: 0; }
.search-input {
  border: none !important;
  background: transparent !important;
  padding: 9px 8px !important;
  box-shadow: none !important;
}
.search-input:focus { box-shadow: none !important; }

/* ── Tables ── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

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

.data-table thead {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background .12s;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:first-child { border-top: none; }

.data-table td {
  padding: 12px 16px;
  color: var(--text);
}

.table-empty {
  text-align: center !important;
  padding: 40px !important;
  color: var(--text-dim);
  font-size: 13px;
}

/* Stage & Class badges */
.stage-badge,
.class-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
}
.stage-initial    { background: var(--blue-light);   color: var(--blue);   border-color: rgba(59,130,246,0.2); }
.stage-diagnosis  { background: var(--purple-light); color: var(--purple); border-color: rgba(168,85,247,0.2); }
.stage-pitch      { background: var(--orange-light); color: var(--orange); border-color: rgba(245,158,11,0.2); }
.stage-demo       { background: var(--purple-light); color: var(--purple); border-color: rgba(168,85,247,0.2); }
.stage-objection  { background: var(--orange-light); color: var(--orange); border-color: rgba(245,158,11,0.2); }
.stage-close      { background: var(--green-light);  color: var(--green);  border-color: rgba(16,185,129,0.2); }
.stage-closed_won { background: var(--green-light);  color: var(--green);  border-color: rgba(16,185,129,0.2); }
.stage-closed_lost{ background: var(--red-light);    color: var(--red);    border-color: rgba(239,68,68,0.2); }

.class-HOT  { background: rgba(255,94,87,0.12); color: var(--hot);  border-color: rgba(255,94,87,0.25); }
.class-WARM { background: rgba(255,184,77,0.12); color: var(--warm); border-color: rgba(255,184,77,0.25); }
.class-COLD { background: rgba(77,171,255,0.12); color: var(--cold); border-color: rgba(77,171,255,0.25); }

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-info {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ╔══════════ HEALTH ══════════╗ */

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.health-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.health-dot.ok    { background: var(--green); box-shadow: 0 0 12px var(--green); }
.health-dot.error { background: var(--red);   box-shadow: 0 0 12px var(--red); }
.health-dot.ok::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--green);
  opacity: .4;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { transform: scale(1); opacity: .4; }
  100% { transform: scale(1.6); opacity: 0; }
}

.health-info { flex: 1; }
.health-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.health-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.metrics-raw {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre;
  line-height: 1.6;
}

/* ╔══════════ MODAL ══════════╗ */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.modal-title { font-size: 15px; font-weight: 600; }

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }

/* Chat bubbles */

.chat-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-end;
}
.chat-msg.assistant { flex-direction: row-reverse; }

.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.chat-msg.user      .chat-avatar { background: var(--blue-light);   border: 1px solid rgba(59,130,246,0.3); }
.chat-msg.assistant .chat-avatar { background: var(--purple-light); border: 1px solid rgba(168,85,247,0.3); }

.chat-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant .chat-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

/* ╔══════════ TOASTS ══════════╗ */

.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 300;
  max-width: 360px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn .25s cubic-bezier(.4, 0, .2, 1);
}
.toast.toast-hot,    .toast.hot     { border-left-color: var(--hot); }
.toast.toast-success,.toast.success { border-left-color: var(--green); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}

/* ╔══════════ TOGGLE SWITCH ══════════╗ */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: .2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  background: white;
  transform: translateX(16px);
}

/* ╔══════════ RESPONSIVE ══════════╗ */

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; padding: 12px; }
  .sidebar-brand { border-bottom: none; padding: 0; margin: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-row { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .templates-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── TEMPLATES ──────────────────────────────────────────── */

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tpl-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.tpl-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.tpl-bar {
  height: 5px;
  width: 100%;
}

.tpl-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tpl-niche {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 99px;
}

.tpl-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tpl-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.tpl-swatches {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.tpl-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.tpl-file {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
}

.tpl-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: 4px;
  transition: color 0.15s;
}
.tpl-link:hover { color: var(--accent-hover); }

.tpl-bar--negocios      { background: linear-gradient(90deg,#1e3a8a,#60a5fa); }
.tpl-bar--lifestyle     { background: linear-gradient(90deg,#831843,#f9a8d4); }
.tpl-bar--salud         { background: linear-gradient(90deg,#065f46,#34d399); }
.tpl-bar--profesionales { background: linear-gradient(90deg,#581c87,#c084fc); }
.tpl-bar--servicios     { background: linear-gradient(90deg,#92400e,#fbbf24); }
.tpl-bar--otros         { background: linear-gradient(90deg,#374151,#9ca3af); }

.tpl-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
}
.tpl-badge--warn {
  background: rgba(234,179,8,0.15);
  color: #ca8a04;
  border: 1px solid rgba(234,179,8,0.3);
}

.tpl-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tpl-aliases {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

.platform-wa {
  color: #16a34a;
  font-weight: 600;
}

.tpl-loading, .tpl-error {
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── New sections (Funnel, Sites, Partners, Changes) ─────────────────── */

.select-input {
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text, #0f172a);
  cursor: pointer;
  outline: none;
}
.select-input:focus { border-color: var(--accent, #3b82f6); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-muted, #f8fafc);
}
.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  color: var(--text, #0f172a);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-muted, #f8fafc); }
.data-table code {
  background: var(--surface-muted, #f1f5f9);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #6366f1;
  font-family: 'SF Mono', Monaco, monospace;
}
.data-table .empty,
.empty-state {
  text-align: center;
  color: var(--text-muted, #94a3b8);
  padding: 32px 16px;
  font-size: 14px;
}
.data-table .empty.error,
.empty-state.error { color: #ef4444; }

.btn-link {
  background: transparent;
  border: none;
  color: #6366f1;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  margin-right: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.btn-link:hover { background: rgba(99,102,241,.08); color: #4338ca; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 7px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
}

.change-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.change-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.change-header strong { font-size: 15px; color: var(--text, #0f172a); }
.change-meta {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #64748b);
  margin-top: 4px;
}
.change-body {
  background: var(--surface-muted, #f8fafc);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text, #0f172a);
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.change-asset {
  margin-top: 10px;
  font-size: 13px;
}
.change-asset a {
  color: #6366f1;
  text-decoration: none;
}
.change-asset a:hover { text-decoration: underline; }

.changes-list { padding: 4px; }
