:root {
  color-scheme: light;
  --page: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #0b1b31;
  --muted: #607086;
  --muted-light: #8795a7;
  --line: #d5dde6;
  --line-strong: #c3ceda;
  --navy: #14243a;
  --red: #c92b24;
  --teal: #007f78;
  --skt: #377ac3;
  --g2g: #cf3979;
  --tp: #17191c;
  --shadow: 0 8px 20px rgba(28, 44, 63, 0.055);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(to bottom, #edf2f5 0, #f4f7f9 180px, var(--page) 440px),
    var(--page);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1380px, calc(100% - 40px));
  margin-inline: auto;
}

.page-header {
  border-bottom: 1px solid rgba(195, 206, 218, 0.7);
}

.header-inner {
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: 28px 24px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.15;
  font-weight: 780;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.meta-divider {
  width: 1px;
  height: 13px;
  background: var(--line-strong);
}

.snapshot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.snapshot-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 120, 0.1);
}

.filter-band {
  background: rgba(248, 250, 251, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 7px 18px rgba(37, 53, 71, 0.06);
}

.filter-inner {
  min-height: 118px;
  display: grid;
  grid-template-columns: auto 260px minmax(320px, 1fr) minmax(320px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding-block: 18px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filter-label,
.period-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.segmented-control {
  display: inline-flex;
  gap: 5px;
}

.segment,
.refresh-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segment {
  min-width: 51px;
  padding: 0 12px;
  border-radius: 6px;
  font-weight: 650;
}

.segment:hover,
.segment:focus-visible,
.refresh-button:hover,
.refresh-button:focus-visible {
  border-color: var(--navy);
  outline: none;
}

.segment.is-active {
  color: #ffffff;
  background: var(--navy);
  border-color: var(--navy);
  box-shadow: 0 4px 10px rgba(20, 36, 58, 0.18);
}

.rates-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rate-filter {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rate-input-wrap {
  height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.rate-input-wrap:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 120, 0.11);
}

.rate-input-wrap input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 6px 0 12px;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.rate-input-wrap span {
  padding-right: 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.period-group {
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: auto minmax(104px, 1fr) auto minmax(104px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.current-period {
  border-color: rgba(0, 127, 120, 0.75);
  background: #f2fbf9;
}

.period-group input[type="date"] {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: #35465a;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-group input[type="date"]:hover,
.period-group input[type="date"]:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 127, 120, 0.1);
}

.date-separator {
  color: var(--muted-light);
  font-size: 12px;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 112px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.refresh-button > span {
  font-size: 19px;
  line-height: 1;
}

.refresh-button.is-refreshing > span {
  animation: rotate 480ms ease;
}

.dashboard-main {
  padding-block: 30px 42px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.formula-note {
  max-width: 450px;
  text-align: right;
}

.brand-sections {
  display: grid;
  gap: 22px;
}

.brand-section {
  min-width: 0;
  padding-top: 1px;
}

.brand-section + .brand-section {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.brand-row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 43px;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 5px;
  color: #ffffff;
  background: var(--brand-color);
  font-size: 12px;
  font-weight: 800;
}

.brand-row-heading h3 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-period {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  min-width: 0;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand-color);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-label {
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 780;
}

.info-button {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: help;
  font-size: 11px;
  font-weight: 800;
}

.metric-value {
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 29px;
  line-height: 1.12;
  font-weight: 790;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-caption {
  min-height: 20px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric-change {
  margin: auto 0 0;
  padding-top: 7px;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.metric-change.is-down {
  color: var(--teal);
}

.metric-change.is-up {
  color: var(--red);
}

.metric-change.is-pending,
.metric-change.is-neutral,
.cell-pending {
  color: var(--muted-light);
}

.metric-change.is-ready {
  color: var(--teal);
}

.daily-report {
  margin-top: 32px;
  padding-top: 26px;
  border-top: 1px solid var(--line-strong);
}

.daily-report-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.daily-report-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.daily-report-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.table-brand-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.daily-table-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.daily-table-scroll {
  max-height: 520px;
  overflow: auto;
  scrollbar-color: #a2acb8 #eef2f5;
  scrollbar-width: thin;
}

.daily-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #26374a;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.daily-table th,
.daily-table td {
  height: 44px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.daily-table th:first-child,
.daily-table td:first-child {
  width: 20%;
  text-align: left;
}

.daily-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  background: #f5f8fa;
  color: #53657a;
  font-size: 11px;
  font-weight: 760;
}

.daily-table tbody th {
  color: #3b4d62;
  font-weight: 620;
}

.daily-table tbody tr:hover th,
.daily-table tbody tr:hover td {
  background: #f8fbfc;
}

.daily-table .roi-value {
  color: var(--ink);
  font-weight: 780;
}

.daily-table tfoot th,
.daily-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  border-bottom: 0;
  background: #eef4f6;
  color: var(--ink);
  font-weight: 780;
}

.page-footer {
  border-top: 1px solid var(--line);
  background: #edf2f5;
}

.footer-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-block: 18px;
}

.footer-inner p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 14px;
  border: 1px solid rgba(0, 127, 120, 0.35);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(28, 44, 63, 0.18);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .filter-inner {
    grid-template-columns: auto 260px 1fr auto;
  }

  .comparison-period {
    grid-column: 3;
  }

  .refresh-button {
    grid-column: 4;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 28px, 1380px);
  }

  .header-inner {
    min-height: 116px;
  }

  .filter-inner {
    grid-template-columns: 1fr 260px;
    gap: 12px;
  }

  .current-period,
  .comparison-period {
    grid-column: 1 / -1;
  }

  .refresh-button {
    grid-column: 2;
    grid-row: 1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formula-note {
    display: none;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 22px, 1380px);
  }

  .header-inner {
    min-height: 126px;
    padding-block: 24px 20px;
  }

  h1 {
    font-size: 27px;
  }

  .meta-divider {
    display: none;
  }

  .header-meta {
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }

  .filter-inner {
    grid-template-columns: 1fr;
    padding-block: 14px;
  }

  .brand-filter,
  .rates-filter,
  .refresh-button {
    grid-column: 1;
    grid-row: auto;
  }

  .brand-filter {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .segmented-control {
    width: 100%;
  }

  .segment {
    min-width: 0;
    flex: 1;
  }

  .period-group {
    grid-template-columns: 1fr auto 1fr;
  }

  .period-label {
    grid-column: 1 / -1;
  }

  .refresh-button {
    width: 100%;
  }

  .dashboard-main {
    padding-block: 24px 32px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading h2 {
    font-size: 20px;
  }

  .brand-row-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .daily-report-heading {
    align-items: flex-start;
  }

  .daily-table th,
  .daily-table td {
    padding-inline: 12px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 150px;
  }

  .metric-value {
    font-size: 27px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
