:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #657189;
  --border: #dfe5ef;
  --accent: #2457d6;
  --soft: #eef4ff;
  --green: #166534;
  --green-bg: #dcfce7;
  --red: #9f1239;
  --red-bg: #fff1f2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar {
  background: #101828;
  color: white;
  padding: 26px 36px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.topbar h1 { margin: 0 0 6px; font-size: 28px; }
.topbar p { margin: 0; color: #cbd5e1; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: white; font-weight: 600; }
.topbar-cta {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff !important;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  text-decoration: none !important;
  box-shadow: 0 2px 12px rgba(245,158,11,0.45);
  animation: topbar-pulse 2.4s ease-in-out infinite;
  white-space: nowrap;
}
.topbar-cta:hover {
  opacity: 0.9;
  text-decoration: none !important;
  transform: scale(1.04);
  transition: transform 0.15s;
}
@keyframes topbar-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(245,158,11,0.45); }
  50%       { box-shadow: 0 2px 22px rgba(245,158,11,0.85); }
}

/* ── Metrics bar ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  padding: 18px 36px;
}
.metrics div, .panel, .card, .blog, .table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.metrics div { padding: 16px; }
.metrics strong { display: block; font-size: 22px; }
.metrics span { color: var(--muted); font-size: 13px; }

/* ── Layout ── */
main { padding: 0 36px 40px; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 8px; }
.panel p { margin: 0; color: var(--muted); }
.panel-header { display: flex; justify-content: space-between; gap: 20px; align-items: center; }

/* ── Buttons ── */
button, .btn {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 16px;
  display: inline-block;
  text-decoration: none;
}
button:hover, .btn:hover { opacity: 0.88; text-decoration: none; }
.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 15px;
  display: inline-block;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }

/* ── Panel actions row ── */
.panel-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Danger button ── */
.btn-danger {
  background: var(--red-bg);
  border: 1.5px solid #fecdd3;
  border-radius: 10px;
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 15px;
  display: inline-block;
  text-decoration: none;
}
.btn-danger:hover { background: #ffe4e6; text-decoration: none; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 260px;
}
.filter-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.filter-search input[type="text"] {
  width: 100%;
  padding: 10px 36px 10px 36px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: white;
  color: var(--text);
  transition: border-color 0.15s;
}
.filter-search input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36,87,214,.12);
}
.filter-clear-x {
  position: absolute;
  right: 10px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: none;
}
.filter-clear-x:hover { color: var(--red); }

