:root {
  color-scheme: light;
  --paper: #f6f7f9;
  --surface: #ffffff;
  --wash: #eef0f3;
  --ink: #1c2330;
  --text: #3a4350;
  --muted: #606b7a;
  --quiet: #687280;
  --line: #e3e6eb;
  --control-line: #8893a3;
  --accent: #2456d6;
  --accent-hover: #1947bb;
  --accent-soft: #e8eefc;
  --accent-line: #cad8f5;
  --mark: #d9e3fa;
  --leaf: #177648;
  --leaf-wash: #e5f5ec;
  --blue: #0b5c86;
  --blue-wash: #e6f4fb;
  --direct-ink: #7a4a00;
  --direct-wash: #fff1d6;
  --ochre: #a64d08;
  --attention-surface: #fef3e2;
  --attention-line: #eed9b8;
  --red: #b42318;
  --red-wash: #fdecea;
  --hover-surface: #fafbfd;
  --shadow: #1c233012;
  --border: 1px solid var(--line);
  --focus: 3px solid var(--accent);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --xs: .75rem;
  --sm: .8125rem;
  --base: .875rem;
  --lg: 1rem;
  --h2: 1.24rem;
  --h1: 1.75rem;
  --number: clamp(1.8rem, 2.15vw, 2rem);
  --metric-height: 5.5rem;
  --compact-input: 2.125rem;
  --line-gap: .125rem;
  --s1: .25rem;
  --s2: .5rem;
  --s3: .75rem;
  --s4: 1rem;
  --s5: 1.25rem;
  --s6: 1.5rem;
  --s7: 2rem;
  --s8: 2.5rem;
  --gutter: clamp(1rem, 3vw, 3.25rem);
  --max: 104rem;
  --header: 4rem;
  --input: 2.5rem;
  --icon: 1rem;
  --r1: .32rem;
  --r2: .5rem;
  --r3: .75rem;
  --pill: 999px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151b24;
  --surface: #1e2632;
  --wash: #2a3442;
  --ink: #e2e8f0;
  --text: #c6d0de;
  --muted: #a8b4c5;
  --quiet: #96a4b7;
  --line: #333e4e;
  --control-line: #748398;
  --accent: #99baff;
  --accent-hover: #b4ccff;
  --accent-soft: #24334b;
  --accent-line: #364c6b;
  --mark: #2d405c;
  --leaf: #95ccad;
  --leaf-wash: #233c32;
  --blue: #9ec9e4;
  --blue-wash: #253b4b;
  --direct-ink: #dbba86;
  --direct-wash: #403528;
  --ochre: #e0bb86;
  --attention-surface: #332e29;
  --attention-line: #514537;
  --red: #eda69f;
  --red-wash: #432f34;
  --hover-surface: #26303e;
  --shadow: #0b101c59;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--base)/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2, p, dl, dd, ul { margin: 0; }
h1, h2, strong, b { font-weight: 650; }
h1, h2 { letter-spacing: -.04em; line-height: 1.15; }
h1 { font-size: var(--h1); }
h2 { font-size: var(--h2); }
a { color: var(--accent); text-decoration: none; }
a[href]:hover { text-decoration: underline; text-underline-offset: .22em; }
:focus-visible { outline: var(--focus); outline-offset: 3px; }
button, select, input { font: inherit; color: inherit; }
input, select, button {
  min-width: 0;
  min-height: var(--input);
  border-radius: var(--r2);
}
input, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--control-line);
  padding: var(--s2) var(--s3);
}
input::placeholder { color: var(--quiet); opacity: 1; }
input:hover, select:hover { border-color: var(--quiet); }
button {
  background: var(--accent);
  color: var(--surface);
  border: 1px solid transparent;
  font-weight: 600;
  padding: var(--s2) var(--s5);
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}
.skip:focus {
  position: absolute;
  z-index: 5;
  inset: var(--s2) auto auto var(--s2);
  background: var(--surface);
  padding: var(--s2) var(--s4);
}
.app-header { background: var(--surface); border-bottom: var(--border); }
.top-inner, .workspace {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.top-inner {
  display: flex;
  align-items: center;
  min-height: var(--header);
  gap: var(--s6);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -.075em;
}
.brand svg { width: 1.78rem; height: 1.78rem; color: var(--accent); }
.brand[href]:hover, .current[href]:hover { text-decoration: none; }
.app-nav { display: flex; gap: var(--s6); align-items: center; }
.app-nav::before { content: ""; height: var(--s6); border-left: var(--border); }
.current, .sections summary, .theme-toggle, .logout {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--input);
  font-size: var(--sm);
  font-weight: 550;
}
.current { min-height: var(--header); color: var(--accent); position: relative; }
.current::after {
  content: ""; position: absolute; inset: auto 0 -1px; height: 3px;
  background: var(--accent); border-radius: var(--r1) var(--r1) 0 0;
}
.current .icon { color: var(--accent); }
.theme-toggle { margin-inline-start: auto; color: var(--muted); }
.theme-toggle:hover { color: var(--accent); }
.logout { color: var(--accent); }
.sections { position: relative; color: var(--muted); }
.sections summary > .icon:last-child { width: var(--s3); }
.sections[open] summary > .icon:last-child { transform: rotate(180deg); }
.section-menu {
  position: absolute;
  z-index: 2;
  top: 100%;
  left: 0;
  min-width: 13rem;
  padding: var(--s4);
  background: var(--surface);
  border: var(--border);
  border-radius: var(--r2);
  box-shadow: 0 var(--s2) var(--s6) var(--shadow);
}
.section-menu p, .field label, .mobile-label {
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 600;
}
.section-menu p { padding-bottom: var(--s2); border-bottom: var(--border); }
.section-menu ul { list-style: none; padding: 0; }
.section-menu li { margin-top: var(--s2); }
.workspace { padding-block: var(--s5) var(--s8); }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s3);
}
.sync { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); min-width: 0; }
.fresh { color: var(--muted); font-size: var(--sm); }
.fresh time { white-space: nowrap; }
.refresh {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--compact-input);
  padding: var(--s1) var(--s3);
  background: var(--surface);
  color: var(--text);
  border-color: var(--control-line);
  font-size: var(--sm);
  font-weight: 550;
}
.refresh:hover { background: var(--wash); border-color: var(--quiet); }
.sync-notice {
  margin-bottom: var(--s3);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--attention-line);
  border-inline-start: 3px solid var(--ochre);
  border-radius: var(--r2);
  background: var(--attention-surface);
  color: var(--ochre);
  font-size: var(--sm);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.metric {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--r3);
  padding: var(--s3) var(--s4);
  display: grid;
  align-content: space-between;
  gap: var(--s1);
  min-height: var(--metric-height);
}
.metric dt { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-weight: 550; font-size: var(--sm); }
.metric dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s2); font-size: var(--number); letter-spacing: -.055em; font-weight: 620; line-height: 1.1; }
.metric small {
  display: inline-block;
  padding: .18rem .42rem;
  border-radius: var(--r1);
  background: var(--wash);
  color: var(--muted);
  font-weight: 570;
  font-size: var(--xs);
  letter-spacing: 0;
}
.metric--total { isolation: isolate; overflow: hidden; position: relative; background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.metric--total dt { color: var(--accent); }
.metric--total::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -1.1rem;
  bottom: var(--s7);
  width: 4.6rem;
  height: .72rem;
  background: var(--mark);
  box-shadow: 0 1rem var(--mark), 0 2rem var(--mark);
  transform: rotate(-14deg) skewX(-25deg);
}
.metric--orders small, .metric--known small { color: var(--leaf); background: var(--leaf-wash); }
.metric--movement { background: var(--attention-surface); border-color: var(--attention-line); }
.metric--movement small { color: var(--ochre); background: var(--direct-wash); }
.metric--movement .icon { color: var(--ochre); }
.ledger, .entry-card { background: var(--surface); border: var(--border); border-radius: var(--r3); }
.filters { --input: var(--compact-input); padding: var(--s3) var(--s6); }
.filters :is(input, select, button) { padding-block: var(--s1); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); margin-bottom: var(--s2); }
.search { position: relative; width: min(100%, 23rem); }
.search label { position: absolute; inset: 0 auto 0 var(--s3); display: grid; place-items: center; color: var(--muted); }
.search input { padding-left: var(--s7); font-size: var(--sm); }
.filter-grid { display: grid; grid-template-columns: minmax(0,.8fr) minmax(0,1.3fr) minmax(0,1.26fr) minmax(0,1fr) auto; align-items: end; gap: var(--s3); }
.field { display: grid; min-width: 0; gap: var(--s1); }
.select-box { position: relative; min-width: 0; }
.select-box select { appearance: none; cursor: pointer; padding-right: var(--s7); text-overflow: ellipsis; }
.select-box .icon { position: absolute; top: 50%; right: var(--s3); transform: translateY(-50%); pointer-events: none; width: var(--s3); }
.field--channel:has(option:checked:not([value=""])) select,
.field--outcome:has(option:checked:not([value=""])) select,
.field--kind:has(option:checked:not([value="inbound"])) select,
.field--period:has([value="custom"]:checked) select { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.actions { display: flex; align-items: center; gap: var(--s4); }
.reset { color: var(--accent); font-size: var(--sm); padding-block: var(--s1); }
.dates { display: flex; flex-wrap: wrap; gap: var(--s3); grid-column: 1 / -2; }
.filter-grid:has(#period [value="custom"]:checked) { grid-template-columns: repeat(4,minmax(0,1fr)); }
.filter-grid:has(#period [value="custom"]:checked) .actions { justify-self: end; }
.dates .field { width: 10.5rem; max-width: 100%; }
.filters:has(#period option:checked:not([value="custom"])) .dates { display: none; }

.journal { width: 100%; table-layout: fixed; border-collapse: collapse; overflow-wrap: anywhere; }
.journal th, .journal td { padding: var(--s3); vertical-align: top; text-align: left; }
.journal th:first-child, .journal td:first-child { padding-left: var(--s6); }
.journal th:last-child, .journal td:last-child { padding-right: var(--s6); }
.journal thead { background: var(--wash); }
.journal th {
  border-block: var(--border);
  color: var(--muted);
  font-size: var(--xs);
  font-weight: 600;
  padding-block: var(--s2);
}
.journal th:nth-child(1) { width: 12%; }
.journal th:nth-child(2) { width: 28%; }
.journal th:nth-child(3) { width: 27%; }
.journal th:nth-child(4) { width: 15%; }
.journal th:nth-child(5) { width: 9%; text-align: right; }
.journal th:nth-child(6) { width: 9%; }
.journal tbody tr + tr { border-top: var(--border); }
.journal tbody tr:hover { background: var(--hover-surface); }
.journal td { padding-block: var(--s2); line-height: 1.35; }
.when { font-size: var(--sm); font-weight: 550; }
.secondary, .path { color: var(--muted); font-weight: 400; font-size: var(--xs); }
.secondary { display: block; margin-top: var(--line-gap); }
.request-inner { display: flex; gap: var(--s3); align-items: flex-start; }
.request-inner > div { min-width: 0; }
.kind-icon {
  display: inline-grid;
  place-items: center;
  width: var(--s7);
  height: var(--s7);
  border-radius: var(--r2);
  flex: none;
}
[data-kind="chat"], [data-kind="ai_chat"] { color: var(--blue); background: var(--blue-wash); }
[data-kind="form"] { color: var(--accent); background: var(--accent-soft); }
[data-kind="call"] { color: var(--leaf); background: var(--leaf-wash); }
[data-kind="manual"], [data-kind="lk"] { color: var(--text); background: var(--wash); }
.channel {
  display: inline-block;
  max-width: 100%;
  padding: .15rem var(--s2);
  border-radius: var(--r1);
  font-size: var(--xs);
  font-weight: 530;
}
[data-channel="direct_search"], [data-channel="direct_network"], [data-channel="direct_unknown"] { background: var(--direct-wash); color: var(--direct-ink); }
[data-channel="organic"] { background: var(--leaf-wash); color: var(--leaf); }
[data-channel="avito"] { background: var(--blue-wash); color: var(--blue); }
[data-channel="referral"], [data-channel="other_ads"], [data-channel="lk"], [data-channel="direct"] { background: var(--wash); color: var(--text); }
[data-channel="messenger"], [data-channel="unknown"] { color: var(--muted); background: transparent; padding-left: 0; }
.path { display: flex; align-items: baseline; gap: var(--s1); margin-top: var(--line-gap); }
.path > .icon { width: var(--xs); height: var(--xs); align-self: flex-start; margin-top: var(--line-gap); }
.attribution { display: flex; align-items: baseline; gap: var(--s2); margin-top: var(--line-gap); font-size: var(--xs); }
.campaign { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.term { min-width: 0; color: var(--muted); }
.campaign + .term { padding-inline-start: var(--s2); border-inline-start: var(--border); }
.outcome { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--sm); font-weight: 550; }
.outcome::before { content: ""; width: .52rem; height: .52rem; border: 1.5px solid currentColor; border-radius: 50%; flex: none; }
[data-outcome="new"] { color: var(--muted); font-weight: 400; }
[data-outcome="work"] { color: var(--accent); }
[data-outcome="work"]::before { border-bottom-style: dotted; }
[data-outcome="paid"], [data-outcome="won"] { color: var(--leaf); }
[data-outcome="paid"]::before, [data-outcome="won"]::before { border: 0; background: currentColor; }
[data-outcome="lost"] { color: var(--red); }
[data-outcome="lost"]::before { height: 2px; border: 0; background: currentColor; }
.journal .amount, .journal .deal-cell { text-align: right; font-size: var(--sm); }
.no-value { color: var(--quiet); }
.deal { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 500; }
.deal:hover, .deal:focus-visible { color: var(--accent-hover); text-decoration: underline; text-underline-offset: .22em; }
.deal .icon { width: var(--s3); height: var(--s3); }
.mobile-label { display: none; }
.pager { border-top: var(--border); display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s6); font-size: var(--sm); }
.pager > span { color: var(--muted); }
.pager a, .empty a { font-weight: 600; }
.empty { display: grid; justify-items: center; text-align: center; max-width: 32rem; margin: auto; gap: var(--s3); padding: var(--s8) var(--s4); }
.empty > .icon, .entry-icon {
  box-sizing: content-box;
  padding: var(--s3);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r3);
}
.empty p { font-size: var(--lg); }
.entry { padding: clamp(3rem, 11vh, 8rem) var(--gutter); }
.entry-card { max-width: 26rem; margin-inline: auto; padding: var(--s7); }
.entry-card h1 { margin: var(--s5) 0 var(--s6); font-size: 2rem; }
.entry-icon { display: inline-flex; --icon: 1.4rem; }
.entry-card p { overflow-wrap: anywhere; }
.entry-card code { font-family: var(--mono); font-size: var(--sm); }
.login-form { display: grid; gap: var(--s5); }
.login-form input[aria-invalid="true"] { border-color: var(--red); background: var(--red-wash); }
.error { font-size: var(--sm); color: var(--red); }

@media (min-width: 49.01rem) {
  .journal .source-cell:has(.attribution) { padding-block: var(--s1); }
}
@media (max-width: 75rem) {
  :root { --gutter: var(--s6); }
  .metric { padding-inline: var(--s3); }
  .metrics { gap: var(--s2); }
  .journal td, .journal th { padding-inline: var(--s2); }
  .journal th:first-child, .journal td:first-child { padding-left: var(--s4); }
  .journal th:last-child, .journal td:last-child { padding-right: var(--s4); }
}
@media (max-width: 60rem) {
  .filter-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .actions, .dates { grid-column: 1 / -1; }
  .filter-grid:has(#period [value="custom"]:checked) .actions { justify-self: stretch; }
  .metrics { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .metric { grid-column: span 2; }
  .metric:nth-child(n+4) { grid-column: span 3; }
  .journal th:nth-child(1) { width: 13%; }
  .journal th:nth-child(2) { width: 24%; }
  .journal th:nth-child(3) { width: 24%; }
  .journal th:nth-child(4) { width: 19%; }
  .journal th:nth-child(6) { width: 11%; }
}
@media (max-width: 49rem) {
  :root { --gutter: var(--s4); }
  .theme-toggle { min-width: var(--s6); justify-content: center; }
  .theme-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
  }
  .app-nav, .top-inner { gap: var(--s3); }
  .filters { --input: 2.5rem; padding: var(--s3); }
  .refresh { min-height: var(--input); }
  .list-head { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .filter-grid, .filter-grid:has(#period [value="custom"]:checked) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .journal, .journal tbody { display: block; }
  .journal thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .journal tbody tr {
    display: grid;
    grid-template-columns: minmax(0,1.15fr) minmax(0,1fr);
    grid-template-areas: "request when" "source result" "amount deal";
    gap: var(--s3);
    padding: var(--s3);
    border-top: var(--border);
  }
  .journal td, .journal td:first-child, .journal td:last-child { padding: 0; min-width: 0; }
  .request { grid-area: request; }
  .journal .when { grid-area: when; text-align: right; }
  .request-inner { gap: var(--s2); }
  .source-cell { grid-area: source; }
  .attribution { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--line-gap); }
  .campaign + .term { padding-inline-start: 0; border: 0; }
  .result { grid-area: result; }
  .journal .amount { grid-area: amount; display: flex; gap: var(--s2); align-items: baseline; text-align: left; }
  .deal-cell { grid-area: deal; }
  .mobile-label { display: block; margin-bottom: var(--s1); }
  .journal tbody .empty-row { display: block; }
  .empty-row td { display: block; }
}
@media (max-width: 36rem) {
  :root { --header: 3.4rem; --gutter: var(--s3); }
  .brand { font-size: 1.5rem; gap: var(--s1); }
  .brand svg { width: var(--s6); height: var(--s6); }
  .current > .icon, .sections summary > .icon:first-child, .app-nav::before { display: none; }
  .app-nav, .top-inner { gap: var(--s2); }
  .current, .sections summary, .logout { font-size: var(--xs); gap: var(--s1); }
  .section-menu { left: auto; right: 0; }
  .workspace { padding-top: var(--s6); }
  .page-head { gap: var(--s2); margin-bottom: var(--s4); }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); margin-bottom: var(--s5); }
  .metric, .metric:nth-child(n+4) { grid-column: auto; }
  .metric { padding: var(--s3); }
  .metric--total { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-start; gap: var(--s4); min-height: 4.2rem; }
  .metric--total dt { order: 1; }
  .metric--total::after { bottom: var(--s6); }
  .metric dt { font-size: var(--xs); }
  .metric dd { gap: var(--s1); }
  .dates { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dates .field { width: auto; }
  .actions { gap: var(--s5); }
  .actions button { flex: 1; }
  .journal tbody tr {
    grid-template-columns: repeat(2,minmax(0,1fr));
    grid-template-areas: "when when" "request request" "source result" "amount deal";
    gap: var(--s2) var(--s3);
  }
  .journal .when { text-align: left; }
  .when time { display: flex; gap: var(--s2); align-items: baseline; }
  .when .secondary { margin: 0; }
  .pager { padding-inline: var(--s3); }
  .entry-card { padding: var(--s6); }
}
@media (max-width: 22rem) {
  .top-inner { flex-wrap: wrap; }
  .metric dd { font-size: 1.55rem; }
}
@media (forced-colors: active) {
  .select-box select { appearance: auto; }
  .select-box .icon { display: none; }
  .current { text-decoration: underline; }
}

/* Каналы и расходы */
:root {
  --plot-height: 200px;
  --plot-left: 2.65rem;
  --plot-right: 4.65rem;
  --trend-previous: #8893a3;
}
:root[data-theme="dark"] { --trend-previous: #748398; }
.section-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--input);
  color: var(--muted);
  font-weight: 550;
  font-size: var(--sm);
}
.report-head, .report-panel-head, .chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
}
.report-head { margin-bottom: var(--s4); }
.data-times { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.data-times dt, .chart-scope, .chart-note, .report-foot, .compare-note {
  font-size: var(--xs);
  color: var(--muted);
}
.data-times dd { font-size: var(--sm); }
.report-filters, .report-panel, .report-metric {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--r3);
}
.report-filters, .cost-form, .date-pair {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
}
.report-filters, .cost-form { --input: var(--compact-input); padding: var(--s3) var(--s4); }
.report-filters { align-items: flex-start; margin-bottom: var(--s3); }
.report-filters > .field { min-width: 10rem; }
.report-filters .actions { padding-top: calc(var(--xs) * 1.45 + var(--s1)); }
.report-filters :is(button, input, select), .cost-form :is(button, input, select) { padding-block: var(--s1); }
.compare-note { display: block; margin-top: var(--s1); }
.report-filters:has(#period option:checked:not([value="custom"])) .period-custom,
.report-filters:has(#compare option:checked:not([value="custom"])) .compare-custom,
.report-filters:has(#compare option:checked:not([value="previous"])) .compare-note { display: none; }
.report-metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: var(--s3); }
.report-metric { min-width: 0; padding: var(--s3) var(--s4); }
.report-metric dt { display: flex; gap: var(--s2); align-items: center; color: var(--muted); font-size: var(--sm); }
.report-value { font-size: clamp(1.4rem,2vw,1.875rem); font-weight: 650; letter-spacing: -.045em; margin-block: var(--s1); }
.metric-compare { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s1) var(--s2); color: var(--muted); font-size: var(--xs); }
.delta {
  display: inline-block;
  padding: 0 var(--s1);
  border-radius: var(--r1);
  color: var(--muted);
  background: var(--wash);
  font-size: var(--xs);
  font-weight: 550;
  white-space: nowrap;
}
.delta--good { color: var(--leaf); background: var(--leaf-wash); }
.delta--bad { color: var(--red); background: var(--red-wash); }
.report-panel { margin-top: var(--s4); min-width: 0; }
.report-panel-head { padding: var(--s4) var(--s5); }
.chart-controls { gap: var(--s3); justify-content: flex-start; }
.metric-switch { display: flex; flex-wrap: wrap; gap: var(--s1); padding: var(--s1); border-radius: var(--r2); background: var(--wash); }
.metric-switch a { border: 1px solid transparent; border-radius: var(--r1); color: var(--text); padding: var(--s1) var(--s2); font-size: var(--sm); }
.metric-switch a[aria-current] { background: var(--surface); border-color: var(--control-line); color: var(--accent); font-weight: 650; }
.channel-clear { display: inline-flex; align-items: center; gap: var(--s2); }
.chart-key { padding: 0 var(--s5); list-style: none; display: grid; gap: var(--line-gap); }
.chart-key li, .chart-tip > div { display: flex; gap: var(--s2); align-items: center; }
.chart-key li { font-size: var(--xs); color: var(--text); }
.line-sample { width: var(--s6); flex: none; border-top: 2px solid var(--accent); }
.line-sample--previous { border-color: var(--trend-previous); border-top-style: dashed; }
.chart-note { padding: 0 var(--s5) var(--s2); }
.chart-stage { margin: 0 var(--s4); padding-inline: var(--plot-left) var(--plot-right); position: relative; }
.plot-box { container-type: inline-size; }
.trend { display: block; width: 100%; height: var(--plot-height); overflow: visible; }
.trend-frame { width: 100cqw; overflow: visible; }
.trend-paths { overflow: visible; }
.trend text { fill: var(--text); font: var(--xs) var(--font); font-variant-numeric: tabular-nums; }
.trend .trend-final { fill: var(--ink); font-weight: 650; }
.trend-grid { stroke: var(--line); stroke-width: 1; }
.trend-area { fill: var(--accent); fill-opacity: .1; }
.trend-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.trend-line--current { stroke: var(--accent); }
.trend-line--previous { stroke: var(--trend-previous); stroke-dasharray: 6 5; }
.trend-end { stroke: var(--surface); stroke-width: 2; }
.trend-end--current { fill: var(--accent); }
.trend-end--previous { fill: var(--trend-previous); }
.trend-guide { stroke: var(--muted); pointer-events: none; }
.trend-hit { fill: transparent; cursor: crosshair; }
.trend-hit:focus-visible { outline: none; stroke: var(--accent); stroke-width: 2; }
.chart-tip {
  pointer-events: none;
  position: absolute;
  z-index: 1;
  top: var(--s1);
  max-width: 100%;
  padding: var(--s2) var(--s3);
  border: var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 var(--s1) var(--s3) var(--shadow);
}
.chart-tip > div + div { margin-top: var(--s1); }
.tip-date { color: var(--muted); font-size: var(--xs); }
.tip-value { margin-left: auto; font-size: var(--lg); }
.chart-data { border-top: var(--border); }
.chart-data summary, .campaign-toggle summary {
  padding: var(--s2) var(--s5);
  color: var(--accent);
  font-size: var(--sm);
  width: fit-content;
}
.chart-data summary::before, .campaign-toggle summary::before { content: "▸"; margin-right: var(--s2); }
.chart-data[open] summary::before, .campaign-toggle[open] summary::before { content: "▾"; }
.report-scroll { max-width: 100%; min-width: 0; overflow-x: auto; }
.report-scroll:focus-visible { outline-offset: -3px; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--sm); }
.report-table :is(th,td) { padding: var(--s2) var(--s3); vertical-align: middle; text-align: right; }
.report-table :is(th,td):first-child { text-align: left; padding-left: var(--s5); }
.report-table :is(th,td):last-child { padding-right: var(--s5); }
.report-table thead th { background: var(--wash); color: var(--muted); font-weight: 600; font-size: var(--xs); border-block: var(--border); }
.report-table tbody th { font-weight: 550; }
.report-table tbody tr + tr, .report-table tfoot { border-top: var(--border); }
.report-table tfoot { background: var(--wash); font-weight: 650; }
.report-table small, .selected-channel { color: var(--muted); font-size: var(--xs); }
.numbers-table td, .campaign-table td { white-space: nowrap; }
.numbers-table .channel { text-decoration: underline; text-underline-offset: .22em; }
.numbers-table .chosen-row { background: var(--accent-soft); }
.chosen-row th { box-shadow: inset 3px 0 var(--accent); }
.selected-channel { display: inline-block; }
.report-foot { padding: var(--s3) var(--s5); border-top: var(--border); }
.report-foot p + p { margin-top: var(--s1); }
.report-panel:has(.campaign-toggle) { display: flex; flex-direction: column; }
.campaign-toggle { order: 1; border-top: var(--border); }
.campaign-toggle ~ .report-foot { order: 2; }
.campaign-toggle:not([open]) summary span:last-child,
.campaign-toggle[open] summary span:first-child,
.campaign-toggle:not([open]) + .report-scroll tbody tr:nth-child(n+11) { display: none; }
.campaign-table th[scope="row"] { overflow-wrap: anywhere; }
.campaign-table :nth-child(2), .cost-table :is(th,td) { text-align: left; }
.cost-table :is(th,td):nth-child(3), .cost-table td:last-child { text-align: right; }
.cost-form { border-top: var(--border); align-items: end; }
.cost-form .field { flex: 1 1 7rem; }
.cost-form .field:has(#note) { flex-grow: 2; }
.delete-cost { color: var(--red); background: transparent; padding: var(--s1) var(--s2); min-height: var(--s7); font-size: var(--sm); font-weight: 500; }
.delete-cost:hover { color: var(--red); background: var(--red-wash); }
@media (max-width: 63rem) {
  .report-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); gap: var(--s2); }
  .report-table.numbers-table { min-width: 50rem; }
  .campaign-table { min-width: 40rem; }
  .cost-table { min-width: 37rem; }
}
@media (max-width: 49rem) {
  .top-inner:has(.section-link) { display: grid; grid-template-columns: 1fr auto auto; gap: 0 var(--s4); }
  .top-inner:has(.section-link) .brand { grid-row: 1; width: fit-content; }
  .top-inner:has(.section-link) .theme-toggle, .top-inner:has(.section-link) .logout { grid-row: 1; min-height: var(--header); }
  .app-nav:has(.section-link) { grid-column: 1 / -1; grid-row: 2; gap: var(--s4); }
  .app-nav:has(.section-link)::before { display: none; }
  .app-nav:has(.section-link) .current, .section-link { min-height: var(--input); }
  .app-nav:has(.section-link) .sections { margin-left: auto; }
  .app-nav:has(.section-link) .section-menu { left: auto; right: 0; }
  .report-head .sync { align-items: flex-end; }
  .report-filters { flex-wrap: wrap; }
  .report-panel-head { padding: var(--s3); }
  .chart-key, .chart-note { padding-inline: var(--s3); }
  .chart-stage { margin-inline: var(--s2); }
  .trend-axis--extra { display: none; }
  .cost-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 36rem) {
  .app-nav:has(.section-link) { gap: var(--s2); }
  .section-link { font-size: var(--xs); }
  .section-link .icon { display: none; }
  .report-head .sync { gap: var(--s2); }
  .data-times { gap: var(--s2); }
  .data-times dl { flex: 1; }
  .data-times dd { font-size: var(--xs); }
  .report-filters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .report-filters > .field { min-width: 0; }
  .report-filters .actions, .date-pair { grid-column: 1 / -1; }
  .date-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .report-filters .actions { padding-top: 0; }
  .report-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .report-metric { padding: var(--s2) var(--s3); }
  .report-metric:first-child { grid-column: 1 / -1; }
  .chart-controls { align-items: flex-start; gap: var(--s2); }
  .metric-switch { max-width: 100%; }
  .metric-switch a { font-size: var(--xs); padding-inline: var(--s1); }
  .cost-form .field:has(#note) { grid-column: 1 / -1; }
}
