:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #262b36;
  --text: #e8eaf0;
  --muted: #98a2b3;
  --accent: #7aa2f7;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar h1 { font-size: 1.05rem; margin: 0; letter-spacing: 0.01em; }
.session { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.9rem; }

main { padding: 1rem; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.auth-view { max-width: 420px; margin: 2rem auto; display: grid; gap: 1rem; }
.auth-card { display: grid; gap: 0.4rem; }
.auth-card h2 { margin: 0 0 0.4rem; font-size: 1rem; }

label { font-size: 0.82rem; color: var(--muted); }
input[type="text"], input:not([type]), input[type="password"] {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.6rem;
  font-size: 0.95rem;
  width: 100%;
}

button {
  background: var(--accent);
  color: #0b1020;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }

.hint { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; }
.banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
}

.limits-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.as-of {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.boxes {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.limit-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.5rem;
}
.limit-box header { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.limit-label { margin: 0; font-size: 0.95rem; }
.limit-status { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.limit-status.rate-limited { color: var(--danger); }
.limit-amount { margin: 0; font-size: 1.35rem; font-weight: 600; }
.limit-reset { margin: 0; font-size: 0.8rem; color: var(--muted); }
.meter { background: #0d0f14; border-radius: 999px; height: 8px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
.meter-fill.over { background: var(--danger); }
.meter-fill.rate-limited { background: var(--warn); }

.chart-card { display: grid; gap: 0.75rem; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.metric-toggle { display: inline-flex; gap: 0.35rem; background: #0d0f14; border: 1px solid var(--border); border-radius: 8px; padding: 0.2rem 0.5rem; }
.metric-toggle label { font-size: 0.85rem; color: var(--text); display: inline-flex; align-items: center; gap: 0.3rem; }
.metric-toggle input { accent-color: var(--accent); }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; font-size: 0.85rem; }
.breadcrumb button { background: none; color: var(--accent); border: 0; padding: 0; font-weight: 500; }
.breadcrumb span { color: var(--muted); }

.chart-wrap { position: relative; width: 100%; overflow: hidden; }
#chart { width: 100%; height: auto; display: block; touch-action: manipulation; }
#chart .bar { fill: var(--accent); cursor: pointer; }
#chart .bar.empty { fill: #2a3040; }
#chart .bar.drillable:hover, #chart .bar.drillable:focus { fill: #a9c2ff; outline: none; }
#chart .bar:not(.drillable) { cursor: default; }
#chart .axis { stroke: #2a3040; stroke-width: 1; }
#chart .grid { stroke: #1e222c; stroke-width: 1; }
#chart .label { fill: var(--muted); font-size: 11px; }
#chart .value { fill: var(--text); font-size: 10px; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text);
  max-width: 220px;
  z-index: 3;
}
.tooltip strong { display: block; }

.empty, .note { margin: 0; font-size: 0.85rem; color: var(--muted); }
.footer { padding: 1rem; color: var(--muted); font-size: 0.78rem; text-align: center; }

@media (max-width: 900px) {
  .boxes { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
}

@media (max-width: 640px) {
  .boxes { grid-template-columns: 1fr; }
  .limits-head { flex-wrap: wrap; }
  .limit-amount { font-size: 1.2rem; }
  main { padding: 0.75rem; }
  .chart-toolbar { align-items: flex-start; }
}

@media (max-width: 380px) {
  .topbar h1 { font-size: 0.95rem; }
  .metric-toggle { width: 100%; justify-content: space-between; }
}
