.header-actions {
  gap: 10px;
}

.auth-widget {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
}

.auth-open {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(237, 242, 248, 0.14);
  cursor: pointer;
  font: 800 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-open:hover {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.18);
}

.auth-widget.is-signed-in .auth-open {
  display: none;
}

.auth-widget:not(.is-signed-in) .account-surface {
  display: none;
}

.account-surface,
.panel-account-surface {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.billing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(237, 242, 248, 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 6px 18px rgba(0, 0, 0, 0.14);
  cursor: pointer;
  font: 600 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.billing-toggle strong {
  min-width: 24px;
  color: rgba(255, 255, 255, 0.98);
  font-size: 15px;
  text-align: right;
}

.billing-toggle:hover {
  border-color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.18);
}

.billing-panel {
  --ui-position: fixed;
  --ui-top: max(92px, calc(env(safe-area-inset-top) + 76px));
  --ui-right: max(18px, env(safe-area-inset-right));
  --ui-z-index: 11;

  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.billing-panel.is-collapsed {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.985);
}

.billing-shell {
  --ui-width: min(372px, calc(100vw - 36px));
  --ui-radius: 30px;

  display: grid;
  gap: 14px;
  padding: 18px;
  color: rgba(255, 255, 255, 0.92);
}

.billing-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.billing-eyebrow,
.billing-note,
.billing-status {
  margin: 0;
}

.billing-eyebrow {
  color: rgba(221, 232, 245, 0.58);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.billing-heading h2 {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.98);
  font-size: 22px;
  line-height: 1.05;
}

.billing-refresh {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font: 700 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.billing-balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06)),
    rgba(12, 18, 28, 0.18);
}

.billing-balance-card span {
  color: rgba(234, 241, 249, 0.7);
  font-size: 13px;
}

.billing-balance-card strong {
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.billing-status {
  min-height: 36px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  color: rgba(235, 242, 250, 0.74);
  background: rgba(5, 10, 18, 0.18);
  font-size: 12px;
  line-height: 1.35;
}

.billing-status[data-tone="success"] {
  border-color: rgba(120, 255, 203, 0.22);
  color: rgba(201, 255, 234, 0.9);
  background: rgba(12, 85, 63, 0.22);
}

.billing-status[data-tone="warning"] {
  border-color: rgba(255, 218, 126, 0.24);
  color: rgba(255, 236, 180, 0.92);
  background: rgba(106, 74, 8, 0.22);
}

.billing-status[data-tone="error"] {
  border-color: rgba(255, 136, 136, 0.24);
  color: rgba(255, 204, 204, 0.94);
  background: rgba(111, 22, 34, 0.25);
}

.billing-auth-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}

.billing-auth-copy {
  display: grid;
  gap: 4px;
}

.billing-auth-copy span,
.api-key-heading span {
  color: rgba(229, 238, 248, 0.62);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.billing-auth-copy p,
.api-key-heading p {
  margin: 0;
  color: rgba(235, 242, 250, 0.7);
  font-size: 12px;
  line-height: 1.35;
}

.customer-auth-mount {
  overflow: hidden;
  border-radius: 18px;
}

.customer-auth-mount:empty,
.panel-account-surface:empty {
  display: none;
}

.customer-auth-shell {
  display: grid;
  gap: 10px;
}

.customer-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(5, 10, 18, 0.15);
}

.customer-auth-tab,
.customer-auth-link {
  border: 0;
  color: rgba(236, 244, 252, 0.72);
  background: transparent;
  cursor: pointer;
  font: 800 11px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.customer-auth-tab {
  min-height: 30px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.customer-auth-tab.is-active {
  color: rgba(255, 255, 255, 0.96);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08)),
    rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.customer-auth-intro,
.customer-auth-small,
.customer-auth-message {
  margin: 0;
  color: rgba(235, 242, 250, 0.7);
  font-size: 12px;
  line-height: 1.35;
}

.customer-auth-message {
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.07);
}

.customer-auth-message[data-tone="success"] {
  border-color: rgba(120, 255, 203, 0.22);
  color: rgba(201, 255, 234, 0.92);
  background: rgba(12, 85, 63, 0.22);
}

.customer-auth-message[data-tone="warning"] {
  border-color: rgba(255, 218, 126, 0.24);
  color: rgba(255, 236, 180, 0.92);
  background: rgba(106, 74, 8, 0.22);
}

.customer-auth-message[data-tone="error"] {
  border-color: rgba(255, 136, 136, 0.24);
  color: rgba(255, 204, 204, 0.94);
  background: rgba(111, 22, 34, 0.25);
}

.customer-auth-providers,
.customer-auth-form {
  display: grid;
  gap: 8px;
}

.customer-auth-provider,
.customer-auth-primary,
.customer-auth-secondary {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.93);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  font: 850 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.customer-auth-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.customer-auth-provider span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: rgba(15, 22, 32, 0.9);
  background: rgba(255, 255, 255, 0.88);
  font-size: 12px;
}

.customer-auth-primary {
  border-color: rgba(120, 255, 203, 0.28);
  background:
    linear-gradient(135deg, rgba(65, 255, 193, 0.22), rgba(106, 151, 255, 0.14)),
    rgba(255, 255, 255, 0.1);
}

.customer-auth-provider:disabled,
.customer-auth-primary:disabled,
.customer-auth-secondary:disabled,
.customer-auth-link:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.customer-auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  color: rgba(235, 242, 250, 0.44);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.customer-auth-divider::before,
.customer-auth-divider::after {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  content: "";
}

