:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7f9;
  color: #182326;
  --muted: #59686c;
  --line: #e4e9eb;
  --green: #176148;
  --mint: #eaf5ef;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid #278061;
  outline-offset: 3px;
}

.shell { max-width: 1184px; width: calc(100% - 72px); margin: 0 auto; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { height: 66px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 15px; font-weight: 700; }
.brand-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 8px;
  background: #193b32;
  border-radius: 8px;
}
.brand-mark i { width: 3px; height: 7px; background: #a6e6cb; border-radius: 1px; }
.brand-mark i:nth-child(2) { height: 11px; }
.brand-mark i:nth-child(3) { height: 15px; }
.refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 106px;
  min-height: 36px;
  padding: 6px 11px;
  color: #243e35;
  background: #fff;
  border: 1px solid #d9e4df;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
}
.refresh:hover:not(:disabled) { background: var(--mint); }
.refresh:disabled { color: #65716c; }
#refresh-icon { display: inline-block; font-size: 19px; line-height: 1; }
.spinning { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 40px 0 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 36px); letter-spacing: -.04em; line-height: 1.24; }
.intro p { font-size: 14px; color: var(--muted); margin-top: 9px; line-height: 1.55; }
.sync { display: flex; align-items: center; gap: 8px; white-space: nowrap; align-self: flex-end; padding-bottom: 2px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #87969c; }
.sync[data-status="ok"] .dot { background: #248363; box-shadow: 0 0 0 4px #e0f1e8; }
.sync[data-status="warn"] .dot { background: #b66b1b; box-shadow: 0 0 0 4px #faecdb; }

.dashboard-views { display: flex; align-items: center; gap: 19px; border-bottom: 1px solid #dce4e6; margin-bottom: 17px; }
.dashboard-views button { padding: 0 1px 10px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); background: transparent; font-size: 14px; font-weight: 650; }
.dashboard-views button:hover, .dashboard-views button[aria-pressed="true"] { color: var(--green); }
.dashboard-views button[aria-pressed="true"] { border-bottom-color: #278061; }

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.plan {
  width: 100%;
  min-height: 80px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  transition: background .15s ease, border-color .15s ease;
}
.plan:hover { border-color: #9dbdb1; }
.plan[aria-selected="true"] { border-color: #5e9d86; background: #f1f9f5; }
.plan-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: -.03em;
}
.plan-icon.opencode { background: #edeafe; color: #514290; }
.plan-icon.opendesign { background: #f8ece0; color: #815327; }
.plan-icon.command { background: #e5eefb; color: #28537f; }
.plan-info { min-width: 0; display: grid; gap: 5px; }
.plan-info strong { font-size: 14px; line-height: 1.2; }
.plan-meta { font-size: 12px; color: var(--muted); }
.plan-price { font-size: 13px; color: #32473e; font-weight: 670; white-space: nowrap; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 20px 22px 14px; }
h2 { font-size: 21px; letter-spacing: -.025em; }
#provider-status { font-size: 12px; margin-top: 6px; color: var(--muted); }
.source { color: var(--green); text-decoration: none; white-space: nowrap; font-size: 13px; font-weight: 650; }
.source:hover { text-decoration: underline; }
.notice {
  margin: 0 22px 10px;
  padding: 10px 12px;
  background: #fff5e8;
  border: 1px solid #f2dfc3;
  border-radius: 7px;
  color: #70450d;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
}
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 22px 15px; }
.views { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: #f1f4f5; }
.view { border: 0; border-radius: 6px; padding: 6px 12px; color: var(--muted); font-size: 13px; background: transparent; white-space: nowrap; }
.view[aria-pressed="true"] { color: #243a33; background: #fff; box-shadow: 0 1px 3px #172d2320; font-weight: 650; }
.search { display: flex; position: relative; width: min(278px, 46%); }
.search input {
  width: 100%;
  height: 35px;
  padding: 6px 10px 6px 33px;
  border: 1px solid #dce4e6;
  background: #fff;
  border-radius: 8px;
  color: #182326;
  font-size: 13px;
}
.search input::placeholder { color: #657579; }
.search-mark { pointer-events: none; position: absolute; top: 10px; left: 12px; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #607176; }
.search-mark::after { content: ""; position: absolute; width: 5px; height: 1.5px; background: #607176; transform: rotate(45deg); left: 6px; top: 7px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { text-align: left; padding: 11px 22px; border-top: 1px solid #edf0f1; }
th { background: #f7f9fa; color: #4f5e62; font-size: 12px; font-weight: 650; }
th:first-child { width: 53%; }
th:nth-child(2) { width: 25%; }
th button { border: 0; padding: 0; color: inherit; background: transparent; white-space: nowrap; text-align: left; }
th button:hover, th[aria-sort] button { color: #1b634b; }
td { font-size: 13px; color: #39494d; height: 41px; }
td.model { font-weight: 590; color: #1c292d; overflow-wrap: anywhere; }
td.numeric, .plan-price, #page-number { font-variant-numeric: tabular-nums; }
.rate { display: inline-block; border-radius: 5px; padding: 2px 7px; color: #165b44; background: #eaf5ef; font: 600 12px/1.45 ui-monospace, SFMono-Regular, monospace; }
.rate.free { color: #4e6067; background: #eef2f4; font-family: inherit; }
tbody tr:hover { background: #fafcfb; }
td.empty, .empty { color: var(--muted); padding: 34px 22px; font-size: 13px; text-align: center; }
.pager { min-height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 22px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pager > div { display: flex; align-items: center; gap: 11px; }
.pager button { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid #dee5e7; border-radius: 6px; background: #fff; color: #253b34; font-size: 17px; line-height: 1; }
.pager button:disabled { color: #9aa6a7; }
.pager button:hover:not(:disabled) { background: #eaf5ef; }

.history-list { margin: 0; padding: 0; list-style: none; }
.history-list li { padding: 12px 22px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; font-size: 13px; }
.history-list strong { color: #1c292d; overflow-wrap: anywhere; }
.history-list time, .history-list p { color: var(--muted); font-size: 12px; }
.history-list p { grid-column: 1 / -1; }

.rate-panel-heading p { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.rate-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); border-top: 1px solid var(--line); }
.rate-chart { min-width: 0; padding: 14px 21px 18px; }
.rate-legend { display: flex; flex-wrap: wrap; gap: 7px 16px; padding: 0; margin: 0 0 14px; list-style: none; color: var(--muted); font-size: 12px; }
.rate-legend li, .rate-match-group h4 { display: flex; align-items: center; gap: 6px; }
.rate-color[data-provider="opencode"] { background: #735fba; }
.rate-color[data-provider="opendesign"] { background: #be7844; }
.rate-color[data-provider="command"] { background: #4076a6; }
.rate-legend .rate-color, .rate-match-group .rate-color { flex: 0 0 9px; height: 9px; border-radius: 3px; }
.rate-chart-labels { display: flex; align-items: center; justify-content: space-between; padding: 4px 9px; color: var(--muted); font-size: 12px; }
.rate-bucket {
  display: grid;
  width: 100%;
  grid-template-columns: 75px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  min-height: 33px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
  color: #354649;
  background: transparent;
  font-size: 12px;
}
.rate-bucket:hover { background: #f6f9f8; }
.rate-bucket[aria-pressed="true"] { border-color: #a8cdbd; background: #eff8f3; color: #185841; }
.rate-bucket.vendor-bucket { grid-template-columns: 113px minmax(0, 1fr) 30px; }
.rate-bucket-label, .rate-bucket-count { font-weight: 650; font-variant-numeric: tabular-nums; }
.rate-bucket-count { text-align: right; }
.rate-track { display: flex; height: 11px; overflow: hidden; border-radius: 4px; background: #eaf0f1; }
.rate-track span { min-width: 0; flex-basis: 0; }

.rate-details { min-width: 0; background: #fbfcfc; border-left: 1px solid var(--line); }
.rate-details-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 14px; padding: 16px 20px 12px; }
.rate-details-heading h3 { margin: 0; color: #20342e; font-size: 16px; }
#rate-total { color: var(--muted); font-size: 12px; }
.vendor-grouping { width: max-content; margin: 0 20px 12px; }
#rate-matches { max-height: 515px; overflow: auto; }
.rate-match-group { padding: 10px 20px; border-top: 1px solid var(--line); }
.rate-match-group h4 { margin: 0; font-size: 13px; }
.rate-match-group h4 small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.rate-match-group p { color: var(--muted); margin-top: 7px; font-size: 12px; }
.rate-match-group ul { margin: 5px 0 0 15px; padding: 0; list-style: none; }
.rate-match-group li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; line-height: 1.4; font-size: 12px; }
.rate-match-group li span:first-child { overflow-wrap: anywhere; }
.rate-match-group li span:nth-child(2) { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-match-group .rate-model-provider { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--muted); font-size: 11px; }
.rate-match-group .rate-model-provider .rate-color { flex-basis: 6px; height: 6px; border-radius: 2px; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin: 14px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.6; }

@media (max-width: 760px) {
  .shell { width: calc(100% - 32px); }
  .intro { margin-top: 26px; }
  .plans { gap: 8px; }
  .plan { grid-template-columns: 31px minmax(0, 1fr); gap: 5px 8px; min-height: 86px; padding: 9px; }
  .plan-icon { width: 31px; height: 31px; }
  .plan-info strong { font-size: 12px; }
  .plan-price { grid-column: 2; font-size: 12px; }
  .rate-layout { grid-template-columns: minmax(0, 1fr); }
  .rate-details { border-left: 0; border-top: 1px solid var(--line); }
  #rate-matches { max-height: none; }
}

@media (max-width: 500px) {
  .dashboard-views { gap: 10px; }
  .dashboard-views button { font-size: 13px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 10px; }
  .sync { align-self: flex-start; }
  .plan { grid-template-columns: minmax(0, 1fr); min-height: 99px; }
  .plan-icon { display: none; }
  .plan-price { grid-column: 1; }
  .panel-heading, .toolbar, th, td, .pager { padding-left: 13px; padding-right: 13px; }
  .notice { margin-left: 13px; margin-right: 13px; }
  h2 { font-size: 18px; }
  .search input { font-size: 16px; padding-left: 29px; }
  .search input::placeholder { font-size: 12px; }
  .search-mark { left: 9px; }
  .view { padding-right: 8px; padding-left: 8px; }
  th:first-child { width: 49%; }
  th:nth-child(2) { width: 24%; }
  .footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
