/* ─── Reset & Variables ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --topbar-h: 52px;

  /* Sidebar – deep indigo-navy */
  --sb-bg:          #1a2d4e;
  --sb-bg-hover:    rgba(255,255,255,.06);
  --sb-bg-active:   rgba(255,255,255,.12);
  --sb-border:      rgba(255,255,255,.08);
  --sb-text:        #94aecb;
  --sb-text-active: #ffffff;
  --sb-logo:        #60a5fa;

  /* Main area */
  --bg:        #f0f4f8;
  --bg-card:   #ffffff;
  --bg-topbar: #ffffff;
  --border:    #e2e8f0;
  --border-md: #cbd5e1;

  /* Text */
  --text:    #1e293b;
  --text-2:  #475569;
  --text-3:  #94a3b8;

  /* Accents */
  --blue:   #2563eb;
  --green:  #16a34a;
  --amber:  #d97706;
  --violet: #7c3aed;
  --teal:   #0891b2;
  --orange: #c2410c;
  --red:    #dc2626;

  /* Misc */
  --radius:    6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Layout ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex; flex-direction: column;
  z-index: 200;
  border-right: 1px solid var(--sb-border);
}
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow-sm);
}
.content {
  flex: 1;
  padding: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.content--wide {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* ─── Sidebar internals ────────────────────────────────────────────────── */
.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  padding: 0 18px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--sb-border);
  font-size: 0.95rem; font-weight: 600; color: var(--sb-text-active);
  flex-shrink: 0;
}
.sidebar-logo svg { color: var(--sb-logo); flex-shrink: 0; }

.sidebar-nav { padding: 12px 8px; flex: 1; overflow-y: auto; }
.nav-section-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--sb-text);
  padding: 4px 10px 6px;
  opacity: .6;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius);
  color: var(--sb-text); text-decoration: none;
  font-size: 0.875rem; font-weight: 450;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-item:hover  { background: var(--sb-bg-hover);  color: var(--sb-text-active); }
.nav-item.active { background: var(--sb-bg-active); color: var(--sb-text-active); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-badge {
  font-size: 0.7rem; color: var(--sb-text);
  background: rgba(255,255,255,.07); border-radius: 4px;
  padding: 2px 7px; display: inline-block; margin-bottom: 4px;
}
.sidebar-date { font-size: 0.7rem; color: var(--sb-text); opacity: .6; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 190;
}

/* ─── Topbar internals ─────────────────────────────────────────────────── */
.topbar-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-2); padding: 4px; border-radius: var(--radius);
  flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--bg); }
