:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #182032;
  --border: #243047;
  --text: #e6edf7;
  --muted: #8ea0bd;
  --accent: #4f8cff;
  --accent-hover: #6aa0ff;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top right, #162136 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.login-backdrop {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: rgba(18, 24, 38, 0.94);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.brand-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1.4px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(79, 140, 255, 0.14);
  border: 1px solid rgba(79, 140, 255, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card p { margin: 0 0 20px; font-size: 13px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
  cursor: pointer;
}
.error-msg {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
  flex-shrink: 0;
}
.topbar h1 { margin: 0; font-size: 20px; }
.subline { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.seg-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.full-width { width: 100%; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.section { margin-bottom: 20px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: #cbd5e1; }

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.wrap-gap { flex-wrap: wrap; }

.quota-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.quota-row { margin-bottom: 11px; }
.quota-row:last-child { margin-bottom: 0; }
.quota-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}
.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #1e293b;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}
.fill-green { background: linear-gradient(90deg, #16a34a, #22c55e); }
.fill-yellow { background: linear-gradient(90deg, #ca8a04, #eab308); }
.fill-red { background: linear-gradient(90deg, #dc2626, #ef4444); }

.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.kpi-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot-input { background: var(--accent); }
.dot-cache { background: var(--cyan); }
.dot-output { background: var(--purple); }
.dot-g5 { background: var(--green); }
.dot-gw { background: var(--accent); }
.dot-c5 { background: #f59e0b; }
.dot-cw { background: var(--purple); }

.chart-box { width: 100%; height: 220px; position: relative; }
.chart-box svg { width: 100%; height: 100%; display: block; }
.chart-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 10px; border-bottom: 1px solid #1d2638; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-exact { background: rgba(34, 197, 94, 0.14); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.35); }
.badge-est { background: rgba(142, 160, 189, 0.14); color: #cbd5e1; border: 1px solid rgba(142, 160, 189, 0.28); }
.badge-err { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }

.prompt-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.pager-btns { display: flex; gap: 8px; }

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(11, 15, 23, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 120;
}

@media (max-width: 640px) {
  .charts-grid { grid-template-columns: 1fr; }
  .app-shell { padding: 14px 12px 36px; }
}
