/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #0a0c10;
  --surface: #111420;
  --surface2: #181d2e;
  /* aliases for admin template */
  --bg2: #111420;
  --bg3: #181d2e;
  --border2: #252d45;
  --accent2: #ef4444;
  --accent3: #3ecf8e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --mono: "JetBrains Mono", "Fira Code", monospace;
  --border: #1e2540;
  --border2: #252d45;
  --accent: #4f8ef7;
  --accent2: #ef4444;
  --yt: #ff4444;
  --green: #3ecf8e;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted2: #64748b;
  --warn: #f59e0b;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-size: inherit; font-family: var(--font); }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.navbar-inner {
  max-width: 1600px; margin: 0 auto; padding: 0 24px;
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.brand-sub { font-size: 10px; color: var(--muted2); text-transform: uppercase; letter-spacing: 0.06em; }
.logo-version {
  font-size: 10px;
  color: var(--muted2);
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  line-height: 1;
}

.nav-links {
  display: flex; align-items: center; gap: 4px; justify-content: center;
}
.nav-links a {
  color: var(--muted); padding: 6px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500; transition: all .15s;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text); background: var(--border); text-decoration: none;
}
.nav-links a.active { color: var(--accent); }
.kw-pill { font-weight: 600; }

.nav-link-with-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pending-indicator {
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(245, 158, 11, .22);
  border: 1px solid rgba(245, 158, 11, .65);
  color: #f59e0b;
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-weight: 700;
}

.nav-right {
  display: flex; align-items: center; gap: 12px; justify-content: flex-end;
}
.nav-user { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.badge-blue { background: rgba(79,142,247,.12); color: var(--accent); border-color: rgba(79,142,247,.3); }

.status-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.status-text { font-size: 12px; }

/* ── Dot / Pulse ──────────────────────────────────────────── */
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted2); display: inline-block; flex-shrink: 0;
}
.dot.pulsing {
  background: var(--green);
  animation: pulse 1s ease-in-out infinite;
}
.dot.error {
  background: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(0.8); }
}

/* ── Container ────────────────────────────────────────────── */
.container { max-width: 1600px; margin: 0 auto; padding: 24px; }

/* ── Dashboard Hero ───────────────────────────────────────── */
.dashboard-hero { padding: 28px 0 16px; }
.dashboard-hero h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.dashboard-hero p { color: var(--muted); margin-top: 6px; font-size: 13px; }

.dashboard-refresh-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, .45);
  background: rgba(245, 158, 11, .12);
  color: #fcd34d;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-refresh-notice strong {
  color: #fde68a;
}

.dashboard-refresh-notice .btn {
  margin-left: auto;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin: 20px 0;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h2 { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
}
.badge-green { background: rgba(62,207,142,.12); color: var(--green); border-color: rgba(62,207,142,.3); }
.badge-gray { background: var(--surface2); color: var(--muted); border-color: var(--border2); }
.badge-type { font-size: 10px; }
.badge-article { background: rgba(79,142,247,.12); color: var(--accent); border-color: rgba(79,142,247,.3); }
.badge-youtube { background: rgba(255,68,68,.12); color: var(--yt); border-color: rgba(255,68,68,.3); }
.badge-cat { background: var(--surface2); color: var(--muted); font-size: 10px; border-color: var(--border); }

/* ── Keyword Manager ──────────────────────────────────────── */
.keyword-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.keyword-row:last-child { border-bottom: none; }
.kw-info { display: flex; flex-direction: column; gap: 4px; }
.kw-name { font-size: 14px; font-weight: 600; color: var(--text); }
.kw-name:hover { color: var(--accent); text-decoration: none; }
.kw-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kw-count, .kw-time { font-size: 12px; color: var(--muted); }
.kw-source-debug {
  font-size: 11px;
  color: var(--muted2);
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
.kw-source-debug strong { color: var(--text); font-weight: 600; }
.kw-actions { display: flex; gap: 8px; }
.empty-hint, .limit-note { color: var(--muted); font-size: 13px; padding: 12px 0; }

.keyword-admin-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface2) 40%, transparent);
  padding: 12px;
}

