:root {
  color-scheme: light;
  --ink: #12131a;
  --muted: #6c6f7d;
  --line: #e5e6eb;
  --surface: #ffffff;
  --canvas: #f5f6f8;
  --primary: #3454d1;
  --primary-dark: #243da5;
  --accent: #c8ff5a;
  --table-stripe: #fafbff;
  --adjusted: #f3f5ff;
  --adjusted-strong: #e8ecff;
  --date-column-width: 136px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: inherit; text-decoration: none; }
code { direction: ltr; display: inline-block; font-size: .9em; }
.topbar { height: 72px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 750; direction: ltr; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: white; background: var(--ink); border-radius: 10px; }
.container { width: min(1440px, 92vw); margin: 0 auto; padding: 54px 0 80px; }
.hero { max-width: 1040px; margin: 4vh auto 0; }
.eyebrow { color: var(--primary); font-weight: 800; letter-spacing: .14em; font-size: 12px; direction: ltr; text-align: left; }
h1 { font-size: clamp(42px, 7vw, 86px); line-height: .98; letter-spacing: -.055em; margin: 18px 0 24px; }
h1 span { color: var(--primary); }
.lead { max-width: 680px; font-size: 20px; line-height: 1.7; color: var(--muted); margin-bottom: 30px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 18px; min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px; font: inherit; font-weight: 750; cursor: pointer; }
.button-primary { color: white; background: var(--primary); box-shadow: 0 8px 22px rgba(52,84,209,.18); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: white; border: 1px solid var(--line); }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 72px; }
.feature-grid article { background: var(--surface); padding: 28px; }
.feature-grid article > span { color: var(--primary); font: 800 12px ui-monospace, monospace; }
.feature-grid h2 { margin: 28px 0 8px; font-size: 19px; }
.feature-grid p { color: var(--muted); margin: 0; line-height: 1.6; }
.setup-card, .alert { padding: 18px 20px; border-radius: 12px; margin: 22px 0; line-height: 1.55; }
.setup-card { max-width: 720px; background: white; border: 1px solid var(--line); }
.setup-card p { margin: 8px 0 0; }
.muted { color: var(--muted); }
.alert-error { color: #7e1f27; background: #fff0f1; border: 1px solid #f1c5c8; }
.alert-info { color: #3d435d; background: #eef1ff; border: 1px solid #d7ddff; }
.link-button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; }
.report-header h1 { font-size: clamp(42px, 5vw, 66px); margin-bottom: 10px; }
.report-header p { color: var(--muted); }
.filters { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(2, minmax(150px, .7fr)) auto; gap: 14px; align-items: end; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 16px; margin: 26px 0; }
label span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 8px; }
select, input { width: 100%; height: 48px; padding: 0 13px; border: 1px solid #d8d9df; border-radius: 10px; background: white; font: inherit; color: var(--ink); }
.account-line { display: flex; justify-content: space-between; align-items: center; margin: 34px 0 18px; }
.account-line strong, .account-line span { display: block; }
.account-line span { color: var(--muted); font-size: 13px; margin-top: 5px; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.kpis article { min-width: 0; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.kpis span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.kpis strong { font-size: clamp(18px, 2vw, 27px); letter-spacing: -.03em; white-space: nowrap; }
.table-card { overflow: hidden; background: white; border: 1px solid #dfe2ec; border-radius: 20px; box-shadow: 0 18px 50px rgba(31, 38, 69, .08); }
.table-title { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 20px 24px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, #fff 55%, #f4f6ff); }
.table-title h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.table-title p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.table-title-meta { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.sort-hint, .count-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.sort-hint { color: var(--primary-dark); background: #edf0ff; }
.sort-hint > span { font-size: 15px; }
.count-pill { color: #4d5160; background: white; border: 1px solid #dfe2ec; }
.table-scroll { max-height: min(70vh, 760px); overflow: auto; scrollbar-color: #c7cad5 transparent; scrollbar-width: thin; }
.analytics-table { width: 100%; min-width: 1960px; border-collapse: separate; border-spacing: 0; white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.analytics-table th, .analytics-table td { padding: 13px 15px; text-align: left; border-bottom: 1px solid #eceef3; }
.analytics-table thead th { position: sticky; top: 0; z-index: 4; height: 54px; padding: 0; color: #565b6b; font-size: 11px; letter-spacing: .025em; background: #f7f8fb; box-shadow: inset 0 -1px #dfe2ea; }
.analytics-table tbody tr:nth-child(even) td { background: var(--table-stripe); }
.analytics-table tbody tr:hover td { background: #f1f4ff; }
.analytics-table tbody tr:last-child td { border-bottom: 0; }
.analytics-table td strong, .analytics-table td small { display: block; }
.analytics-table td small { color: #858a98; margin-top: 5px; direction: ltr; text-align: left; font-size: 10px; }
.sort-button { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 7px; padding: 9px 15px; border: 0; color: inherit; background: transparent; font: inherit; font-weight: 800; letter-spacing: inherit; text-align: left; cursor: pointer; white-space: nowrap; }
.sort-button:hover { color: var(--primary-dark); background: #eef1ff; }
.sort-button:focus-visible { position: relative; z-index: 1; outline: 3px solid rgba(52, 84, 209, .28); outline-offset: -3px; }
.sort-indicator { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: 0 0 18px; margin-left: auto; border-radius: 6px; color: #9a9eaa; background: rgba(110, 116, 137, .08); }
.sort-indicator::before { content: "↕"; font-size: 11px; }
.analytics-table th[aria-sort="ascending"] .sort-button, .analytics-table th[aria-sort="descending"] .sort-button { color: var(--primary-dark); background: #e9edff; }
.analytics-table th[aria-sort="ascending"] .sort-indicator, .analytics-table th[aria-sort="descending"] .sort-indicator { color: white; background: var(--primary); }
.analytics-table th[aria-sort="ascending"] .sort-indicator::before { content: "↑"; }
.analytics-table th[aria-sort="descending"] .sort-indicator::before { content: "↓"; }
.numeric-header .sort-button { justify-content: flex-end; text-align: right; }
.numeric-header .sort-indicator { margin-left: 3px; }
.numeric-cell { text-align: right !important; }
.money-cell { font-weight: 700; color: #303442; }
.adjusted-header { background: #eef1ff !important; color: #454b72 !important; }
.range-metric { background: var(--adjusted) !important; box-shadow: inset 1px 0 rgba(52, 84, 209, .06), inset -1px 0 rgba(52, 84, 209, .06); }
.analytics-table tbody tr:nth-child(even) .range-metric { background: #edf0fc !important; }
.analytics-table tbody tr:hover .range-metric { background: var(--adjusted-strong) !important; }
.range-metric > strong { color: var(--primary-dark); }
.date-cell { min-width: var(--date-column-width); }
.date-cell strong { font-size: 12px; color: #303442; }
.campaign-cell { width: 238px; min-width: 238px; max-width: 238px; box-shadow: 8px 0 18px -18px rgba(22, 27, 48, .6); }
.campaign-name { max-width: 205px; overflow: hidden; color: #1e2230; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; cursor: help; border-radius: 5px; }
.campaign-name:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.campaign-id { max-width: 205px; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.campaign-tooltip { position: fixed; z-index: 1000; width: max-content; max-width: min(380px, calc(100vw - 24px)); padding: 13px 15px 14px; color: white; background: linear-gradient(145deg, #171a27, #292e48); border: 1px solid rgba(255, 255, 255, .14); border-radius: 13px; box-shadow: 0 16px 38px rgba(18, 21, 34, .28); white-space: normal; pointer-events: auto; user-select: text; cursor: text; animation: campaign-tooltip-in 140ms ease-out; }
.campaign-tooltip[hidden] { display: none; }
.campaign-tooltip::after { content: ""; position: absolute; left: var(--tooltip-arrow-left, 24px); width: 10px; height: 10px; background: #242941; transform: rotate(45deg); }
.campaign-tooltip[data-placement="top"]::after { bottom: -6px; border-right: 1px solid rgba(255, 255, 255, .14); border-bottom: 1px solid rgba(255, 255, 255, .14); }
.campaign-tooltip[data-placement="bottom"]::after { top: -6px; border-left: 1px solid rgba(255, 255, 255, .14); border-top: 1px solid rgba(255, 255, 255, .14); }
.campaign-tooltip-label { display: block; margin-bottom: 7px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.campaign-tooltip-value { display: block; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.campaign-tooltip-id { display: block; margin-top: 9px; color: #b8bed6; font-size: 10px; }
@keyframes campaign-tooltip-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.actions-cell { min-width: 150px; white-space: normal; }
.actions-cell details { min-width: 126px; }
.actions-cell summary { width: fit-content; padding: 6px 9px; color: var(--primary-dark); background: #eef1ff; border-radius: 9px; cursor: pointer; font-weight: 750; white-space: nowrap; list-style: none; }
.actions-cell summary::-webkit-details-marker { display: none; }
.actions-cell summary::after { content: "+"; margin-left: 8px; color: var(--primary); }
.actions-cell details[open] summary::after { content: "−"; }
.actions-cell summary span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-right: 3px; color: white; background: var(--primary); border-radius: 6px; font-size: 10px; }
.action-list { display: grid; gap: 10px; margin-top: 12px; }
.action-item { display: grid; grid-template-columns: auto 1fr; gap: 5px 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafafa; }
.action-item code { grid-column: 1 / -1; overflow-wrap: anywhere; }
.action-item > span:not(.action-category) { color: var(--muted); font-size: 12px; }
.action-category { width: fit-content; padding: 2px 6px; border-radius: 999px; color: #4e5260; background: #eceef2; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.category-purchase { color: #275a18; background: #eaffd6; }
.category-lead { color: #243da5; background: #e8ecff; }
.roas { display: inline-block; min-width: 52px; padding: 6px 10px; text-align: center; border: 1px solid transparent; border-radius: 9px; font-weight: 850; }
.roas-kpi { width: fit-content; font-size: clamp(18px, 2vw, 27px); }
.roas-high { color: #17632d; background: #e5f8ea; border-color: #9ed7ad; box-shadow: 0 4px 12px rgba(23,99,45,.12); }
.roas-neutral { color: #535966; background: #f1f2f4; border-color: #d9dbe1; }
.roas-low { color: #9d2433; background: #ffe8ec; border-color: #efb3bc; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.empty { padding: 50px; text-align: center; color: var(--muted); }
.empty-state { padding: 60px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 16px; }

@media (max-width: 980px) {
  .feature-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:first-child { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .table-title { align-items: flex-start; flex-direction: column; }
}
@media (min-width: 1100px) {
  .analytics-table .sticky-date { position: sticky; left: 0; z-index: 3; width: var(--date-column-width); min-width: var(--date-column-width); max-width: var(--date-column-width); }
  .analytics-table .sticky-campaign { position: sticky; left: var(--date-column-width); z-index: 3; }
  .analytics-table thead .sticky-date, .analytics-table thead .sticky-campaign { z-index: 6; }
  .analytics-table tbody .sticky-date, .analytics-table tbody .sticky-campaign { background: white; }
  .analytics-table tbody tr:nth-child(even) .sticky-date, .analytics-table tbody tr:nth-child(even) .sticky-campaign { background: var(--table-stripe); }
  .analytics-table tbody tr:hover .sticky-date, .analytics-table tbody tr:hover .sticky-campaign { background: #f1f4ff; }
}
@media (max-width: 620px) {
  .container { padding-top: 34px; }
  .filters, .kpis { grid-template-columns: 1fr; }
  .filters label:first-child { grid-column: auto; }
  .account-line { align-items: flex-start; gap: 14px; flex-direction: column; }
  .table-title-meta { align-items: flex-start; flex-direction: column; }
}
