:root {
  --blue: #0000ff;
  --blue-dark: #08086f;
  --blue-soft: #eeeeff;
  --ink: #11152b;
  --muted: #6e7488;
  --line: #e8eaf2;
  --surface: #ffffff;
  --canvas: #f5f6fa;
  --positive: #087f5b;
  --positive-bg: #e7f7f0;
  --negative: #c4314b;
  --negative-bg: #fff0f2;
  --amber: #a45d00;
  --amber-bg: #fff5dc;
  --shadow: 0 8px 30px rgba(19, 28, 80, 0.07);
}

* {
  box-sizing: border-box;
}
html {
  min-width: 320px;
  background: var(--canvas);
}
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(
      circle at 93% 3%,
      rgba(0, 0, 255, 0.055),
      transparent 22rem
    ),
    var(--canvas);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}
.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 34px 30px;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(19, 28, 80, 0.08);
}
.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink);
  text-decoration: none;
}
.brand img {
  width: 126px;
  height: auto;
  display: block;
}
.brand-divider {
  width: 1px;
  height: 27px;
  background: #d9dce8;
}
.product-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.month-control {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 12px;
  border: 1px solid #dfe2ed;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  color: #3b4158;
}
.month-control span {
  color: #8a8fa1;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.month-control select {
  max-width: 180px;
  padding: 5px 25px 5px 8px;
  border: 0;
  outline: 0;
  color: #30364d;
  background: #f2f2f9;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.icon-button,
.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #dfe2ed;
  background: white;
  border-radius: 50%;
  color: var(--ink);
}
.icon-button:hover,
.avatar:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.icon-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.avatar {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 800;
  font-size: 13px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 31px 2px 20px;
}
.eyebrow,
.panel-kicker {
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
h1 {
  margin: 7px 0 0;
  font-size: clamp(25px, 2.2vw, 36px);
  letter-spacing: -0.045em;
  line-height: 1.06;
}
.updated {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.executive-signal {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 17px;
  color: #222743;
  background: linear-gradient(90deg, #f0f0ff, rgba(255, 255, 255, 0.82));
  border: 1px solid #ddddff;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
}
.signal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(0, 0, 255, 0.08);
  flex: 0 0 auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpi-card {
  min-height: 144px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 21px 18px;
  background: var(--surface);
  border: 1px solid rgba(219, 222, 234, 0.8);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.kpi-primary {
  color: white;
  border: 0;
  background: linear-gradient(135deg, #0000ff 0%, #090991 100%);
  box-shadow: 0 12px 32px rgba(0, 0, 255, 0.21);
}
.kpi-primary::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  right: -72px;
  top: -94px;
  border: 28px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}
.kpi-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.kpi-primary .kpi-heading,
.kpi-primary .kpi-footer {
  color: rgba(255, 255, 255, 0.72);
}
.kpi-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 15px;
  font-weight: 900;
}
.kpi-primary .kpi-icon {
  color: white;
  background: rgba(255, 255, 255, 0.14);
}
.kpi-value {
  margin: 13px 0 10px;
  font-size: clamp(27px, 2.3vw, 38px);
  font-weight: 830;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
}
.change-pill {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 850;
}
.change-pill.positive {
  color: var(--positive);
  background: var(--positive-bg);
}
.change-pill.negative {
  color: var(--negative);
  background: var(--negative-bg);
}
.change-pill.neutral {
  color: var(--muted);
  background: #eff0f5;
}
.kpi-primary .change-pill.positive,
.kpi-primary .change-pill.negative,
.kpi-primary .change-pill.neutral {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(330px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid rgba(219, 222, 234, 0.82);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.trend-panel,
.funnel-panel {
  min-height: 364px;
  padding: 21px 22px 18px;
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.panel-heading h2 {
  margin: 5px 0 0;
  font-size: 16px;
  letter-spacing: -0.025em;
}
.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 17px;
  height: 3px;
  display: inline-block;
  border-radius: 2px;
}
.legend-line {
  background: var(--blue);
}
.legend-bar {
  background: #ffc62e;
}
.chart-frame {
  height: 282px;
  margin-top: 12px;
}
.chart-frame svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart-grid {
  stroke: #eceef4;
  stroke-width: 1;
}
.chart-axis {
  fill: #8a8fa1;
  font-size: 9px;
  font-family: inherit;
}
.chart-bar {
  fill: #ffc62e;
  opacity: 0.82;
}
.chart-area {
  fill: url(#salesGradient);
}
.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-point {
  fill: white;
  stroke: var(--blue);
  stroke-width: 2;
}

.funnel {
  display: grid;
  grid-template-columns: 1fr 26px 1fr 26px 1fr;
  align-items: stretch;
  gap: 8px;
  margin-top: 34px;
}
.funnel-stage {
  min-width: 0;
  padding: 15px 10px;
  text-align: center;
  background: #f6f6fb;
  border: 1px solid #ececf4;
  border-radius: 13px;
}
.funnel-stage.primary {
  color: white;
  background: linear-gradient(145deg, var(--blue), #111188);
  border-color: transparent;
}
.funnel-stage strong {
  display: block;
  margin-bottom: 7px;
  font-size: clamp(22px, 2vw, 31px);
  line-height: 1;
  letter-spacing: -0.04em;
}
.funnel-stage span {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 750;
  line-height: 1.25;
}
.funnel-stage.primary span {
  color: rgba(255, 255, 255, 0.75);
}
.funnel-arrow {
  display: grid;
  place-items: center;
  color: #b5b8c6;
  font-size: 20px;
}
.funnel-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.funnel-summary div {
  padding: 13px 14px;
  background: #f8f8fb;
  border-radius: 11px;
}
.funnel-summary span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}
.funnel-summary strong {
  font-size: 18px;
  letter-spacing: -0.03em;
}

.channel-panel {
  padding: 21px 22px 10px;
}
.channel-heading {
  align-items: center;
  margin-bottom: 13px;
}
.breakdown-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 9px;
}
.segment-control {
  display: inline-flex;
  padding: 3px;
  background: #f0f1f6;
  border-radius: 9px;
}
.segment-control button {
  padding: 6px 12px;
  border: 0;
  color: #73788b;
  background: transparent;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
}
.segment-control button.active {
  color: var(--blue);
  background: white;
  box-shadow: 0 2px 8px rgba(19, 28, 80, 0.09);
}
.channel-signals {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.signal-chip {
  padding: 7px 10px;
  color: #3a4057;
  background: #f5f6fa;
  border: 1px solid #e7e9f1;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 750;
}
.signal-chip strong {
  color: var(--blue);
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
th {
  padding: 10px 11px;
  color: #8a8fa1;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th:hover {
  color: var(--blue);
}
td {
  padding: 11px;
  border-bottom: 1px solid #f0f1f6;
  color: #34394e;
  font-weight: 590;
  white-space: nowrap;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fafaff;
}
.numeric {
  text-align: right;
}
.channel-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 780;
  color: var(--ink);
}
.channel-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
.roas-badge {
  display: inline-block;
  min-width: 48px;
  padding: 4px 7px;
  text-align: center;
  color: var(--positive);
  background: var(--positive-bg);
  border-radius: 6px;
  font-weight: 850;
}
.roas-badge.review {
  color: var(--amber);
  background: var(--amber-bg);
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 17px 3px 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
}
footer span {
  display: flex;
  align-items: center;
  gap: 7px;
}
footer a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 750;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #12a875;
  box-shadow: 0 0 0 4px rgba(18, 168, 117, 0.1);
}

.loading-screen,
.error-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #f7f8fc;
}
.loading-screen img {
  width: 155px;
}
.loading-screen p {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.loading-bar {
  width: 155px;
  height: 3px;
  margin-top: 23px;
  overflow: hidden;
  background: #e4e5ef;
  border-radius: 3px;
}
.loading-bar span {
  display: block;
  width: 45%;
  height: 100%;
  background: var(--blue);
  animation: loading 1.1s ease-in-out infinite alternate;
}
@keyframes loading {
  from {
    transform: translateX(-70%);
  }
  to {
    transform: translateX(190%);
  }
}
.error-screen[hidden] {
  display: none;
}
.error-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--negative);
  border-radius: 50%;
  font-weight: 900;
}
.error-screen h2 {
  margin: 17px 0 7px;
  font-size: 20px;
}
.error-screen p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.error-screen button {
  padding: 10px 16px;
  border: 0;
  color: white;
  background: var(--blue);
  border-radius: 8px;
  font-weight: 750;
}

@media (max-width: 1050px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 680px) {
  .app-shell {
    padding: 0 14px 22px;
  }
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 12px 0;
  }
  .product-name,
  .brand-divider {
    display: none;
  }
  .month-control {
    padding-left: 6px;
  }
  .month-control span,
  #refresh-button {
    display: none;
  }
  .month-control select {
    width: 130px;
  }
  .brand img {
    width: 112px;
  }
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 24px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .trend-panel,
  .funnel-panel {
    padding: 18px 15px;
  }
  .panel-heading {
    flex-direction: column;
  }
  .funnel {
    grid-template-columns: 1fr;
    margin-top: 22px;
  }
  .funnel-arrow {
    transform: rotate(90deg);
  }
  .channel-panel {
    padding: 18px 10px 8px;
  }
  .channel-heading {
    align-items: flex-start;
  }
  .breakdown-actions {
    width: 100%;
    align-items: stretch;
  }
  .segment-control {
    align-self: flex-start;
  }
  footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }
}

@media print {
  body {
    background: white;
  }
  .app-shell {
    max-width: none;
    padding: 0;
  }
  .icon-button,
  .avatar,
  footer a {
    display: none;
  }
  .panel,
  .kpi-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
