/* NewsBreak Pulse — warm neutral shell, NewsBreak coral + navy accents */
:root {
  --bg: #ecebe8;
  --surface: #ffffff;
  --surface-subtle: #f6f5f3;
  --surface-hover: #f2f1ee;
  --border: #e8e6e2;
  --border-strong: #d6d3ce;
  --text: #17202b;
  --text-muted: #6b6862;
  --text-faint: #a19d96;

  --nb-red: #ff5a5a;
  --nb-red-deep: #e23b3b;
  --nb-navy: #274464;

  --accent: var(--nb-red-deep);
  --accent-hover: #cc2f2f;
  --accent-soft: #fdecea;
  --navy: var(--nb-navy);
  --navy-soft: #e8edf3;
  --blue: var(--nb-navy);
  --blue-soft: var(--navy-soft);
  --green: #2f7a45;
  --green-soft: #e4f2e7;
  --amber: #9a5a0c;
  --amber-soft: #fbefd8;
  --red: #c2302f;
  --red-soft: #fde6e4;
  --tag-gray: #efedea;
  --tag-gray-text: #55524c;

  --ink: #17191c;
  --ink-text: #f3f2f0;

  --shadow-sm: 0 1px 2px rgba(23, 25, 28, 0.04);
  --shadow-md: 0 12px 32px rgba(23, 25, 28, 0.12), 0 2px 6px rgba(23, 25, 28, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #121315;
  --surface: #1a1c1f;
  --surface-subtle: #212327;
  --surface-hover: #26282c;
  --border: #2a2d31;
  --border-strong: #3a3d42;
  --text: #eeedeb;
  --text-muted: #9c9a95;
  --text-faint: #6b6965;
  --accent: #ff6b6b;
  --accent-hover: #ff8080;
  --accent-soft: rgba(255, 90, 90, 0.14);
  --navy: #8fb0d6;
  --navy-soft: rgba(143, 176, 214, 0.14);
  --blue: var(--navy);
  --blue-soft: var(--navy-soft);
  --green: #6fcf8a;
  --green-soft: rgba(111, 207, 138, 0.13);
  --amber: #f0b45a;
  --amber-soft: rgba(240, 180, 90, 0.13);
  --red: #ff7b7b;
  --red-soft: rgba(255, 123, 123, 0.13);
  --tag-gray: #2a2c30;
  --tag-gray-text: #b5b3ae;
  --ink: #f3f2f0;
  --ink-text: #17191c;
  --shadow-sm: none;
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--text); }
code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--tag-gray);
  color: var(--tag-gray-text);
  padding: 1px 5px;
  border-radius: 4px;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
svg.i { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Layout: sidebar on canvas, content in an inset panel */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  padding: 10px 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.brand-title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; line-height: 1.15; color: var(--text); }
.brand-sub { font-size: 11.5px; color: var(--text-muted); }

.nav-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: auto; }
.nav-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  padding: 0 10px 6px;
  letter-spacing: 0.02em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(23, 25, 28, 0.04); color: var(--text); }
[data-theme="dark"] .nav-item:hover { background: rgba(255, 255, 255, 0.04); }
.nav-item.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }
.nav-item.active svg.i { color: var(--accent); }
.nav-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--tag-gray);
  color: var(--tag-gray-text);
}
.nav-count.badge-new { background: var(--accent-soft); color: var(--accent); }

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.sidebar-card-title { font-size: 12.5px; color: var(--text-muted); }
.sidebar-card-val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.sidebar-card-desc { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; }
.sidebar-footer { display: flex; flex-direction: column; gap: 6px; }
.sidebar-meta { font-size: 11.5px; color: var(--text-faint); padding: 0 10px; font-variant-numeric: tabular-nums; }

/* Main panel */
.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-sm);
}

.topbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  padding: 28px 36px 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.topbar-subtitle { font-size: 13.5px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
  white-space: nowrap;
  text-decoration: none !important;
  color: inherit;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible, .nav-item:focus-visible, .pill:focus-visible, .seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 1px 2px rgba(226,59,59,0.3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 10px 18px; font-size: 14.5px; }
.btn-full { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; font-size: 15px; }
.btn code { background: rgba(0,0,0,0.06); color: inherit; }

.input, .select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6862' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-sm { padding: 6px 9px; font-size: 13px; }

/* Job progress — floating dark bar */
.job-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 32px));
  background: #17191c;
  color: #f3f2f0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  z-index: 45;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
