:root {
  color-scheme: light;
  --canvas: #edf2f7;
  --paper: #fff;
  --ink: #13243b;
  --muted: #4a6078;
  --line: #d6e0eb;
  --blue: #2044bd;
  --blue-light: #edf2ff;
  --green: #08684c;
  --warning: #8a4c10;
  --error: #a1263b;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid #4265eb; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.site-header { border-top: 4px solid #375ad8; background: #101e34; color: #fff; }
.topbar, .content { width: min(100% - 3.5rem, 87.5rem); margin-inline: auto; }
.topbar { min-height: 4.1rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .62rem; font-size: 1.12rem; font-weight: 720; white-space: nowrap; }
.brand svg { width: 27px; height: 27px; color: #87a7fe; }
.brand-divider { height: 1.2rem; width: 1px; background: #4b5c77; margin: 0 .1rem; }
#brand-label { color: #d1def6; font-weight: 480; font-size: .91rem; }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.header-actions select {
  max-width: 8rem; border: 1px solid #64748e; border-radius: 6px; padding: .38rem .45rem;
  color: #fff; background: #1b2b45; font-size: .88rem;
}
.content { padding-block: 2rem 3.25rem; }
.button {
  border-radius: 7px; padding: .62rem .92rem; border: 1px solid transparent; cursor: pointer;
  font-weight: 680; font-size: .9rem; min-height: 42px; white-space: nowrap; text-decoration: none;
  display: inline-flex; gap: .45rem; align-items: center; justify-content: center;
}
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: #173495; }
.button.secondary { background: var(--paper); border-color: #b7c8dc; color: #223b59; }
.button.secondary:hover { border-color: var(--blue); color: var(--blue); }
.button.subtle { background: transparent; padding: .36rem .25rem; color: #f0f4ff; }
.button.subtle:hover { text-decoration: underline; }
.button:disabled { opacity: .58; cursor: wait; }
.initial-loading { font-size: 1rem; color: var(--muted); padding: 1.25rem 0; }
.auth {
  width: min(100%, 28rem); margin: clamp(2rem, 9vh, 7rem) auto 0; padding: clamp(1.45rem, 4vw, 2.45rem);
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 15px 65px #263b6510;
}
.auth-mark { height: 50px; margin-bottom: .95rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 3.25rem); letter-spacing: -.055em; line-height: 1.06; }
h2 { font-size: 1.2rem; letter-spacing: -.018em; line-height: 1.25; }
.auth h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.auth > p { margin-top: .65rem; color: var(--muted); }
.auth form { display: grid; gap: 1rem; margin-top: 1.7rem; }
.field { display: grid; gap: .32rem; font-size: .89rem; font-weight: 650; color: var(--muted); }
.field input, .field select {
  width: 100%; min-width: 0; min-height: 43px; padding: .53rem .65rem; font-size: 1rem; font-weight: 520;
  border: 1px solid #adc0d6; border-radius: 7px; background: #fff; color: var(--ink);
}
.form-error { margin-block: .6rem; color: var(--error); font-size: .93rem; }
.report-heading { display: flex; gap: 1rem; align-items: end; justify-content: space-between; margin-block: .5rem 1.5rem; }
.report-type { color: var(--blue); font-size: .92rem; font-weight: 670; margin-bottom: .25rem; }
.report-domain { color: var(--muted); margin-top: .42rem; }
.report-actions { display: flex; gap: .6rem; align-items: end; }
.client-select { min-width: 10rem; }
.filters { align-items: end; display: flex; flex-wrap: wrap; column-gap: 1.15rem; row-gap: .8rem; }
.presets { display: flex; border-radius: 8px; padding: 3px; border: 1px solid var(--line); background: #e5ecf5; }
.preset {
  background: transparent; border: 0; border-radius: 5px; padding: .46rem .8rem; cursor: pointer;
  font-size: .91rem; font-weight: 610; color: #314a68; min-height: 36px;
}
.preset[aria-pressed=true] { background: var(--paper); color: var(--blue); box-shadow: 0 0 0 1px #b8c8ed; }
.range { display: flex; align-items: end; gap: .55rem; flex-wrap: wrap; }
.range input[type=date] { min-width: 9.4rem; }
.report-metadata { display: flex; flex-wrap: wrap; column-gap: 1rem; row-gap: .2rem; margin: 1rem 0 1.22rem; color: var(--muted); font-size: .875rem; }
.freshness { color: var(--green); font-weight: 670; }
.freshness.pending { color: var(--warning); }
.metrics {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 0 1.1rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: 11px; overflow: hidden;
}
.metric { min-height: 7rem; padding: .95rem 1.15rem; border-inline-start: 1px solid var(--line); min-width: 0; }
.metric:first-child { border-inline-start: 0; }
.metric.primary-metric { background: var(--blue-light); }
.metric dt { font-size: .92rem; color: var(--muted); font-weight: 640; }
.metric dd { margin: .28rem 0 0; font-size: clamp(1.55rem, 2.3vw, 2.25rem); font-weight: 740; line-height: 1.1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.metric.primary-metric dd { color: var(--blue); }
.metric small { display: block; font-size: .81rem; color: var(--muted); margin-top: .24rem; }
.insights { display: grid; grid-template-columns: 2fr 1fr; gap: 1.1rem; margin-bottom: 1.1rem; }
.panel { padding: 1.2rem; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; min-width: 0; }
.panel h2 { margin-bottom: .95rem; }
.chart-panel { min-height: 16rem; }
.daily-chart { display: block; width: 100%; height: auto; max-height: 16.4rem; overflow: visible; }
.daily-chart line { stroke: #dee6f1; }
.daily-chart text { font-size: 13px; fill: #455f7b; }
.chart-path { stroke: var(--blue); stroke-width: 2.5; stroke-linecap: round; }
.daily-chart circle { fill: var(--blue); stroke: white; stroke-width: 1.3; }
.empty-chart {
  min-height: 10rem; display: grid; place-items: center; text-align: center; color: var(--muted);
  border: 1px dashed #c3d0e3; border-radius: 8px; padding: 1rem; background: #f5f8fc;
}
.note { color: var(--muted); font-size: .875rem; margin: .8rem 0 0; }
.funnel { list-style: none; margin: 0; padding: 0; counter-reset: funnel; }
.funnel li {
  border-bottom: 1px solid #e3eaf3; padding-block: .53rem; display: grid; gap: .65rem;
  grid-template-columns: 1.6rem minmax(0,1fr) max-content; align-items: start; font-size: .92rem;
}
.funnel li::before {
  counter-increment: funnel; content: counter(funnel); display: grid; place-items: center;
  font-size: .79rem; font-weight: 710; border-radius: 4px; background: var(--blue-light); color: var(--blue); min-height: 1.45rem;
}
.funnel li:last-child { border-bottom: 0; }
.funnel strong { color: var(--ink); font-size: 1.08rem; text-align: end; font-variant-numeric: tabular-nums; }
.channel-panel { margin-bottom: 1.1rem; }
.table-wrap { overflow: auto; border: 1px solid #e0e8f1; border-radius: 8px; width: 100%; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; font-variant-numeric: tabular-nums; }
thead { background: #eef4fa; }
th, td { padding: .58rem .72rem; white-space: nowrap; text-align: right; border-bottom: 1px solid #e5edf5; }
th { font-weight: 650; }
thead th { color: #314d6b; }
thead th:first-child, tbody th { text-align: left; position: sticky; left: 0; }
thead th:first-child { background: #eef4fa; }
tbody th { background: var(--paper); padding-inline-end: 1.35rem; box-shadow: 1px 0 #e7eef6; }
tbody tr:nth-child(even) td, tbody tr:nth-child(even) th { background: #f8fafc; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th i { display: inline-block; width: .43rem; height: .43rem; margin-inline-end: .49rem; background: #7190ed; border-radius: 2px; vertical-align: middle; }
tbody tr:nth-child(n+4) th i { background: #6b90ab; }
.services { margin: 0; padding: 0; list-style: none; }
.services li { display: flex; justify-content: space-between; padding: .45rem 0; border-top: 1px solid var(--line); }
.admin-panel { margin-top: 1.1rem; }
.admin-panel summary { cursor: pointer; color: var(--blue); font-weight: 670; }
.admin-panel h2 { margin: .95rem 0 .45rem; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .75rem; }
.source-grid dt { font-weight: 690; }
.source-grid dd { margin: .25rem 0 0; color: var(--muted); font-size: .89rem; }
.manual-form .field { width: 9.4rem; }
#manual-status { margin-top: .45rem; }
@media (max-width: 950px) {
  .metric { padding-inline: .75rem; }
}
@media (max-width: 740px) {
  .topbar, .content { width: calc(100% - 1.65rem); }
  .content { padding-top: 1.18rem; }
  .report-heading { align-items: start; flex-direction: column; margin-bottom: 1.05rem; }
  .report-actions { width: 100%; flex-wrap: wrap; gap: .55rem; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { border-top: 1px solid var(--line); }
  .metric:nth-child(odd) { border-inline-start: 0; }
  .metric:nth-child(-n + 2) { border-top: 0; min-height: 5.7rem; }
  .insights { grid-template-columns: minmax(0,1fr); }
  .chart-panel { min-height: 0; }
  .panel { padding: .85rem; }
  .daily-chart text { font-size: 18px; }
}
@media (max-width: 390px) {
  .brand { gap: .37rem; font-size: 1rem; }
  .brand svg { width: 21px; height: 21px; }
  #brand-label { display: none; }
  .brand-divider { display: none; }
  .range input[type=date] { min-width: 7.8rem; }
  .field input, .field select { padding-inline: .37rem; }
}