.topbar-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); flex: 1; }
.topbar-right { margin-left: auto; }
.topbar-env-badge {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; padding: 2px 8px; border-radius: 999px;
  background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
}

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.summary-card { padding: 16px 18px; }
.card-label { font-size: 0.75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.card-value  { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.card-value-sm { font-size: 0.8125rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-top:2px; }
.card-sub    { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }
.accent-violet { color: var(--violet) !important; }
.accent-teal   { color: var(--teal)   !important; }
.accent-orange { color: var(--orange) !important; }

/* ─── Filters ──────────────────────────────────────────────────────────── */
.filters-bar { padding: 12px 16px; margin-bottom: 14px; }
.filters-row {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group--search { flex: 1; min-width: 180px; }
.filter-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

.filter-select, .filter-input {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: #fff; color: var(--text);
  font-family: var(--font); font-size: 0.8125rem;
  outline: none; transition: border-color .15s, box-shadow .15s;
  min-width: 120px;
}
.filter-select:focus, .filter-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.search-wrapper { position: relative; }
.search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-input { padding-left: 30px; width: 100%; }

.btn-reset {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: #fff; color: var(--text-2);
  font-family: var(--font); font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; align-self: flex-end;
  transition: background .15s, border-color .15s;
}
.btn-reset:hover { background: var(--bg); border-color: var(--border); }

/* ─── Table card ───────────────────────────────────────────────────────── */
.table-card { overflow: hidden; }
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8125rem;
}
.data-table thead th {
  padding: 10px 12px 9px;
  text-align: left; white-space: nowrap;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
  cursor: pointer;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table td {
  padding: 9px 12px;
  vertical-align: middle;
  color: var(--text);
}
.col-rank   { width: 36px; text-align: center; }
.col-scope  { width: 90px; }
.col-role   { width: 130px; }
.col-geo    { width: 90px; }
.col-niche  { width: 90px; }
.col-landing{ max-width: 140px; }
.col-pattern{ max-width: 130px; }
.col-form   { max-width: 100px; }
.col-num    { width: 80px; text-align: right; }
.col-action { width: 70px; text-align: center; }

.cell-truncate {
  max-width: 100%; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; display: block;
}
.cell-rank {
  display: inline-flex; width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg);
  font-size: 0.6875rem; font-weight: 700; color: var(--text-2);
  margin: 0 auto;
}
.cell-num { font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
.cell-num.green { color: var(--green); }
.cell-num.red   { color: var(--red); }

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem; color: var(--text-3);
}

/* ─── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 0.6875rem; font-weight: 600;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap; vertical-align: middle;
}
.badge-core    { background: #dcfce7; color: #15803d; }
.badge-review  { background: #dbeafe; color: #1d4ed8; }
.badge-test    { background: #fef3c7; color: #92400e; }
.badge-all     { background: #ede9fe; color: #6d28d9; }
.badge-t1      { background: #cffafe; color: #0e7490; }
.badge-t2      { background: #fef9c3; color: #854d0e; }
.badge-launch  { background: #dcfce7; color: #15803d; }
.badge-review2 { background: #dbeafe; color: #1d4ed8; }
.badge-manual  { background: #fef3c7; color: #92400e; }
.badge-reject  { background: #fee2e2; color: #991b1b; }
.badge-test2   { background: #f3f4f6; color: #374151; }

/* ─── Detail button ────────────────────────────────────────────────────── */
.btn-detail {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 0.75rem; font-weight: 500;
  border: 1px solid var(--border-md); border-radius: var(--radius);
  background: #fff; color: var(--text-2); cursor: pointer;
  white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  font-family: var(--font);
}
.btn-detail:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ─── States ───────────────────────────────────────────────────────────── */
.state-loading, .state-error, .state-empty {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 48px 24px;
  color: var(--text-3); font-size: 0.875rem;
}
.state-error { color: var(--red); }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-md);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ─── Mobile cards ─────────────────────────────────────────────────────── */
.mobile-cards { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.mobile-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; background: #fff;
}
.mc-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.mc-rank {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; color: var(--text-2);
  flex-shrink: 0; margin-top: 1px;
}
.mc-title { flex: 1; }
.mc-geo-niche { font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.mc-landing   { font-size: 0.75rem; color: var(--text-2); margin-top: 2px; }
.mc-badges    { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.mc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 10px;
}
.mc-field { font-size: 0.6875rem; }
.mc-field-label { color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 1px; }
.mc-field-value { color: var(--text); }
.mc-risk {
  background: #fef9f0; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: 7px 10px; font-size: 0.75rem; color: var(--amber); margin-bottom: 10px;
}
.mc-action { display: flex; justify-content: flex-end; }

/* ─── Drawer ───────────────────────────────────────────────────────────── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 300;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 310;
  width: 460px; max-width: 100vw;
  background: #fff; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  transform: translateX(0);
  overflow: hidden;
}
.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { flex: 1; font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.drawer-close {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 5px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.drawer-close:hover { background: var(--bg); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* Drawer content sections */
.d-section { margin-bottom: 20px; }
.d-section-title {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-field {}
.d-field-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .05em; }
.d-field-value { font-size: 0.8125rem; color: var(--text); word-break: break-word; }
.d-field-value.mono { font-family: var(--font-mono); font-size: 0.75rem; }
.d-field--full { grid-column: 1 / -1; }
.d-text-block {
  background: var(--bg); border-radius: var(--radius);
  padding: 10px 12px; font-size: 0.8125rem; color: var(--text-2);
  line-height: 1.5; grid-column: 1 / -1;
}
.d-metric-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
.d-metric-row:last-child { border-bottom: none; }
.d-metric-label { color: var(--text-2); }
.d-metric-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.d-metric-value.green { color: var(--green); }
.d-metric-value.red   { color: var(--red); }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  body.sidebar-open .sidebar          { transform: translateX(0); box-shadow: var(--shadow-md); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .main-wrapper { margin-left: 0; }
  .topbar-hamburger { display: flex; align-items: center; }
  .content { padding: 14px; }

  .summary-cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .card-value { font-size: 1.5rem; }

  .filters-row { gap: 8px; }
  .filter-select, .filter-input { min-width: 0; width: 100%; }
  .filter-group { width: calc(50% - 4px); }
  .filter-group--search { width: 100%; }
  .btn-reset { width: 100%; }

  /* Hide desktop table, show mobile cards */
  .table-wrapper { display: none !important; }
  .mobile-cards  { display: flex !important; }

  .drawer { width: 100vw; }
}

@media (min-width: 769px) {
  .mobile-cards { display: none !important; }
}

@media (max-width: 480px) {
  .summary-cards { grid-template-columns: 1fr; }
  .filter-group  { width: 100%; }
}

/* ─── Cluster list ─────────────────────────────────────────────────────────── */
.cluster-list {
  display: flex; flex-direction: column; gap: 10px;
}

.cluster-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.cluster-card:hover { border-color: var(--blue); box-shadow: 0 2px 8px rgba(37,99,235,.1); }

.cc-top {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px;
}
.cc-ids { flex: 1; min-width: 0; }
.cc-id-main {
  font-size: 0.8125rem; font-weight: 600; color: var(--text);
  font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cc-id-legacy { font-size: 0.6875rem; color: var(--text-3); margin-top: 1px; }
.cc-badges { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }

.cc-preview {
  font-size: 0.8125rem; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}

.cc-meta {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.cc-meta-item { font-size: 0.75rem; }
.cc-meta-label { color: var(--text-3); display: block; }
.cc-meta-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.cc-meta-value.green { color: var(--green); }
.cc-meta-value.red   { color: var(--red);   }

.cc-bottom {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.cc-bottom-left  { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cc-img-coverage { font-size: 0.6875rem; color: var(--text-3); }
.cc-img-coverage.warn { color: var(--amber); font-weight: 600; }

.load-more-row {
  display: flex; justify-content: center; padding: 16px 0;
}
.btn-load-more {
  padding: 8px 24px; font-size: 0.875rem; font-weight: 500;
  border: 1px solid var(--border-md); border-radius: var(--radius);
  background: #fff; color: var(--text-2); cursor: pointer;
  font-family: var(--font); transition: background .15s, border-color .15s;
}
.btn-load-more:hover { background: var(--bg); }

/* ─── Drawer wide variant ──────────────────────────────────────────────────── */
.drawer--wide { width: 560px; }
@media (max-width: 768px) { .drawer--wide { width: 100vw; } }

/* ─── Drawer tabs ──────────────────────────────────────────────────────────── */
.drawer-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
.drawer-tabs::-webkit-scrollbar { display: none; }
.dtab {
  padding: 10px 14px; font-size: 0.8125rem; font-weight: 500;
  border: none; background: none; cursor: pointer;
  color: var(--text-3); border-bottom: 2px solid transparent;
  white-space: nowrap; font-family: var(--font);
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.dtab:hover { color: var(--text); }
.dtab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ─── Text examples ────────────────────────────────────────────────────────── */
.text-example {
  background: var(--bg); border-radius: var(--radius);
  padding: 10px 12px; font-size: 0.8125rem; color: var(--text-2);
  line-height: 1.5; margin-bottom: 8px; border: 1px solid var(--border);
  position: relative;
}
.text-example.collapsed {
  max-height: 4.5em; overflow: hidden;
}
.text-example-toggle {
  font-size: 0.6875rem; color: var(--blue); cursor: pointer;
  margin-top: 4px; display: inline-block; background: none; border: none;
  font-family: var(--font); padding: 0;
}

/* ─── Creatives grid ───────────────────────────────────────────────────────── */
.creatives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
@media (max-width: 480px) {
  .creatives-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

.creative-thumb {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--bg);
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.creative-thumb:hover { border-color: var(--blue); box-shadow: 0 2px 8px rgba(37,99,235,.12); }

.thumb-img-wrap {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  background: var(--bg); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.thumb-img {
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity .2s;
}
.thumb-img.loading { opacity: 0; }
.thumb-img.loaded  { opacity: 1; }
.thumb-missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--text-3); font-size: 0.6875rem; padding: 12px;
  text-align: center;
}
.thumb-missing svg { color: var(--amber); }
.thumb-status-badge {
  position: absolute; bottom: 4px; left: 4px;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; text-transform: uppercase; letter-spacing: .04em;
}
.tsb-local    { background: #dcfce7; color: #15803d; }
.tsb-research { background: #dbeafe; color: #1d4ed8; }
.tsb-remote   { background: #fef3c7; color: #92400e; }
.tsb-missing  { background: #fee2e2; color: #991b1b; }

.thumb-info {
  padding: 6px 8px;
}
.thumb-adid    { font-size: 0.6875rem; font-family: var(--font-mono); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-metrics { font-size: 0.6875rem; color: var(--text-3); margin-top: 2px; }
.thumb-metrics.green { color: var(--green); }
.thumb-metrics.red   { color: var(--red); }
.thumb-landing { font-size: 0.6875rem; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Placements table in drawer ───────────────────────────────────────────── */
.placement-table {
  width: 100%; border-collapse: collapse; font-size: 0.8125rem;
}
.placement-table th {
  padding: 7px 10px; text-align: left;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); background: var(--bg); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.placement-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top;
}
.placement-table tr:last-child td { border-bottom: none; }
.placement-table .col-right { text-align: right; font-variant-numeric: tabular-nums; }

/* Placement mobile cards */
.placement-cards { display: flex; flex-direction: column; gap: 8px; }
.placement-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--bg); font-size: 0.8125rem;
}
.pc-landing { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.pc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.pc-field-label { font-size: 0.6875rem; color: var(--text-3); text-transform: uppercase; font-weight: 600; }
.pc-field-value { font-size: 0.8125rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* ─── Historical Baselines page ────────────────────────────────────────────── */
.accent-green  { color: var(--green)  !important; }
.accent-amber  { color: var(--amber)  !important; }
.accent-red    { color: var(--red)    !important; }
.accent-gray   { color: var(--text-3) !important; }
.mono { font-family: var(--font-mono); font-size: 0.75rem !important; }

.hb-unavailable {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 40px 32px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text-2);
}
.hb-unavailable svg { flex-shrink: 0; color: var(--amber); margin-top: 2px; }
.hb-unavailable-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.hb-unavailable-sub   { font-size: 0.875rem; }

.hb-summary-cards {
  grid-template-columns: repeat(6, 1fr) !important;
  margin-bottom: 12px;
}
@media (max-width: 1100px) { .hb-summary-cards { grid-template-columns: repeat(3, 1fr) !important; } }
@media (max-width: 700px)  { .hb-summary-cards { grid-template-columns: repeat(2, 1fr) !important; } }

.hb-meta-notice {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 14px; margin-bottom: 14px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius);
  font-size: 0.8125rem; color: #1e40af; line-height: 1.55;
}
.hb-meta-notice svg { flex-shrink: 0; margin-top: 2px; }

.hb-tabs { overflow: hidden; }
.hb-filters { border: none; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.hb-tab-panel { }
.hb-tab-intro {
  padding: 14px 16px; font-size: 0.8125rem; color: var(--text-2);
  border-bottom: 1px solid var(--border); background: #f8fafc;
}

/* Table column hint */
.hb-table-hint {
  padding: 6px 16px 7px;
  font-size: 0.75rem; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  line-height: 1.5;
}
.hb-table-hint b { color: var(--text-2); }

/* Reliability badges */
.rel-reliable     { background: #dcfce7; color: #15803d; }
.rel-low          { background: #fef3c7; color: #92400e; }
.rel-noisy        { background: #fef9c3; color: #854d0e; }
.rel-insufficient { background: #f3f4f6; color: #374151; }
.rel-unusable     { background: #fee2e2; color: #991b1b; }

/* Conflict / noise flag pills */
.flag-conflict { background: #fee2e2; color: #991b1b; font-size: 0.6rem; padding: 1px 5px; border-radius: 3px; font-weight: 700; }
.flag-noise    { background: #fef9c3; color: #854d0e; font-size: 0.6rem; padding: 1px 5px; border-radius: 3px; font-weight: 700; }

/* Launch cohort trend badges */
.trend-badge { display: inline-block; font-size: 0.68rem; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.trend-up     { background: #dcfce7; color: #15803d; }
.trend-down   { background: #fee2e2; color: #991b1b; }
.trend-stable { background: #e0f2fe; color: #0369a1; }
.trend-nodata { background: #f3f4f6; color: #6b7280; }

/* Mini weekly launch table in drawer */
.hb-launch-week-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.hb-launch-week-table th,
.hb-launch-week-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.hb-launch-week-table th {
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.72rem;
  background: var(--bg);
}
.hb-launch-week-table .cell-num { text-align: right; }
.text-muted { color: var(--text-3); }

/* Agreement badges in scope comparison */
.agr-agree    { background: #dcfce7; color: #15803d; }
.agr-slight   { background: #fef3c7; color: #92400e; }
.agr-conflict { background: #fee2e2; color: #991b1b; }
.agr-t1       { background: #cffafe; color: #0e7490; }
.agr-t2       { background: #fef9c3; color: #854d0e; }
.agr-insuff   { background: #f3f4f6; color: #374151; }

/* Drawer detail sections */
.hb-drawer-explain {
  background: #f0fdf4; border: 1px solid #86efac;
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 0.8125rem; color: #166534; line-height: 1.55;
}
.hb-drawer-explain.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.hb-drawer-explain.danger { background: #fff1f2; border-color: #fca5a5; color: #991b1b; }
.hb-drawer-explain.muted  { background: var(--bg); border-color: var(--border); color: var(--text-2); }

/* ─── Historical Baselines — wide table behaviour ──────────────────────────── */
/* Overflow-x on the inner wrapper is already correct (.table-wrapper { overflow-x: auto }).
   These rules ensure the table never collapses below a readable minimum and that cells
   don't wrap, so horizontal scroll appears instead of squished columns. */
.hb-tabs .table-wrapper {
  overflow-x: auto;
}
.hb-tabs .data-table {
  min-width: 1200px;
}
.hb-tabs .data-table th,
.hb-tabs .data-table td {
  white-space: nowrap;
}

/* ─── Sortable column headers ─────────────────────────────────────────────── */
th.th-sort {
  cursor: pointer;
  user-select: none;
}
th.th-sort:hover { color: var(--blue); }
.th-sort-ind {
  display: inline-block;
  min-width: 10px;
  font-size: 0.85em;
  color: var(--blue);
  font-weight: 700;
}
th.th-sort:not(.sort-asc):not(.sort-desc):hover .th-sort-ind::after { content: ' ↓'; opacity: .35; }

/* ─── Column tooltip button ───────────────────────────────────────────────── */
.th-tip-wrap {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
}
.th-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px; height: 13px;
  border: 1px solid var(--text-3);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  padding: 0;
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.6rem;
  color: var(--text-3);
  line-height: 1;
  flex-shrink: 0;
  transition: color .12s, border-color .12s;
}
.th-tip-btn:hover,
.th-tip-btn:focus {
  color: var(--blue);
  border-color: var(--blue);
  outline: none;
}

/* ─── Global tooltip (position:fixed, bypasses overflow clipping) ─────────── */
.hb-tooltip {
  display: none;
  position: fixed;
  background: #1e293b;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.55;
  text-transform: none;
  letter-spacing: 0;
  padding: 8px 12px;
  border-radius: 6px;
  max-width: 240px;
  white-space: normal;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  z-index: 600;
  pointer-events: none;
  transform: translateX(-50%);
}
.hb-tooltip.visible { display: block; }

/* ─── Image modal ──────────────────────────────────────────────────────────── */
.img-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.img-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.75);
}
.img-modal-content {
  position: relative; z-index: 1; max-width: 90vw; max-height: 90vh;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.img-modal-close {
  position: absolute; top: -32px; right: 0;
  background: rgba(255,255,255,.2); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.img-modal-close:hover { background: rgba(255,255,255,.35); }
.img-modal-img {
  max-width: 85vw; max-height: 80vh; border-radius: var(--radius);
  object-fit: contain; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.img-modal-caption { color: rgba(255,255,255,.7); font-size: 0.75rem; }

/* ─── First-wave cluster link ──────────────────────────────────────────────── */
.btn-cluster-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 0.75rem; font-weight: 500;
  border: 1px solid var(--teal); border-radius: var(--radius);
  background: #f0fdfa; color: var(--teal); cursor: pointer;
  white-space: nowrap; text-decoration: none; font-family: var(--font);
  transition: background .15s, color .15s;
}
.btn-cluster-link:hover { background: var(--teal); color: #fff; }

/* ─── Shared metric card (used on data-sources and future pages) ────────────── */
.metric-card { padding: 14px 16px; }
.metric-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.metric-value {
  font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.1;
}

/* ─── Shared button styles ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; font-size: 0.875rem; font-weight: 500; line-height: 1;
  border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; font-family: var(--font);
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #1d4ed8; border-color: #1d4ed8;
}

/* ─── Data Sources page ────────────────────────────────────────────────────── */
.ds-page { max-width: 900px; }

.ds-state-msg {
  padding: 24px; color: var(--text-2); font-size: 15px; text-align: center;
}
.ds-error-msg { color: #b91c1c; }

.ds-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 16px;
}
.ds-section-title {
  font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}

/* File info card */
.ds-file-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; background: var(--bg);
}
.ds-file-missing { border-color: #fca5a5; background: #fff1f2; }
.ds-file-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.ds-file-name { font-weight: 600; font-size: 14px; color: var(--text); }
.ds-file-path {
  font-size: 11px; font-family: monospace; color: var(--text-3);
  word-break: break-all; margin-bottom: 8px;
}
.ds-file-meta {
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  font-size: 13px; color: var(--text-2);
}
.ds-file-meta strong { color: var(--text); }

.ds-import-info {
  margin-top: 10px; padding: 10px 14px;
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: var(--radius);
}
.ds-import-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #0369a1; font-weight: 600; margin-bottom: 6px;
}
.ds-import-none {
  font-size: 13px; color: var(--text-3); margin-top: 8px; padding: 8px 0;
}

/* Notice block */
.ds-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 12px; padding: 10px 14px;
  background: #f9fafb; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; color: var(--text-2);
}
.ds-notice svg { flex-shrink: 0; margin-top: 1px; }

/* Upload panel */
.ds-upload-panel {
  margin-top: 16px; padding: 16px; border: 1px dashed var(--border-md);
  border-radius: var(--radius-lg); background: #fafbfc;
}
.ds-upload-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.ds-upload-note  { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.ds-upload-row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ds-file-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border-md); border-radius: var(--radius);
  background: var(--bg-card); font-size: 13px; color: var(--text-2); cursor: pointer;
  transition: border-color .15s;
}
.ds-file-label:hover { border-color: var(--blue); color: var(--blue); }

.ds-upload-status {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px;
}
.ds-upload-success  { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.ds-upload-error    { background: #fff1f2; border: 1px solid #fca5a5; color: #991b1b; }
.ds-upload-duplicate{ background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.ds-upload-progress { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Staged table */
.ds-table-wrap { overflow-x: auto; }
.ds-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.ds-table th {
  padding: 8px 10px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ds-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.ds-table tr:last-child td { border-bottom: none; }
.ds-table tr:hover td { background: var(--bg); }
.ds-td-fname { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-td-hash  { font-family: monospace; font-size: 12px; }

/* Summary card small text */
.ds-small { font-size: 14px; }
.ds-muted  { color: var(--text-3) !important; }

/* Pipeline notice (replaces legacy phase1-notice) */
.ds-pipeline-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.55;
}
.ds-pipeline-notice svg { flex-shrink: 0; margin-top: 2px; }

/* Job progress panel */
.ds-job-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.ds-job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ds-job-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-1);
}
.ds-job-progress {
  padding: 14px 16px;
}
.ds-job-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-job-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.ds-step-name {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-2);
  min-width: 180px;
}
.ds-step-rows {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 4px;
}
.ds-step-error {
  font-size: 11px;
  color: #dc2626;
  margin-left: 4px;
}
.ds-step-note {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 4px;
  font-style: italic;
}
.ds-step-link {
  font-size: 11px;
  color: var(--accent);
  margin-left: 4px;
  text-decoration: none;
}
.ds-step-link:hover {
  text-decoration: underline;
}
.ds-job-steps-empty {
  color: var(--text-3);
  font-size: 13px;
  padding: 4px 0;
}
.ds-job-message {
  padding: 8px 16px 12px;
  font-size: 13px;
  color: #dc2626;
}

/* Recent increment jobs cards */
.ds-recent-job {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.ds-rj-success { border-left: 3px solid #22c55e; }
.ds-rj-failed  { border-left: 3px solid #ef4444; }
.ds-rj-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
  background: var(--bg);
}
.ds-rj-id {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-1);
  min-width: 56px;
}
.ds-rj-fname {
  font-size: 13px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ds-rj-summary {
  font-size: 12px;
  flex: 1;
}
.ds-rj-dates {
  font-size: 11px;
  white-space: nowrap;
}
.ds-rj-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.ds-rj-toggle:hover { background: var(--bg-2); }
.ds-rj-details {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2, #f9fafb);
}
/* In the details panel step-name shows the machine key as title tooltip; make it slightly wider */
.ds-rj-details .ds-step-name { min-width: 200px; }

@media (max-width: 600px) {
  .ds-file-meta { flex-direction: column; gap: 4px; }
  .ds-upload-row { flex-direction: column; align-items: flex-start; }
  .ds-file-label { width: 100%; }
  #ds-upload-btn { width: 100%; }
  .ds-step-name { min-width: 130px; }
  .ds-rj-fname { max-width: 140px; }
  .ds-rj-details .ds-step-name { min-width: 140px; }
}
