*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --navy: #1a2e4a;
  --navy-light: #243651;
  --green: #2e7d32;
  --green-light: #388e3c;
  --accent: #e8f5e9;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 220px;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #2d4a6b 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

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

.login-logo .brand {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 4px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

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

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}

.form-group input:focus {
  border-color: var(--green);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover { background: var(--green-light); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}

.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.error-msg {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

/* ── App shell ──────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--green);
  display: block;
}

.sidebar-brand h2 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 16px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: all .12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active .nav-icon { color: var(--green); }

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  text-transform: capitalize;
}

.btn-logout {
  width: 100%;
  padding: 7px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .12s;
}

.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Main content ───────────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.alltime-notice {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 41px;
  z-index: 48;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-body {
  padding: 24px 28px;
}

/* ── Cards & metrics ────────────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.metric-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

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

.metric-card.green .metric-value { color: var(--green); }
.metric-card.blue .metric-value { color: #1565c0; }
.metric-card.purple .metric-value { color: #6a1b9a; }

/* ── Charts ─────────────────────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

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

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.chart-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-wrap {
  position: relative;
  height: 200px;
}

/* Disclaimer shown below the GA daily traffic chart to flag pending data */
.chart-pending-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Dashed grey line swatch matching the pending dataset style on the chart */
.chart-pending-swatch {
  display: inline-block;
  width: 20px;
  height: 0;
  border-top: 2px dashed #bdbdbd;
  flex-shrink: 0;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  min-width: 0; /* prevent grid/flex item from expanding beyond container */
  margin-bottom: 24px;
}

.table-scroll {
  width: 100%;        /* constrain to card width — content overflows this, not the page */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}


.table-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover { color: var(--text); }
th.sorted { color: var(--green); }

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.rank-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Badges & pills ─────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-Agriculture { background: #e8f5e9; color: #2e7d32; }
.badge-Livestock    { background: #fff3e0; color: #e65100; }
.badge-Markets      { background: #e3f2fd; color: #1565c0; }
.badge-Weather      { background: #e8eaf6; color: #283593; }
.badge-Policy       { background: #fce4ec; color: #880e4f; }
.badge-Community    { background: #f3e5f5; color: #6a1b9a; }
.badge-default      { background: var(--bg); color: var(--text-muted); }

.contributor-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 20px;
  font-size: 11px;
  margin-right: 4px;
}

/* ── Author avatar ──────────────────────────────────────────────────────── */

.author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.author-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.author-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.story-link:hover { color: var(--green); text-decoration: underline; cursor: pointer; }

.stories-search-toggle {
  position: relative;
}

.search-active-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* ── Filters bar ────────────────────────────────────────────────────────── */

.filters-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  margin-bottom: 0;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease, padding .25s ease;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: auto;
}

.filters-bar.open {
  max-height: 240px;
  padding: 14px 28px;
  margin-bottom: 16px;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }

.filter-group label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  min-width: 140px;
}

.filter-group select:focus,
.filter-group input:focus { border-color: var(--green); }

/* ── Author cards grid ──────────────────────────────────────────────────── */

.authors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.author-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}

.author-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.author-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.author-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.author-avatar-xl {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.author-card-name { font-size: 15px; font-weight: 700; }
.author-card-role { font-size: 12px; color: var(--text-muted); }

.author-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.author-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.author-stat-value { font-size: 16px; font-weight: 700; color: var(--text); }

/* ── Report builder ─────────────────────────────────────────────────────── */

.report-builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.section-card h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.report-filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Detail view ────────────────────────────────────────────────────────── */

.detail-hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

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

.detail-stat {
  text-align: center;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

.social-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.social-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.social-platform {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.social-card.facebook .social-platform { color: #1877f2; }
.social-card.x .social-platform { color: #000; }
.social-card.instagram .social-platform { color: #e1306c; }

.social-metric { font-size: 18px; font-weight: 700; }
.social-metric-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── Back button ────────────────────────────────────────────────────────── */

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 16px;
}

.back-btn:hover { color: var(--green); }

/* Inline text button that looks like a link — used for clickable locations, tags, etc. */
.inline-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}
.inline-link:hover { color: var(--green); text-decoration-color: var(--green); }

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

.column-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: box-shadow .15s, transform .12s;
}
.column-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-left-color: var(--green-light);
}
.column-card-body {
  flex: 1;
  min-width: 0;
}
.column-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.column-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.column-card-stats strong {
  color: var(--text);
  font-weight: 600;
}
.column-card-arrow {
  color: var(--text-light);
  flex-shrink: 0;
  transition: transform .12s;
}
.column-card:hover .column-card-arrow {
  transform: translateX(2px);
  color: var(--green);
}

.reporter-mini-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0;
}

.reporter-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  min-width: 200px;
  flex: 1 1 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.reporter-mini-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.reporter-mini-name { font-size: 13px; font-weight: 600; }
.reporter-mini-stats { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Geographic ─────────────────────────────────────────────────────────── */

.geo-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

#geo-map {
  height: 500px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  /* Leaflet requires explicit z-index to stay behind modals/dropdowns */
  z-index: 0;
  position: relative;
}

/* Suppress default Leaflet popup — map uses the drawer instead */
.leaflet-popup { display: none !important; }

/* Empty state when no geocoded data yet */
.geo-empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  flex-direction: column;
  gap: 12px;
  color: var(--text-muted);
}
.geo-empty-icon { font-size: 48px; opacity: .4; }

@media (max-width: 768px) {
  .geo-layout { grid-template-columns: 1fr; }
  #geo-map { height: 320px; }
}

/* ── Trends ─────────────────────────────────────────────────────────────── */

.trends-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.trends-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.trends-search-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  position: sticky;
  top: calc(41px + var(--header-h));
  z-index: 47;
}

.trends-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.trends-search-inner:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}

.trends-search-icon {
  font-size: 18px;
  color: var(--text-muted);
  user-select: none;
}

.trends-search {
  flex: 1;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.trends-search::placeholder { color: var(--text-muted); }

.trends-search-results {
  display: none;
  position: absolute;
  left: 28px;
  right: 28px;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
}
.trends-search-results.open { display: block; }

.trends-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.trends-search-result:last-child { border-bottom: none; }
.trends-search-result:hover { background: var(--bg); }

.trends-result-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}
.trends-result-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.trends-search-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.drilldown-row {
  cursor: pointer;
}
.drilldown-row:hover {
  background: var(--bg);
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #e8f0fe;
  color: #1a56db;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cat-pill-sm {
  font-size: 10px;
  padding: 1px 6px;
}

.table-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.page-btns { display: flex; gap: 4px; }

.page-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
}

.page-btn:hover, .page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Empty & loading ────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 999;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Number formatting ──────────────────────────────────────────────────── */
.num { font-variant-numeric: tabular-nums; }

/* ── Date filter bar ────────────────────────────────────────────────────── */

.date-filter-bar--hidden { visibility: hidden; pointer-events: none; }
.date-filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 49;
  flex-wrap: wrap;
}

