@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/usage/fonts/space-grotesk-latin.woff2?v=20260713-2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/usage/fonts/jetbrains-mono-latin.woff2?v=20260713-2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0a0c0f;
  --surface: #111419;
  --surface-raised: #15191e;
  --line: rgba(242, 240, 232, 0.11);
  --line-strong: rgba(242, 240, 232, 0.2);
  --text: #f2f0e8;
  --muted: #9da59f;
  --faint: #7c857f;
  --accent: #b7ee68;
  --accent-soft: rgba(183, 238, 104, 0.12);
  --ok: #79d9a2;
  --warn: #efbd68;
  --bad: #f47b73;
  --font-display: "Space Grotesk", "Segoe UI Variable Display", "Aptos Display", "Segoe UI", sans-serif;
  --font-body: "Segoe UI Variable Text", "Aptos", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -8%, rgba(183, 238, 104, 0.08), transparent 34rem),
    radial-gradient(circle at 92% 5%, rgba(242, 240, 232, 0.045), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(242, 240, 232, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 240, 232, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--accent);
  color: #10140d;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.wrap {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(calc(100% - 48px), 1380px);
  min-height: 100dvh;
  margin-inline: auto;
  flex-direction: column;
  padding: 30px 0 22px;
}

.topbar {
  margin-bottom: 16px;
}

.masthead-line,
.masthead-primary,
.actions,
.footer,
.provider-lockup,
.card-head,
.window-line,
.window-meta,
.unmetered-main,
.unmetered-meta,
.model-group-head,
.model-row,
.health-row {
  display: flex;
  align-items: center;
}

.masthead-line {
  justify-content: space-between;
  gap: 20px;
}

.masthead-primary {
  min-width: max-content;
  gap: 18px;
}

.brand {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.system-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.system-label::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  content: "";
}

.actions {
  min-width: max-content;
  justify-content: flex-end;
  gap: 14px;
}

.pill {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--accent);
  border-radius: 10px 2px 10px 2px;
  background: var(--accent);
  color: #11150d;
  cursor: pointer;
  padding: 10px 16px;
  font: 700 0.82rem/1 var(--font-body);
  transition:
    transform 220ms var(--ease-out),
    background-color 220ms ease,
    box-shadow 220ms ease;
}

.btn:hover {
  transform: translateY(-2px);
  background: #c7f77a;
  box-shadow: 0 10px 28px rgba(183, 238, 104, 0.12);
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.68;
}

.refresh-icon {
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1;
}

.btn:disabled .refresh-icon {
  animation: spin 800ms linear infinite;
}

.meter-key {
  margin: 12px 0 0;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.error,
.notice {
  display: none;
  margin: 0 0 18px;
  border-left: 2px solid var(--bad);
  background: rgba(244, 123, 115, 0.08);
  color: #ffd8d4;
  padding: 13px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.notice {
  border-left-color: var(--warn);
  background: rgba(239, 189, 104, 0.08);
  color: #f9dfb4;
}

.provider-region {
  flex: 0 0 auto;
}

.grid-message {
  column-span: all;
  margin: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 28px 0;
}

.grid {
  columns: 2;
  column-gap: 10px;
}

.card {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 0;
  margin: 0 0 10px;
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid var(--line);
  border-radius: 24px 6px 24px 6px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  padding: clamp(20px, 2.2vw, 28px);
  animation: card-in 520ms var(--ease-out) both;
  animation-delay: var(--delay, 0ms);
  transition:
    transform 260ms var(--ease-out),
    border-color 260ms ease,
    background-color 260ms ease;
}

.card::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 100% 0%, rgba(183, 238, 104, 0.08), transparent 34%);
  content: "";
  opacity: 0;
  transition: opacity 260ms ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(183, 238, 104, 0.3);
  background-color: var(--surface-raised);
}

.card:hover::before {
  opacity: 1;
}

