:root {
  --navy: #0b1929; --navy2: #132d49; --blue: #1a5ea8; --blue2: #2d7dd2;
  --accent: #f59e0b; --green: #10b981; --red: #ef4444;
  --ink: #1e2d3d; --muted: #64748b; --line: #e2eaf3;
  --surface: #ffffff; --bg: #f0f4f9; --sidebar-bg: #0f2035;
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --radius: 14px; --radius-lg: 20px; --radius-xl: 28px;
  --shadow: 0 4px 24px rgba(11,25,41,0.08);
  --shadow-lg: 0 12px 48px rgba(11,25,41,0.14);
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); height: 100vh; overflow: hidden; display: flex; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ── SIDEBAR ── */
.admin-sidebar {
  width: 260px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
  padding: 0 0 24px; overflow-y: auto; transition: var(--transition);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 0; text-decoration: none;
}
.sidebar-brand img { height: 52px; width: auto; border-radius: 8px; background: white; padding: 4px; }
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand-name { color: white; font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-brand-sub { color: rgba(255,255,255,0.4); font-size: 11px; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 16px 0; }

.sidebar-section-label {
  padding: 0 20px 8px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.3);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.tab-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; border: none;
  background: transparent; color: rgba(255,255,255,0.55);
  font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; width: 100%;
  transition: var(--transition);
}
.tab-btn .tab-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.tab-btn:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.tab-btn.active { background: var(--blue); color: white; box-shadow: 0 4px 16px rgba(26,94,168,0.35); }
.tab-btn .tab-badge {
  margin-left: auto; background: var(--accent); color: #7c2d00;
  border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center;
}

.sidebar-status { margin: auto 0 0; padding: 0 12px; display: flex; flex-direction: column; gap: 6px; }
.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,0.06);
  font-size: 12px; color: rgba(255,255,255,0.5);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.status-dot.warn { background: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }

/* ── MAIN AREA ── */
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); gap: 20px;
  flex-shrink: 0;
}
.topbar-left { display: flex; flex-direction: column; gap: 2px; }
.topbar-title { font-size: 20px; font-weight: 700; color: var(--navy); }
.topbar-sub { font-size: 13px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-time { font-size: 13px; color: var(--muted); padding: 6px 12px; background: var(--bg); border-radius: 8px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: none; font-weight: 600; font-size: 14px; cursor: pointer; transition: var(--transition); }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue2); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,94,168,0.25); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); border-color: var(--blue); color: var(--blue); }
.btn-danger { background: transparent; border: 1px solid rgba(239,68,68,0.2); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.06); }
.btn-success { background: var(--green); color: white; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.btn-icon:hover { background: var(--bg); color: var(--blue); border-color: var(--blue); }
button:disabled { opacity: 0.5; cursor: not-allowed !important; transform: none !important; box-shadow: none !important; }

/* ── CONTENT AREA ── */
.admin-content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.tab-panel { display: none; flex-direction: column; gap: 22px; }
.tab-panel.active { display: flex; }

/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); }
.card-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 22px; }
.card-body-flush { padding: 0; }

/* ── METRICS ── */
.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.metric-card::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--blue2));
  opacity: 0; transition: opacity 0.2s;
}
.metric-card:hover::after { opacity: 1; }
.metric-icon { font-size: 22px; margin-bottom: 4px; }
.metric-value { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1; }
.metric-label { font-size: 13px; color: var(--muted); }
.metric-delta { font-size: 12px; font-weight: 600; color: var(--green); }
.metric-delta.neg { color: var(--red); }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ── CHART BARS ── */
.chart-list { display: flex; flex-direction: column; gap: 12px; }
.chart-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.chart-label { font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.chart-track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; grid-column: 1/-1; }
.chart-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--blue2)); transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }
.chart-count { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ── LEADS CRM ── */
.crm-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; min-height: 600px; }
.lead-list-panel { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 700px; padding-right: 4px; }
.lead-list-panel::-webkit-scrollbar { width: 4px; }
.lead-list-panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.lead-mini {
  padding: 14px 16px; border-radius: var(--radius); border: 2px solid transparent;
  background: var(--surface); cursor: pointer; transition: var(--transition);
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.lead-mini:hover { border-color: var(--blue); transform: translateX(2px); }
.lead-mini.active { border-color: var(--blue); background: rgba(26,94,168,0.04); }
.lead-mini-name { font-weight: 700; color: var(--navy); font-size: 14px; }
.lead-mini-info { font-size: 12px; color: var(--muted); }
.lead-detail { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.lead-detail-head { padding: 22px 24px; background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%); color: white; }
.lead-detail-name { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; }
.lead-detail-meta { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 4px; }
.lead-detail-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.lead-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-field label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 4px; }
.info-field span { font-size: 14px; color: var(--ink); }

