:root {
  color-scheme: light;
  --ink: #162132;
  --muted: #718096;
  --line: #e5e9ef;
  --paper: #f5f7fa;
  --white: #ffffff;
  --navy: #101927;
  --navy-soft: #1d2d42;
  --orange: #f36a3d;
  --orange-soft: #fff0e9;
  --blue: #3279bd;
  --blue-soft: #eaf4fb;
  --green: #2a9771;
  --green-soft: #e8f6f0;
  --cream: #f3ede1;
  --shadow: 0 12px 35px rgba(24, 40, 61, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 76px;
  padding: 16px clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--navy);
  color: var(--white);
}

.brand-lockup, .topbar-actions, .hero-note, .panel-heading, .section-heading, .heading-actions, .table-toolbar, .dialog-heading {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--orange);
  color: var(--white);
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  line-height: 1.1;
}
.topbar .eyebrow { color: #9dacc0; }
.eyebrow.accent { color: var(--orange); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 18px; letter-spacing: -.02em; }
h2 { max-width: 650px; margin-bottom: 10px; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.045em; line-height: 1.02; }
h3 { margin-bottom: 0; font-size: 17px; letter-spacing: -.025em; }

.topbar-actions { gap: 16px; }
.muted { color: #9dacc0; font-size: 12px; }
.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, border .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-quiet { border-color: #3c4b5f; background: transparent; color: white; }
.button-quiet:hover { background: #1d2d42; }
.button-primary { background: var(--orange); color: white; }
.button-primary:hover { background: #dd5830; }

main { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 70px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; margin: 0 0 42px; }
.hero-copy { max-width: 620px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.hero-note { gap: 10px; padding: 12px 16px; border: 1px solid #dde4ed; border-radius: 10px; background: rgba(255,255,255,.7); }
.hero-note strong, .hero-note span { display: block; }
.hero-note strong { font-size: 12px; }
.hero-note span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-dot, .legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 100%; }
.status-dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.tabs { display: flex; gap: 3px; margin-bottom: 30px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #ebeff4; }
.tab, .duplicate-tab { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.tab { min-height: 38px; padding: 0 18px; border-radius: 7px; }
.tab.is-active { background: white; box-shadow: 0 2px 8px rgba(24, 40, 61, .08); color: var(--ink); }
.tab:hover:not(.is-active), .duplicate-tab:hover:not(.is-active) { color: var(--ink); }
.tab-panel { position: relative; display: none; }
.tab-panel.is-active { display: block; }

.loading-state { display: flex; min-height: 55px; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 1px dashed #cfd8e4; border-radius: 10px; color: var(--muted); text-align: center; }
.loading-state[hidden] { display: none; }
.loading-spinner { display: inline-block; width: 17px; height: 17px; flex: 0 0 auto; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; color: var(--orange); animation: dashboard-spin .75s linear infinite; }
.tab-panel.is-loading::before { position: absolute; z-index: 2; top: 50%; left: 50%; width: 28px; height: 28px; margin: -14px; border: 3px solid var(--orange); border-right-color: transparent; border-radius: 50%; content: ''; pointer-events: none; animation: dashboard-spin .75s linear infinite; }
.tab-panel.is-loading::after { position: absolute; z-index: 1; inset: 0; border-radius: 12px; background: rgba(245,247,250,.68); content: ''; pointer-events: none; }
@keyframes dashboard-spin { to { transform: rotate(360deg); } }
.error-banner { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #f3b4a1; border-radius: 9px; background: var(--orange-soft); color: #a83e22; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card { min-height: 148px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.metric-card-dark { border-color: var(--navy); background: var(--navy); color: white; }
.metric-label, .metric-meta { display: block; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.metric-card-dark .metric-label { color: #aab8c8; }
.metric-card strong { display: block; margin: 22px 0 7px; font-size: 34px; letter-spacing: -.06em; line-height: 1; }
.metric-meta { color: var(--muted); font-size: 11px; }
.metric-card-dark .metric-meta { color: #aab8c8; }

.overview-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.panel-large, .overview-grid > .panel { min-height: 340px; padding: 24px; }
.panel-heading { justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.panel-caption { color: var(--muted); font-size: 11px; }
.bar-list { display: grid; gap: 17px; }
.bar-item { display: grid; gap: 7px; }
.bar-label, .bar-values { display: flex; justify-content: space-between; gap: 10px; }
.bar-label { font-size: 12px; font-weight: 700; }
.bar-values { color: var(--muted); font-size: 11px; }
.bar-track { height: 7px; overflow: hidden; border-radius: 20px; background: #ecf0f4; }
.bar-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--orange); }
.source-list { display: grid; gap: 14px; }
.source-card { padding: 15px; border-radius: 9px; background: var(--blue-soft); }
.source-card:nth-child(2) { background: var(--orange-soft); }
.source-card h4 { margin: 0 0 10px; font-size: 13px; }
.source-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.source-stats strong, .source-stats span { display: block; }
.source-stats strong { font-size: 20px; letter-spacing: -.04em; }
.source-stats span { margin-top: 2px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.mailing-activity-panel { min-width: 0; }
.mailing-table { min-width: 720px; }
.mailing-table th, .mailing-table td { white-space: nowrap; }
.mailing-run-list { display: grid; gap: 0; }
.mailing-run { padding: 14px 0; border-bottom: 1px solid #e7edf3; }
.mailing-run:first-child { padding-top: 0; }
.mailing-run:last-child { border-bottom: 0; }
.mailing-run-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mailing-run-heading strong { font-size: 13px; }
.mailing-run-status { padding: 4px 7px; border-radius: 5px; background: var(--blue-soft); color: var(--blue); font-size: 10px; font-weight: 800; }
.mailing-run-status-completed { background: var(--green-soft); color: var(--green); }
.mailing-run-status-failed { background: var(--orange-soft); color: #a83e22; }
.mailing-run-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.mailing-run-failure { color: #a83e22; font-weight: 750; }
.mailing-empty { margin: 0; }
.mailing-recipients-panel { margin-top: 18px; overflow: hidden; }
.mailing-recipients-heading { align-items: flex-start; margin: 0; padding: 22px 22px 16px; }
.mailing-recipients-heading h3 { margin: 0 0 5px; }
.mailing-recipients-heading .panel-caption { display: block; color: #5f6c7c; line-height: 1.5; }
.mailing-recipients-heading .table-count { color: #5f6c7c; }
.mailing-recipient-filters { display: grid; grid-template-columns: minmax(220px, 1.5fr) minmax(220px, 1fr); gap: 12px; padding: 0 22px 18px; }
.mailing-recipient-filters label { display: grid; gap: 7px; min-width: 0; }
.mailing-recipient-filters label > span { color: #5f6c7c; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.mailing-recipient-table { min-width: 680px; }
.mailing-recipient-table td:first-child { overflow-wrap: anywhere; font-weight: 700; }
.mailing-recipient-table td:nth-child(3) { color: #5f6c7c; white-space: nowrap; }
.mailing-recipient-status { display: inline-flex; padding: 4px 8px; border-radius: 5px; background: #eef1f5; color: #526174; font-size: 11px; font-weight: 800; white-space: nowrap; }
.mailing-recipient-status-accepted { background: var(--green-soft); color: #1d6b50; }
.mailing-recipient-status-queued { background: var(--blue-soft); color: #24649b; }
.mailing-recipient-status-transient_failure, .mailing-recipient-status-permanent_bounce { background: var(--orange-soft); color: #a83e22; }
.mailing-recipient-status-reserved, .mailing-recipient-status-unknown { background: #fff4dc; color: #855a0c; }
.mailing-recipient-detail-button { min-height: 30px; padding: 0 4px; }
.mailing-recipient-detail-row:hover { background: transparent; }
.mailing-recipient-detail-row > td { padding: 14px 18px 18px; background: #f8fafc; }
.mailing-attempt-list { display: grid; gap: 9px; }
.mailing-attempts-current { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 11px; color: #5f6c7c; font-size: 11px; }
.mailing-attempt { padding: 12px 14px; border: 1px solid #e2e8ef; border-radius: 8px; background: white; }
.mailing-attempt-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mailing-attempt-heading strong { font-size: 12px; }
.mailing-attempt-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 8px; color: #5f6c7c; font-size: 11px; overflow-wrap: anywhere; }
.mailing-attempt-error { margin: 8px 0 0; color: #9c3e28; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.mailing-attempts-empty { margin: 0; color: #5f6c7c; font-size: 12px; }
.mailing-recipient-pagination { border-top: 1px solid var(--line); }

.callout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.callout { min-height: 130px; padding: 20px; border-radius: 12px; }
.callout-orange { background: var(--orange); color: white; }
.callout-blue { background: var(--blue); color: white; }
.callout-cream { background: var(--cream); }
.callout-kicker { display: block; margin-bottom: 20px; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.callout strong { display: block; margin-bottom: 5px; font-size: 27px; letter-spacing: -.05em; }
.callout > span:last-child { font-size: 11px; opacity: .78; }

.section-heading { justify-content: space-between; gap: 28px; margin: 0 0 26px; }
.section-heading p:not(.eyebrow) { max-width: 650px; margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.compact-heading { align-items: flex-end; }
.filters, .seller-toolbar { display: grid; grid-template-columns: 2fr repeat(6, 1fr); gap: 12px; margin-bottom: 16px; padding: 15px; }
.seller-toolbar { grid-template-columns: 2fr 1fr; }
.filters label, .seller-toolbar label { display: grid; gap: 7px; min-width: 0; }
.filters label > span, .seller-toolbar label > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.score-filter-label { position: relative; display: flex; align-items: center; gap: 6px; }
.score-filter-label > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.tooltip-trigger { display: inline-flex; width: 17px; height: 17px; align-items: center; justify-content: center; padding: 0; border: 1px solid #b8c5d3; border-radius: 50%; background: white; color: var(--blue); cursor: help; font-size: 11px; font-weight: 900; line-height: 1; }
.tooltip-trigger:hover, .tooltip-trigger:focus { border-color: var(--orange); color: var(--orange); outline: none; box-shadow: 0 0 0 3px var(--orange-soft); }
.score-tooltip { position: absolute; z-index: 5; top: calc(100% + 10px); left: 0; display: grid; width: min(330px, calc(100vw - 48px)); gap: 6px; padding: 13px 14px; border: 1px solid #cbd6e2; border-radius: 9px; background: var(--navy); box-shadow: 0 12px 28px rgba(16, 25, 39, .2); color: #f7fafc !important; font-size: 11px !important; font-weight: 500 !important; letter-spacing: normal !important; line-height: 1.45; text-transform: none !important; }
.score-tooltip[hidden] { display: none; }
.score-tooltip strong { color: white; font-size: 12px; }
output { color: var(--orange); }
input, select { width: 100%; height: 37px; padding: 0 10px; border: 1px solid #d9e0e8; border-radius: 7px; outline: none; background: white; color: var(--ink); }
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
input[type="range"] { height: 37px; padding: 0; accent-color: var(--orange); }
.table-panel { overflow: hidden; }
.table-toolbar { min-height: 54px; justify-content: space-between; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.table-count { color: var(--muted); font-size: 12px; font-weight: 700; }
.legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.legend-dot-green { background: var(--green); margin-left: 12px; }
.legend-dot-orange { background: var(--orange); }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.sort-button { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; letter-spacing: inherit; text-align: left; text-transform: inherit; }
.sort-button:hover, .sort-button:focus { color: var(--ink); outline: none; }
.sort-button:focus-visible { border-radius: 4px; box-shadow: 0 0 0 3px var(--orange-soft); }
.sort-indicator { color: var(--orange); font-size: 14px; line-height: .8; }
[data-lead-sort-header][aria-sort="none"] .sort-indicator { color: #aeb9c6; opacity: .8; }
td { font-size: 12px; }
tbody tr:hover { background: #fbfcfd; }
.score-pill { display: inline-flex; min-width: 38px; justify-content: center; padding: 5px 8px; border-radius: 20px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.score-pill.low { background: #eef1f5; color: var(--muted); }
.contact-cell strong, .contact-cell span { display: block; }
.contact-cell strong { font-size: 12px; }
.contact-cell span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.seller-name { font-weight: 700; }
.subtle { color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 230px; }
.tag { display: inline-flex; padding: 4px 7px; border-radius: 5px; background: #f0f3f6; color: #526174; font-size: 10px; white-space: nowrap; }
.signal-list { display: flex; flex-wrap: wrap; gap: 4px; }
.signal { padding: 3px 6px; border-radius: 4px; background: var(--orange-soft); color: #b44c2c; font-size: 10px; font-weight: 700; }
.action-button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 11px; font-weight: 800; }
.action-button:hover { text-decoration: underline; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 58px; padding: 0 18px; }
.pagination button { min-width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--muted); cursor: pointer; }
.pagination button:disabled { cursor: not-allowed; opacity: .45; }
.pagination span { color: var(--muted); font-size: 11px; }
.empty-row { padding: 28px !important; color: var(--muted); text-align: center; }

.duplicate-switcher { display: flex; width: fit-content; margin-bottom: 14px; padding: 4px; border-radius: 9px; background: #ebeff4; }
.duplicate-tab { padding: 9px 14px; border-radius: 6px; }
.duplicate-tab.is-active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(24,40,61,.08); }
.duplicate-tab span { display: inline-block; min-width: 25px; margin-left: 4px; color: var(--orange); }
.duplicate-summary { display: flex; gap: 22px; min-height: 45px; align-items: center; color: var(--muted); font-size: 12px; }
.duplicate-summary strong { color: var(--ink); }

.lead-dialog { width: min(740px, calc(100% - 32px)); max-height: 85vh; padding: 0; border: 0; border-radius: 14px; box-shadow: 0 20px 70px rgba(16,25,39,.25); color: var(--ink); }
.lead-dialog::backdrop { background: rgba(16,25,39,.56); }
.dialog-heading { justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 24px; }
.icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 28px; line-height: 1; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
.button:disabled:hover { transform: none; }
#dialog-content { overflow-y: auto; padding: 24px; }
.dialog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.dialog-stat { padding: 12px; border-radius: 8px; background: var(--paper); }
.dialog-stat span, .dialog-stat strong { display: block; }
.dialog-stat span { margin-bottom: 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.dialog-stat strong { font-size: 14px; overflow-wrap: anywhere; }
.dialog-ads { display: grid; gap: 8px; }
.dialog-ad { padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.dialog-ad a { color: var(--blue); font-weight: 750; text-decoration: none; }
.dialog-ad a:hover { text-decoration: underline; }
.dialog-ad-meta { display: flex; flex-wrap: wrap; gap: 7px 13px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.footer { display: flex; justify-content: space-between; padding: 20px clamp(20px, 5vw, 72px); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (prefers-reduced-motion: reduce) {
  .loading-spinner, .tab-panel.is-loading::before { animation-duration: 1.5s; }
}

@media (max-width: 1050px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .filter-search { grid-column: span 3; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1440px); padding-top: 32px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .hero-row, .section-heading { align-items: flex-start; flex-direction: column; }
  .hero-row { gap: 22px; margin-bottom: 28px; }
  .hero-note { width: 100%; }
  .tabs { overflow-x: auto; }
  .tab { flex: 0 0 auto; padding: 0 14px; }
  .overview-grid, .callout-grid { grid-template-columns: 1fr; }
  .panel-large, .overview-grid > .panel { min-height: auto; }
  .filters, .seller-toolbar { grid-template-columns: repeat(2, 1fr); }
  .filter-search { grid-column: span 2; }
  .heading-actions, .heading-actions .button { width: 100%; }
  .duplicate-switcher { width: 100%; overflow-x: auto; }
  .duplicate-tab { flex: 1 0 auto; }
  .duplicate-summary { flex-wrap: wrap; gap: 8px 15px; padding: 8px 0; }
  .mailing-recipient-filters { grid-template-columns: 1fr; padding-right: 14px; padding-left: 14px; }
  .mailing-recipients-heading { align-items: flex-start; flex-direction: column; gap: 8px; padding-right: 14px; padding-left: 14px; }
  .mailing-recipient-detail-row > td { padding-right: 10px; padding-left: 10px; }
  .dialog-grid { grid-template-columns: 1fr 1fr; }
  .footer { gap: 10px; flex-direction: column; }
}

@media (max-width: 440px) {
  .metric-grid { grid-template-columns: 1fr; }
  .filters, .seller-toolbar { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .dialog-grid { grid-template-columns: 1fr; }
}
