:root {
  color-scheme: light;
  --page: #f6f7f8;
  --surface: #ffffff;
  --surface-subtle: #f9fafb;
  --ink: #181b20;
  --muted: #626872;
  --line: #e3e6e9;
  --line-strong: #cfd4d9;
  --accent: #1769aa;
  --accent-soft: #eaf3fa;
  --lead: #287a55;
  --lead-soft: #e9f5ef;
  --partner: #9a5b24;
  --partner-soft: #fff1e5;
  --spam: #a33d36;
  --spam-soft: #fbeceb;
  --outbound: #426c91;
  --inbound: #75864b;
  --unmarked: #77808a;
  --unmarked-soft: #eff1f2;
  --shadow: 0 18px 48px rgba(22, 29, 37, 0.16);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 28px; line-height: 1.15; font-weight: 650; }
h2 { margin-bottom: 0; font-size: 19px; line-height: 1.25; font-weight: 650; }
h3 { margin-bottom: 7px; font-size: 13px; line-height: 1.3; font-weight: 650; }

.topbar, main { width: min(1480px, 100%); margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding-top: 30px; padding-bottom: 24px; }
.eyebrow { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.topbar-note, .section-note { margin-bottom: 0; color: var(--muted); }
.topbar-note { max-width: 760px; }
.period-mark { padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
main { padding-bottom: 56px; }

.summary-section { padding: 23px 0 21px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); border-top: 1px solid var(--line); }
.metric { min-height: 76px; padding: 11px 15px 0; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; }
.metric:hover, .metric.active { background: var(--surface-subtle); box-shadow: inset 0 -2px 0 var(--accent); }
.metric strong { display: block; font-size: 28px; line-height: 1.04; font-variant-numeric: tabular-nums; font-weight: 630; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.metric.lead strong { color: var(--lead); }
.metric.partner strong { color: var(--partner); }
.metric.spam strong { color: var(--spam); }

.chart-section { padding: 28px 0 25px; border-bottom: 1px solid var(--line-strong); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 17px; }
.section-head.compact { margin-bottom: 13px; }
.chart-frame { min-height: 480px; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.chart-frame svg { display: block; min-width: 860px; width: 100%; height: auto; }
.chart-grid { stroke: #e8ebee; stroke-width: 1; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart-label-secondary { fill: #7b6858; }
.chart-axis-title { fill: var(--accent); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.chart-axis-title-secondary { fill: #7b6858; }
.chart-source-divider { stroke: var(--line-strong); stroke-width: 1; }
.chart-source-title { fill: var(--muted); }
.chart-source-note { fill: var(--muted); font-size: 9px; font-weight: 650; }
.chart-value-badge, .value-leader { pointer-events: none; }
.chart-value-badge rect { fill: #fff; stroke-width: 1.4; }
.chart-value-badge text { font-size: 10px; font-weight: 800; stroke: none; }
.value-leader { stroke-width: 1; stroke-dasharray: 2 2; opacity: .55; }
.value-overall rect, .value-leader.value-overall { stroke: var(--accent); }
.value-overall text { fill: var(--accent); }
.value-spam rect, .value-leader.value-spam { stroke: var(--spam); }
.value-spam text { fill: var(--spam); }
.value-lead rect, .value-leader.value-lead { stroke: var(--lead); }
.value-lead text { fill: var(--lead); }
.value-partner rect, .value-leader.value-partner { stroke: var(--partner); }
.value-partner text { fill: var(--partner); }
.value-mixed rect, .value-leader.value-mixed { stroke: var(--line-strong); }
.value-mixed text { fill: var(--ink); }
.line-path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.line-overall { stroke: var(--accent); stroke-width: 3.25; }
.line-spam { stroke: var(--spam); }
.line-lead { stroke: var(--lead); }
.line-partner { stroke: var(--partner); }
.chart-legend text { fill: var(--muted); font-size: 11px; font-weight: 650; }
.month-target { cursor: pointer; outline: none; }
.chart-hit { fill: transparent; }
.dot-overall { fill: var(--accent); }
.dot-spam { fill: var(--spam); }
.dot-lead { fill: var(--lead); }
.dot-partner { fill: var(--partner); }
.source-bar-target { cursor: pointer; outline: none; }
.source-bar { opacity: .86; }
.bar-outbound { fill: var(--outbound); }
.bar-inbound { fill: var(--inbound); }
.source-bar-value { font-size: 9px; font-weight: 800; pointer-events: none; }
.source-bar-value.inside { fill: #fff; }
.source-bar-value.outside.bar-outbound { fill: var(--outbound); }
.source-bar-value.outside.bar-inbound { fill: var(--inbound); }
.source-bar-target:hover .source-bar, .source-bar-target:focus .source-bar { opacity: 1; stroke: var(--ink); stroke-width: 1.5; }
.month-target:hover .dot, .month-target:focus .dot { stroke: var(--ink); stroke-width: 2; }
.month-target.selected .dot { r: 6.5; stroke: var(--ink); stroke-width: 1.5; }
.month-target.selected .month-label { fill: var(--accent); font-weight: 800; }

.table-section { padding-top: 28px; }
.table-head { align-items: flex-end; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 7px; }
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.filters select, .filters input, .reset-button { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); padding: 6px 8px; }
.filters select { min-width: 105px; }
.filters input { width: 210px; }
.reset-button { color: var(--muted); }
.reset-button:hover { background: var(--surface-subtle); color: var(--ink); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { width: 100%; min-width: 1140px; border-collapse: collapse; text-align: left; table-layout: fixed; }
th { padding: 9px 11px; border-bottom: 1px solid var(--line-strong); background: var(--surface-subtle); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
th:nth-child(1) { width: 12%; }
th:nth-child(2) { width: 28%; }
th:nth-child(3) { width: 13%; }
th:nth-child(4) { width: 12%; }
th:nth-child(5) { width: 20%; }
th:nth-child(6) { width: 15%; }
td { padding: 13px 11px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
tbody tr { cursor: pointer; transition: background-color 150ms ease; }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover, tbody tr.selected { background: #fafbfd; }
td strong, td span, td small { display: block; }
td strong { font-weight: 650; }
td span, td small { color: var(--muted); }
td small { margin-top: 4px; font-size: 10px; }
.type-select { width: 100%; min-height: 31px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); padding: 5px 7px; font-size: 12px; font-weight: 650; }
.type-select[data-type="Lead"] { color: var(--lead); }
.type-select[data-type="Partner"] { color: var(--partner); }
.type-select[data-type="Spam"] { color: var(--spam); }
.type-select[data-type="Repeatable deal"] { color: var(--lead); }
.type-select[data-type="Repeatable partner"] { color: var(--partner); }
.type-select[data-type="Not enough information"],
.type-select[data-type="Unmarked"] { color: var(--unmarked); }
.tag { display: inline-block; width: max-content; border-radius: 3px; padding: 3px 6px; font-size: 10px; line-height: 1.25; }
.tag.outbound { background: var(--accent-soft); color: var(--accent); }
.tag.inbound { background: var(--lead-soft); color: var(--lead); }
.tag.untracked { background: var(--unmarked-soft); color: var(--unmarked); }
.no-link { color: var(--muted); font-size: 12px; }
.hubspot-display { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hubspot-display a, .hubspot-display .no-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hubspot-edit, .hubspot-save, .hubspot-cancel { min-height: 28px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); padding: 4px 7px; color: var(--muted); font-size: 10px; font-weight: 650; }
.hubspot-edit:hover, .hubspot-cancel:hover { background: var(--surface-subtle); color: var(--ink); }
.hubspot-editor { display: grid; gap: 6px; }
.hubspot-input { width: 100%; min-height: 32px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); padding: 6px 7px; color: var(--ink); font-size: 11px; }
.hubspot-input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.hubspot-input:invalid { border-color: var(--spam); }
.hubspot-actions { display: flex; gap: 5px; }
.hubspot-save { border-color: var(--accent); background: var(--accent); color: #fff; }
.hubspot-save:hover { background: #12598f; }
.empty { padding: 28px; color: var(--muted); text-align: center; }

.detail-backdrop { position: fixed; inset: 0; z-index: 4; background: rgba(28, 34, 40, .25); }
.detail-drawer { position: fixed; top: 0; right: 0; z-index: 5; width: min(560px, 100%); height: 100dvh; padding: 24px 27px 36px; transform: translateX(102%); background: var(--surface); box-shadow: var(--shadow); overflow-y: auto; transition: transform 220ms cubic-bezier(.16, 1, .3, 1); }
.detail-drawer.open { transform: translateX(0); }
.detail-drawer > header { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line-strong); }
.close-button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 20px; line-height: 1; }
.close-button:hover { background: var(--surface-subtle); color: var(--ink); }
#detailBody { display: grid; gap: 18px; padding-top: 20px; }
#detailBody section { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
#detailBody section:last-child { border-bottom: 0; }
#detailBody p { margin-bottom: 8px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.detail-grid div { padding: 9px 10px; border-left: 2px solid var(--line-strong); background: var(--surface-subtle); }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { color: var(--muted); font-size: 10px; }
.detail-grid strong { margin-top: 3px; font-size: 12px; }
.detail-links { display: grid; gap: 7px; }

@media (max-width: 920px) {
  .topbar, main { padding-left: 18px; padding-right: 18px; }
  .topbar, .section-head, .table-head { align-items: stretch; flex-direction: column; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:first-child { padding-left: 15px; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .filters { justify-content: flex-start; }
  .filters input { width: min(100%, 300px); }
}

@media (max-width: 560px) {
  h1 { font-size: 24px; }
  .topbar { gap: 16px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .detail-drawer { padding: 20px 18px 28px; }
  .filters label, .filters select, .filters input { width: 100%; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .search-label { grid-column: 1 / -1; }
}