.card-head {
  position: relative;
  z-index: 1;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.provider-lockup {
  min-width: 0;
  align-items: flex-start;
  gap: 13px;
}

.provider-code {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px 2px 9px 2px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.provider {
  margin: -2px 0 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.1vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.meta {
  max-width: 42ch;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mini-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.state-live {
  color: var(--ok);
}

.state-cached {
  color: var(--warn);
}

.state-down {
  color: var(--bad);
}

.window-list {
  position: relative;
  z-index: 1;
  display: grid;
  border-top: 1px solid var(--line);
}

.unmetered-list,
.model-groups {
  margin-top: 0;
}

.usage-window,
.unmetered-row,
.model-group {
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 16px 0 17px;
}

.usage-window:last-child,
.unmetered-row:last-child,
.model-group:last-child {
  border-bottom-color: transparent;
}

.window-line,
.unmetered-main,
.model-group-head,
.model-row {
  justify-content: space-between;
  gap: 12px;
}

.usage-label {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-value {
  flex: 0 0 auto;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.window-meter {
  --used: 0%;
  --time: 0%;
  position: relative;
  width: 100%;
  height: 5px;
  margin-top: 13px;
  overflow: visible;
  border-radius: 2px;
  background: rgba(242, 240, 232, 0.08);
}

.meter-used {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--used);
  border-radius: inherit;
  background: var(--ok);
  transform-origin: left center;
  animation: meter-in 720ms var(--ease-out) both;
}

.usage-window.warn .meter-used {
  background: var(--warn);
}

.usage-window.bad .meter-used {
  background: var(--bad);
}

.time-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: var(--time);
  width: 1px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--surface);
}

.window-meta,
.unmetered-meta {
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.window-meta > :last-child,
.unmetered-meta > :last-child {
  text-align: right;
}

.unmetered-list,
.model-groups {
  display: grid;
}

.model-group {
  padding: 0;
}

.model-group-head {
  padding: 15px 0 11px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.model-count {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.model-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.model-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-usage {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.model-reset {
  margin-left: 8px;
  color: var(--faint);
  font-weight: 500;
}

.unavailable {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding-top: 18px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.health-list {
  position: relative;
  z-index: 1;
  display: grid;
  margin-top: 16px;
}

.health-row {
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 0;
  font-size: 0.72rem;
}

.health-label {
  color: var(--text);
  font-weight: 600;
}

.loading-card {
  min-height: 250px;
}

.skeleton {
  overflow: hidden;
  border-radius: 2px;
  background: rgba(242, 240, 232, 0.07);
}

.skeleton::after {
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(242, 240, 232, 0.1), transparent);
  content: "";
  transform: translateX(-120%);
  animation: shimmer 1.25s ease-in-out infinite;
}

.skeleton-title {
  width: 34%;
  height: 24px;
}

.skeleton-meta {
  width: 52%;
  height: 10px;
  margin-top: 10px;
}

.skeleton-row {
  height: 72px;
  margin-top: 20px;
}

.footer {
  justify-content: flex-end;
  gap: 20px;
  margin-top: 0;
  padding-top: 24px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer a {
  text-decoration-color: rgba(242, 240, 232, 0.25);
  text-underline-offset: 4px;
}

.footer a:hover {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

time {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes meter-in {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(300%);
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (min-width: 2200px) {
  html {
    font-size: 17px;
  }

  .wrap {
    width: min(calc(100% - 96px), 3040px);
    padding-top: 32px;
  }

  .grid {
    column-gap: 14px;
  }

  .card {
    margin-bottom: 14px;
  }

  .window-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    column-gap: 28px;
  }

  .usage-window:nth-child(even) {
    border-left: 1px solid var(--line);
    padding-left: 28px;
  }

  .window-meta {
    gap: 20px;
  }
}

@media (max-width: 960px) {
  .wrap {
    width: min(calc(100% - 32px), 760px);
  }

  .grid {
    columns: 1;
  }

  .actions {
    min-width: 0;
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  body::before {
    background-size: 48px 48px;
  }

  .wrap {
    width: min(calc(100% - 24px), 560px);
    padding-top: 18px;
  }

  .masthead-line {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .masthead-primary,
  .actions {
    width: 100%;
    justify-content: space-between;
  }

  .actions {
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }

  .card {
    border-radius: 20px 5px 20px 5px;
    padding: 18px;
  }

  .card:hover {
    transform: none;
  }

  .provider {
    font-size: 1.35rem;
  }

  .meta {
    white-space: normal;
  }

  .window-meta,
  .unmetered-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .window-meta > :last-child,
  .unmetered-meta > :last-child {
    text-align: left;
  }

  .model-row {
    align-items: flex-start;
  }

  .model-usage {
    max-width: 58%;
    line-height: 1.45;
    text-align: right;
    white-space: normal;
  }

  .model-reset {
    display: block;
    margin-top: 3px;
    margin-left: 0;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
