/* Ads Metrics Hub — light modern tech UI */
:root {
  --bg: #f4f6fb;
  --bg2: #eef1f8;
  --surface: #ffffff;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-ring: rgba(79, 70, 229, 0.28);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.1);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --top-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    radial-gradient(900px 420px at 10% -8%, rgba(99, 102, 241, 0.09), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(14, 165, 233, 0.07), transparent 50%);
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

code {
  font-family: var(--mono);
  font-size: 0.78em;
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--muted);
}

/* ---- Gate ---- */
.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: var(--shadow-lg);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}

.gate-card h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gate-card .sub {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0 0 22px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="password"],
input[type="date"],
input[type="text"],
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, color 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.38);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.82rem;
}

.btn-ghost:hover {
  background: var(--bg2);
  color: var(--text);
}

.btn-block {
  width: 100%;
  display: block;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.msg {
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 10px 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.45;
}

.msg.error {
  background: var(--err-soft);
  border: 1px solid rgba(220, 38, 38, 0.22);
  color: #b91c1c;
}

.msg.warn {
  background: var(--warn-soft);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: #b45309;
}

.msg.ok {
  background: var(--green-soft);
  border: 1px solid rgba(5, 150, 105, 0.22);
  color: #047857;
}

.health-line {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--muted-2);
  text-align: center;
  line-height: 1.4;
  font-family: var(--mono);
}

/* ---- App shell ---- */
.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.brand-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.persona-wrap select {
  margin: 0;
  width: auto;
  max-width: 150px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bg2);
  border-color: transparent;
}

.main {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.screen-head {
  margin-bottom: 14px;
}

.screen-head h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.flow-steps {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.flow-steps .step {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.82rem;
}

.flow-steps .step-sep {
  color: var(--muted-2);
  font-size: 0.75rem;
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(79, 70, 229, 0.28);
  box-shadow: none;
}

.date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.date-row input[type="date"] {
  margin: 0;
  width: auto;
  min-width: 0;
  flex: 1 1 120px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.date-row.tight {
  margin-bottom: 0;
}

/* Calendar date range — big clickable fields open native picker */
.date-range-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
}

.date-range-picker.home-dates {
  margin-bottom: 14px;
}

.date-field {
  position: relative;
  flex: 1 1 140px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  margin: 0 !important;
  padding: 12px 40px 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  color: var(--text);
  font-weight: 500;
}

.date-field:hover {
  border-color: var(--accent);
  background: #fff;
}

.date-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: #fff;
}

.date-caption {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.date-display {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.date-cal-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  pointer-events: none;
  display: flex;
}

.date-native {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0.011 !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 1.2rem;
  z-index: 2;
  background: transparent !important;
  box-shadow: none !important;
  color: transparent !important;
}

.date-native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.date-arrow {
  align-self: center;
  color: var(--muted-2);
  font-weight: 600;
  flex-shrink: 0;
}

.date-presets {
  margin-bottom: 10px;
}

.date-range-picker .btn-secondary {
  align-self: stretch;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(3, 1fr);
}

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

.kpi.highlight {
  grid-column: 1 / -1;
  border-color: rgba(79, 70, 229, 0.22);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), var(--card));
}

.kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.28rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Cards & tables */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

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

.card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  background: var(--bg);
}

.data-table tbody tr:hover {
  background: rgba(79, 70, 229, 0.03);
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.data-table td.name {
  white-space: normal;
  max-width: 220px;
  line-height: 1.35;
  font-weight: 500;
}

.data-table tr.row-click {
  cursor: pointer;
}

.data-table tr.row-click:active {
  background: var(--accent-soft);
}

/* Account cards */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.account-card:hover {
  border-color: rgba(79, 70, 229, 0.25);
  box-shadow: var(--shadow);
}

.account-card .ac-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.account-card .ac-meta {
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  font-family: var(--mono);
}

.account-card .ac-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted-2);
}