/* ── STATUS BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-new { background: rgba(26,94,168,0.1); color: var(--blue); }
.badge-contacted { background: rgba(245,158,11,0.12); color: #b45309; }
.badge-qualified { background: rgba(16,185,129,0.1); color: #059669; }
.badge-won { background: rgba(16,185,129,0.15); color: #047857; }
.badge-lost { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-abandoned { background: rgba(100,116,139,0.1); color: var(--muted); }
.badge-draft { background: rgba(100,116,139,0.1); color: var(--muted); }

/* ── SEARCH/TOOLBAR ── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; min-width: 240px;
}
.search-field input { border: none; background: transparent; outline: none; font-size: 14px; color: var(--ink); flex: 1; }
.search-field-icon { color: var(--muted); font-size: 16px; }
.filter-select {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 14px; color: var(--ink); cursor: pointer; outline: none;
}
.filter-select:focus { border-color: var(--blue); }

/* ── AI EDITORIAL ── */
.ai-studio { display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; align-items: start; }
.ai-form { display: flex; flex-direction: column; gap: 14px; }
.ai-topics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topic-chip {
  padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px; color: var(--ink);
  transition: var(--transition); text-align: left;
}
.topic-chip:hover { border-color: var(--blue); color: var(--blue); background: rgba(26,94,168,0.04); }
.topic-chip.selected { border-color: var(--blue); background: rgba(26,94,168,0.07); color: var(--blue); font-weight: 600; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.form-input, .form-textarea, .form-select {
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 14px; color: var(--ink); outline: none; transition: var(--transition);
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,94,168,0.08); }
.form-textarea { resize: vertical; min-height: 80px; }
.ai-preview-panel { position: sticky; top: 0; }
.ai-preview-content { min-height: 400px; max-height: 600px; overflow-y: auto; line-height: 1.8; }
.ai-preview-content h2 { font-family: var(--font-display); color: var(--navy); margin: 20px 0 10px; font-size: 1.3rem; border-left: 3px solid var(--blue); padding-left: 12px; }
.ai-preview-content p { margin-bottom: 14px; color: var(--ink); font-size: 15px; }
.ai-preview-content ul { padding-left: 20px; margin-bottom: 14px; }
.ai-preview-content li { margin-bottom: 6px; color: var(--ink); }
.ai-provider-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(16,185,129,0.1); color: var(--green); font-size: 12px; font-weight: 700; }
.ai-generating { display: flex; align-items: center; gap: 10px; color: var(--blue); font-size: 14px; font-weight: 600; padding: 20px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── POSTS TABLE ── */
.posts-table { width: 100%; border-collapse: collapse; }
.posts-table th { padding: 10px 14px; border-bottom: 2px solid var(--line); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); text-align: left; }
.posts-table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.posts-table tr:last-child td { border-bottom: none; }
.posts-table tr:hover td { background: rgba(26,94,168,0.02); }
.post-title-cell { font-weight: 600; color: var(--navy); max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-actions { display: flex; gap: 6px; }

/* ── OPERATIONS ── */
.ops-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.ops-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.ops-icon { font-size: 28px; }
.ops-title { font-weight: 700; color: var(--navy); font-size: 15px; }
.ops-desc { font-size: 13px; color: var(--muted); flex-grow: 1; line-height: 1.5; }

/* ── OVERVIEW FUNNEL ── */
.funnel-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.funnel-row:last-child { border: none; }
.funnel-label { font-size: 13px; color: var(--ink); min-width: 160px; }
.funnel-bar-wrap { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--blue2)); }
.funnel-count { font-size: 13px; font-weight: 700; color: var(--navy); min-width: 30px; text-align: right; }

/* ── LOGIN ── */
.login-shell { width: 100vw; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 40px; width: min(460px, 92vw); box-shadow: var(--shadow-lg); }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-logo img { height: 56px; }
.auth-logo-text h1 { font-family: var(--font-display); font-size: 1.3rem; color: var(--navy); margin: 0; }
.auth-logo-text p { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .form-input { width: 100%; }
.auth-error { color: var(--red); font-size: 13px; min-height: 20px; }

/* ── NOTIFICATIONS ── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  background: var(--navy); color: white; padding: 12px 20px;
  border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── EMPTY STATES ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 60px 20px; color: var(--muted); text-align: center; }
.empty-icon { font-size: 40px; opacity: 0.4; }
.empty-text { font-size: 15px; }

/* ── SCROLLBAR ── */
.admin-content::-webkit-scrollbar { width: 6px; }
.admin-content::-webkit-scrollbar-track { background: transparent; }
.admin-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .ai-studio, .crm-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .ops-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  body { overflow: auto; flex-direction: column; }
  .admin-sidebar { width: 100%; min-height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .admin-main { min-height: calc(100vh - 80px); }
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 12px 16px; }
}