.date-preset-btns {
  display: flex;
  gap: 4px;
}

.date-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .12s;
  white-space: nowrap;
}

.date-btn:hover { border-color: var(--green); color: var(--green); }

.date-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.date-custom-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-custom-inputs.hidden { display: none; }

.date-custom-inputs input[type="date"] {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  color: var(--text);
}

.date-custom-inputs input[type="date"]:focus { border-color: var(--green); }

.date-arrow { color: var(--text-muted); font-size: 12px; }

.date-active-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── Date panel (chart click) ───────────────────────────────────────────── */

.date-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: none;
  align-items: stretch;
  justify-content: flex-end;
}

.date-panel-overlay.open { display: flex; }

.date-panel {
  width: 680px;
  max-width: 95vw;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  animation: slideInRight .2s ease;
}

@keyframes slideInRight {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.date-panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
}

.date-panel-title {
  font-size: 18px;
  font-weight: 700;
}

.date-panel-sub {
  font-size: 13px;
  color: rgba(255,255,255,.6);
  margin-top: 3px;
}

.date-panel-close {
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s;
}

.date-panel-close:hover { background: rgba(255,255,255,.2); }

.date-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Section divider headers inside the date panel — labels GA vs WP sections */
.date-panel-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.date-panel-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.date-sum-item {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
  text-align: center;
}

.date-sum-item:last-child { border-right: none; }