[data-theme="dark"] .job-banner { background: #2a2c30; border: 1px solid #3a3d42; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.job-banner-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.job-banner-status { display: flex; align-items: center; gap: 9px; font-size: 13.5px; min-width: 0; }
.job-banner-status strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-banner-actions { display: flex; align-items: center; gap: 8px; }
.job-elapsed { font-family: var(--mono); font-size: 12px; color: #9c9a95; font-variant-numeric: tabular-nums; }
.job-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--nb-red); }
.job-banner .btn-danger { background: rgba(255,90,90,0.16); color: #ff8b8b; }
.job-banner .btn-danger:hover { background: var(--nb-red); color: #fff; }
.job-banner .btn-ghost { color: #c9c7c2; }
.job-banner .btn-ghost:hover { background: rgba(255,255,255,0.08); color: #fff; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nb-red); flex-shrink: 0; animation: pulse 1.2s infinite; }
.pulse-dot.done { background: #6fcf8a; animation: none; }
.pulse-dot.error { background: var(--nb-red); animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
.progress-track { height: 4px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #d23434, var(--nb-red)); border-radius: 999px; transition: width 0.25s ease; }
.job-message { font-size: 12px; color: #9c9a95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Content */
.content { padding: 4px 36px 96px; width: 100%; max-width: 1440px; }
.view { display: none; flex-direction: column; gap: 20px; }
.view.active { display: flex; }
#overview-body { display: flex; flex-direction: column; gap: inherit; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-header h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12.5px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

/* KPI strip — single container, hairline dividers */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kpi-card {
  background: var(--surface);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  transition: background 0.12s;
}
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { background: var(--surface-subtle); }
.kpi-label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kpi-val { font-size: 26px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-val small { font-size: 14px; color: var(--text-muted); font-weight: 500; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-card.highlight-new .kpi-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--nb-red); }

/* Charts */
.chart-box { min-height: 190px; display: flex; flex-direction: column; justify-content: flex-end; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 172px; padding-top: 22px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-val { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-stack { width: 100%; max-width: 40px; border-radius: 4px 4px 0 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-height: 4px; }
.bar-seg-news { background: var(--nb-red); width: 100%; }
.bar-seg-partner { background: var(--navy); width: 100%; }
.bar-label { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); white-space: nowrap; margin-top: 4px; margin-bottom: -22px; }
.bar-chart { margin-bottom: 22px; }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.bucket-list { display: flex; flex-direction: column; gap: 14px; }
.bucket-row { display: grid; grid-template-columns: 96px 1fr 120px; align-items: center; gap: 12px; font-size: 13px; }
.bucket-row strong { font-weight: 500; }
.bucket-bar-bg { height: 8px; background: var(--surface-subtle); border-radius: 999px; overflow: hidden; }
.bucket-bar-fill { height: 100%; background: var(--navy); border-radius: 999px; }
.bucket-meta { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bucket-meta strong { color: var(--text); }

/* Leaderboards */
.leaderboard { display: flex; flex-direction: column; }
.leaderboard.compact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.lb-row:hover { background: var(--surface-hover); }
.compact-grid .lb-row { margin: 0; border: 1px solid var(--border); padding: 10px 12px; }
.lb-rank { width: 28px; font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; text-align: right; }
.lb-main { flex: 1; min-width: 0; }
.lb-name-row { display: flex; align-items: center; gap: 6px; }
.lb-name { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar-wrap { height: 4px; background: var(--surface-subtle); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.lb-bar { height: 100%; background: var(--navy); border-radius: 999px; }
.lb-bar.low { background: var(--amber); }
.lb-stats { text-align: right; font-variant-numeric: tabular-nums; }
.lb-count { font-weight: 500; font-size: 13.5px; }
.lb-sub { font-size: 11.5px; color: var(--text-muted); }

/* Segmented control */
.segmented { display: inline-flex; background: var(--surface-subtle); padding: 3px; border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0; }
.seg-btn { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }

/* Tags / badges — mono uppercase, squared */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-domain { background: var(--navy-soft); color: var(--navy); }
.badge-partner { background: var(--tag-gray); color: var(--tag-gray-text); }
.badge-both { background: var(--amber-soft); color: var(--amber); }
.badge-tracked { background: var(--amber-soft); color: var(--amber); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-err { background: var(--red-soft); color: var(--red); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-family: var(--mono); font-size: 11.5px; padding: 1px 5px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.delta-pos { background: var(--green-soft); color: var(--green); }
.delta-neg { background: var(--red-soft); color: var(--red); }
.delta-zero { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }

/* Tracked chips */
.tracked-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tracked-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tracked-chip:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.tracked-chip strong { font-size: 13.5px; font-weight: 500; }
.tracked-chip span { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Toolbar & filter pills */
.toolbar { display: flex; flex-direction: column; gap: 12px; padding: 0; border: 0; }
.toolbar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 240px;
  padding-left: 34px;
  background-color: var(--surface-subtle);
  border-color: var(--border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a19d96' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}
.search-input:focus { background-color: var(--surface); }
.filter-pills { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 9px; align-self: flex-start; }
.pill {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }

/* Data table */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-header { padding: 18px 20px 0; }
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  white-space: nowrap;
}
.data-table th.num { text-align: right; }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.clickable-row { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr.clickable-row:hover { background: var(--surface-subtle); }
.pub-cell { display: flex; align-items: center; gap: 12px; }
.pub-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}
.pub-name { font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pub-sub { font-size: 12.5px; color: var(--text-muted); }

.pagination { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

/* New publishers hero */
.new-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--surface-subtle); }
.new-hero h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.new-hero p { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 580px; }
.new-hero-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Empty hero */
.empty-hero { text-align: center; padding: 72px 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-hero-icon { width: 48px; height: 48px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 22px; }
.empty-hero h2 { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.015em; }
.empty-hero p { margin: 0 auto 22px; max-width: 520px; color: var(--text-muted); }
.empty-hero-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.field .select, .field .input { width: 100%; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }
.form-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; min-height: 18px; }
.tracked-table-wrap { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.tracked-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(23, 25, 28, 0.32); z-index: 40; animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed;
  top: 10px;
  right: 10px;
  bottom: 10px;
  width: min(720px, calc(100vw - 20px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-header { padding: 22px 24px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawer-title-row h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.drawer-links { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; align-items: center; }
.drawer-body > * { flex-shrink: 0; }
.drawer-body { padding: 20px 24px 36px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.drawer-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.drawer-kpi { background: var(--surface); padding: 12px 14px; }
.drawer-kpi .k { font-size: 12px; color: var(--text-muted); }
.drawer-kpi .v { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.drawer-section h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.mini-chart { display: flex; align-items: flex-end; gap: 6px; height: 104px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.mini-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.mini-bar { width: 100%; max-width: 28px; background: var(--nb-red); border-radius: 3px 3px 0 0; min-height: 3px; }
.mini-bar-lbl { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }

.drawer-articles-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.drawer-articles-bar h4 { margin: 0; }
.articles-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.article-row { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); transition: background 0.12s; }
.article-row:last-child { border-bottom: 0; }
.article-row:hover { background: var(--surface-subtle); }
.article-title { font-weight: 500; font-size: 13.5px; color: var(--text); }
.article-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.drawer-pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23, 25, 28, 0.36); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade 0.16s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(460px, 95vw); box-shadow: var(--shadow-md); overflow: hidden; animation: pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

/* Toasts */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #17191c; color: #f3f2f0; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-md); animation: pop 0.2s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-sm); }
.login-card .brand { padding: 0; margin-bottom: 28px; }
.login-card h1 { margin: 0 0 18px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login-error { min-height: 18px; font-size: 13px; color: var(--red); margin: -4px 0 -2px; }

/* Roles: viewers see read-only UI */
html:not([data-role="admin"]) .admin-only { display: none !important; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; font-family: var(--mono); font-size: 11px; color: var(--text-muted); text-transform: uppercase; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; line-height: 1.25; }
.user-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11.5px; color: var(--text-muted); text-transform: capitalize; }

/* ---------- Mobile: top header + bottom tab bar ---------- */
@media (max-width: 760px) {
  html, body { font-size: 15px; }
  .app-shell { display: block; height: auto; padding: 0; }

  /* Sidebar becomes a compact header: brand left, theme + account right */
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
  }
  .brand { padding: 0; }
  .brand-sub, .sidebar-card, .sidebar-meta, .user-meta { display: none; }
  .sidebar-footer { flex-direction: row; align-items: center; gap: 2px; }
  .sidebar-footer > .nav-item { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .sidebar-footer > .nav-item span { display: none; }
  .user-row { border-top: 0; margin: 0; padding: 0 0 0 4px; gap: 4px; }
  .user-row .btn { min-height: 36px; }

  /* Nav becomes a fixed bottom tab bar */
  .nav-list {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .nav-list .nav-item {
    position: relative;
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    min-height: 50px;
    justify-content: center;
    font-size: 0;
    border-radius: 10px;
  }
  .nav-list .nav-item.active { box-shadow: none; background: transparent; color: var(--accent); }
  .nav-list .nav-item svg.i { width: 22px; height: 22px; }
  .nav-list .nav-item span[data-short]::after { content: attr(data-short); font-size: 11px; font-weight: 500; }
  .nav-list .nav-count { position: absolute; top: 2px; left: 50%; margin: 0 0 0 8px; font-size: 10px; padding: 0 5px; }
  #nav-count-pubs { display: none; }

  /* Content: full-bleed, room for the tab bar */
  .main-wrap { border: 0; border-radius: 0; box-shadow: none; overflow: visible; min-height: 100vh; }
  .topbar { position: static; backdrop-filter: none; padding: 18px 16px 14px; gap: 12px; }
  .topbar h1 { font-size: 24px; }
  .topbar-subtitle { font-size: 13px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 auto; min-height: 40px; }
  .content { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
  .view { gap: 16px; }

  /* 16px inputs stop iOS zoom-on-focus; bigger tap targets */
  .input, .select { font-size: 16px; min-height: 42px; }
  .btn-xs, .seg-btn { min-height: 32px; }
  .pill { padding: 7px 12px; }

  .card { padding: 16px; }
  .toolbar.card, .table-card { padding: 0; }
  .card-header { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { padding: 12px 14px 14px; }
  .kpi-val { font-size: 22px; }
  .bucket-row { grid-template-columns: 84px 1fr auto; gap: 10px; font-size: 12.5px; }
  .bar-chart { gap: 4px; }
  .bar-val { font-size: 9.5px; }

  /* Filters scroll sideways instead of wrapping into a wall */
  .toolbar-row .search-input { flex-basis: 100%; }
  .toolbar-row .select { flex: 1; }
  .filter-pills { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .filter-pills::-webkit-scrollbar { display: none; }
  .pill { flex-shrink: 0; }
  .new-hero-controls { width: 100%; }
  .new-hero-controls > * { flex: 1 1 100%; }
  .new-hero > *, .new-hero-controls .select { min-width: 0; max-width: 100%; }
  .inline-form { flex-wrap: wrap; }
  .inline-form .btn { flex: 1; }

  /* Tables: keep the essential columns */
  .data-table th, .data-table td { padding: 12px 10px; }
  .data-table th:first-child, .data-table td:first-child { padding-left: 14px; }
  .data-table th:last-child, .data-table td:last-child { padding-right: 14px; }
  #view-publishers .data-table :is(th, td):is(:nth-child(2), :nth-child(4), :nth-child(5), :nth-child(7), :nth-child(8)),
  #view-new-publishers .data-table :is(th, td):is(:nth-child(2), :nth-child(5), :nth-child(6)),
  #view-imports .data-table :is(th, td):is(:nth-child(2), :nth-child(5), :nth-child(6), :nth-child(7), :nth-child(8)) { display: none; }
  .pub-avatar { width: 28px; height: 28px; }
  .data-table td:first-child { max-width: 0; width: 100%; }
  .pub-cell, .pub-cell > div { min-width: 0; }
  .pub-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pub-name .badge { margin-left: 4px; }
  .table-meta { flex-wrap: wrap; padding: 10px 14px; }

  /* Drawer and modal go full-screen / bottom sheet */
  .drawer { inset: 0; width: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .drawer-header { padding: 16px; }
  .drawer-header .btn-icon, .modal-header .btn-icon { width: 40px; height: 40px; }
  body:has(.drawer:not(.hidden)), body:has(.modal-backdrop:not(.hidden)) { overflow: hidden; }
  .drawer-body { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
  .drawer-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-articles-bar { flex-wrap: wrap; }
  .drawer-articles-bar .input { flex: 1 1 100%; }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }

  /* Floating job bar sits above the tab bar */
  .job-banner { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast-container { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
}