.status-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.status-dot.off {
  background: var(--err);
}

/* Scope tabs (1 TKQC vs cross-campaign) */
.scope-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.scope-btn {
  flex: 1;
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  color: var(--muted);
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.scope-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.live-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--green-soft);
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #047857;
  font-weight: 600;
}

.live-meta .dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
  animation: pulse-live 1.6s ease infinite;
}

@keyframes pulse-live {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.live-meta .meta-muted {
  color: var(--muted);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.live-meta .meta-pill {
  background: #fff;
  border: 1px solid rgba(5, 150, 105, 0.25);
  color: #047857;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--mono);
}

.match-yes {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  color: #047857;
  background: var(--green-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.match-no {
  color: var(--muted-2);
  font-size: 0.75rem;
}

.data-table tr.row-miss {
  opacity: 0.55;
}

.data-table tr.row-match {
  background: rgba(5, 150, 105, 0.04);
}

.action-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 12px 0 6px;
}

.action-group-label:first-child {
  margin-top: 0;
}

.metric-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.mchip {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--bg2);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.action-card.v-border-KILL {
  border-left: 3px solid #dc2626;
}
.action-card.v-border-PAUSE {
  border-left: 3px solid #ea580c;
}
.action-card.v-border-SCALE {
  border-left: 3px solid #059669;
}
.action-card.v-border-WATCH {
  border-left: 3px solid #d97706;
}
.action-card.v-border-LEARNING {
  border-left: 3px solid #64748b;
}
.action-card.v-border-KEEP {
  border-left: 3px solid #2563eb;
}

.verdict-chip.is-zero {
  opacity: 0.45;
}

.cross-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-toggle {
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-goal {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-goal.g-purchase {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
}
.badge-goal.g-messaging {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}
.badge-goal.g-lead {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}
.badge-goal.g-traffic {
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
}
.badge-goal.g-awareness {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}
.badge-goal.g-general {
  background: #f1f5f9;
  color: #64748b;
}

#campaign-table-hint {
  margin: -4px 0 10px;
}

/* Auto-refresh realtime bar */
.auto-refresh-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.auto-refresh-toggle {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  gap: 10px;
}

.auto-refresh-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.auto-refresh-interval select {
  margin: 0;
  width: auto;
  min-width: 130px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface);
}

.auto-refresh-status {
  flex: 1 1 100%;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.auto-refresh-status.is-on {
  color: #047857;
}

.auto-refresh-status.is-paused {
  color: #b45309;
}

.auto-refresh-status.is-off {
  color: var(--muted);
}

.auto-refresh-status .pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px var(--green-soft);
  animation: pulse-live 1.6s ease infinite;
}

@media (min-width: 560px) {
  .auto-refresh-status {
    flex: 1 1 auto;
    text-align: right;
  }
}

@media (max-width: 720px) {
  .auto-refresh-bar {
    padding: 10px;
    gap: 8px;
  }

  .auto-refresh-interval {
    flex: 1 1 auto;
  }

  .auto-refresh-interval select {
    width: 100%;
    min-height: 40px;
  }

  .auto-refresh-toggle {
    flex: 1 1 100%;
    min-height: 40px;
  }
}

#cross-account-search {
  margin-bottom: 8px;
}

.account-picks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.account-pick {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}

.account-pick input {
  width: auto;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.cross-account-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.playbook {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-radius: 12px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
}

.playbook strong {
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.playbook ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.playbook li {
  margin-bottom: 3px;
}

.action-card .next {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.4;
}

.action-card .meta-line {
  font-size: 0.72rem;
  color: var(--muted-2);
  margin-top: 4px;
  font-family: var(--mono);
}

/* Filter card / steps */
.filter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.filter-card .field {
  margin-bottom: 4px;
}

.filter-card label {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.84rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.filter-card input,
.filter-card select {
  margin-bottom: 6px;
}

.field-hint {
  margin: -2px 0 14px;
  font-size: 0.78rem;
  color: var(--muted-2);
  line-height: 1.4;
}

#field-campaign input#campaign-filter {
  margin-top: 2px;
}

#campaign-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg2);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

/* Verdicts */
.verdict-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.verdict-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg2);
}

.badge-verdict {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.v-SCALE {
  background: var(--green-soft);
  color: #047857;
  border-color: rgba(5, 150, 105, 0.25);
}

.v-KEEP {
  background: var(--blue-soft);
  color: #1d4ed8;
}

.v-WATCH {
  background: var(--warn-soft);
  color: #b45309;
}

.v-LEARNING {
  background: #f1f5f9;
  color: #475569;
}

.v-PAUSE {
  background: rgba(234, 88, 12, 0.1);
  color: #c2410c;
}

.v-KILL {
  background: var(--err-soft);
  color: #b91c1c;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.action-card .ah {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.action-card .ar {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  appearance: none;
  background: var(--bg2);
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}

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

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(79, 70, 229, 0.2);
}

.tab-panel {
  margin-top: 4px;
}

.footer-note {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

td.reason {
  white-space: normal;
  max-width: 220px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
}

td.name .sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted-2);
  font-weight: 400;
  margin-top: 2px;
  font-family: var(--mono);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-facebook {
  background: var(--blue-soft);
  color: #1d4ed8;
}

.badge-tiktok {
  background: rgba(219, 39, 119, 0.1);
  color: #be185d;
}

.stack-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.hint-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.persona-hint {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.04);
}

.nav-item {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 4px;
  transition: color 0.12s;
}

.nav-item .nav-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active .nav-icon {
  transform: scale(1.05);
}

/* Visibility helpers */
.mobile-only-block {
  display: none;
}
.desktop-only-block {
  display: block;
}

/* Campaign cards (mobile) */
.campaign-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.camp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 10px;
}