.date-sum-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.date-sum-val {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}

.date-panel-body table { width: 100%; }
.date-panel-body td { padding: 10px 16px; }

/* ── Filter notice ───────────────────────────────────────────────────────── */

.filter-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffde7;
  border: 1px solid #f9a825;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: #5d4037;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-notice-icon { color: #f9a825; font-size: 15px; flex-shrink: 0; }

.filter-notice-link {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.filter-notice-link:hover { color: var(--green-light); }

/* ── Help Modal ─────────────────────────────────────────────────────────── */

.help-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.help-modal-overlay.open { display: flex; }

.help-modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-modal-title { font-size: 16px; font-weight: 700; }
.help-modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.help-modal-close:hover { background: var(--bg); color: var(--text); }

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

.help-section {
  display: flex;
  gap: 16px;
  margin-bottom: 4px;
}
.help-section-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  padding-top: 2px;
}
.help-section-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.help-modal-body p { font-size: 13px; color: var(--text); line-height: 1.6; margin: 0 0 10px; }
.help-example { background: var(--bg); border-left: 3px solid var(--green); padding: 8px 12px; border-radius: 0 4px 4px 0; }
.help-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.help-list { font-size: 13px; line-height: 1.7; padding-left: 18px; margin: 8px 0 10px; color: var(--text); }
.help-list li { margin-bottom: 6px; }
.help-green { color: var(--green); }
.help-amber { color: #e65100; }
.help-red   { color: #c62828; }

@media (max-width: 600px) {
  .help-modal { max-height: 92vh; }
  .help-section { flex-direction: column; gap: 6px; }
  .help-section-icon { width: auto; }
}

/* ── Keywords ───────────────────────────────────────────────────────────── */

.kw-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.kw-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}

.kw-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

.kw-tab:hover:not(.active) { color: var(--text); }

.kw-tab-body { }

.kw-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Shared sortable header — used by both server-side (stories/keywords) and client-side tables */
.th-sort,
.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.th-sort:hover,
.th-sortable:hover { color: var(--green); }

.sort-icon,
.sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: .3;
  transition: opacity .1s;
}
.th-sort.sort-asc .sort-icon,
.th-sort.sort-desc .sort-icon,
.sort-asc .sort-arrow,
.sort-desc .sort-arrow { opacity: 1; color: var(--green); }
.sort-none { opacity: .3; }

.kw-search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.kw-search-input:focus { outline: none; border-color: var(--green); }

.kw-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.kw-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.kw-name { font-weight: 600; }

.kw-row { cursor: pointer; }
.kw-row:hover { background: var(--bg) !important; }