.keyword-admin-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.keyword-metric-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface2) 60%, transparent);
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.keyword-metric-value {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--mono);
}

.keyword-metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.keyword-admin-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.keyword-search-input,
.keyword-sort-select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  padding: 7px 10px;
}

.keyword-search-input {
  flex: 1;
  min-width: 220px;
}

.keyword-sort-select {
  min-width: 180px;
}

.keyword-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.keyword-bucket-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.keyword-bucket {
  border: 1px solid var(--border2);
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

.keyword-bucket.active {
  border-color: rgba(79,142,247,.45);
  color: var(--accent);
  background: rgba(79,142,247,.12);
}

.keyword-owner-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .keyword-admin-stats {
    grid-template-columns: 1fr;
  }
}

.keyword-owner-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--surface2) 50%, transparent);
}

.keyword-owner-accordion {
  padding: 0;
}

.keyword-owner-accordion[open] {
  box-shadow: inset 0 0 0 1px rgba(79, 142, 247, .12);
}

.keyword-owner-group:last-child {
  margin-bottom: 0;
}

.keyword-owner-group-mine {
  border-color: rgba(62, 207, 142, .5);
  background: rgba(62, 207, 142, .08);
}

.keyword-owner-group-other {
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface2) 58%, transparent);
}

.keyword-owner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px dashed transparent;
  list-style: none;
  cursor: pointer;
}

.keyword-owner-header::-webkit-details-marker {
  display: none;
}

.keyword-owner-accordion[open] > .keyword-owner-header {
  border-bottom-color: var(--border);
}

