:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  --bg: #090d14;
  --panel: #111722;
  --panel-soft: #151d2a;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #8e9bad;
  --good: #5de2a5;
  --warn: #ffc65a;
  --danger: #ff707b;
  --accent: #8ca8ff;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(74, 104, 180, 0.22), transparent 38%),
    var(--bg);
}

.login-page {
  display: grid;
  min-height: 100svh;
  place-items: center;
}

.login-shell {
  width: min(100%, 430px);
  padding: max(24px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.login-brand {
  margin-bottom: 24px;
  text-align: center;
}

.login-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(21, 29, 42, 0.98), rgba(14, 20, 30, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-card h2 {
  margin-bottom: 8px;
}

.login-copy {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-card form,
.login-card label {
  display: grid;
}

.login-card label {
  margin-bottom: 8px;
  color: #cbd4e1;
  font-size: 0.82rem;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: rgba(7, 11, 18, 0.72);
}

.login-card input:focus {
  border-color: rgba(140, 168, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(140, 168, 255, 0.12);
}

.login-card button {
  min-height: 48px;
  border: 1px solid rgba(140, 168, 255, 0.35);
  border-radius: 14px;
  color: #f7f9ff;
  background: linear-gradient(135deg, #4768c8, #344e9f);
  cursor: pointer;
  font-weight: 750;
}

.login-card button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.login-error {
  min-height: 21px;
  margin: 8px 0 10px;
  color: #ff9ca5;
  font-size: 0.78rem;
}

button,
input {
  font: inherit;
}

.dashboard {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(30px, env(safe-area-inset-bottom));
}

.hero,
.card-heading,
.dashboard-footer,
.credits-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero {
  padding: 4px 2px 22px;
}

.eyebrow,
.card-kicker,
.detail-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 7vw, 2rem);
  letter-spacing: -0.04em;
}

h1 span {
  color: var(--muted);
  font-weight: 500;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 12px rgba(93, 226, 165, 0.72);
}

.status-message {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin-bottom: 12px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #b7c3d3;
  background: rgba(21, 29, 42, 0.78);
  font-size: 0.82rem;
}

.status-icon {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.status-message.is-loading .status-icon {
  animation: pulse 1.1s infinite ease-in-out;
}

.status-message.is-success .status-icon {
  background: var(--good);
}

.status-message.is-warning {
  color: #ffe0a1;
  border-color: rgba(255, 198, 90, 0.24);
  background: rgba(85, 58, 12, 0.22);
}

.status-message.is-warning .status-icon,
.status-message.is-error .status-icon {
  background: var(--warn);
}

.usage-card,
.credits-card,
.other-usage,
.fatal-state {
  position: relative;
  margin-bottom: 12px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(21, 29, 42, 0.96), rgba(14, 20, 30, 0.98));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.16);
}

.usage-card::after {
  position: absolute;
  top: -90px;
  right: -90px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: var(--health-color, var(--accent));
  content: "";
  filter: blur(72px);
  opacity: 0.1;
  pointer-events: none;
}

.usage-card.health-good {
  --health-color: var(--good);
}

.usage-card.health-warning {
  --health-color: var(--warn);
}

.usage-card.health-danger {
  --health-color: var(--danger);
}

.card-heading h2,
.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.health-label {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.health-good .health-label {
  color: var(--good);
  border-color: rgba(93, 226, 165, 0.24);
  background: rgba(93, 226, 165, 0.08);
}

.health-warning .health-label {
  color: var(--warn);
  border-color: rgba(255, 198, 90, 0.24);
  background: rgba(255, 198, 90, 0.08);
}

.health-danger .health-label {
  color: var(--danger);
  border-color: rgba(255, 112, 123, 0.24);
  background: rgba(255, 112, 123, 0.08);
}

.metric-row {
  display: flex;
  align-items: flex-end;
  gap: 11px;
  margin: 23px 0 14px;
}

.metric-value {
  font-size: clamp(3.4rem, 17vw, 4.9rem);
  font-weight: 760;
  line-height: 0.78;
  letter-spacing: -0.075em;
}

.metric-value small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.32em;
  letter-spacing: -0.02em;
}

.metric-caption {
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.progress-fill {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--health-color, var(--accent));
  box-shadow: 0 0 18px color-mix(in srgb, var(--health-color, var(--accent)) 38%, transparent);
  transition: width 420ms ease;
}

.usage-detail {
  display: flex;
  justify-content: space-between;
  padding: 10px 1px 18px;
  color: var(--muted);
  font-size: 0.78rem;
}

.usage-detail strong {
  color: #cdd6e3;
}

.reset-block {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.reset-block .detail-label {
  grid-column: 1 / -1;
  margin: 0;
}

.reset-block strong {
  min-width: 0;
  font-size: 0.92rem;
}

.countdown {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.credits-card {
  min-height: 94px;
}

.credits-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.credits-card h2 span {
  font-size: 2rem;
}

.credits-badge {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.credits-badge span:first-child {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--accent);
  font-size: 1rem;
}

.section-heading {
  margin-bottom: 12px;
}

.unknown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.unknown-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.fatal-state {
  display: grid;
  gap: 6px;
  color: #ffd0d4;
  border-color: rgba(255, 112, 123, 0.24);
  background: rgba(80, 20, 29, 0.24);
}

.fatal-state[hidden],
.other-usage[hidden] {
  display: none;
}

.fatal-state span {
  color: #cba3aa;
  font-size: 0.8rem;
  line-height: 1.5;
}

.dashboard-footer {
  align-items: flex-end;
  padding: 10px 2px 0;
}

.updated-block {
  display: grid;
  gap: 2px;
}

.updated-block .detail-label {
  margin: 0;
}

.updated-block strong {
  font-size: 0.88rem;
}

.updated-block > span:last-child {
  color: var(--muted);
  font-size: 0.7rem;
}

#refresh-button {
  min-width: 142px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(140, 168, 255, 0.35);
  border-radius: 14px;
  color: #f7f9ff;
  background: linear-gradient(135deg, #4768c8, #344e9f);
  box-shadow: 0 9px 24px rgba(47, 74, 154, 0.28);
  cursor: pointer;
  font-weight: 700;
}

#refresh-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.refresh-icon {
  display: inline-block;
  margin-right: 5px;
  font-size: 1.1rem;
}

#refresh-button.is-spinning .refresh-icon {
  animation: spin 0.9s infinite linear;
}

.logout-button {
  display: block;
  min-height: 44px;
  margin: 20px auto 0;
  padding: 0 14px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
}

.logout-button:hover,
.logout-button:focus-visible {
  color: var(--text);
}

.usage-card.is-loading .metric-value,
.usage-card.is-loading .progress-track,
.usage-card.is-loading .reset-block strong {
  color: transparent;
  background: linear-gradient(90deg, #1a2331 25%, #243044 50%, #1a2331 75%);
  background-size: 200% 100%;
  animation: shimmer 1.45s infinite linear;
}

.usage-card.is-loading .metric-value {
  border-radius: 10px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.72);
  }
}

@media (max-width: 370px) {
  .dashboard {
    padding-right: 12px;
    padding-left: 12px;
  }

  .usage-card,
  .credits-card,
  .other-usage,
  .fatal-state {
    padding: 17px;
    border-radius: 18px;
  }

  .dashboard-footer {
    align-items: stretch;
    flex-direction: column;
  }

  #refresh-button {
    width: 100%;
  }
}

@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;
  }
}
