:root {
  --bg: #0B0F19;
  --surface: #111827;
  --surface-2: #1a2035;
  --surface-3: #232b44;
  --border: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);
  --text: #F9FAFB;
  --muted: #9CA3AF;
  --faint: #6B7280;
  --primary: #6366F1;
  --primary-hover: #818CF8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 13px; }

/* ───────── AUTH ───────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-wrap { width: 100%; max-width: 440px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-logo { width: 40px; height: 40px; border-radius: 8px; }
.auth-brand h1 { font-size: 18px; }
.auth-brand p { font-size: 13px; color: var(--muted); }
.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.auth-card label { font-size: 13px; color: var(--muted); }
.auth-card input, .auth-card textarea, .auth-card select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
}
.auth-card button[type="submit"], .primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
}
.auth-card button[type="submit"]:hover, .primary:hover { background: var(--primary-hover); }
.auth-card button[type="submit"]:disabled { background: var(--faint); cursor: not-allowed; }
.auth-status { margin-top: 14px; font-size: 14px; min-height: 18px; }
.auth-status.ok { color: var(--success); }
.auth-status.err { color: var(--danger); }
.auth-foot { margin-top: 24px; font-size: 13px; text-align: center; }

/* ───────── DASHBOARD HEADER ───────── */
.dash-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.dash-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.dash-brand { display: flex; align-items: center; gap: 12px; }
.dash-logo { width: 32px; height: 32px; border-radius: 6px; }
.dash-brand strong { font-size: 16px; }
.dash-brand span { display: block; font-size: 12px; }
.dash-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--muted);
}
.pill.ok { color: var(--success); border-color: rgba(16,185,129,0.3); }
.pill.warn { color: var(--warning); }
.link-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.link-btn:hover { background: var(--surface-2); }

.dash-tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

/* ───────── MAIN PANELS ───────── */
.dash-main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-head { margin-bottom: 20px; }
.panel-head h2 { font-size: 22px; margin-bottom: 4px; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-row input, .filter-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.filter-row input { flex: 1; min-width: 240px; }
.filter-row button {
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
}
.filter-row button:hover { background: var(--primary-hover); }

.podcast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.pod-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pod-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Top row: artwork + heading block */
.pod-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.pod-art {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pod-art-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0B0F19;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  border: none;
  font-family: 'Inter', -apple-system, sans-serif;
}
.pod-head {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pod-card h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.pod-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  font-size: 12px;
  padding-left: 4px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.pod-link:hover { opacity: 1; color: var(--primary); }
.pod-card .pod-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.pod-card .pod-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Stats row */
.pod-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.stat {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1.4;
}
.stat small {
  font-size: 10px;
  opacity: 0.65;
  font-weight: 400;
}
.stat.auth { font-weight: 700; }
.stat.auth.auth-elite {
  background: linear-gradient(135deg, rgba(255,184,0,0.18), rgba(255,184,0,0.08));
  color: #FFB800;
  border: 1px solid rgba(255,184,0,0.35);
}
.stat.auth.auth-strong {
  background: rgba(0,201,167,0.14);
  color: #00C9A7;
  border: 1px solid rgba(0,201,167,0.35);
}
.stat.auth.auth-mid {
  background: rgba(74,144,217,0.12);
  color: #4A90D9;
  border: 1px solid rgba(74,144,217,0.3);
}
.stat.auth.auth-low { opacity: 0.7; }
.stat.rating { color: #FFB800; }
.stat.recency.rec-fresh { color: var(--success); }
.stat.recency.rec-warm { color: var(--muted); }
.stat.recency.rec-cool { color: var(--warning); opacity: 0.85; }
.stat.recency.rec-stale { color: var(--danger); opacity: 0.7; }
.stat.yt { color: #FF4444; }

.pod-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}
.badge.tier1 { background: rgba(255,184,0,0.15); color: #FFB800; border-color: rgba(255,184,0,0.4); }
.badge.tier2 { background: rgba(0,201,167,0.12); color: #00C9A7; border-color: rgba(0,201,167,0.3); }
.badge.tier3 { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge.media { background: rgba(255,68,68,0.12); color: #FF6B6B; border-color: rgba(255,68,68,0.3); }
.badge.warn { background: rgba(245,158,11,0.12); color: var(--warning); border-color: rgba(245,158,11,0.35); }
.badge.danger { background: rgba(239,68,68,0.12); color: var(--danger); border-color: rgba(239,68,68,0.35); }
.badge.ok { background: rgba(16,185,129,0.12); color: var(--success); border-color: rgba(16,185,129,0.35); }

.pod-actions { display: flex; gap: 6px; margin-top: 4px; }
.pod-actions button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  flex: 1;
}
.btn-pitch {
  background: var(--primary);
  color: white;
}
.btn-pitch:hover { background: var(--primary-hover); }
.btn-pitch:active { transform: translateY(1px); }
.btn-locked {
  background: var(--surface-3) !important;
  color: var(--faint) !important;
  cursor: not-allowed !important;
  font-weight: 500 !important;
}
.pod-actions button:disabled { background: var(--surface-3); color: var(--faint); cursor: not-allowed; }

#pager { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
#pager button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
}
#pager button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ───────── PITCHES LIST ───────── */
.pitch-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.pitch-row .subj { font-weight: 600; }
.pitch-row .meta { font-size: 12px; color: var(--muted); }
.pitch-row .status-tag { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-tag.queued { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-tag.sent { background: rgba(16,185,129,0.15); color: var(--success); }
.status-tag.failed { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ───────── OAUTH ───────── */
.oauth-buttons { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.oauth-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
}
.oauth-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.oauth-btn.outlook::before { content: "📧 "; }
.oauth-btn.gmail::before { content: "✉️ "; }
.oauth-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.oauth-row .prov { font-weight: 600; text-transform: capitalize; }
.oauth-row .email { color: var(--muted); font-size: 13px; }
.oauth-row .disconnect {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
}

/* ───────── MODAL ───────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%; max-width: 560px;
  position: relative;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer;
}
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-top: 14px; margin-bottom: 6px; }
.modal input, .modal textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.modal textarea { resize: vertical; min-height: 160px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.modal-actions .ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
}

/* templates list */
.tpl-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 8px;
}
.tpl-row .name { font-weight: 600; }
.tpl-row .subj { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tpl-row .body { font-size: 13px; color: var(--muted); margin-top: 8px; white-space: pre-wrap; max-height: 120px; overflow: hidden; }