.keyword-owner-header h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.keyword-owner-meta {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.keyword-owner-preview {
  color: var(--muted2);
  font-size: 11px;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keyword-owner-body {
  padding: 0 14px 12px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 10px;
}

.keyword-form-inline {
  margin-top: 12px;
}

/* Keyword add form */
.keyword-form { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.keyword-form input {
  flex: 1; min-width: 220px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); padding: 9px 12px; font-size: 13px; font-family: var(--font); outline: none;
  transition: border-color .15s;
}
.keyword-form input::placeholder { color: var(--muted2); }
.keyword-form input:focus { border-color: var(--accent); }
.form-error { color: var(--accent2); font-size: 12px; margin-top: 8px; }
.hidden { display: none; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { padding: 8px 16px; border-radius: 6px; font-weight: 600; font-size: 13px; font-family: var(--font); cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--accent); color: #fff; border: none; }
.btn-primary:hover { background: #6ba3f9; }
.btn-outline { border: 1px solid var(--border2); color: var(--muted); background: transparent; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { border: 1px solid rgba(239,68,68,.3); color: #fca5a5; background: rgba(239,68,68,.12); }
.btn-danger:hover { background: rgba(239,68,68,.2); border-color: rgba(239,68,68,.5); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Summary Grid ─────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin: 20px 0;
}
.summary-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; transition: border-color .15s, transform .1s;
  text-decoration: none; display: block;
}
.summary-card:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.sc-keyword { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.sc-count { font-size: 38px; font-weight: 700; color: var(--accent); line-height: 1; font-family: var(--mono); }
.sc-label { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.sc-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.sc-progress { margin-bottom: 8px; }
.sc-progress-bar { height: 4px; background: var(--border2); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.sc-progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 2px; transition: width .4s ease; }
.sc-progress-text { font-size: 11px; color: var(--accent); font-family: var(--mono); }

/* ── Live Log ─────────────────────────────────────────────── */
.live-log {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
}
.live-log .card-header {
  flex-shrink: 0;
}
.log-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.log-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.log-item:last-child { border-bottom: none; }
.log-item.hint { font-style: italic; }
.log-item .log-kw { font-weight: 700; color: var(--accent); cursor: pointer; }
.log-item .log-kw:hover { text-decoration: underline; }
.log-item .log-time { margin-left: auto; font-size: 11px; white-space: nowrap; font-family: var(--mono); color: var(--muted2); }
.log-new { animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

/* ── Feed Page ────────────────────────────────────────────── */
.feed-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 28px 0 16px; flex-wrap: wrap; gap: 12px; }
.feed-title { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; letter-spacing: -0.02em; }
.feed-kw { text-transform: capitalize; }
.feed-badge { font-size: 11px; }
.feed-sub { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Filters ──────────────────────────────────────────────── */
.filters {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 20px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group span { font-size: 11px; color: var(--muted2); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.filter-group select {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); padding: 7px 10px; font-size: 13px; font-family: var(--font); outline: none; cursor: pointer;
  transition: border-color .15s;
}
.filter-group select:focus { border-color: var(--accent); }

/* ── Tiles Grid ───────────────────────────────────────────── */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

/* ── Tile ─────────────────────────────────────────────────── */
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.tile:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: var(--shadow); }
.tile-thumb { position: relative; display: block; width: 100%; height: 0; padding-bottom: 56.25%; overflow: hidden; }
.tile-thumb img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.tile:hover .tile-thumb img { transform: scale(1.03); }
.yt-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; background: rgba(0,0,0,.7); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; pointer-events: none;
}
.tile-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tile-meta-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile-title { font-size: 13px; font-weight: 600; line-height: 1.5; }
.tile-title a { color: var(--text); }
.tile-title a:hover { color: var(--accent); text-decoration: none; }
.tile-blurb { font-size: 12px; color: var(--muted); line-height: 1.6; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; flex-wrap: wrap; }
.tile-source { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.tile-time { font-size: 11px; color: var(--muted2); font-family: var(--mono); }
.tile-yt .tile-body { padding-top: 14px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.empty-state p { margin-bottom: 8px; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .navbar-inner { grid-template-columns: auto 1fr auto; }
  .nav-links { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .tiles-grid { grid-template-columns: 1fr; }
  .navbar-inner { padding: 0 12px; gap: 8px; }
  .brand-sub { display: none; }
  .logo-version { display: none; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .status-text { display: none; }
}

/* ── Admin layout ─────────────────────────────────────────── */
.main-content { max-width: 1600px; margin: 0 auto; padding: 24px; }

.page-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-hero-text h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-hero-text p { color: var(--muted); font-size: 13px; }

/* ── Admin tabs ───────────────────────────────────────────── */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.admin-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent; border-bottom: none;
  text-decoration: none; transition: color .15s, background .15s, border-color .15s;
  position: relative; bottom: -1px;
}
.admin-tab:hover { color: var(--text); text-decoration: none; }
.admin-tab.active { background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface); color: var(--text); }
.admin-tab-icon { font-size: 13px; }
.tab-actions-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ── Panel ────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.panel-icon { color: var(--accent); font-size: 14px; }
.count-badge { font-size: 11px; background: var(--surface2); color: var(--muted); padding: 2px 8px; border-radius: 20px; }
.filter-badge { font-size: 11px; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 20px; font-weight: 500; }

/* ── Stat pills ───────────────────────────────────────────── */
.stat-pill { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; display: flex; gap: 5px; align-items: center; }
.stat-num { font-weight: 700; color: var(--accent); font-size: 13px; }
.stat-label { color: var(--muted2); font-size: 12px; }

/* ── Settings bar ─────────────────────────────────────────── */
.settings-bar { padding: 14px 20px; }
.settings-bar-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.settings-label { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.settings-interval-row { display: flex; align-items: center; gap: 8px; }
.settings-interval-input {
  width: 72px; padding: 6px 10px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); font-size: 13px; font-family: var(--mono); text-align: center;
}
.settings-interval-input:focus { outline: none; border-color: var(--accent); }
.settings-unit { font-size: 13px; color: var(--muted2); }
.settings-hint { font-size: 12px; color: var(--muted2); }
.btn-add-source {
  padding: 9px 18px; background: var(--accent); color: #fff; border: none; border-radius: 7px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: background .15s;
  white-space: nowrap; flex-shrink: 0;
}
.btn-add-source:hover { background: #6ba3f9; }

/* ── Sources nav ──────────────────────────────────────────── */
.sources-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }
.sources-nav-chip {
  padding: 5px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12px; color: var(--muted); transition: all .15s;
}
.sources-nav-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.sources-sections { display: flex; flex-direction: column; gap: 20px; }
.sources-section { }
.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0; }

/* ── Source card ──────────────────────────────────────────── */
.source-card { padding: 10px 14px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; position: relative; }
.source-card:hover { background: var(--surface2); }
.source-card:hover .source-card-actions { opacity: 1; }
.source-card-header { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.source-card-name { font-size: 12px; font-weight: 600; color: var(--text); }
.source-card-badges { display: flex; gap: 4px; align-items: center; }
.source-url { font-size: 10px; color: var(--muted2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-url:hover { color: var(--accent); }
.badge-custom  { background: rgba(124,90,240,.15); color: #a78bfa; border-color: rgba(124,90,240,.3); }
.badge-region  { background: rgba(62,207,142,.12); color: var(--green); border-color: rgba(62,207,142,.3); }
.badge-kw      { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; border: 1px solid rgba(79,142,247,.3); background: rgba(79,142,247,.1); color: var(--accent); font-family: var(--mono); }
.badge-kw-regex { border-color: rgba(168,85,247,.4); background: rgba(168,85,247,.12); }
.regex-badge { font-size: 8px; font-weight: 700; text-transform: uppercase; color: #d946ef; margin-left: 3px; letter-spacing: 0.5px; opacity: 0.8; }
.sources-summary { display: flex; gap: 8px; align-items: center; }
.source-card-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; margin-top: 2px; }
.source-error-msg { font-size: 10px; color: var(--danger); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-card:has(.source-error-msg) .source-card-actions { opacity: 1; }

/* ── Icon buttons ─────────────────────────────────────────── */
.btn-icon { padding: 3px 7px; background: transparent; border: 1px solid var(--border2); border-radius: 4px; font-size: 11px; cursor: pointer; font-family: var(--font); transition: all .12s; line-height: 1.4; }
.btn-edit { color: var(--accent); }
.btn-edit:hover { background: rgba(79,142,247,.12); border-color: var(--accent); }
.btn-delete { color: var(--danger); }
.btn-delete:hover { background: rgba(239,68,68,.12); border-color: var(--danger); }
.btn-retry { color: var(--warn); }
.btn-retry:hover { background: rgba(245,158,11,.12); border-color: var(--warn); }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: background .12s; }
.btn-primary:hover { background: #6ba3f9; }
.btn-primary:disabled,
.btn-outline:disabled,
.btn-secondary:disabled,
.btn-sm:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-secondary { padding: 8px 16px; background: transparent; border: 1px solid var(--border2); color: var(--muted); border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: all .12s; }
.btn-secondary:hover { background: var(--surface2); color: var(--text); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 24px; backdrop-filter: blur(4px); }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 12px; width: 100%; max-width: 480px; box-shadow: 0 24px 60px rgba(0,0,0,.6); animation: modalIn .18s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted2); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1; font-family: var(--font); }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--muted); }
.form-group label .required { color: var(--danger); }
.form-group input { background: var(--surface2); border: 1px solid var(--border2); color: var(--text); padding: 9px 12px; border-radius: 7px; font-size: 13px; font-family: var(--font); outline: none; transition: border-color .15s; }
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--muted2); }
.form-error { font-size: 12px; color: var(--danger); background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); border-radius: 6px; padding: 8px 12px; }
.form-error.hidden { display: none; }
.form-hint { font-size: 11px; color: var(--muted); display: block; margin-top: 4px; }
code { background: var(--surface2); border: 1px solid var(--border2); color: var(--accent); padding: 2px 6px; border-radius: 3px; font-family: var(--mono); font-size: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }

/* confirm modal */
.confirm-modal { text-align: center; max-width: 380px; padding: 32px 28px; }
.confirm-modal-icon { font-size: 32px; margin-bottom: 12px; line-height: 1; }
.confirm-modal-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.confirm-modal-body { font-size: 14px; color: var(--muted); line-height: 1.55; margin-bottom: 24px; }

/* ── Status dots (admin dot variants) ────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted2); display: inline-block; flex-shrink: 0; }
.status-dot.pulsing { background: var(--green); animation: pulse 1s ease-in-out infinite; }
.dot-fetching { color: var(--accent); }
.dot-done     { color: var(--green); }
.dot-error    { color: var(--danger); }
.dot-pending  { color: var(--muted2); }

/* ── Crawl monitor ────────────────────────────────────────── */
.crawl-header-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.crawl-summary { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.crawl-header-actions { display: flex; align-items: center; gap: 14px; }
.interval-control { display: flex; align-items: center; gap: 6px; }
.interval-label { font-size: 12px; color: var(--muted); }
.interval-input { width: 60px; background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); font-size: 13px; padding: 4px 8px; text-align: center; }
.interval-input:focus { outline: none; border-color: var(--accent); }
.crawl-live-indicator { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.crawl-panel { padding: 0; overflow: hidden; }
.crawl-filter-bar { display: flex; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.crawl-filter-option { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.crawl-filter-sep { color: var(--border2); }
.crawl-search-input { background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); font-size: 13px; padding: 4px 10px; width: 200px; outline: none; }
.crawl-search-input:focus { border-color: var(--accent); }

.crawl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crawl-table thead th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted2); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.crawl-row td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.crawl-row:last-child td { border-bottom: none; }
.crawl-row-fetching { background: rgba(79,142,247,.04); }
.crawl-row-error    { background: rgba(239,68,68,.04); }
.crawl-source-name { font-weight: 500; color: var(--text); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crawl-url         { color: var(--muted2); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.crawl-url-link    { color: var(--muted2); }
.crawl-url-link:hover { color: var(--accent); text-decoration: underline; }
.crawl-count       { color: var(--muted); text-align: right; width: 70px; }
.crawl-time        { color: var(--muted2); font-size: 12px; white-space: nowrap; font-family: var(--mono); }
.crawl-error-cell  { max-width: 300px; }
.crawl-error-text  { color: var(--danger); font-size: 12px; word-break: break-all; }

.cs-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.cs-fetching { background: rgba(79,142,247,.15);  color: var(--accent); }
.cs-done     { background: rgba(62,207,142,.15);  color: var(--green); }
.cs-error    { background: rgba(239,68,68,.15);   color: var(--danger); }
.cs-pending  { background: rgba(100,116,139,.12); color: var(--muted2); }

/* ── Toast ────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface); border: 1px solid var(--border2); border-radius: 8px; padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow); z-index: 999; transition: all .3s; max-width: 320px; }
.toast.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.info    { border-color: var(--accent); color: var(--accent); }
.toast.error   { border-color: var(--danger); color: var(--danger); }

/* mono utility */
.mono { font-family: var(--mono); }

/* ── Alerts tab ───────────────────────────────────────────── */
.alerts-header-bar { padding: 12px 24px; }
.alerts-intro { color: var(--muted); font-size: 13px; max-width: 700px; }
.alerts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; padding: 0 24px 32px; }
.alert-card { padding: 20px; }
.alert-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 6px; }
.alert-card-title { display: flex; align-items: center; gap: 8px; }
.alert-kw-badge { background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 10px; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.alert-status-badge { font-size: 11px; border-radius: 20px; padding: 2px 8px; font-weight: 600; }
.alert-active { background: rgba(62,207,142,.15); color: var(--green); border: 1px solid rgba(62,207,142,.3); }
.alert-disabled { background: rgba(100,116,139,.12); color: var(--muted); border: 1px solid var(--border); }
.alert-none { background: var(--surface2); color: var(--muted2); border: 1px solid var(--border); }
.alert-last-triggered { font-size: 11px; color: var(--muted2); }
.alert-section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.alert-history-section { margin-bottom: 16px; }
.alert-history-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.alert-rec-pill { font-size: 12px; color: var(--warn); display: flex; align-items: center; gap: 6px; }
.alert-rec-pill.muted { color: var(--muted2); }
.btn-apply-rec { font-size: 10px; padding: 2px 7px; }
.btn-xs { font-size: 10px; padding: 2px 7px; }
.sparkline-wrap { height: 64px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface2); }
.sparkline-svg { display: block; }
.sparkline-empty { height: 40px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted2); border: 1px dashed var(--border); border-radius: 6px; }
/* bar chart */
.barchart-wrap { height: 88px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface2); }
.barchart-svg { display: block; }
/* anomaly stats row */
.anomaly-stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.anomaly-stat-pill { font-size: 11px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 2px 8px; color: var(--muted); }
.anomaly-stat-pill strong { color: var(--text); }
.anomaly-stat-high { border-color: rgba(239,68,68,.45); color: #ef4444; background: rgba(239,68,68,.08); }
.anomaly-stat-high strong { color: #ef4444; }
.alert-anomaly { background: rgba(239,68,68,.12); color: #ef4444; border: 1px solid rgba(239,68,68,.35); }
.alert-threshold-form { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.alert-form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.form-group-sm { flex: 1 1 120px; }
.form-group-sm label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.form-group-sm input[type="number"] { width: 100%; background: var(--surface); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; }
.form-group-toggle { display: flex; flex-direction: column; align-items: flex-start; }
.alert-form-actions { display: flex; gap: 8px; }
/* toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; margin-top: 2px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border2); border-radius: 20px; transition: .2s; cursor: pointer; }
.toggle-slider:before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: rgba(62,207,142,.25); }
.toggle-switch input:checked + .toggle-slider:before { background: var(--green); transform: translateX(16px); }
/* actions list */
.alert-actions-section { margin-top: 4px; }
.alert-actions-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.alert-action-row { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; }
.action-type-icon { font-size: 14px; }
.action-label { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-type-badge { font-size: 10px; background: var(--bg); border: 1px solid var(--border2); border-radius: 4px; padding: 1px 6px; color: var(--muted); flex-shrink: 0; }
.action-row-btns { display: flex; gap: 4px; flex-shrink: 0; }
.muted-hint { font-size: 12px; color: var(--muted2); margin-top: 8px; }
/* wide modal variant */
.modal-wide { max-width: 560px; }


/* ── Confirm modal ────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 12px; padding: 28px 28px 22px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.modal-title { font-size: 16px; font-weight: 700; margin: 0 0 10px; color: var(--text); }
.modal-body  { font-size: 14px; color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }

/* ── Users table ──────────────────────────────────────────── */
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table thead th { text-align: left; padding: 10px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted2); border-bottom: 1px solid var(--border); }
.users-table tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tbody tr:last-child td { border-bottom: none; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.cell-muted { font-size: 12px; color: var(--muted); }
.cell-actions { display: flex; gap: 6px; }
.badge-google { font-size: 10px; font-weight: 700; color: #4285F4; background: rgba(66,133,244,.12); border: 1px solid rgba(66,133,244,.3); border-radius: 4px; padding: 1px 5px; flex-shrink: 0; }
.pending-panel { margin-bottom: 16px; border-left: 3px solid #f97316; }
.pending-title { color: #f97316 !important; }

/* ── Nav user widget ──────────────────────────────────────── */
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border2); flex-shrink: 0; }
.user-avatar-placeholder { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ── Login page ───────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.login-logo-icon { font-size: 24px; }
.login-logo-text { font-size: 22px; font-weight: 700; color: var(--text); }
.login-subtitle { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 24px; }
.login-desc { font-size: 14px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }
.login-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; text-align: left; line-height: 1.5; }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 12px; background: #fff; color: #3c4043; border: 1px solid #dadce0; border-radius: 8px; padding: 11px 20px; font-size: 14px; font-weight: 500; font-family: var(--font); cursor: pointer; text-decoration: none; transition: box-shadow .15s, background .15s; width: 100%; }
.btn-google:hover { background: #f8f9fa; box-shadow: 0 2px 8px rgba(0,0,0,.25); text-decoration: none; }
.google-icon { width: 18px; height: 18px; flex-shrink: 0; }
