/* ===== Auth (Supabase login) ===== */
#auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 55%, #60a5fa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}
.auth-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #0f172a;
  text-align: center;
}
.auth-sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: #64748b;
  text-align: center;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-field input {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
}
.auth-field input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
  border-color: #3b82f6;
}
.auth-error {
  margin: 0;
  padding: 8px 12px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  font-size: 13px;
}
.auth-submit { margin-top: 6px; padding: 10px; font-size: 14px; font-weight: 600; }
.auth-submit:disabled { opacity: 0.6; cursor: wait; }

.auth-userbox {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 12px;
}
.auth-userbox-email {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-logout { font-size: 12px; padding: 6px 12px; }

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f9fd;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--text); }

.view { display: none; }
.view.active { display: block; }

/* ----- BRAND ----- */
.brand { display: flex; gap: 10px; align-items: center; }
.logo-img {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
}
.brand-title { font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ----- BUTTONS ----- */
.btn {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--blue-50); border-color: var(--blue-200); }

/* ----- DASHBOARD LAYOUT ----- */
#view-dashboard.active {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  background: var(--bg-subtle);
}

.sidebar {
  background: var(--blue-50);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.sidebar-group + .sidebar-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--blue-200);
}
.sidebar-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 4px 6px;
  background: transparent;
  border: none;
  font: inherit;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 6px;
}
.sidebar-toggle:hover { background: var(--blue-100); color: var(--text); }
.sidebar-toggle .chevron {
  font-size: 11px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.sidebar-group.collapsed .sidebar-toggle .chevron { transform: rotate(-90deg); }
.sidebar-group.collapsed .portfolio-list { display: none; }
.portfolio-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.portfolio-list li {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  transition: background 0.12s ease;
}
.portfolio-list li:hover { background: var(--blue-100); }
.portfolio-list li.active { background: var(--blue-500); color: #fff; }
.portfolio-list li.active .dot { background: #fff; }
.portfolio-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-400); flex-shrink: 0; }
.portfolio-list .dot.no-token { background: #cbd5e1; }
.portfolio-list li.all { /* visual divider removed per request */ }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.main { padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; overflow-x: auto; }
#view-clients > * + * { margin-top: 24px; }
.main-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; position: relative; }
.main-header-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.main-header h2 { margin: 0; font-size: 22px; }
.api-status { font-size: 12px; color: var(--muted); margin-top: 4px; }
.api-status.ok { color: var(--success); }
.api-status.err { color: var(--danger); }
.header-actions { display: flex; gap: 10px; align-items: flex-end; }

.select-wrap { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.select-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.select-ctrl {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select-ctrl:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-400); }
.card-header-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ----- KPI ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: #fff;
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  position: relative;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.kpi.copied::after {
  content: "Copied";
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 1px 8px;
  border-radius: 999px;
  pointer-events: none;
  animation: kpi-copied-pulse 0.9s ease forwards;
}
.kpi.kpi-highlight.copied::after {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}
@keyframes kpi-copied-pulse {
  0%   { opacity: 0; transform: translateY(-2px); }
  15%  { opacity: 1; transform: translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
.kpi-range {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.kpi-highlight { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.kpi-highlight .kpi-label { color: rgba(255, 255, 255, 0.9); }
.kpi-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Header for each KPIs pane. */
.kpis-page-header { text-align: center; margin: 4px 0 20px; }
.kpis-page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}
.kpis-page-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Three KPIs panes: Andres + Elijah on top row (vertical divider between them),
   Merlyn below them spanning full width (horizontal divider above it). */
.kpis-trio {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "andres elijah"
    "merlyn merlyn";
  gap: 0;
  align-items: start;
  margin-top: 32px;
}
.kpis-pane[data-owner="andres"] {
  grid-area: andres;
  padding: 0 24px 0 0;
  border-right: 1px solid var(--border);
}
.kpis-pane[data-owner="elijah"] {
  grid-area: elijah;
  padding: 0 0 0 24px;
}
.kpis-pane[data-owner="merlyn"] {
  grid-area: merlyn;
  padding: 28px 0 0;
  margin-top: 28px;
  border-top: 1px solid var(--border);
}
@media (max-width: 1100px) {
  .kpis-trio {
    grid-template-columns: 1fr;
    grid-template-areas:
      "andres"
      "elijah"
      "merlyn";
  }
  .kpis-pane[data-owner="andres"],
  .kpis-pane[data-owner="elijah"] {
    padding: 0 0 24px;
    margin-bottom: 24px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .kpis-pane[data-owner="merlyn"] { margin-top: 0; padding-top: 24px; }
}

/* KPI cards within each pane: 2-column layout so they fit the narrower pane.
   The 7th item spans both columns to stay centered in the bottom row. */
.kpi-grid.kpi-grid-large {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.kpi-grid.kpi-grid-large > .kpi:nth-child(7) { grid-column: 1 / -1; }
@media (max-width: 540px) {
  .kpi-grid.kpi-grid-large { grid-template-columns: 1fr; }
  .kpi-grid.kpi-grid-large > .kpi:nth-child(7) { grid-column: auto; }
}
/* Elijah pane has a single KPI — let it fill the pane to avoid dead space. */
.kpis-pane[data-owner="elijah"] .kpi-grid.kpi-grid-large {
  grid-template-columns: 1fr;
}

/* KPI widgets on the Merlyn dashboard — same .kpi-grid-large layout but
   slightly more compact since the widget itself is narrower. */
.widget-kpi-body { padding: 14px 16px; }
.widget-kpi-body .kpi-grid.kpi-grid-large .kpi {
  padding: 14px 14px;
  min-height: 92px;
}
.widget-kpi-body .kpi-grid.kpi-grid-large .kpi-value { font-size: 26px; margin-top: 6px; }
.widget-kpi-body-single .kpi-grid.kpi-grid-large { grid-template-columns: 1fr; }

/* Clock widget — multiple analog clocks per widget. */
.widget-body.widget-clock-body { padding: 46px 24px 64px; }
.widget-clock-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}
.widget-clock-add-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.widget-clock-add-header:hover {
  background: var(--blue-50);
  color: var(--blue-600);
  border-color: var(--blue-500);
}
.widget-clock-empty {
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 8px;
}
.clock-item {
  position: relative;
  width: 176px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.clock-remove,
.clock-settings {
  position: absolute;
  top: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, opacity 0.15s ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.clock-remove { right: -6px; opacity: 0; pointer-events: none; }
.clock-settings { left: -6px; opacity: 0; pointer-events: none; }
.clock-item:hover .clock-remove,
.clock-item:hover .clock-settings { opacity: 1; pointer-events: auto; }
.clock-remove:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.clock-settings:hover { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-500); }
.clock-settings svg { width: 12px; height: 12px; }
.clock-tz { color: var(--muted); font-weight: 400; font-size: 10px; }
.clock-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 2px;
}

/* Style picker popover for clocks */
.clock-style-picker {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 10px;
  z-index: 200;
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.clock-style-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.clock-style-option:hover { background: var(--blue-50); }
.clock-style-option.is-active { border-color: var(--blue-500); background: var(--blue-50); }
.clock-style-preview { width: 56px; height: 56px; }
.clock-style-preview svg { width: 100%; height: 100%; display: block; }
.clock-style-name {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
}
.clock-style-option-custom .clock-style-preview {
  border: 2px dashed var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.clock-style-option-custom:hover .clock-style-preview {
  border-color: var(--blue-500);
  background: var(--blue-50);
}
.clock-style-add-icon {
  font-size: 26px;
  color: var(--muted);
  font-weight: 300;
  line-height: 1;
}
.clock-style-option-custom:hover .clock-style-add-icon { color: var(--blue-500); }
.clock-style-option-custom.is-active .clock-style-preview { border-style: solid; border-color: var(--blue-500); padding: 0; }
.clock-face {
  width: 162px;
  height: 162px;
  display: block;
}
.clock-face svg { width: 100%; height: 100%; display: block; }
.clock-face-bg {
  fill: #f8fafc;
  stroke: #e2e8f0;
  stroke-width: 1;
}
.clock-tick { stroke: #94a3b8; stroke-width: 1.4; stroke-linecap: round; }
.clock-tick-big { stroke: #475569; stroke-width: 2.2; }
.clock-hand-hour { stroke: #0f172a;        stroke-width: 3.2; }
.clock-hand-min  { stroke: #334155;        stroke-width: 2;   }
.clock-hand-sec  { stroke: var(--blue-500);stroke-width: 1.2; }
.clock-center { fill: #0f172a; }
.clock-digital {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  margin-top: 2px;
}
.clock-city {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  max-width: 168px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clock-add {
  width: 162px;
  height: 162px;
  border: 2px dashed var(--border);
  border-radius: 50%;
  background: #fff;
  font-size: 44px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 300;
  line-height: 1;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease, transform 0.12s ease;
  align-self: flex-start;
  margin-top: 0;
}
.clock-add:hover {
  border-color: var(--blue-500);
  color: var(--blue-500);
  background: var(--blue-50);
  transform: translateY(-2px);
}

/* Floating clock picker (popover under the + button) */
.clock-picker {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 8px;
  width: 280px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.clock-picker-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.clock-picker-input:focus { outline: 2px solid var(--blue-500); outline-offset: -1px; }
.clock-picker-suggestions {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.clock-picker-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.clock-picker-suggestion strong { font-weight: 600; }
.clock-picker-suggestion .muted { font-size: 11px; color: var(--muted); }
.clock-picker-suggestion:hover { background: var(--blue-50); }
.clock-picker-suggestion-custom { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.clock-picker-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.clock-picker-header strong { color: var(--blue-600); font-weight: 700; }
.kpi-grid.kpi-grid-large .kpi {
  padding: 18px 16px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-grid.kpi-grid-large .kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.10);
}
.kpi-grid.kpi-grid-large .kpi-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kpi-grid.kpi-grid-large .kpi-value {
  font-size: 30px;
  margin-top: 8px;
  line-height: 1.05;
}
.kpi-grid.kpi-grid-large .kpi-range {
  font-size: 11px;
  right: 12px;
  bottom: 8px;
}

/* ----- CARD + TABLE ----- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.card-header h3 { margin: 0; font-size: 16px; }
.card-header input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; width: 240px; font-family: inherit; font-size: 14px; }
.card-header input:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-400); }

.search-wrap { position: relative; display: inline-block; }
.search-wrap input { padding-right: 34px; }
.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: #e5e7eb;
  color: #475569;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.search-clear:hover { background: var(--blue-100); color: var(--blue-600); }
.search-wrap.has-value .search-clear { display: flex; }

.client-table { width: 100%; border-collapse: collapse; }
.client-table th, .client-table td { text-align: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.client-table th:first-child, .client-table td:first-child { text-align: left; padding-left: 20px; }
.client-table th { background: var(--bg-subtle); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.client-table tbody tr:last-child td { border-bottom: none; }
.client-table tbody tr { cursor: pointer; }
.client-table tbody tr:hover td { background: var(--blue-50); }
.client-table .score-bar { justify-content: center; }
.client-table .col-portfolio { display: none; }
.client-table.show-portfolio .col-portfolio { display: table-cell; }

.chart-breadcrumb {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  flex-wrap: wrap;
}
.chart-breadcrumb .crumb {
  color: var(--blue-600);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 6px;
}
.chart-breadcrumb .crumb:hover { background: var(--blue-50); }
.chart-breadcrumb .crumb.current {
  color: var(--text);
  background: var(--blue-100);
  font-weight: 600;
}
.chart-breadcrumb .crumb-sep { color: var(--muted); }

.chart-body {
  display: flex;
  gap: 56px;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  flex-wrap: wrap;
}
.chart-body svg { width: 460px; height: 460px; max-width: 100%; flex-shrink: 0; }
@media (max-width: 720px) {
  .chart-body svg { width: 320px; height: 320px; }
  .chart-body { padding: 24px 16px; gap: 28px; }
}
.chart-body svg path,
.chart-body svg circle {
  transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
  transform-origin: 0 0;
}
.chart-body svg path.slice-active,
.chart-body svg circle.slice-active {
  filter: brightness(1.18) drop-shadow(0 4px 10px rgba(15, 23, 42, 0.18));
  transform: scale(1.04);
}
.legend-item {
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.legend-item.slice-active {
  background: var(--blue-50);
}
.legend-item.slice-active .legend-label {
  color: var(--blue-600);
  font-weight: 600;
}
.legend-item.slice-active .legend-swatch {
  transform: scale(1.25);
  transition: transform 0.12s ease;
}
.legend-item.clickable { cursor: pointer; }
.chart-legend {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 240px;
}
.legend-total {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-label { flex: 1; }
.legend-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.legend-item.highlighted {
  background: var(--blue-50);
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
}
.legend-item.clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.12s ease;
}
.legend-item.clickable:hover { background: var(--blue-50); }

.chart-client-table { width: 100%; border-collapse: collapse; }
.chart-client-table th,
.chart-client-table td {
  text-align: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.chart-client-table th:first-child,
.chart-client-table td:first-child {
  text-align: left;
  padding-left: 20px;
}
.chart-client-table th {
  background: var(--bg-subtle);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.chart-client-table tbody tr:last-child td { border-bottom: none; }
.portfolio-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--blue-100); color: var(--blue-600); font-weight: 500; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-l1 { background: #fef3c7; color: #92400e; }
.badge-l2 { background: #d1fae5; color: #065f46; }
.badge-l3 { background: #dbeafe; color: #1e3a8a; }
.badge-live { background: #dbeafe; color: #1e3a8a; }
.badge-paused { background: #f1f5f9; color: #475569; }
.badge-payment { background: #fee2e2; color: #991b1b; }

.score-bar { display: flex; align-items: center; gap: 10px; }
.score-bar-track { width: 96px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; background: var(--blue-500); border-radius: 3px; transition: width 0.25s ease, background 0.15s ease; }
.score-bar-fill.score-good { background: var(--blue-500); }
.score-bar-fill.score-mid  { background: var(--warn); }
.score-bar-fill.score-bad  { background: var(--danger); }
.score-value { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 28px; display: inline-block; text-align: right; }

/* ----- DRAWER ----- */
.drawer { position: fixed; inset: 0; display: none; z-index: 10; }
.drawer.open { display: block; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.35); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(680px, 94vw);
  background: #fff;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
  display: flex; flex-direction: column;
}
.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.drawer-header h2 { margin: 0; font-size: 20px; text-align: center; }
.drawer-titleblock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.drawer-client-logo {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 4px;
}
.drawer-website-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.drawer-website-link:hover {
  background: var(--blue-50);
  color: var(--blue-500);
  border-color: var(--blue-500);
}
.drawer-website-link[hidden] { display: none; }
.drawer-meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; }
.drawer-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; align-items: stretch; }
.drawer-actions .btn { white-space: nowrap; }
.drawer-body { padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.metric { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-value { font-weight: 600; font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }

.section {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.section h4 { margin: 0 0 8px; font-size: 12px; color: var(--blue-600); text-transform: uppercase; letter-spacing: 0.08em; }
.section ul { margin: 0; padding-left: 18px; }
.section li { margin-bottom: 4px; }
.section-text { margin: 4px 0; font-size: 13px; line-height: 1.5; }
.section-text.muted-text { color: var(--muted); }

/* ----- ANALYSIS: key metrics row (denser than header) ----- */
.metric-row-analysis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ----- ANALYSIS: charts grid ----- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.chart-title {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--blue-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; flex-direction: column; gap: 4px; }
.funnel-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.funnel-bar-wrap { background: var(--bg-subtle); border-radius: 6px; height: 26px; position: relative; overflow: hidden; }
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-400));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  transition: width 0.3s ease;
}
.funnel-value { color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-rate { font-size: 11px; color: var(--muted); padding-left: 2px; }

/* Gauges (bars vs benchmark) */
.gauges { display: flex; flex-direction: column; gap: 14px; }
.gauge-row { display: flex; flex-direction: column; gap: 4px; }
.gauge-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.gauge-label { color: var(--text); font-weight: 500; }
.gauge-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.gauge-value.tone-positive { color: var(--success); }
.gauge-value.tone-concern  { color: var(--danger); }
.gauge-value.tone-neutral  { color: var(--text); }
.gauge-track {
  position: relative;
  height: 10px;
  background: var(--bg-subtle);
  border-radius: 5px;
  overflow: visible;
}
.gauge-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
}
.gauge-fill.tone-positive { background: var(--success); }
.gauge-fill.tone-concern  { background: var(--danger); }
.gauge-fill.tone-neutral  { background: var(--blue-400); }
.gauge-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #0f172a;
  border-radius: 1px;
}
.gauge-marker::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -3px;
  width: 8px;
  height: 4px;
  background: #0f172a;
  border-radius: 2px 2px 0 0;
}
.gauge-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ----- ANALYSIS: callouts (wins / improvements / mistakes) ----- */
.callout {
  background: #fff;
  border: 1px solid var(--border);
  border-left-width: 4px;
}
.callout h4 { color: var(--text); margin-bottom: 10px; }
.callout-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.callout-list li {
  position: relative;
  padding: 8px 10px 8px 28px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-subtle);
  border-radius: 6px;
}
.callout-list li::before {
  position: absolute;
  left: 9px;
  top: 8px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
}

.callout-wins { border-left-color: var(--success); background: #f0fdf4; }
.callout-wins h4 { color: #166534; }
.callout-wins .callout-list li { background: #fff; border: 1px solid #bbf7d0; }
.callout-wins .callout-list li::before { content: '✓'; color: var(--success); }

.callout-improve { border-left-color: var(--blue-500); background: var(--blue-50); }
.callout-improve h4 { color: var(--blue-600); }
.callout-improve .callout-list li { background: #fff; border: 1px solid var(--blue-100); }
.callout-improve .callout-list li::before { content: '→'; color: var(--blue-500); }

.callout-mistakes { border-left-color: var(--danger); background: #fef2f2; }
.callout-mistakes h4 { color: #991b1b; }
.callout-mistakes .callout-list li { background: #fff; border: 1px solid #fecaca; }
.callout-mistakes .callout-list li::before { content: '!'; color: var(--danger); }

/* ----- DRAWER: campaigns table ----- */
.campaigns-table-wrap { overflow-x: auto; margin: 0 -6px; }
.campaigns-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.campaigns-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  white-space: nowrap;
}
.campaigns-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
.campaigns-table tr:last-child td { border-bottom: none; }
.campaigns-table tr:hover td { background: var(--blue-50); }

/* ===== START DATE INVESTIGATION ===== */
#startdate-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 8px;
}
#startdate-body > * { min-width: 0; }
.sd-headline { grid-column: 1 / -1; }
.sd-region-grid { grid-column: 1 / -1; }
@media (max-width: 960px) {
  #startdate-body { grid-template-columns: 1fr; }
}

/* Headline (portfolio-wide verdict) */
.sd-headline {
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 5px;
  background: #fff;
}
.sd-headline.sd-tone-good     { border-left-color: var(--success); background: #f0fdf4; }
.sd-headline.sd-tone-marginal { border-left-color: var(--warn);    background: #fffbeb; }
.sd-headline.sd-tone-bad      { border-left-color: var(--danger);  background: #fef2f2; }
.sd-headline-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.sd-headline-text { font-size: 15px; line-height: 1.55; color: var(--text); }
.sd-headline-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.sd-headline-metrics > div {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sd-metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sd-metric-value { font-weight: 700; font-size: 18px; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Stylized US map */
.sd-map-card, .sd-bars-card {
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sd-map-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue-600);
  font-weight: 600;
  margin-bottom: 14px;
}
.sd-map { width: 100%; height: auto; display: block; }
.sd-map-region { cursor: pointer; transition: opacity 0.18s ease; }
.sd-map-region rect { transition: filter 0.18s ease, stroke 0.18s ease, stroke-width 0.18s ease; }
.sd-map-region:hover rect,
.sd-map-region.sd-active rect {
  filter: brightness(1.12) drop-shadow(0 3px 8px rgba(15, 23, 42, 0.25));
  stroke: #0f172a;
  stroke-width: 2.5;
}
#view-startdate [data-region]:not(.sd-active) { opacity: 1; }
#view-startdate.has-hover [data-region]:not(.sd-active) { opacity: 0.35; }

/* state-code label inside each tile */
.sd-tile-label {
  font-size: 13px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  pointer-events: none;
  letter-spacing: 0.02em;
  font-family: "Inter", sans-serif;
}

/* floating region badge overlay */
.sd-region-badge { opacity: 0.95; }
.sd-region-badge-label {
  font-size: 13px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  font-family: "Inter", sans-serif;
  letter-spacing: 0.03em;
}
.sd-region-badge-sub {
  font-size: 10px;
  font-weight: 500;
  fill: rgba(255, 255, 255, 0.85);
  text-anchor: middle;
  font-family: "Inter", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sd-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}
.sd-legend-item { display: flex; align-items: center; gap: 6px; }
.sd-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Side-by-side bar charts */
.sd-bars { display: flex; flex-direction: column; gap: 14px; }
.sd-bar-row { display: grid; grid-template-columns: 90px 1fr; gap: 14px; align-items: center; cursor: default; }
.sd-bar-row.sd-active { background: var(--bg-subtle); border-radius: 8px; padding: 4px; margin: -4px; }
.sd-bar-label { font-weight: 600; font-size: 13px; }
.sd-bar-group { display: flex; flex-direction: column; gap: 6px; }
.sd-bar-sub { display: grid; grid-template-columns: 130px 1fr 56px; gap: 8px; align-items: center; }
.sd-bar-sub-label { font-size: 11px; color: var(--muted); }
.sd-bar-track { background: var(--bg-subtle); height: 12px; border-radius: 6px; overflow: hidden; }
.sd-bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; }
.sd-bar-fill.sd-bar-pre  { background: linear-gradient(90deg, var(--blue-400), var(--blue-300)); }
.sd-bar-fill.sd-bar-peak { background: linear-gradient(90deg, var(--blue-600), var(--blue-500)); }
.sd-bar-value { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }

/* Region detail cards */
.sd-region-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 720px) { .sd-region-grid { grid-template-columns: 1fr; } }

.sd-region-card {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--blue-400);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.sd-region-card.sd-active { box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08); transform: translateY(-2px); }
.sd-region-card.sd-tone-good      { border-top-color: var(--success); }
.sd-region-card.sd-tone-marginal  { border-top-color: var(--warn); }
.sd-region-card.sd-tone-bad       { border-top-color: var(--danger); }
.sd-region-card.sd-tone-unknown   { border-top-color: var(--muted); }

.sd-region-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sd-region-name { font-weight: 700; font-size: 18px; }
.sd-region-verdict {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
}
.sd-tone-good     .sd-region-verdict { background: #d1fae5; color: #065f46; }
.sd-tone-marginal .sd-region-verdict { background: #fef3c7; color: #92400e; }
.sd-tone-bad      .sd-region-verdict { background: #fee2e2; color: #991b1b; }
.sd-tone-unknown  .sd-region-verdict { background: #e5e7eb; color: #334155; }

.sd-region-headline { font-size: 14px; line-height: 1.5; color: var(--text); }
.sd-region-recommendation {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: 8px;
  border-left: 3px solid var(--blue-300);
}

.sd-region-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sd-region-table th, .sd-region-table td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.sd-region-table th { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.sd-region-table td:first-child, .sd-region-table th:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.sd-region-table .sd-th-sub { font-weight: 400; color: var(--muted); font-size: 10px; text-transform: none; letter-spacing: 0; }
.sd-region-table .sd-muted-row td { color: var(--muted); font-size: 12px; background: var(--bg-subtle); }

.sd-region-foot { font-size: 12px; color: var(--muted); }

/* ----- MODAL ----- */
.modal { position: fixed; inset: 0; display: none; z-index: 10; }
.modal.open { display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.35); }
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(620px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.tokens-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.tokens-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.tokens-form textarea {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}
.tokens-form textarea:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-400); }
.tokens-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ----- MERLYN TASK LIST ----- */
.merlyn-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.merlyn-col-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 1100px) {
  .merlyn-grid { grid-template-columns: 1fr; }
}
.task-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.task-divider {
  list-style: none;
  margin-top: 8px;
  padding: 6px 2px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-top: 1px dashed var(--border);
}
.task-input-row { display: flex; gap: 8px; }
.task-input-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}
.task-input-row input:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-400); }

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.task-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue-500);
  cursor: pointer;
  flex-shrink: 0;
}
.task-text { flex: 1; font-size: 14px; word-break: break-word; }
.task-item.done {
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.task-item.done .task-text {
  color: var(--success);
  text-decoration: line-through;
}
.task-item.vault {
  background: #f8fafc;
  border-color: var(--border);
  opacity: 0.85;
}
.task-item.vault .task-text {
  color: var(--muted);
  text-decoration: line-through;
}
.task-actions { display: flex; gap: 4px; flex-shrink: 0; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--blue-500);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}
.btn-link:hover { background: var(--blue-50); }
.btn-link-danger { color: var(--danger); }
.btn-link-danger:hover { background: #fef2f2; }
.task-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}

/* ----- CAMPAIGN SNIPPETS ----- */
.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.campaign-snippet {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.campaign-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.campaign-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}
.campaign-badge-cold { background: #dbeafe; color: #1d4ed8; }
.campaign-badge-warm { background: #fef3c7; color: #b45309; }
.campaign-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.campaign-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  word-break: break-word;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  position: relative;
}
.campaign-line:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
}
.campaign-line:active { transform: translateY(1px); }
.campaign-line.copied {
  background: #ecfdf5;
  border-color: var(--success);
  color: var(--success);
}
/* ----- NAME MISMATCHES ----- */
.mismatch-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mismatch-group-header {
  list-style: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: center;
}
.mismatch-group-header:first-child { margin-top: 14px; }
.mismatch-group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--blue-50);
  border-radius: 999px;
  padding: 1px 8px;
  letter-spacing: 0;
}
.mismatch-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.4s ease, transform 0.4s ease;
}
.mismatch-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}
.mismatch-item.fixed .mismatch-time { color: var(--success); }

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.news-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.news-item:hover {
  border-color: var(--blue-300);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.news-source {
  font-weight: 700;
  color: var(--blue-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.news-dot { color: var(--border); }
.news-date { font-variant-numeric: tabular-nums; }
.news-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.news-title:hover { text-decoration: underline; color: var(--blue-600); }
.news-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.5;
}
.news-empty {
  list-style: none;
  color: var(--muted);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
}
.mismatch-item.copied::after {
  content: "Copied";
  position: absolute;
  top: 6px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 1px 8px;
  border-radius: 999px;
  pointer-events: none;
  animation: mismatch-copied-pulse 0.9s ease forwards;
}
@keyframes mismatch-copied-pulse {
  0%   { opacity: 0; transform: translateY(-2px); }
  15%  { opacity: 1; transform: translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
.mismatch-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue-500);
  cursor: pointer;
  flex-shrink: 0;
}
.mismatch-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.mismatch-name { font-size: 14px; font-weight: 600; word-break: break-word; }
.mismatch-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.mismatch-arrow { color: var(--muted); font-weight: 700; }
.mismatch-dot { color: var(--border); }
.badge-prefix {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: #fee2e2;
  color: #b91c1c;
}
.badge-prefix-suggested {
  background: #dcfce7;
  color: #166534;
}
.mismatch-item.fixed {
  background: #ecfdf5;
  border-color: var(--success);
  opacity: 0.55;
}
.mismatch-item.fixed .mismatch-name { text-decoration: line-through; color: var(--success); }
.mismatch-item.fixed .mismatch-meta { color: var(--success); }

.campaign-line.copied::after {
  content: "Copied";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--success);
  background: #ecfdf5;
  padding: 0 4px;
}

/* ----- EVENT HAWK VIEW ----- */
#view-eventhawk { padding: 12px 0 24px; }
#view-eventhawk > section,
#view-eventhawk > .eh-grid,
#view-eventhawk > .eh-advisor-grid { margin-bottom: 28px !important; }
#view-eventhawk > section:last-child,
#view-eventhawk > .eh-grid:last-child,
#view-eventhawk > .eh-advisor-grid:last-child { margin-bottom: 0 !important; }
.eh-hero { padding: 22px 24px; }
.eh-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.eh-hero-title { display: flex; gap: 12px; align-items: center; }
.eh-hero-title h3 { margin: 0; font-size: 18px; }
.eh-hero-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.eh-hero .drawer-meta { justify-content: flex-start; margin-top: 4px; }
.eh-logo {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}
.eh-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  align-items: start;
}
@media (max-width: 1100px) {
  .eh-grid { grid-template-columns: 1fr; }
}
.eh-grid > .callout { padding: 32px 20px 20px !important; }
.eh-grid > .callout h4 { margin: 0 0 14px !important; padding-top: 4px; }
.eh-campaigns-wrap { padding: 20px 24px 24px; }

.year-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.year-toggle-btn {
  background: #fff;
  border: 0;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.year-toggle-btn + .year-toggle-btn { border-left: 1px solid var(--border); }
.year-toggle-btn:hover { background: var(--blue-50); color: var(--blue-500); }
.year-toggle-btn.is-active { background: var(--blue-500); color: #fff; }
.year-toggle-btn.is-active:hover { background: var(--blue-500); color: #fff; }

.eh-trend-body { padding: 20px 28px 24px; }
.eh-trend-chart { width: 100%; height: auto; display: block; }
.trend-grid { stroke: #eef2f7; stroke-width: 1; stroke-dasharray: 4 4; }
.trend-grid-base { stroke: #cbd5e1; stroke-dasharray: none; }
.trend-axis-label {
  font-size: 12px;
  fill: var(--muted);
  font-family: inherit;
  font-weight: 500;
}
.trend-area { fill: url(#trend-area-gradient); }
.trend-line {
  fill: none;
  stroke: #3b82f6;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.trend-dot-outer { fill: #fff; stroke: #3b82f6; stroke-width: 2.5; transition: r 0.12s ease; }
.trend-dot-inner { fill: #3b82f6; transition: r 0.12s ease; }
.trend-point-positive .trend-dot-outer { stroke: #10b981; }
.trend-point-positive .trend-dot-inner { fill: #10b981; }
.trend-point-concern .trend-dot-outer { stroke: #f59e0b; }
.trend-point-concern .trend-dot-inner { fill: #f59e0b; }
.trend-point:hover .trend-dot-outer { r: 8; }
.trend-point:hover .trend-dot-inner { r: 5; }
.trend-value-label {
  font-size: 12px;
  font-weight: 700;
  fill: #1e293b;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.trend-point-positive .trend-value-label { fill: #047857; }
.trend-point-concern .trend-value-label { fill: #b45309; }
.trend-empty-label {
  font-size: 15px;
  font-weight: 600;
  fill: var(--muted);
  font-family: inherit;
}

.eh-trend-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.eh-trend-stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.eh-trend-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.eh-trend-stat-value {
  font-weight: 700;
  font-size: 17px;
  margin-top: 4px;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* ROAS / CTR advisor cards */
.eh-advisor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) { .eh-advisor-grid { grid-template-columns: 1fr; } }
.eh-advisor .card-header { align-items: baseline; }
.eh-advisor-roas .card-header h3 { color: var(--success); }
.eh-advisor-ctr  .card-header h3 { color: var(--blue-600); }
.eh-advisor-body { padding: 22px 24px 24px; }

.eh-advisor-headline {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.eh-advisor-value {
  font-size: 56px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.eh-advisor-value.tone-positive { color: var(--success); }
.eh-advisor-value.tone-concern  { color: var(--danger); }
.eh-advisor-value.tone-neutral  { color: var(--text); }
.eh-advisor-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.eh-advisor-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.eh-advisor-bullets li {
  position: relative;
  padding: 0 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.eh-advisor-bullets li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-400);
}
.eh-advisor-roas .eh-advisor-bullets li::before { background: var(--success); }
.eh-advisor-ctr  .eh-advisor-bullets li::before { background: var(--blue-500); }

/* Campaigns → ad sets → ads tree */
.eh-tree-table tr.eh-tree-row { cursor: pointer; }
.eh-tree-table tr.eh-tree-row > td { vertical-align: top; }
.eh-tree-toggle {
  display: inline-block;
  width: 14px;
  color: var(--muted);
  transition: transform 0.15s ease;
  font-size: 11px;
  margin-right: 4px;
}
.eh-tree-row.open > td .eh-tree-toggle { transform: rotate(90deg); color: var(--blue-500); }
.eh-tree-name-col { min-width: 280px; }

/* Per-row recommendation icon — sits to the left of the toggle. */
.eh-rec-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  margin-right: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  flex-shrink: 0;
}
.eh-rec-icon:hover { transform: scale(1.18); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25); }
.eh-rec-icon-pause   { background: #dc2626; }
.eh-rec-icon-restart { background: #2563eb; }
.eh-rec-icon-good    { background: #10b981; }

.eh-rec-inline {
  margin-top: 8px;
  margin-left: 28px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  border-left: 3px solid;
}
.eh-rec-inline-pause {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}
.eh-rec-inline-restart {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e3a8a;
}
.eh-rec-inline-good {
  background: #f0fdf4;
  border-color: #10b981;
  color: #14532d;
}
.eh-rec-inline strong { font-weight: 700; }

.eh-ad-thumb { cursor: zoom-in; transition: transform 0.12s ease; }
.eh-ad-thumb:hover { transform: scale(1.04); }
.eh-ad-thumb-video {
  cursor: pointer;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* Ad lightbox */
.ad-lightbox { position: fixed; inset: 0; z-index: 200; }
.ad-lightbox[hidden] { display: none; }
.ad-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  cursor: zoom-out;
}
.ad-lightbox-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  pointer-events: none;
}
.ad-lightbox-img,
.ad-lightbox-video {
  max-width: 95vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  background: #000;
  pointer-events: auto;
}
.ad-lightbox-img { background: #fff; }
.ad-lightbox-video { width: min(95vw, 1280px); }
.ad-lightbox-loading {
  color: #fff;
  font-size: 15px;
  padding: 30px 60px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  pointer-events: auto;
}
.ad-lightbox-caption {
  color: #fff;
  font-size: 14px;
  text-align: center;
  max-width: 80vw;
  pointer-events: auto;
}
.ad-lightbox-caption strong { font-size: 16px; display: block; margin-bottom: 4px; }
.ad-lightbox-caption a { color: #60a5fa; }
.ad-lightbox-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  pointer-events: auto;
}
.ad-lightbox-actions .btn { padding: 9px 18px; font-size: 14px; }
.ad-lightbox-actions .btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
.ad-lightbox-actions .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}
.ad-lightbox-actions .btn:disabled { opacity: 0.6; cursor: progress; }
.ad-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 0;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.12s ease;
}
.ad-lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

.eh-tree-children-cell {
  background: var(--bg-subtle);
  padding: 12px 14px 14px 36px !important;
  border-bottom: 1px solid var(--border) !important;
}
.eh-subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.eh-subtable th {
  background: var(--blue-50);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.eh-subtable td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
.eh-subtable tr:last-child td { border-bottom: none; }
.eh-subtable tr.eh-tree-row { cursor: pointer; }
.eh-subtable tr.eh-tree-row:hover td { background: var(--blue-50); }

.eh-tree-loading, .eh-tree-empty, .eh-tree-error {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}
.eh-tree-error { color: var(--danger); }

/* Dim paused rows so active campaigns/ad sets/ads pop visually. */
.eh-tree-paused > td { opacity: 0.62; background: #fafafa; }
.eh-tree-paused > td strong { font-weight: 500; }
.eh-tree-paused:hover > td { opacity: 0.85; }

.eh-ad-leaf { display: flex; gap: 10px; align-items: flex-start; }
.eh-ad-thumb {
  width: 44px; height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}
.eh-ad-thumb-empty { background: var(--bg-subtle); }
.eh-ad-leaf a { color: var(--blue-600); text-decoration: none; }
.eh-ad-leaf a:hover { text-decoration: underline; }

/* Optimization suggestions */
.eh-rec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 20px 24px 24px;
}
@media (max-width: 900px) { .eh-rec-grid { grid-template-columns: 1fr; } }
.eh-rec-col { display: flex; flex-direction: column; gap: 12px; }
.eh-rec-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-radius: 6px;
}
.eh-rec-head-on  { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.eh-rec-head-off { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.eh-rec-list { display: flex; flex-direction: column; gap: 10px; }
.eh-rec-item {
  background: #fff;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 12px 14px;
}
.eh-rec-item-on  { border-left-color: var(--success); }
.eh-rec-item-off { border-left-color: var(--danger); }
.eh-rec-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.eh-rec-item-head strong { font-size: 14px; line-height: 1.3; }
.eh-rec-item-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.eh-rec-metric-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}
.eh-rec-item-reason {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

/* Quick-filter multi-select dropdowns on the Clients view */
.quick-filters { padding: 22px 24px 26px; }
.quick-filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
}
.quick-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}
.quick-filter-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}
.quick-multi { position: relative; }
.quick-multi-trigger {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.quick-multi-trigger:hover {
  border-color: var(--blue-300);
  background: var(--blue-50);
}
.quick-multi.open .quick-multi-trigger {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.quick-multi-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  padding: 6px 0;
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
}
.quick-multi-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  transition: background 0.1s ease, color 0.1s ease;
}
.quick-multi-option:hover { background: var(--blue-50); }
.quick-multi-option input[type=checkbox] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.quick-multi-option:has(input:checked) {
  background: var(--blue-500);
  color: #fff;
  font-weight: 500;
}
.quick-multi-option:has(input:checked):hover {
  background: var(--blue-600);
}
.quick-filter-clear {
  align-self: flex-end;
  padding: 10px 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.quick-filter-clear:hover {
  background: var(--bg-subtle);
  border-color: var(--blue-300);
  color: var(--text);
}
@media (max-width: 720px) {
  .quick-filter-field { min-width: 0; width: 100%; }
}

/* ROAS-by-level breakdown on the Regions & Units chart */
.chart-roas-card #chart-roas-body { padding: 16px 20px 20px; }
.chart-roas-rows { display: flex; flex-direction: column; gap: 14px; }
.chart-roas-row {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.chart-roas-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.chart-roas-swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.chart-roas-label { font-weight: 600; flex: 1; }
.chart-roas-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-roas-bar {
  height: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.chart-roas-fill { height: 100%; transition: width 0.25s ease; }
.chart-roas-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chart-roas-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

/* ===== US distribution map ===== */
#view-map > section { margin-bottom: 24px; }
.map-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  padding: 16px 24px 24px;
  align-items: start;
}
.custom-map-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 620;
  border-radius: 14px;
  overflow: hidden;
  background: #f1f5f9;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
}
.map-state-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  background: rgba(241, 245, 249, 0.7);
  pointer-events: none;
}
.map-loading[hidden] { display: none; }

/* Each state lives in a <g class="map-state-group"> that bundles its path,
   label and client dots — so the spotlight effect (blur others, lift active)
   applies to all the state's elements consistently. */
.map-state-group {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition:
    filter 0.22s ease,
    opacity 0.22s ease,
    transform 0.28s cubic-bezier(0.34, 1.46, 0.64, 1);
}
.map-shapes.is-hovering .map-state-group:not(.is-active) {
  filter: blur(0.8px);
  opacity: 0.72;
}
.map-state-group.is-active {
  transform: scale(1.07);
  filter: drop-shadow(0 8px 18px rgba(15, 23, 42, 0.30));
}
.map-state-group.is-active.has-clients {
  filter: drop-shadow(0 10px 24px rgba(59, 130, 246, 0.55));
}

.map-state-shape {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 0.6;
  stroke-linejoin: round;
  transition:
    fill 0.16s ease,
    stroke 0.16s ease,
    stroke-width 0.16s ease;
}
.map-state-shape.has-clients {
  fill: var(--blue-500);
  stroke: var(--blue-600);
  stroke-width: 0.9;
}
.map-state-group.is-active .map-state-shape {
  fill: var(--blue-50);
  stroke: var(--blue-500);
  stroke-width: 1.6;
}
.map-state-group.is-active.has-clients .map-state-shape {
  fill: var(--blue-600);
  stroke: #1e3a8a;
  stroke-width: 1.6;
}

.map-svg-label {
  font-size: 9px;
  font-weight: 700;
  fill: #475569;
  font-family: inherit;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.04em;
}
.map-svg-label.has-clients {
  fill: #ffffff;
  font-weight: 800;
}

.map-client-dot-svg {
  stroke: #ffffff;
  stroke-width: 1.4;
  pointer-events: auto;
  cursor: pointer;
  transition: r 0.15s ease;
}
.map-client-dot-svg:hover { r: 5.5; }
.map-client-dot-svg-good    { fill: #022c22; }
.map-client-dot-svg-ok      { fill: #fef3c7; stroke: #b45309; }
.map-client-dot-svg-bad     { fill: #fecaca; stroke: #b91c1c; }
.map-client-dot-svg-neutral { fill: #cbd5e1; }

.map-tooltip {
  position: fixed;
  z-index: 250;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  min-width: 140px;
  max-width: 260px;
  font-variant-numeric: tabular-nums;
}
.map-tip-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.map-tip-count {
  margin: 6px 0;
  color: #e2e8f0;
}
.map-tip-count strong {
  color: #34d399;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.map-tip-row { color: #cbd5e1; font-size: 12px; }
.map-tip-muted { color: #94a3b8; font-style: italic; }
.map-state-halo {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 1;
}
.map-state-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1f2937;
  text-shadow:
    0 0 2px rgba(255, 255, 255, 0.95),
    0 0 4px rgba(255, 255, 255, 0.85);
  pointer-events: none; /* let mouse fall through to the underlying state shape */
  cursor: default;
  user-select: none;
  z-index: 2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.map-state-label.has-clients {
  color: #0f172a;
  font-weight: 800;
}
.map-client-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.4);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  z-index: 2;
}
.map-client-dot:hover {
  transform: translate(-50%, -50%) scale(1.45);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.55);
  z-index: 3;
}
.map-client-dot:focus { outline: 2px solid #3b82f6; outline-offset: 2px; }
.map-client-dot-good { background: #059669; }
.map-client-dot-ok { background: #f59e0b; }
.map-client-dot-bad { background: #dc2626; }
.map-client-dot-neutral { background: #94a3b8; }

.map-legend {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}
.legend-block { padding: 6px 8px; }
.legend-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.legend-rows { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; color: var(--text); }
.legend-swatch {
  width: 16px; height: 16px; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.1);
}
.legend-dot.us-dot-good { background: #059669; }
.legend-dot.us-dot-ok { background: #f59e0b; }
.legend-dot.us-dot-bad { background: #dc2626; }
.legend-dot.us-dot-neutral { background: #94a3b8; }
.legend-gradient { display: flex; flex-direction: column; gap: 6px; }
.legend-gradient-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, rgb(219, 234, 254), rgb(29, 78, 216));
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.legend-gradient-labels {
  display: flex; justify-content: space-between;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}

.map-state-summary { padding: 0 0 4px; }
.map-leaderboard-wrap { overflow-x: auto; }
.map-leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.map-leaderboard th {
  text-align: left;
  background: var(--blue-50);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.map-leaderboard td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.map-leaderboard tr:last-child td { border-bottom: none; }
.map-leaderboard tr:hover td { background: #f8fafc; }
.map-warn {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
}
.map-warn-red {
  background: #fee2e2;
  color: #991b1b;
}

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

/* Per-state client list shown when a state is clicked. */
.map-state-clients { padding: 0 0 4px; }
.map-clients-table-wrap { overflow-x: auto; }
.map-clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.map-clients-table th {
  text-align: left;
  background: var(--blue-50);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.map-clients-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.map-clients-table tr:last-child td { border-bottom: none; }
.map-clients-table tr.map-client-row { cursor: pointer; transition: background 0.12s ease; }
.map-clients-table tr.map-client-row:hover td { background: #f8fafc; }
.map-client-tone {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.map-client-tone-good { background: #059669; }
.map-client-tone-ok { background: #f59e0b; }
.map-client-tone-bad { background: #dc2626; }
.map-client-tone-neutral { background: #94a3b8; }

/* ===== Merlyn dashboard widgets ===== */
/* Masonry-style layout: widgets pack into 2 columns with no dead space.
   The user drags to reorder; CSS column-fill: balance keeps both columns
   roughly the same height. Each widget keeps its natural size. */
.widget-grid {
  column-count: 2;
  column-gap: 16px;
  column-fill: balance;
  margin-top: 18px;
}
@media (max-width: 900px) {
  .widget-grid { column-count: 1; }
}
.widget-grid.widget-grid-empty {
  column-count: 1;
  min-height: 100px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(241, 245, 249, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.widget-grid.widget-grid-empty::after {
  content: 'Drop a widget here';
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.widget {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: block;
  width: 100%;
  margin: 0 0 16px 0;
  min-width: 0;
  transition: box-shadow 0.16s ease;
}
.widget-header {
  position: relative;
  padding: 22px 56px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
  border-radius: 12px 12px 0 0;
}
.widget-grip {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  color: #cbd5e1;
  font-size: 16px;
  letter-spacing: -3px;
  user-select: none;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.12s ease, background 0.12s ease;
}
.widget-grip:hover { color: #64748b; background: #f1f5f9; }
.widget-grip:active { cursor: grabbing; }
.widget-titleblock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  width: 100%;
  min-width: 0;
}
.widget-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-actions {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}
.widget-actions .btn { padding: 4px 10px; font-size: 12px; }
.widget-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  font-size: 14px !important;
  line-height: 1;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.widget-icon-btn:hover {
  background: var(--blue-50);
  color: var(--blue-500);
  border-color: var(--blue-500);
}
.widget-remove-btn { font-size: 18px !important; }
.widget-remove-btn:hover { color: #dc2626; background: #fee2e2; border-color: #fca5a5; }
.widget-refresh-btn { font-size: 14px !important; }
.widget-body { padding: 0; }
.widget.widget-ghost { opacity: 0.4; }
.widget.sortable-chosen { box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18); }
.widget.sortable-drag { box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25); cursor: grabbing; }


.widget-add-row { margin-top: 16px; }
.widget-add-btn-sm {
  width: auto !important;
  padding: 10px 22px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  border-radius: 999px !important;
  border-width: 1px !important;
  align-self: center;
}
.widget-add-btn {
  width: 100%;
  padding: 14px;
  background: #fff;
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.widget-add-btn:hover {
  border-color: var(--blue-500);
  color: var(--blue-500);
  background: var(--blue-50);
}

.widget-picker {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 6px;
  min-width: 240px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.widget-picker button {
  background: #fff;
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  font-family: inherit;
  transform-origin: center;
}
.widget-picker button:hover:not(:disabled) {
  background: var(--blue-50);
  transform: scale(1.03);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.widget-picker button:hover:not(:disabled) .widget-picker-icon {
  background: var(--blue-100);
}
.widget-picker button:disabled { opacity: 0.5; cursor: not-allowed; }
.widget-picker-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--blue-50);
  color: var(--blue-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.widget-picker-icon svg { width: 20px; height: 20px; display: block; }
.widget-picker-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.widget-picker button strong { font-size: 14px; color: var(--text); font-weight: 600; }
.widget-picker button .muted { font-size: 12px; }

/* Client info widget */
.widget-client-config {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.widget-client-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.widget-client-input:focus { outline: 2px solid var(--blue-500); outline-offset: -1px; }
.widget-client-search { flex: 1; position: relative; min-width: 0; }
.widget-client-search .widget-client-input { width: 100%; padding-right: 32px; }
.widget-client-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.widget-client-clear:hover { background: #fee2e2; color: #dc2626; }
.widget-client-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 4px;
}
.widget-client-suggestions[hidden] { display: none; }
.widget-client-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.widget-client-suggestion strong { font-weight: 600; }
.widget-client-suggestion .muted { font-size: 11px; color: var(--muted); }
.widget-client-suggestion:hover { background: var(--blue-50); }
.widget-client-content { padding: 16px 20px; }
.widget-client-meta { margin-bottom: 12px; }
.widget-client-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.widget-kpi {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.widget-kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.widget-kpi-value {
  font-weight: 700;
  font-size: 18px;
  margin-top: 4px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Map widget */
.widget-map .widget-body { padding: 0; }
.widget-map-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 620;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: #f1f5f9;
}
.widget-map-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.widget-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  background: rgba(241, 245, 249, 0.7);
  pointer-events: none;
}
.widget-map-loading[hidden] { display: none; }

.widget-map-clients[hidden] { display: none; }
.widget-map-clients {
  border-top: 1px solid var(--border);
  background: #fff;
  border-radius: 0 0 12px 12px;
}
.widget-map-clients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.widget-map-clients-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.widget-map-clients-clear {
  padding: 4px 12px !important;
  font-size: 12px !important;
}
.widget-map-clients-body { padding: 4px 0 8px; }
.widget-map-clients-body .map-clients-table { width: 100%; }