.camp-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.camp-spend {
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.camp-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.35;
  margin-bottom: 4px;
  word-break: break-word;
}

.camp-card-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 10px;
  word-break: break-all;
}

.camp-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 6px;
}

.camp-card-grid .k {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted-2);
  margin-bottom: 2px;
}

.camp-card-grid .v {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty-card {
  padding: 16px;
  text-align: center;
}

/* ========== Mobile (≤720px) ========== */
@media (max-width: 720px) {
  .mobile-only-block {
    display: block;
  }
  .desktop-only-block {
    display: none !important;
  }

  :root {
    --nav-h: 60px;
    --top-h: 52px;
  }

  /* Prevent iOS input zoom */
  input[type="password"],
  input[type="date"],
  input[type="text"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .topbar {
    padding: 8px 10px;
    gap: 6px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 0.62rem;
    border-radius: 9px;
  }

  .brand-title {
    font-size: 0.82rem;
  }

  .brand-sub {
    max-width: 28vw;
    font-size: 0.65rem;
  }

  .persona-wrap select {
    max-width: 108px;
    padding: 7px 8px;
    font-size: 0.7rem !important;
  }

  .btn-ghost {
    padding: 8px 10px;
    min-height: 40px;
  }

  .main {
    padding: 12px 12px 28px;
  }

  .screen-head h2 {
    font-size: 1.15rem;
  }

  .screen-head .muted,
  .flow-steps {
    font-size: 0.78rem;
  }

  .flow-steps .step {
    font-size: 0.75rem;
  }

  /* Scope tabs */
  .scope-tabs {
    gap: 4px;
    padding: 3px;
  }

  .scope-btn {
    padding: 12px 8px;
    font-size: 0.78rem;
    min-height: 44px;
  }

  /* Filter */
  .filter-card {
    padding: 14px 12px;
  }

  .step-num {
    width: 24px;
    height: 24px;
  }

  .chip-row {
    gap: 6px;
  }

  .chip {
    padding: 10px 12px;
    min-height: 40px;
    font-size: 0.78rem;
  }

  .date-range-picker {
    flex-direction: column;
    gap: 8px;
  }

  .date-arrow {
    display: none;
  }

  .date-field {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 56px;
  }

  .date-range-picker.home-dates .btn-secondary {
    width: 100%;
    min-height: 44px;
  }

  .cross-account-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .cross-account-actions {
    width: 100%;
  }

  .cross-account-actions .btn-ghost {
    flex: 1;
  }

  .account-picks {
    max-height: 160px;
  }

  .account-pick {
    padding: 6px 0;
    min-height: 40px;
    align-items: center;
  }

  /* KPI — 2 col, compact */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi-grid.compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .kpi {
    padding: 12px 10px;
  }

  .kpi-label {
    font-size: 0.62rem;
  }

  .kpi-value {
    font-size: 1.05rem;
  }

  .kpi-grid.compact .kpi-value {
    font-size: 0.95rem;
  }

  /* Live meta */
  .live-meta {
    font-size: 0.74rem;
    padding: 8px 10px;
    gap: 6px 8px;
  }

  .live-meta .meta-muted {
    font-size: 0.65rem;
  }

  /* Cards & actions */
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }

  .card-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-head h3 {
    font-size: 0.9rem;
  }

  .verdict-row {
    gap: 6px;
  }

  .verdict-chip {
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    margin-left: -2px;
    margin-right: -2px;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    padding: 10px 14px;
    min-height: 40px;
    font-size: 0.76rem;
  }

  .action-card {
    padding: 12px;
  }

  .action-card .ah {
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .metric-chips {
    gap: 4px;
  }

  .mchip {
    font-size: 0.68rem;
    padding: 4px 6px;
  }

  .playbook {
    font-size: 0.78rem;
    padding: 10px 12px;
  }

  /* Tables that remain (home, finance, daily) */
  .table-wrap {
    margin: 0 -4px;
    padding: 0 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .data-table {
    font-size: 0.78rem;
    min-width: 520px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }

  .data-table td.name {
    max-width: 160px;
  }

  /* Sticky run CTA feel */
  .filter-card .btn-primary.btn-block {
    min-height: 48px;
    font-size: 0.95rem;
    position: sticky;
    bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
    z-index: 5;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
  }

  /* Bottom nav */
  .bottom-nav {
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
  }

  .nav-item {
    min-height: 48px;
    font-size: 0.62rem;
    gap: 3px;
    padding: 6px 2px;
  }

  .nav-item .nav-icon {
    font-size: 1.15rem;
  }

  .app {
    padding-bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
  }

  /* Gate login */
  .gate {
    padding: 16px 14px;
  }

  .gate-card {
    padding: 24px 18px;
  }

  .gate-card h1 {
    font-size: 1.25rem;
  }

  .msg {
    font-size: 0.8rem;
  }

  .camp-card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .kpi-grid.compact {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .persona-wrap select {
    max-width: 92px;
  }

  .brand-sub {
    display: none;
  }
}

/* Desktop */
@media (min-width: 721px) {
  .mobile-only-block {
    display: none !important;
  }
  .desktop-only-block {
    display: block;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .kpi-grid.compact {
    grid-template-columns: repeat(6, 1fr);
  }

  .kpi.highlight {
    grid-column: auto;
  }

  .brand-sub {
    max-width: 360px;
  }

  .persona-wrap select {
    max-width: 200px;
  }

  .bottom-nav {
    max-width: 980px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 18px 18px 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .main {
    padding-top: 22px;
  }
}

body.persona-mkt .kpi-value {
  font-size: 1.2rem;
}

body.persona-mkt .nav-item {
  font-size: 0.68rem;
  min-height: 48px;
}

@media (min-width: 721px) {
  body.persona-mkt .kpi-value {
    font-size: 1.38rem;
  }
}
