:root {
  --bg: #f4f6f9;
  --surface: rgba(255, 255, 255, 0.92);
  --ink: #101828;
  --muted: #667085;
  --line: #e5e9f0;
  --blue: #2878ee;
  --blue-soft: #eaf3ff;
  --green: #0f9f75;
  --violet: #7758d9;
  --yellow: #e7b91b;
  --shadow: 0 14px 34px rgba(28, 44, 78, 0.07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(40, 120, 238, .11), transparent 30%),
    radial-gradient(circle at 94% 8%, rgba(119, 88, 217, .09), transparent 25%),
    var(--bg);
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.top-actions { display: flex; gap: 10px; }
.card { background: var(--surface); border: 1px solid rgba(218, 224, 234, .9); border-radius: 20px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.button { border: 0; border-radius: 11px; padding: 10px 16px; color: var(--ink); background: #fff; font-weight: 650; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, #2173e8, #5b87ed); box-shadow: 0 8px 18px rgba(40, 120, 238, .2); }
.button.ghost { border: 1px solid var(--line); }
.button.reset { align-self: end; margin-bottom: 1px; background: transparent; color: var(--muted); }

.filters { display: flex; align-items: end; gap: 14px; padding: 17px; margin-bottom: 18px; }
.field { display: flex; min-width: 160px; flex-direction: column; gap: 7px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.field.grow { flex: 1; }
.field.compact { min-width: 110px; }
.date-field { min-width: 330px; }
.date-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.date-row i { color: #98a2b3; font-style: normal; }
input, select {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 11px; outline: 0;
  padding: 0 12px; color: var(--ink); background: #fbfcfe; transition: .16s ease;
}
input:focus, select:focus { border-color: rgba(40,120,238,.55); box-shadow: 0 0 0 4px rgba(40,120,238,.08); background: #fff; }

.metric-grid { display: grid; grid-template-columns: 1.15fr 1fr .75fr; gap: 16px; margin-bottom: 18px; }
.metric { position: relative; min-height: 154px; padding: 22px 24px; overflow: hidden; }
.metric::after { content: ""; position: absolute; inset: auto -25px -45px auto; width: 135px; height: 135px; border-radius: 50%; opacity: .12; }
.accent-cost::after { background: var(--green); }
.accent-token::after { background: var(--blue); }
.accent-request::after { background: var(--violet); }
.metric-label { color: var(--muted); font-weight: 650; }
.metric strong { display: block; margin-top: 8px; font-size: clamp(29px, 3vw, 40px); line-height: 1.18; letter-spacing: -.04em; }
.metric-note { margin-top: 9px; color: #8992a3; }
.token-parts { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.token-parts span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; }
.input-dot::before { background: var(--green); }
.output-dot::before { background: var(--violet); }
.token-parts b { color: currentColor; }

.chart-card { padding: 21px 22px 16px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 0 3px 15px; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 17px; height: 4px; border-radius: 8px; }
.legend-token { background: var(--blue); }
.legend-cost { background: var(--yellow); }
.chart-wrap { position: relative; height: 420px; }
#usageChart { width: 100%; height: 100%; display: block; }
.chart-tooltip { position: absolute; z-index: 3; display: none; min-width: 168px; pointer-events: none; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.97); box-shadow: 0 12px 28px rgba(16,24,40,.14); color: var(--muted); font-size: 12px; }
.chart-tooltip strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 13px; }
.chart-tooltip b { float: right; margin-left: 15px; color: var(--ink); }
.empty-state { position: absolute; inset: 0; display: none; place-content: center; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 10px 0 3px; color: var(--ink); }
.empty-state p { margin: 0; }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; margin: auto; border-radius: 15px; background: var(--blue-soft); color: var(--blue); font-size: 22px; }

.model-card { margin-top: 18px; padding: 21px 24px 24px; }
.compact-heading { padding-bottom: 12px; }
.model-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.model-tag { border: 1px solid #dce8f8; border-radius: 999px; padding: 6px 11px; color: #37628f; background: #f5f9ff; font-size: 12px; }

dialog { width: min(760px, calc(100% - 28px)); border: 0; border-radius: 22px; padding: 0; box-shadow: 0 30px 90px rgba(13, 24, 45, .25); }
dialog::backdrop { background: rgba(18, 27, 45, .38); backdrop-filter: blur(4px); }
.dialog-card { padding: 24px; }
.dialog-title { display: flex; justify-content: space-between; align-items: start; }
.dialog-title h2 { margin: 4px 0 0; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #f2f4f7; font-size: 22px; }
.privacy-note { color: var(--muted); }
.key-add-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 9px; margin: 18px 0; }
.key-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; }
.key-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; padding: 11px 13px; }
.key-item strong, .key-item span { display: block; }
.key-item span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.delete-key { border: 0; background: transparent; color: #d04444; }
.dialog-footer { display: flex; justify-content: end; margin-top: 18px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 26px; opacity: 0; transform: translate(-50%, 15px); pointer-events: none; padding: 11px 16px; border-radius: 11px; color: #fff; background: #1f2937; box-shadow: 0 10px 28px rgba(0,0,0,.18); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .page-shell { width: min(100% - 24px, 760px); padding-top: 20px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .field, .date-field { min-width: 0; }
  .date-field, .field.grow { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:last-child { grid-column: 1 / -1; }
  .chart-wrap { height: 350px; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column-reverse; }
  .top-actions .button { padding: 9px 12px; }
  .filters, .metric-grid { grid-template-columns: 1fr; }
  .date-field, .field.grow, .metric:last-child { grid-column: auto; }
  .metric { min-height: 132px; padding: 19px; }
  .chart-card { padding: 18px 12px 10px; }
  .section-heading { padding-inline: 6px; }
  .section-heading p { font-size: 12px; }
  .legend { gap: 9px; }
  .chart-wrap { height: 330px; }
  .key-add-row { grid-template-columns: 1fr; }
}
