:root {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  color: #18181b;
  background: #f8fafc;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; }
main {
  max-width: 920px;
  margin: 28px auto 48px;
  padding: 0 20px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0 0 4px;
}
h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.muted {
  color: #71717a;
  font-size: 12px;
  margin: 0;
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
button {
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid #d4d4d8;
  background: #fff;
  color: #18181b;
  cursor: pointer;
}
button:hover:not(:disabled) {
  background: #f4f4f5;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button.ghost {
  color: #71717a;
}
.panel {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.auth-primary {
  margin-top: 14px;
}
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 7px;
  background: #18181b;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.primary-btn:hover {
  background: #27272a;
}
.token-fallback {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f4f4f5;
}
.token-fallback summary {
  font-size: 12px;
  color: #71717a;
  cursor: pointer;
  user-select: none;
}
.token-fallback summary:hover {
  color: #18181b;
}
.token-fallback p.muted {
  margin-top: 8px;
}
.token-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.token-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #d4d4d8;
  border-radius: 7px;
}
.error-text {
  color: #dc2626;
  font-size: 12px;
  margin: 10px 0 0;
}
.status-line {
  font-size: 12px;
  color: #52525b;
  margin: 0 0 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 10px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}
.balance-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 15px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.stale {
  border-color: #f59e0b;
}
.card.exhausted {
  border-color: #fca5a5;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f4f4f5;
  color: #52525b;
  white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.exhausted, .badge.error { background: #fee2e2; color: #991b1b; }
.badge.stale { background: #ffedd5; color: #9a3412; }

.group-label {
  font-size: 11px;
  font-weight: 600;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 4px;
}
.window-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.window-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}
.window-name {
  font-weight: 500;
  color: #27272a;
}
.window-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.track {
  position: relative;
  width: 100%;
  height: 8px;
  margin: 2px 0;
  border-radius: 999px;
  background: #f4f4f5;
}
.track-clip {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
}
.fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}
.fill.ok { background: #22c55e; }
.fill.warning { background: #f59e0b; }
.fill.exhausted { background: #ef4444; }
.pace-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: #3f3f46;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
  transform: translateX(-50%);
  pointer-events: auto;
}
.pace-marker.over {
  background: #d97706;
}
.pace-marker.critical {
  background: #dc2626;
}
.window-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #71717a;
}
.window-pace {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #52525b;
  font-variant-numeric: tabular-nums;
}
.pace-text {
  color: #71717a;
}
.pace-pill {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pace-pill.under { background: #ecfdf5; color: #15803d; }
.pace-pill.on_track { background: #f4f4f5; color: #3f3f46; }
.pace-pill.over { background: #fef3c7; color: #92400e; }
.pace-pill.critical { background: #fee2e2; color: #991b1b; }
.pace-pill.idle, .pace-pill.ended { background: #f4f4f5; color: #71717a; }
.balance-value {
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 2px 0;
}
.balance-value.exhausted { color: #dc2626; }
.balance-value.warning { color: #d97706; }
.card-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #71717a;
  padding-top: 6px;
  border-top: 1px solid #f4f4f5;
}
.warn-note {
  font-size: 11px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 5px 8px;
}
footer {
  margin-top: 28px;
  font-size: 12px;
  color: #71717a;
}
@media (max-width: 600px) {
  main { margin: 16px auto; padding: 0 12px; }
  .grid { grid-template-columns: 1fr; }
  .balance-grid { grid-template-columns: repeat(2, 1fr); }
}