/* Keyword source badges */
.kw-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.kw-badge-extracted { background: #e3f2fd; color: #1565c0; }
.kw-badge-tag       { background: #e8f5e9; color: #2e7d32; }
.kw-badge-cat       { background: #fff8e1; color: #e65100; }

/* Gap analysis */
.gap-section {
  margin-bottom: 28px;
}

.gap-section-header {
  margin-bottom: 12px;
}

.gap-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.gap-section-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.gap-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}

.gap-card:hover { box-shadow: var(--shadow-md); }

.gap-card-green { border-left-color: var(--green); }
.gap-card-amber { border-left-color: #f59e0b; }
.gap-card-red   { border-left-color: #ef4444; }

.gap-card-icon {
  font-size: 16px;
  font-weight: 700;
  width: 20px;
  flex-shrink: 0;
  line-height: 1.4;
}

.gap-card-green .gap-card-icon { color: var(--green); }
.gap-card-amber .gap-card-icon { color: #f59e0b; }
.gap-card-red   .gap-card-icon { color: #ef4444; }

.gap-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gap-card-stat {
  font-size: 12px;
  color: var(--text-muted);
}

/* Reporter keyword map */
.reporter-kw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.reporter-kw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.reporter-kw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.reporter-kw-author { font-weight: 700; font-size: 14px; }

.reporter-kw-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reporter-kw-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px 3px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.reporter-kw-pill:hover { background: #e8f5e9; border-color: var(--green); }

.reporter-profile-kw {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.reporter-profile-kw:last-child { border-bottom: none; }
.reporter-profile-kw:hover { background: #e8f5e9; }
.reporter-profile-kw .reporter-kw-name { font-size: 13px; }
.reporter-kw-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-left: 8px; }

.reporter-kw-name { font-weight: 600; color: var(--text); }
.reporter-kw-count {
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
}

@media (max-width: 768px) {
  .gap-cards { grid-template-columns: 1fr; }
  .reporter-kw-grid { grid-template-columns: 1fr; }
  .kw-controls { gap: 6px; }
  .kw-search-input { min-width: 100%; }
}

/* ── Utility ────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

/* ── Responsive layout grids ────────────────────────────────────────────── */

.dash-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dash-tables-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.author-detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.reports-layout-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}

/* ── Mobile topbar (hidden on desktop) ─────────────────────────────────── */

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 90;
  flex-shrink: 0;
}

.mobile-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .2s;
}

/* Sidebar overlay (mobile) */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive: tablet / mobile ──────────────────────────────────────── */

@media (max-width: 768px) {

  /* Show mobile topbar */
  .mobile-topbar { display: flex; }

  /* Sidebar slides in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  /* Main content fills full width */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Responsive grids → single column */
  .dash-tables-grid,
  .author-detail-grid,
  .reports-layout-grid {
    grid-template-columns: 1fr !important;
  }

  /* Trends: stack topic/category tables, limit height so they scroll vertically */
  .trends-tables {
    grid-template-columns: 1fr;
  }

  .trends-tables .table-scroll {
    max-height: 360px;
    overflow-y: auto;
  }

  /* Stories filter bar mobile padding */
  .filters-bar.open {
    padding: 12px;
  }

  /* Charts: single column stack on mobile (swipe scroll breaks chart touch) */
  .charts-grid {
    grid-template-columns: 1fr;
  }

  /* Tables: force min-width so scroll always activates, lock cell wrapping */
  .table-scroll table {
    min-width: 560px;
  }
  .table-scroll th,
  .table-scroll td {
    white-space: nowrap;
    overflow: hidden;
    max-width: 200px;
    text-overflow: ellipsis;
  }
  /* Fade at right edge signals more content; disappears when fully scrolled */
  .table-scroll {
    background:
      linear-gradient(to right, var(--surface) 0%, transparent 16px) left / 16px 100% no-repeat local,
      linear-gradient(to left, rgba(0,0,0,.07) 0%, transparent 28px) right / 40px 100% no-repeat scroll;
  }

  /* Date filter bar: not sticky on mobile — avoids overlap with page-header
     when the bar wraps to multiple rows at small widths */
  .date-filter-bar {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
    position: static;
  }

  /* Page header sticks just below the mobile topbar */
  .page-header {
    top: 52px;
  }

  .date-btns {
    flex-wrap: wrap;
    gap: 4px;
  }

  .date-btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 36px;
  }

  /* Page header */
  .page-header {
    padding: 0 16px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-header h1 { font-size: 17px; }

  /* Page body */
  .page-body { padding: 16px 12px; }

  /* Metrics grid: 2 cols on tablet, fills well */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* 2-col reporter/author grids → single column */
  .authors-grid {
    grid-template-columns: 1fr;
  }

  .reporter-mini-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Columns grid */
  .columns-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Trends search */
  .trends-search-bar {
    padding: 10px 12px;
    top: 145px;
  }

  /* Date panel */
  .date-panel {
    width: calc(100vw - 24px);
    left: 12px !important;
    right: 12px !important;
  }

  /* Login card */
  .login-card {
    width: calc(100vw - 32px);
    padding: 28px 20px;
  }

  /* Story/author detail */
  .detail-meta-grid {
    grid-template-columns: 1fr;
  }

  /* Author profile header */
  .author-profile-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Trends topic rows */
  .drilldown-row td:nth-child(3),
  .drilldown-row td:nth-child(4) {
    display: none;
  }

  /* Hide less important table cols */
  .stories-table th:nth-child(4),
  .stories-table td:nth-child(4),
  .stories-table th:nth-child(5),
  .stories-table td:nth-child(5) {
    display: none;
  }

  .cat-pill, .tag-pill {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* Detail stat grids: 2 columns on mobile instead of 3-4 */
  .detail-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Social platform grid: 1 column on mobile */
  .social-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .metric-card { padding: 14px 12px; }
  .metric-value { font-size: 22px; }

  .reporter-mini-grid {
    grid-template-columns: 1fr;
  }

  .columns-grid {
    grid-template-columns: 1fr !important;
  }

  .page-body { padding: 12px 10px; }

  .date-btns { gap: 3px; }
  .date-btn { padding: 5px 8px; font-size: 11px; }
}

/* ── Google Analytics UI elements ───────────────────────────────────────── */

/* Inline "GA" badge used in chart titles and headings */
.ga-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
  line-height: 1.4;
}

/* Larger badge for section headers */
.ga-badge-lg {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 4px;
  padding: 2px 8px;
  vertical-align: middle;
}

/* Small inline badge for WP / Lifetime labels on metric headings */
.data-source-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  background: #f5f5f5;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  vertical-align: middle;
  text-transform: uppercase;
}

/* GA metrics section — sits between WP stats row and social/other content */
.ga-metrics-section {
  background: #f9fdf9;
  border: 1px solid #c8e6c9;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.ga-metrics-section.ga-metrics-empty {
  padding: 10px 16px;
  display: flex;
  align-items: center;
}

.ga-metrics-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ga-metrics-range {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Ad revenue section (admin-only) ───────────────────────────────────────── */

/* Mirrors the GA metrics section visually but uses amber/gold tones to signal
   monetization data and distinguish it from editorial metrics at a glance. */
.ad-metrics-section {
  background: #fffde7;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.ad-metrics-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* Amber badge for the "Ad Revenue" section label */
.ad-badge-lg {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffcc80;
  border-radius: 4px;
  padding: 2px 8px;
  vertical-align: middle;
}

/* Small red pill indicating the section is restricted to admins */
.admin-only-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
  border-radius: 4px;
  padding: 2px 7px;
  vertical-align: middle;
  text-transform: uppercase;
}

/* ── Traffic source breakdown ──────────────────────────────────────────────── */

.source-breakdown-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.source-breakdown-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* Segmented horizontal bar — each segment is a channel, width = % of total views */
.source-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 12px;
}

.source-bar-segment {
  border-radius: 3px;
  min-width: 3px;
  transition: opacity 0.15s;
  cursor: default;
}

.source-bar-segment:hover {
  opacity: 0.8;
}

/* Legend row below the bar */
.source-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.source-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.source-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-legend-label {
  color: var(--text);
}

.source-legend-pct {
  font-size: 11px;
}

/* Floating tooltip for source bar segments */
.source-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1a1a2e;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 160px;
}

.source-tooltip.visible {
  opacity: 1;
}

.source-tip-channel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.source-tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 2px;
}

.source-tip-pct {
  color: rgba(255,255,255,0.6);
}

.source-tip-sessions {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
}

.source-tip-divider {
  border-top: 1px solid rgba(255,255,255,0.15);
  margin: 8px 0 6px;
}

.source-tip-sub {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 11px;
  padding: 2px 0;
}

.source-tip-sub-name {
  color: rgba(255,255,255,0.85);
}

.source-tip-sub-views {
  color: rgba(255,255,255,0.5);
  font-variant-numeric: tabular-nums;
}

/* ── Sync panel ────────────────────────────────────────────────────────────── */

.sync-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 20px;
}

.sync-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sync-panel-header #sync-now-btn {
  flex-shrink: 0;
  width: auto;
  margin-left: auto;
}