/* ── Top picks toggle pill ── */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.filter-toggle input[type="checkbox"] { display: none; }
.filter-toggle:hover { border-color: #f59e0b; color: #92400e; background: #fffbeb; }
.filter-toggle--on {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #92400e;
}

/* ── Apply button ── */
.btn-apply {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 22px;
  white-space: nowrap;
}
.btn-apply:hover { opacity: 0.88; }

/* ── Legacy filters (keep for other pages) ── */
.filters { display: flex; gap: 12px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.filters input[type="text"], .filters input[name="q"] {
  min-width: 320px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

/* ── News cards ── */
.cards { display: grid; gap: 14px; }
.card { padding: 20px; }
.card.top-pick { border-color: #9bb9ff; background: var(--soft); }
.card h3 { margin: 8px 0 8px; font-size: 20px; }
.card p { margin: 0 0 10px; color: #364152; line-height: 1.55; }
.card-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.badge { background: #dbeafe; color: #164aa5; border-radius: 999px; padding: 2px 8px; font-weight: 700; font-size: 12px; }

/* ── News UID badge ── */
.uid-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: #f1f5f9;
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 6px;
  letter-spacing: 0.02em;
}

/* ── Keyword tags on cards ── */
.kw-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kw-tag {
  background: #f0f4ff;
  color: #2457d6;
  border: 1px solid #c7d7fc;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.kw-tag:hover { background: #dbeafe; text-decoration: none; }

/* ── Keywords grid page ── */
.kw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.kw-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kw-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(36,87,214,.10); text-decoration: none; }
.kw-name { font-weight: 700; color: var(--text); font-size: 15px; }
.kw-count { color: var(--muted); font-size: 13px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 16px; justify-content: center; padding: 24px; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; overflow: hidden; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: #f1f5f9; font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f1f5f9; padding: 2px 5px; border-radius: 4px; }

/* ── Source active badges ── */
.badge-active { color: var(--green); background: var(--green-bg); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.badge-inactive { color: var(--red); background: var(--red-bg); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.error-count { color: var(--red); font-weight: 700; }

/* ── Legacy blog page (kept as fallback) ── */
.blog { padding: 30px; margin-bottom: 18px; }
.source-list li { margin-bottom: 10px; }
.source-list small { display: block; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════
   BLOGS LISTING PAGE
═══════════════════════════════════════════════════════════════ */

/* ── Page header ── */
.blogs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.blogs-header-text h2 { margin: 0 0 4px; font-size: 28px; }
.blogs-header-text p  { margin: 0; color: var(--muted); max-width: 560px; }
.blogs-header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── Featured (hero) card ── */
.blog-featured {
  display: block;
  border-radius: 20px;
  overflow: hidden;
  text-decoration: none;
  margin-bottom: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  transition: transform 0.2s, box-shadow 0.2s;
}
.blog-featured:hover { transform: translateY(-2px); box-shadow: 0 14px 48px rgba(0,0,0,.22); text-decoration: none; }
.blog-featured-img {
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
  min-height: 400px;
  position: relative;
  display: flex;
  align-items: flex-end;
}
.blog-featured-overlay {
  width: 100%;
  padding: 40px 40px 36px;
  background: linear-gradient(to top, rgba(0,0,0,.88) 0%, rgba(0,0,0,.5) 60%, transparent 100%);
}
.blog-featured-series { display: flex; gap: 8px; margin-bottom: 12px; }
.series-pill {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.series-pill--ch { background: rgba(29,78,216,.7); border-color: #3b82f6; }
.blog-featured-title {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 900;
  color: white;
  line-height: 1.2;
  max-width: 800px;
}
.blog-featured-summary {
  margin: 0 0 16px;
  color: rgba(255,255,255,.8);
  font-size: 15px;
  line-height: 1.5;
  max-width: 700px;
}
.blog-featured-meta {
  display: flex;
  gap: 16px;
  color: rgba(255,255,255,.55);
  font-size: 13px;
}

/* ── Section divider ── */
.blogs-section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}
.blogs-section-title h3 { margin: 0; font-size: 18px; }
.blogs-count { color: var(--muted); font-size: 13px; }

/* ── Blog cards grid ── */
.blogs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.blog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.blog-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(36,87,214,.12);
  transform: translateY(-2px);
  text-decoration: none;
}
.blog-card-img {
  height: 160px;
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
  flex-shrink: 0;
}
.blog-card-img--gradient {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f2b5c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.blog-card-icon { font-size: 32px; color: #60a5fa; opacity: 0.7; }
.blog-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.blog-card-badges { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.blog-badge-topic {
  background: var(--soft);
  color: var(--accent);
  border: 1px solid #c7d7fc;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.blog-badge-ch {
  background: #0f172a;
  color: #60a5fa;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 800;
}
.blog-badge-digest {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
}
.blog-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin: 0 0 8px;
  flex: 1;
}
.blog-card-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 14px;
}
.blog-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.blog-card-date { font-size: 12px; color: var(--muted); }
.blog-card-read { font-size: 13px; font-weight: 700; color: var(--accent); }

/* ── Add Source form ── */
.form-panel { max-width: 720px; }
.add-form { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group label { font-weight: 600; font-size: 14px; }
.form-group small { color: var(--muted); font-size: 13px; }
.required { color: #e53e3e; }
.muted-label { color: var(--muted); font-weight: 400; }
.form-group input[type="text"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.form-check label { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; cursor: pointer; }
.form-check input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; width: 16px; height: 16px; }
.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 4px; }

/* ── Error box ── */
.error-box {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fecdd3;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14px;
}
.empty { color: var(--muted); }
.error { white-space: pre-wrap; color: var(--red); background: var(--red-bg); padding: 12px; border-radius: 8px; }

/* ── Source add tabs ── */
.source-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  max-width: 720px;
}
.source-tab {
  padding: 9px 22px;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border: 1.5px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: color 0.15s;
}
.source-tab:hover { color: var(--accent); text-decoration: none; }
.source-tab--active {
  color: var(--accent);
  background: white;
  border-color: var(--border);
  border-bottom-color: white;
}

/* ── Bulk import results ── */
.bulk-summary-banner {
  padding: 13px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  max-width: 720px;
}
.bulk-banner--ok   { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.bulk-banner--warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.bulk-banner--info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.bulk-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bulk-results-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.bulk-results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.bulk-url {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  max-width: 400px;
}
.bulk-row--added td { background: #f0fdf4; }
.bulk-row--exists td, .bulk-row--duplicate_in_batch td { background: #f8fafc; opacity: 0.7; }
.bulk-row--invalid td, .bulk-row--error td { background: #fff1f2; }

/* ── Card thumbnail (news list) ── */
.card { display: grid; grid-template-columns: auto 1fr; gap: 0; padding: 0; overflow: hidden; }
.card-thumb-link { display: block; flex-shrink: 0; }
.card-thumb {
  width: 180px;
  height: 140px;
  object-fit: cover;
  display: block;
  border-radius: 13px 0 0 13px;
}
.card-body { padding: 18px 20px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; gap: 8px; }
.card-actions { display: flex; align-items: center; gap: 10px; }
.read-link { font-weight: 600; font-size: 14px; white-space: nowrap; }

/* ── Star / top-pick toggle ── */
.star-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.star-btn:hover { border-color: #f59e0b; color: #f59e0b; background: #fffbeb; }
.star-btn--on { border-color: #f59e0b; color: #f59e0b; background: #fef3c7; }
.badge-read { background: #d1fae5; color: #065f46; border-radius: 999px; padding: 2px 8px; font-weight: 700; font-size: 12px; }
.card-summary { color: #364152; line-height: 1.55; margin: 0 0 6px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Article detail reader ── */
.article-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 0 60px;
}
.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 18px;
  font-weight: 600;
}
.back-link:hover { color: var(--accent); }
.article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(16,24,40,.06);
}
.article-hero img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}
.article-header {
  padding: 30px 36px 20px;
  border-bottom: 1px solid var(--border);
}
.article-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}
.article-source { font-weight: 700; color: var(--accent); }
.article-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  color: var(--text);
}
.article-lead {
  margin: 14px 0 0;
  color: #364152;
  font-size: 17px;
  line-height: 1.6;
}

/* ── Article body typography ── */
.article-body {
  padding: 28px 36px;
  font-size: 16px;
  line-height: 1.75;
  color: #1e293b;
}
.article-body p { margin: 0 0 16px; }
.article-body div { margin-bottom: 4px; }
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 { margin: 28px 0 10px; line-height: 1.3; color: var(--text); }
.article-body h1 { font-size: 26px; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.article-body h2 { font-size: 22px; }
.article-body h3 { font-size: 19px; }
.article-body h4 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.article-body h5, .article-body h6 { font-size: 15px; }
.article-body ul, .article-body ol { padding-left: 22px; margin: 0 0 16px; }
.article-body li { margin-bottom: 6px; }
.article-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 20px 0;
  padding: 12px 20px;
  color: #475569;
  background: var(--soft);
  border-radius: 0 8px 8px 0;
}
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 16px auto;
  display: block;
}
.article-body figure { margin: 20px 0; }
.article-body figcaption { text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.article-body pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 14px;
  margin: 16px 0;
}
.article-body code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.article-body pre code { background: none; padding: 0; color: inherit; }
.article-body a { color: var(--accent); }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.article-body th, .article-body td { padding: 8px 12px; border: 1px solid var(--border); }
.article-body th { background: #f8fafc; font-weight: 600; }

.no-content-note {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

/* ── Article keywords + source bar ── */
.article-keywords {
  padding: 18px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.kw-label { font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; }
.article-source-bar {
  padding: 18px 36px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.article-source-bar a { word-break: break-all; }

/* ══════════════════════════════════════════════════════════════
   TOPIC SERIES & DEEP-RESEARCH BLOG
═══════════════════════════════════════════════════════════════ */

/* ── Topics grid ── */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  margin-bottom: 30px;
}
.topic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.topic-card:hover { box-shadow: 0 6px 24px rgba(36,87,214,.13); border-color: var(--accent); text-decoration: none; }
.topic-card-img {
  height: 180px;
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
}
.topic-card-img--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.topic-icon { font-size: 40px; color: #60a5fa; }
.topic-card-body { padding: 18px 20px 20px; }
.topic-chapter-count { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.topic-name { font-size: 20px; font-weight: 800; margin: 0 0 8px; color: var(--text); }
.topic-latest { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.topic-date { font-size: 12px; color: var(--muted); margin: 0; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 40px; }
.empty-state-inner { max-width: 480px; margin: 0 auto; }
.empty-icon { font-size: 48px; color: #60a5fa; margin-bottom: 16px; }
.empty-state h3 { margin: 0 0 12px; font-size: 22px; }
.empty-state p { color: var(--muted); margin: 0 0 10px; }

/* ── Topic detail: chapter list ── */
.topic-detail-wrap { max-width: 900px; margin: 0 auto; padding-bottom: 60px; }
.topic-detail-header { margin: 20px 0 30px; }
.topic-detail-header h1 { margin: 0 0 6px; font-size: 32px; }
.topic-detail-header p { color: var(--muted); margin: 0; }

.chapter-list { display: flex; flex-direction: column; gap: 16px; }
.chapter-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: grid;
  grid-template-columns: 120px 1fr;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chapter-row:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(36,87,214,.10); text-decoration: none; }
.chapter-row--latest { border-color: #9bb9ff; background: var(--soft); }
.chapter-left { position: relative; }
.chapter-thumb {
  width: 120px;
  height: 100%;
  min-height: 120px;
  background-size: cover;
  background-position: center;
  background-color: #0f172a;
}
.chapter-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #60a5fa;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
}
.chapter-body { padding: 18px 20px; }
.chapter-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.chapter-badge-num { background: var(--accent); color: white; border-radius: 6px; padding: 2px 8px; font-weight: 700; font-size: 12px; }
.chapter-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--text); }
.chapter-summary { margin: 0 0 8px; font-size: 14px; color: #475569; line-height: 1.5; }
.chapter-news-count { font-size: 12px; color: var(--muted); }

/* ── Blog detail: series nav (chapter pill bar) ── */
.blog-detail-wrap { max-width: 900px; margin: 0 auto; padding-bottom: 60px; }
.series-nav {
  background: #0f172a;
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.series-title-link { text-decoration: none; flex-shrink: 0; }
.series-title-link:hover { text-decoration: none; }
.series-label { display: block; font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; }
.series-name { display: block; font-size: 16px; font-weight: 800; color: white; }
.series-chapters { display: flex; gap: 6px; flex-wrap: wrap; }
.series-ch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid #334155;
  color: #94a3b8;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.series-ch:hover { border-color: #60a5fa; color: #60a5fa; background: #1e3a5f; text-decoration: none; }
.series-ch--active { border-color: #60a5fa; background: #1d4ed8; color: white; }

/* ── Blog hero image ── */
.blog-hero-wrap { position: relative; border-radius: 18px; overflow: hidden; margin-bottom: 24px; }
.blog-hero-img { width: 100%; max-height: 420px; object-fit: cover; display: block; }
.blog-hero-badge {
  position: absolute;
  bottom: 16px;
  left: 20px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}
.hero-ch-num { background: #1d4ed8; border-radius: 6px; padding: 2px 8px; font-size: 12px; }

/* ── Blog article body ── */
.blog-article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 40px;
  margin-bottom: 20px;
}
.blog-article-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-bottom: 24px; flex-wrap: wrap; }
.blog-body { max-width: 100%; line-height: 1.78; font-size: 16px; color: #1e293b; }
.blog-body h1 { font-size: 28px; line-height: 1.2; margin: 0 0 20px; }
.blog-body h2 { font-size: 22px; margin: 32px 0 12px; border-bottom: 2px solid var(--border); padding-bottom: 6px; }
.blog-body h3 { font-size: 18px; margin: 24px 0 10px; }
.blog-body h4 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 8px; }
.blog-body p { margin: 0 0 16px; }
.blog-body ul, .blog-body ol { padding-left: 22px; margin: 0 0 16px; }
.blog-body li { margin-bottom: 6px; line-height: 1.6; }
.blog-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 20px 0;
  padding: 14px 22px;
  background: var(--soft);
  border-radius: 0 10px 10px 0;
  color: #334155;
  font-style: italic;
}
.blog-body blockquote strong { color: var(--accent); font-style: normal; }
.blog-body table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.blog-body th { background: #0f172a; color: white; padding: 10px 14px; text-align: left; }
.blog-body td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.blog-body tr:nth-child(even) td { background: #f8fafc; }
.blog-body code { background: #1e293b; color: #7dd3fc; padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.blog-body pre { background: #0f172a; border-radius: 10px; padding: 18px 22px; overflow-x: auto; margin: 16px 0; }
.blog-body pre code { background: none; color: #e2e8f0; }
.blog-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.blog-body a { color: var(--accent); }

/* ── Chapter prev/next pagination ── */
.chapter-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.ch-nav-index {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 12px;
}
.ch-nav-index:hover { color: var(--accent); }
.ch-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ch-nav-link:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(36,87,214,.10); text-decoration: none; }
.ch-nav-link--next { text-align: right; }
.ch-nav-label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.ch-nav-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; }

/* ── Blog sources panel ── */
.blog-sources-panel { margin-top: 20px; }
.blog-sources-panel h3 { margin: 0 0 14px; }

/* ── Responsive ── */
@media (max-width: 850px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); padding: 16px; }
  main { padding: 0 16px 30px; }
  .filters input[name="q"] { min-width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .kw-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card { grid-template-columns: 1fr; }
  .card-thumb { width: 100%; height: 180px; border-radius: 13px 13px 0 0; }
  .article-header, .article-body, .article-keywords, .article-source-bar { padding-left: 20px; padding-right: 20px; }
  .article-title { font-size: 22px; }
  .article-wrap { padding: 0 0 40px; }
  .topic-grid { grid-template-columns: 1fr; }
  .chapter-row { grid-template-columns: 90px 1fr; }
  .chapter-thumb { width: 90px; }
  .blog-article { padding: 22px 18px; }
  .chapter-pagination { grid-template-columns: 1fr; }
  .ch-nav-index { display: none; }
  .blog-detail-wrap, .topic-detail-wrap { padding-bottom: 30px; }
  .series-nav { gap: 12px; }
  .blogs-header { flex-direction: column; align-items: flex-start; }
  .blogs-header-actions { flex-wrap: wrap; }
  .blog-featured-img { min-height: 280px; }
  .blog-featured-overlay { padding: 24px 20px 20px; }
  .blog-featured-title { font-size: 20px; }
  .blog-featured-summary { display: none; }
  .blog-featured-meta { flex-wrap: wrap; gap: 8px; }
  .blogs-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   ADMIN PORTAL
═══════════════════════════════════════════════════════════════ */

/* ── Login page ── */
.admin-login-body {
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.admin-login-wrap { width: 100%; max-width: 420px; }
.admin-login-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.admin-login-header { text-align: center; margin-bottom: 28px; }
.admin-login-icon { font-size: 40px; color: #60a5fa; margin-bottom: 12px; }
.admin-login-title { margin: 0 0 6px; font-size: 26px; font-weight: 800; color: white; }
.admin-login-sub { margin: 0; color: #64748b; font-size: 14px; }
.admin-login-form .form-group label { color: #94a3b8; font-size: 13px; font-weight: 600; }
.admin-login-form .form-group input {
  background: #0f172a;
  border-color: #334155;
  color: white;
  border-radius: 10px;
}
.admin-login-form .form-group input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.admin-login-form .form-group input::placeholder { color: #475569; }
.admin-login-btn {
  width: 100%;
  background: #2563eb;
  border: 0;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  padding: 13px;
  margin-top: 8px;
  transition: background 0.15s;
}
.admin-login-btn:hover { background: #1d4ed8; }
.admin-login-footer { text-align: center; margin-top: 20px; }
.admin-login-footer a { color: #64748b; font-size: 13px; }
.admin-login-footer a:hover { color: #94a3b8; }

/* ── Admin layout ── */
.admin-body { background: #f1f5f9; }
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ── Sidebar ── */
.admin-sidebar {
  background: #0f172a;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid #1e293b;
}
.admin-brand-icon { font-size: 24px; color: #60a5fa; flex-shrink: 0; }
.admin-brand-title { font-weight: 800; font-size: 15px; color: white; }
.admin-brand-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.admin-nav { padding: 12px 0; flex: 1; }
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}
.admin-nav-link:hover { background: #1e293b; color: white; text-decoration: none; }
.admin-nav-active { background: #1d4ed8; color: white !important; }
.admin-nav-active:hover { background: #1d4ed8 !important; }
.admin-nav-icon { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; }
.admin-nav-divider { border-top: 1px solid #1e293b; margin: 8px 0; }
.admin-nav-logout { color: #f87171 !important; margin-top: 4px; }
.admin-nav-logout:hover { background: #2d1b1b !important; }

/* ── Admin main area ── */
.admin-main { display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-page-title { margin: 0; font-size: 20px; font-weight: 800; color: var(--text); }
.admin-topbar-right { display: flex; gap: 8px; align-items: center; }
.admin-meta-pill {
  background: var(--soft);
  color: var(--accent);
  border: 1px solid #c7d7fc;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
}
.admin-meta-pill--green { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.admin-content { padding: 24px 28px 40px; flex: 1; }

/* ── Flash messages ── */
.admin-flash {
  margin: 0 28px 0;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.admin-flash--success { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.admin-flash--error { background: var(--red-bg); color: var(--red); border: 1px solid #fecdd3; }
.admin-flash--info { background: var(--soft); color: var(--accent); border: 1px solid #c7d7fc; }

/* ── Dashboard stats ── */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.admin-stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.admin-stat-num { font-size: 32px; font-weight: 900; color: var(--text); line-height: 1; margin-bottom: 4px; }
.admin-stat-green { color: var(--green); }
.admin-stat-red { color: var(--red); }
.admin-stat-label { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.admin-stat-sub { font-size: 12px; color: var(--muted); }

/* ── Sections ── */
.admin-section { margin-bottom: 28px; }
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.admin-section-title { margin: 0; font-size: 16px; font-weight: 800; color: var(--text); }
.admin-actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Info card (key-value pairs) ── */
.admin-info-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.admin-info-row {
  display: flex;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 16px;
}
.admin-info-row:last-child { border-bottom: 0; }
.admin-info-key { color: var(--muted); font-weight: 600; min-width: 160px; flex-shrink: 0; }
.admin-info-val { color: var(--text); }

/* ── Admin tables ── */
.admin-table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: #f8fafc; }
.admin-row-muted td { opacity: 0.55; }
.admin-row-muted:hover td { opacity: 0.75; }
.admin-link { color: var(--accent); font-weight: 600; }
.admin-link:hover { text-decoration: underline; }
.admin-row-actions { display: flex; gap: 6px; align-items: center; }

/* ── Search / filter inputs ── */
.admin-search-input {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  min-width: 220px;
  background: white;
  color: var(--text);
  font-family: inherit;
}
.admin-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,87,214,.1); }
.admin-select {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: white;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.admin-select:focus { outline: none; border-color: var(--accent); }

/* ── Sortable table headers ── */
.th-sort {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: block;
}
.th-sort:hover { color: var(--accent); }

/* ── Admin form styles ── */
.add-form .form-group { margin-bottom: 16px; }
.add-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.add-form input[type="text"],
.add-form input[type="url"],
.add-form input[type="number"],
.add-form select,
.add-form textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: white;
  box-sizing: border-box;
}
.add-form input:focus,
.add-form select:focus,
.add-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36,87,214,.1);
}
.add-form small { display: block; margin-top: 4px; }
.admin-section-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 14px; }
.admin-stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.admin-section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }

/* ── Responsive admin ── */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 0; }
  .admin-brand { border-bottom: 0; border-right: 1px solid #1e293b; }
  .admin-nav { display: flex; flex-direction: row; padding: 6px; overflow-x: auto; }
  .admin-nav-divider { display: none; }
  .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 14px 16px; }
}