.customer-auth-form label {
  display: grid;
  gap: 5px;
  color: rgba(229, 238, 248, 0.62);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.customer-auth-form input {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 15px;
  outline: none;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(0, 0, 0, 0.18);
  font: 700 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.customer-auth-form input:focus {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(0, 0, 0, 0.24);
}

.customer-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.customer-auth-link {
  padding: 0;
  color: rgba(201, 226, 255, 0.86);
}

.account-chip {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.96);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.32), transparent 36%),
    linear-gradient(135deg, rgba(65, 255, 193, 0.34), rgba(106, 151, 255, 0.2)),
    rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font: 900 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.customer-account-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.customer-account-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.96);
  background: linear-gradient(135deg, rgba(65, 255, 193, 0.34), rgba(106, 151, 255, 0.26));
  font: 900 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.customer-account-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.customer-account-copy strong,
.customer-account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-account-copy strong {
  color: rgba(255, 255, 255, 0.95);
  font-size: 12px;
}

.customer-account-copy span {
  color: rgba(235, 242, 250, 0.58);
  font-size: 11px;
}

.billing-dev-controls {
  display: grid;
  gap: 8px;
}

.billing-dev-controls[hidden],
.billing-auth-card[hidden],
.api-key-card[hidden] {
  display: none;
}

.billing-dev-warning {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 218, 126, 0.22);
  border-radius: 15px;
  color: rgba(255, 236, 180, 0.88);
  background: rgba(106, 74, 8, 0.18);
  font-size: 11px;
  line-height: 1.35;
}

.billing-dev-warning code {
  color: rgba(255, 255, 255, 0.96);
}

.billing-account-form {
  display: grid;
  gap: 8px;
  margin: 0;
}

.billing-dev-controls label {
  display: grid;
  gap: 5px;
  color: rgba(229, 238, 248, 0.62);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.billing-dev-controls input {
  width: 100%;
  min-height: 35px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  outline: none;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.18);
  font: 500 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.billing-dev-controls input:focus {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(0, 0, 0, 0.24);
}

.billing-account-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.billing-login,
.billing-logout,
.api-key-create,
.api-key-revoke,
.api-key-copy {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font: 800 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.billing-login {
  border-color: rgba(120, 255, 203, 0.28);
  background:
    linear-gradient(135deg, rgba(65, 255, 193, 0.22), rgba(106, 151, 255, 0.14)),
    rgba(255, 255, 255, 0.1);
}

.billing-login:hover,
.billing-logout:hover,
.api-key-create:hover,
.api-key-revoke:hover,
.api-key-copy:hover {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.18);
}

.billing-account-card,
.billing-log {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.billing-account-card span,
.billing-log span {
  color: rgba(229, 238, 248, 0.62);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.billing-account-card code {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.86);
  font: 600 11px/1.25 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.billing-log p {
  margin: 0;
  color: rgba(235, 242, 250, 0.74);
  font-size: 12px;
  line-height: 1.35;
}

.credit-pack-list {
  display: grid;
  gap: 9px;
}

.credit-pack-card,
.credit-pack-empty {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
}

.credit-pack-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  text-align: left;
}

.credit-pack-card:not(:disabled):hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.15);
}

.credit-pack-card:disabled {
  cursor: wait;
  opacity: 0.72;
}

.credit-pack-name {
  min-width: 0;
  overflow: hidden;
  color: rgba(231, 240, 251, 0.7);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-pack-credits {
  grid-column: 1;
  color: #fff;
  font-size: 18px;
  line-height: 1.05;
}

.credit-pack-price {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 800;
}

.credit-pack-empty {
  padding: 14px;
  color: rgba(232, 240, 250, 0.64);
  font-size: 13px;
}

.api-key-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}

.api-key-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.api-key-create {
  flex: 0 0 auto;
  border-color: rgba(120, 255, 203, 0.24);
  background:
    linear-gradient(135deg, rgba(65, 255, 193, 0.2), rgba(106, 151, 255, 0.12)),
    rgba(255, 255, 255, 0.1);
}

.api-key-create:disabled,
.api-key-revoke:disabled,
.api-key-copy:disabled {
  cursor: wait;
  opacity: 0.62;
}

.api-key-secret {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(120, 255, 203, 0.22);
  border-radius: 16px;
  background: rgba(12, 85, 63, 0.18);
}

.api-key-secret strong {
  color: rgba(201, 255, 234, 0.94);
  font-size: 12px;
}

.api-key-secret code {
  overflow-wrap: anywhere;
  color: rgba(255, 255, 255, 0.94);
  font: 700 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.api-key-secret-actions {
  display: flex;
  gap: 8px;
}

.api-key-list {
  display: grid;
  gap: 8px;
}

.api-key-row,
.api-key-empty {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.12);
}

.api-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  padding: 10px;
}

.api-key-row strong {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-key-row code,
.api-key-row time {
  color: rgba(232, 240, 250, 0.64);
  font: 600 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.api-key-revoke {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  min-height: 32px;
  color: rgba(255, 218, 218, 0.95);
  background: rgba(111, 22, 34, 0.16);
}

.api-key-empty {
  padding: 10px;
  color: rgba(232, 240, 250, 0.62);
  font-size: 12px;
}

.billing-note {
  color: rgba(232, 240, 250, 0.56);
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 520px) {
  .billing-toggle {
    min-height: 38px;
    padding: 0 11px;
    font-size: 12px;
  }

  .billing-toggle span {
    display: none;
  }

  .billing-panel {
    --ui-top: max(82px, calc(env(safe-area-inset-top) + 70px));
    --ui-right: max(12px, env(safe-area-inset-right));
    --ui-left: max(12px, env(safe-area-inset-left));
  }

  .billing-shell {
    --ui-width: 100%;
    --ui-radius: 26px;

    gap: 12px;
    padding: 14px;
  }

  .billing-heading h2 {
    font-size: 20px;
  }
}