.sync-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sync-panel-meta {
  font-size: 12px;
  flex: 1;
}

/* Status grid: 4 columns — name, status dot, time, detail */
.sync-status-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sync-row {
  display: grid;
  grid-template-columns: 120px 100px 140px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.sync-row-name {
  font-weight: 500;
  color: var(--text);
}

.sync-row-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

.sync-ok      { background: #e8f5e9; color: #2e7d32; }
.sync-running { background: #e3f2fd; color: #1565c0; }
.sync-error   { background: #fce4ec; color: #b71c1c; }
.sync-never   { background: var(--bg); color: var(--text-muted); }

/* Tiny inline spinner for the "Syncing…" button state */
.spinner-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@media (max-width: 768px) {
  .sync-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .sync-row-detail {
    grid-column: 1 / -1;
  }
}

/* ── Admin section ────────────────────────────────────────────────────────── */

.nav-section-admin {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 12px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.admin-tab {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--green); border-bottom-color: var(--green); }

.admin-panel-actions {
  margin-bottom: 16px;
}

/* Role cards */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.role-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.role-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.role-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-transform: capitalize;
}

.badge-system {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.role-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.role-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.45;
}

.role-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

.role-perm-summary { color: var(--text-muted); }

/* Permission checkboxes in role modal */
.perm-group { margin-bottom: 16px; }

.perm-group-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.perm-note {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--text-light);
}

.perm-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.perm-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  user-select: none;
  transition: background .1s, border-color .1s;
}
.perm-check:has(input:checked) {
  background: var(--accent);
  border-color: var(--green);
  color: var(--green);
}
.perm-check input { accent-color: var(--green); }

/* User role pill */
.role-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-muted);
  text-transform: capitalize;
  border: 1px solid var(--border);
}
.role-pill-admin { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.role-pill-editor { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }

/* Status indicator */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  margin-right: 5px;
  vertical-align: middle;
}
.status-dot.active { background: var(--green); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

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

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.modal-footer .modal-error { flex: 1; font-size: 13px; }

/* Form rows in modal */
.form-row {
  margin-bottom: 16px;
}
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--green); }
.form-input:disabled { background: var(--bg); color: var(--text-muted); }

