:root {
  color-scheme: light;
  --frame: #eff4fb;
  --surface: #fff;
  --ink: #142844;
  --muted: #53667e;
  --secondary: #596d86;
  --line: #dfe7f1;
  --quiet-line: #ecf0f6;
  --accent: #0758c5;
  --accent-hover: #064aa7;
  --wash: #f2f7ff;
  --bar: #2c77d5;
  --radius: 16px;
  --control-radius: 9px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font: 16px/1.5 var(--font);
  font-optical-sizing: auto;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--frame); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p, dl, dd { margin: 0; }

.appbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: 22px 30px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.brand-mark {
  display: inline-flex;
  align-items: end;
  justify-content: center;
  gap: 2px;
  width: 25px;
  padding: 3px;
  color: var(--accent);
}
.brand-mark i { width: 4px; display: block; background: currentColor; border-radius: 2px; }
.brand-mark i:nth-child(1) { height: 7px; opacity: .54; }
.brand-mark i:nth-child(2) { height: 12px; opacity: .76; }
.brand-mark i:nth-child(3) { height: 18px; }
.app-context { color: var(--muted); font-size: 13px; }

.frame {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: calc(100svh - 52px);
  padding: 0 8px 8px 0;
}
.sidebar { padding: 26px 14px; }
.sidebar-label { margin: 0 0 10px 10px; color: var(--secondary); font-size: 13px; }
.nav-item {
  min-height: 44px;
  display: flex;
  gap: 11px;
  align-items: center;
  border-radius: var(--control-radius);
  padding: 0 10px;
  color: var(--muted);
  font-size: 14px;
  margin: 3px 0;
}
.nav-item.selected { background: #e3edfb; color: var(--accent); font-weight: 650; }
.nav-icon { width: 19px; height: 19px; flex: 0 0 19px; }

.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.content { max-width: 1480px; padding: 32px 40px 28px; margin-inline: auto; }
.page-head, .summary-head, .section-head, .summary-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.page-head { align-items: end; margin-bottom: 24px; }
.dateline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.dateline-zone { border-left: 1px solid var(--line); padding-left: 8px; font-size: 13px; }
.calendar-mark {
  position: relative; width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 3px;
}
.calendar-mark::after { content: ""; position: absolute; inset: 3px 0 auto; border-top: 1px solid; }
h1 { margin-top: 8px; font-size: clamp(1.5rem, 3.2vw, 2rem); letter-spacing: -.038em; line-height: 1.16; }
h2 { font-size: 1.125rem; line-height: 1.4; letter-spacing: -.015em; }
.refresh {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 122px;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--accent);
  color: #fff;
}
.refresh-mark { font-size: 19px; line-height: 1; }
.refresh[aria-disabled="true"] { background: #e7effb; color: var(--muted); cursor: default; }
.refresh:active:not([aria-disabled="true"]) { background: var(--accent-hover); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); }
.summary { background: var(--wash); border-color: #dbe8fa; }
.summary-head { padding: 19px 24px 0; }
.scope { color: var(--muted); font-size: 13px; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: 1.48fr 1.15fr .9fr .85fr; padding-block: 20px; }
.metric {
  min-width: 0;
  padding: 0 24px;
  min-height: 73px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric + .metric { border-left: 1px solid #dce7f6; }
.metric dt { color: var(--muted); font-size: 14px; }
.metric dt span { margin-left: 5px; color: var(--secondary); font-size: 12px; }
.metric dd {
  font-size: clamp(1.25rem, 2.42vw, 2.125rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
.metric.lead dd { color: var(--accent); font-size: clamp(1.6rem, 3.5vw, 2.5rem); }
.metric dd.missing, .missing { color: var(--secondary); }
.summary-footer {
  border-top: 1px solid #dce7f6;
  min-height: 45px;
  padding: 8px 24px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.status-line { display: flex; align-items: baseline; gap: 8px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #6480a0; }
.status-dot[data-state="ready"] { background: var(--bar); }
.status-dot[data-state="error"] { background: #a95325; }
#sync-next { white-space: nowrap; }

.accounts { margin-top: 32px; scroll-margin-top: 18px; }
.summary[hidden] ~ .accounts { margin-top: 0; }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 1.25rem; }
#account-count { margin-top: 3px; color: var(--muted); font-size: 13px; }
.filters { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search, .filters select {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface);
}
.search { position: relative; width: min(24vw, 228px); }
.search input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: inherit;
  padding: 0 10px 0 34px;
  background: transparent;
  font-size: 16px;
}
.search input::placeholder { color: var(--muted); font-size: 14px; }
.search-mark {
  position: absolute; z-index: 1; pointer-events: none; left: 13px; width: 11px; height: 11px;
  border: 1.5px solid var(--muted); border-radius: 50%;
}
.search-mark::after {
  content: ""; position: absolute; height: 4px; width: 1.5px; border-radius: 1px;
  right: -2px; bottom: -3px; background: var(--muted); transform: rotate(-43deg);
}
.filters select { padding: 0 9px; font-size: 14px; }
.ledger { padding-inline: 18px; }
table { border-spacing: 0; table-layout: fixed; width: 100%; }
thead th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 0 6px;
  text-align: right;
}
thead th:first-child { width: 28%; text-align: left; }
thead th:last-child { width: 19%; }
.column-sort {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  white-space: nowrap;
}
.sort-arrows {
  display: grid;
  gap: 2px;
  width: 8px;
  justify-items: center;
}
.sort-arrows::before, .sort-arrows::after {
  content: "";
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  opacity: .56;
  transform: rotate(-45deg);
}
.sort-arrows::after { transform: rotate(135deg); }
th[aria-sort] .column-sort { color: var(--accent); }
th[aria-sort="ascending"] .sort-arrows::before,
th[aria-sort="descending"] .sort-arrows::after { opacity: 1; }
th[aria-sort="ascending"] .sort-arrows::after,
th[aria-sort="descending"] .sort-arrows::before { opacity: .34; }
tbody th, tbody td {
  padding: 9px 6px;
  border-top: 1px solid var(--quiet-line);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
tbody th { text-align: left; font-weight: 650; }
tbody td { text-align: right; overflow-wrap: anywhere; }
.avatar {
  --avatar-bg: #eef1f5;
  display: inline-grid; place-items: center; vertical-align: middle;
  inline-size: 30px; block-size: 30px;
  margin-right: 9px; border-radius: 50%;
  color: var(--muted); font-size: 13px;
  position: relative; overflow: hidden;
}
.avatar:not(:has(img)) { background: var(--avatar-bg); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }
.account-name {
  display: inline-block;
  max-inline-size: calc(100% - 43px);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.account-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border-radius: 5px;
}
.account-link .avatar { flex: 0 0 30px; }
.account-link .account-name {
  min-width: 0;
  max-inline-size: none;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-link:focus-visible .account-name { text-decoration: underline; }
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.plan-head { margin: 4px 0 14px; }
.plan-status { margin-top: 4px; color: var(--muted); font-size: 13px; }
.plan-scroll { overflow-x: auto; }
.plan-table {
  display: table;
  table-layout: auto;
  min-width: 730px;
}
.plan-table thead { position: static; width: auto; height: auto; clip-path: none; }
.plan-table tbody { display: table-row-group; }
.plan-table tr { display: table-row; }
.plan-table td, .plan-table th { padding: 10px 8px; }
.plan-table td { border-top: 1px solid var(--quiet-line); white-space: nowrap; }
.plan-table th:first-child { width: 21%; }
.plan-table th:nth-child(2), .plan-table td:nth-child(2) { text-align: left; }
.plan-table th:last-child { width: auto; }
.plan-table .plan-video { text-align: left; }
.plan-cover {
  display: inline-grid; place-items: center; position: relative; vertical-align: middle;
  width: 36px; height: 48px; overflow: hidden; border-radius: 6px;
  background: var(--wash); color: var(--muted); font-size: 12px;
}
.plan-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.plan-description {
  display: inline-block; vertical-align: middle; margin-left: 9px; max-width: clamp(78px, 10vw, 150px);
  overflow: hidden; text-overflow: ellipsis;
}
.plan-progress progress { width: 36px; }
.plan-id { color: var(--muted); }
.session-controls { display: flex; align-items: center; gap: 5px 9px; color: var(--muted); font-size: 13px; }
.session-controls > span { max-width: 18vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-button {
  min-height: 40px; padding: 0 8px; border: 0; border-radius: var(--control-radius);
  background: transparent; color: var(--accent); font-size: 14px; font-weight: 600;
}
.text-button:disabled { opacity: .6; cursor: default; }
.text-button:hover { background: var(--wash); }
.date-toolbar { display: flex; margin: 0 0 16px; }
.date-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: var(--control-radius);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.date-trigger .calendar-mark { color: var(--accent); }
.dashboard-dialog {
  box-sizing: border-box; margin: auto; max-height: calc(100dvh - 24px);
  max-width: calc(100% - 24px); padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); background: var(--surface);
  box-shadow: 0 14px 44px #16284326;
}
.dashboard-dialog::backdrop { background: #14284444; }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--quiet-line);
}
.date-dialog { width: 790px; }
.calendar-body { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
.date-presets { display: grid; gap: 5px; align-content: start; padding: 12px; background: #f6f8fc; }
.date-presets button {
  min-height: 34px; padding: 2px 4px; font-size: 13px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--surface);
}
.date-presets button:hover, .date-presets button:focus-visible { color: var(--accent); border-color: var(--accent); }
.calendar-months { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 13px 14px; }
.calendar-months h3 { text-align: center; font-size: 15px; margin: 4px 0 10px; }
.month-step {
  position: absolute; inset-block-start: 8px; min-width: 40px; min-height: 40px; border: 0;
  border-radius: var(--control-radius); background: var(--surface); color: var(--accent); font-size: 21px;
}
.month-step:disabled { color: var(--secondary); opacity: .45; cursor: default; }
.previous-month { left: 10px; }
.next-month { right: 10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday, .calendar-day {
  min-height: 37px; display: grid; place-items: center; color: var(--ink); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.calendar-weekday { color: var(--muted); }
.calendar-day { position: relative; border: 0; background: transparent; }
.calendar-day:disabled { opacity: .4; cursor: default; }
.calendar-day:not(:disabled):hover { box-shadow: inset 0 0 0 1px var(--accent); border-radius: 20px; }
.calendar-day.today::after {
  content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px;
  border-radius: 50%; background: currentColor;
}
.calendar-day.in-range { background: #e7f1ff; }
.calendar-day.range-bound { border-radius: 20px; background: var(--accent); color: #fff; font-weight: 700; }
.calendar-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 3px; padding: 10px 14px; border-top: 1px solid var(--quiet-line); color: var(--muted); font-size: 13px;
}
.calendar-footer .refresh { min-width: 72px; }
.refresh:disabled { opacity: .5; cursor: default; }
.access-screen { min-height: 100svh; display: grid; align-items: center; justify-items: center; padding: 20px; }
.access-card { width: min(100%, 390px); padding: 30px; background: var(--surface); }
.access-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted); }
.access-card h1 { margin: 16px 0 22px; }
.access-form { display: grid; gap: 12px; }
.access-form label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.access-form input {
  min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--control-radius); color: var(--ink); background: var(--surface); font-size: 16px;
}
.form-message { min-height: 1.4em; color: var(--muted); font-size: 14px; }
.access-card > .text-button { margin-top: 10px; }
.account-dialog { width: 410px; }
.account-dialog form, .review-dialog > p, .review-dialog ul { padding: 14px 16px; }
.review-dialog { width: 510px; }
.review-dialog ul { margin: 0; list-style: none; }
.review-dialog li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-block: 4px; }
.review-dialog li > span { color: var(--muted); font-size: 14px; white-space: nowrap; }
@media (max-width: 600px) {
  .session-controls { gap: 0; }
  .session-controls > span { display: none; }
  .session-controls .text-button { padding-inline: 6px; font-size: 13px; }
  .calendar-body { grid-template-columns: minmax(0, 1fr); }
  .date-presets { display: flex; overflow: auto; }
  .date-presets button { padding-inline: 8px; white-space: nowrap; }
  .calendar-months { grid-template-columns: minmax(0, 1fr); padding-top: 10px; }
  #month-right { display: none; }
  .calendar-day { min-height: 40px; }
}
.contribution-cell { white-space: nowrap; color: var(--muted); }
progress {
  appearance: none; vertical-align: .19em; width: min(48%, 66px); height: 5px;
  margin-right: 8px; border: 0; border-radius: 8px; background: #e1ebf9; color: var(--bar);
}
progress::-webkit-progress-bar { background: #e1ebf9; border-radius: 8px; }
progress::-webkit-progress-value { background: var(--bar); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--bar); border-radius: 8px; }
.contribution-cell span { display: inline-block; min-width: 45px; }
.mobile-label { display: none; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; border-top: 1px solid var(--quiet-line); font-size: 14px; }
.footnote { margin-top: 10px; color: var(--secondary); font-size: 13px; }

@media (hover: hover) and (pointer: fine) {
  .refresh:not([aria-disabled="true"], :focus-visible) { transition: transform 130ms var(--ease-out); }
  .refresh:hover:not([aria-disabled="true"]) { background: var(--accent-hover); }
  .column-sort:hover { color: var(--accent); }
  .account-link:hover .account-name, .back-link:hover { text-decoration: underline; }
  .refresh:active:not([aria-disabled="true"], :focus-visible) { transform: scale(.97); }
  .nav-item:not(.selected):hover, tbody tr:hover { background: var(--wash); }
}
@media (prefers-reduced-motion: reduce) {
  .refresh:not([aria-disabled="true"], :focus-visible) { transition: none; }
  .refresh:active:not([aria-disabled="true"], :focus-visible) { transform: none; }
}

@media (max-width: 1040px) {
  .frame { grid-template-columns: 150px minmax(0, 1fr); }
  .content { padding-inline: 24px; }
  .metric { padding-inline: 16px; }
  .ledger { padding-inline: 10px; }
}
@media (max-width: 820px) {
  .frame { display: block; padding: 0 8px 8px; }
  .sidebar { display: none; }
}
@media (max-width: 600px) {
  .appbar { height: 48px; padding-inline: 14px 16px; }
  .frame { padding: 0; min-height: calc(100svh - 48px); }
  .sheet { border-width: 1px 0 0; border-radius: 0; min-height: calc(100svh - 48px); }
  .content { padding: 17px 16px max(20px, env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 15px; gap: 8px; }
  .dateline-zone { display: none; }
  h1 { margin-top: 4px; font-size: 1.5rem; }
  .refresh { padding: 0 9px; min-width: 106px; }
  .summary-head { padding: 12px 14px 0; }
  .summary-head h2 { font-size: 1rem; }
  .metrics { grid-template-columns: 1fr 1fr; padding: 5px 0 0; }
  .metric { padding: 8px 14px; min-height: 58px; justify-content: center; }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid #dce7f6; }
  .metric.lead dd, .metric dd { font-size: 1.43rem; }
  .summary-footer { padding: 7px 14px; gap: 1px 8px; flex-wrap: wrap; font-size: 12px; }
  .accounts { margin-top: 22px; }
  .section-head { display: grid; gap: 7px; margin-bottom: 10px; }
  .section-head h2 { font-size: 1.125rem; }
  .filters { justify-content: space-between; }
  .search { width: auto; flex: 1; }
  .filters select { max-width: 52%; font-size: 16px; }
  .ledger { padding-inline: 10px; overflow: hidden; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .column-sort { display: none; }
  tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
    padding: 10px 4px;
  }
  tbody tr + tr { border-top: 1px solid var(--quiet-line); }
  tbody th, tbody td { border: 0; padding: 0; }
  tbody th { grid-column: 1 / 3; }
  tbody td[data-field="salesFen"] { align-self: center; grid-column: 3; color: var(--accent); font-weight: 650; }
  tbody td[data-field="spendFen"], tbody td[data-field="roi"], tbody td[data-field="orders"] {
    font-size: 13px; text-align: left;
  }
  tbody td[data-field="orders"] { text-align: right; }
  td:not([data-field="salesFen"]) .mobile-label { display: inline; margin-right: 4px; color: var(--muted); }
  .contribution-cell { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
}
