:root {
  color-scheme: light;
  --bg: #faf9f5; --card: #fffdf9; --fg: #2d2a26;
  --muted: #827c74; --line: #e5e2db; --soft: #f0eee8; --green: #658375;
  --font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --font-base: 13px; --font-meta: 12px; --font-heading: 14px; --font-metric: 18px;
  --line-base: 1.5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-family); font-size: var(--font-base); line-height: var(--line-base); -webkit-font-smoothing: antialiased; }
main { padding: 20px; max-width: 1200px; margin: auto; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.quota-banner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--card);
  column-gap: 0;
}
.account-group, .quota-group, .time-group { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; padding-right: 20px; }
.quota-group, .time-group { border-left: 1px solid var(--line); padding-left: 20px; }
.update-group { padding-right: 0; }
.account-group { gap: 7px; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.connected { background: var(--green); }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: var(--font-base); }
.badge { flex-shrink: 0; font-size: var(--font-meta); padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--soft); }
.muted { color: var(--muted); }
strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.progress { flex: 1; min-width: 28px; max-width: 80px; height: 4px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.progress > div { background: var(--green); height: 100%; width: 0; transition: width .3s; }
.time-group { font-size: var(--font-meta); font-variant-numeric: tabular-nums; }
.update-group { color: var(--muted); }
.error { font-size: var(--font-meta); color: #b45243; margin-top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); width: min(380px, calc(100vw - 32px)); padding: 24px; }
dialog::backdrop { background: #28251f55; }
h2 { font-size: var(--font-heading); font-weight: 600; line-height: var(--line-base); margin: 0 0 12px; }
form p { font-size: var(--font-base); color: var(--muted); }
form label { display: block; margin: 15px 0; }
input { display: block; margin-top: 7px; width: 100%; height: 36px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; }
form button { width: 100%; border: 0; border-radius: 5px; padding: 10px; background: var(--fg); color: var(--card); }
#login-error { color: #b45243; }
:root[data-theme=dark] { color-scheme: dark; --bg: #151412; --card: #1d1b18; --fg: #f6f4f1; --muted: #a69f97; --line: #3a3530; --soft: #262320; --green: #95b7a3; }
@media (max-width: 980px) {
  .quota-banner { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .quota-group { padding-right: 0; }
  .time-group:not(.update-group) { border-left: 0; padding-left: 0; }
}
@media (max-width: 540px) {
  main { padding: 12px; }
  .quota-banner { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 10px; }
  .account-group, .quota-group, .time-group { border-left: 0; padding-left: 0; padding-right: 0; }
  .progress { max-width: none; }
  .time-group { font-size: var(--font-meta); gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.overview { display: grid; gap: 16px; margin-top: 16px; }
.overview-card { border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.table-wrap { overflow-x: auto; }
.users-table { width: 100%; min-width: 1100px; table-layout: fixed; border-collapse: collapse; font-size: var(--font-base); }
.users-table th { height: 40px; padding: 0 16px; font-weight: 500; color: var(--muted); }
.users-table td { padding: 12px 16px; border-top: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
.users-table th:first-child, .users-table td:first-child { padding-left: 20px; text-align: left; }
.users-table th:nth-last-child(-n+2), .users-table td:nth-last-child(-n+2) { text-align: right; }
.users-table th:last-child, .users-table td:last-child { padding-right: 20px; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cost-cell { font-weight: 600; }
.quota-track { position: relative; height: 28px; border-radius: 5px; overflow: hidden; background: var(--soft); }
.quota-fill { height: 100%; background: #6d9c8033; }
.quota-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-size: var(--font-meta); }
.quota-text > span:last-child { font-size: var(--font-meta); }
.card-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
.card-heading h2 { margin: 0; font-size: var(--font-heading); font-weight: 600; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 13px 16px; border-top: 1px solid var(--line); }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: var(--font-meta); font-variant-numeric: tabular-nums; }
.legend-item i { width: 9px; height: 9px; border-radius: 2px; }
.empty { padding: 24px !important; color: var(--muted); text-align: center !important; }
.recharts-weekly { width: 100%; height: 256px; padding: 0 8px; }
.cost-tooltip { min-width: 192px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 12px; color: var(--fg); font-size: var(--font-base); box-shadow: 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a; }
.tooltip-date { margin: 0 0 8px; font-weight: 500; }
.tooltip-users { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.tooltip-row, .tooltip-total { display: flex; align-items: center; justify-content: space-between; gap: 20px; font-variant-numeric: tabular-nums; }
.tooltip-user { display: flex; align-items: center; gap: 8px; }
.tooltip-user i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.tooltip-total { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 500; }
@media (max-width: 640px) { .recharts-weekly { height: 240px; } }
:root { --health-card: var(--card); --health-fg: var(--fg); --health-muted: var(--muted); --health-empty: var(--line); --health-future: var(--soft); --health-good: var(--green); --health-bad: #b96657; --health-warn: #b58d51; --health-low: #739b98; --health-cancelled: #b98b66; --health-caller: #7b8f9e; --health-tooltip-bg: var(--card); --health-tooltip-header: var(--soft); }
.logs-section { display: grid; gap: 16px; margin-top: 16px; }
.health-card { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--health-card); color: var(--health-fg); }
.health-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.health-header h2 { margin: 0; font-size: var(--font-heading); font-weight: 600; line-height: var(--line-base); }
.health-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding-top: 1px; }
.health-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.health-legend > span { display: inline-flex; align-items: center; gap: 4px; font-size: var(--font-meta); color: var(--health-muted); line-height: var(--line-base); }
.health-dot { display: inline-block; flex-shrink: 0; width: 8px; height: 8px; border-radius: 2px; }
.health-dot.no_data, .health-cell.no_data { background: var(--health-empty); }
.health-dot.future, .health-cell.future { background: var(--health-future); opacity: .6; }
.health-dot.unavailable, .health-cell.unavailable { background: var(--health-bad); }
.health-dot.unstable, .health-cell.unstable { background: var(--health-warn); }
.health-dot.low_sample, .health-cell.low_sample { background: var(--health-low); }
.health-dot.stable, .health-cell.stable { background: var(--health-good); }
.health-dot.cancelled { background: var(--health-cancelled); }
.health-dot.caller { background: var(--health-caller); }
.health-overall { font-size: var(--font-base); font-weight: 600; line-height: var(--line-base); font-variant-numeric: tabular-nums; }
.health-overall.stable, .health-point-percent.stable { color: var(--health-good); }
.health-overall.unavailable, .health-point-percent.unavailable { color: var(--health-bad); }
.health-overall.unstable, .health-point-percent.unstable { color: var(--health-warn); }
.health-overall.low_sample, .health-point-percent.low_sample { color: var(--health-low); }
.health-overall.no_data, .health-point-percent.no_data { color: var(--health-muted); }
.health-grid { display: grid; grid-template-columns: repeat(var(--health-columns), minmax(0, 1fr)); align-items: end; gap: 4px 2px; margin-top: 16px; }
.health-point { display: flex; align-items: flex-end; width: 100%; min-width: 2px; height: 20px; padding: 0; border: 0; background: transparent; }
.health-point[aria-disabled=true] { cursor: default; }
.health-cell { display: block; width: 100%; height: 14px; border-radius: 2px; transform-origin: bottom; }
.health-point[aria-disabled=false]:hover .health-cell { filter: brightness(1.05); }
.health-tooltip { z-index: 50; width: 300px; max-width: calc(100vw - 24px); color: var(--health-fg); background: var(--health-tooltip-bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a; }
.health-tooltip-arrow { fill: var(--health-tooltip-bg); }
.health-tooltip-body { overflow: hidden; border-radius: 8px; }
.health-tooltip-body header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--health-tooltip-header); }
.health-point-label { display: flex; align-items: center; gap: 8px; }
.health-point-label strong { font-size: var(--font-base); font-weight: 600; }
.health-point-badge { padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; font-size: var(--font-meta); font-weight: 500; background: var(--soft); }
.health-tooltip-muted { color: var(--health-muted); font-size: var(--font-meta); }
.health-point-content { display: grid; gap: 14px; padding: 14px; }
.health-point-metrics { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.health-point-percent { display: block; font-size: var(--font-metric); font-weight: 600; line-height: 1.2; margin-top: 8px; }
.health-valid-count { text-align: right; }
.health-valid-count strong { display: block; margin-top: 8px; font-size: var(--font-metric); font-weight: 600; line-height: 1.2; }
.health-composition { display: flex; height: 6px; overflow: hidden; border-radius: 4px; background: var(--health-empty); }
.health-composition .health-dot { height: 100%; border-radius: 0; }
.health-point-counts { display: grid; gap: 10px; font-size: var(--font-meta); }
.health-point-counts > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.health-point-counts > div > span { display: flex; align-items: center; gap: 7px; }
.health-point-counts strong { font-size: var(--font-meta); }
.health-loading { padding: 22px; color: var(--muted); }
#health-error { margin: 0; }
@media(max-width:640px) { .health-grid { grid-template-columns: repeat(var(--health-columns-small), minmax(0, 1fr)); } .health-actions { gap: 12px; } }
#logs-error { margin: 0; }