.text-danger { color: #c62828; }
.btn-danger {
  background: #fce4ec;
  color: #c62828;
  border: 1px solid #ffcdd2;
}
.btn-danger:hover { background: #ffcdd2; }

@media (max-width: 768px) {
  .roles-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
}

/* ── Surfaces ───────────────────────────────────────────────────────────── */

/* The group rollup uses 3 cards, not the default 4-column metrics grid. */
.metrics-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.surface-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* --surface-color is set inline per card so the accent, dot and hover border
   all track the same value used by the chart series. */
.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--surface-color, var(--green));
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.surface-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.surface-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-color, var(--green));
  flex-shrink: 0;
}

.surface-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.surface-trend {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
}

.surface-trend.up   { color: var(--green); }
.surface-trend.down { color: #c62828; }

.surface-share {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.surface-share-pct {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 1px;
}

.surface-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.surface-blurb {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  opacity: .8;
  line-height: 1.35;
}

.surface-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

/* Share bar in the breakdown table — min-width keeps the track from
   collapsing when the table is horizontally scrolled on mobile. */
.surface-bar-track {
  min-width: 90px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.surface-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.surface-footnote {
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

@media (max-width: 768px) {
  .metrics-grid-3 {
    grid-template-columns: 1fr;
  }
  .surface-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* ── Recipes ────────────────────────────────────────────────────────────── */

.recipe-search-wrap {
  min-width: 240px;
}

.recipe-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recipe-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.recipe-type-chip:hover {
  border-color: var(--green);
}

.recipe-type-chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.recipe-type-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.recipe-type-chip.active .recipe-type-count {
  color: rgba(255, 255, 255, .85);
}

.recipe-row {
  cursor: pointer;
}

.recipe-row:hover {
  background: var(--hover, #f7f9fa);
}

/* Long recipe titles must not blow out the table on mobile — the
   .table-scroll wrapper handles overflow, this keeps rows readable. */
.recipe-title-cell {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.recipe-related-row {
  cursor: pointer;
}

.recipe-type-link {
  cursor: pointer;
  border: none;
  font: inherit;
}

.recipe-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.empty-cell {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .recipe-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .recipe-search-wrap {
    min-width: 0;
    width: 100%;
    margin-top: 10px;
  }
  .recipe-title-cell {
    max-width: 220px;
  }
}

/* Featured-image column + filter */
.recipe-img-cell {
  text-align: center;
}

.img-yes {
  color: var(--green);
  font-size: 13px;
}

.img-no {
  color: var(--text-muted);
  opacity: .5;
}

.recipe-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.recipe-filter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 4px;
}

.recipe-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.recipe-filter-btn:hover { border-color: var(--green); }

.recipe-filter-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.recipe-filter-count {
  font-size: 11px;
  color: var(--text-muted);
}

.recipe-filter-btn.active .recipe-filter-count { color: rgba(255,255,255,.85); }
