/* Spending caps: the per-key monthly limit on /dashboard/keys (.kcap,
   keysCapHTML() in app.js) and the Playground's "Max credits for this
   task" field (.pgmc, setupPgMaxCredits()). Only tokens from app.css, so
   both themes follow the :root[data-theme] swaps. */

/* ---- API keys: per-key spend limit -------------------------------- */

/* The limit sits on its own line under the key's name, dates and Revoke. */
.key-row.kcap-row { flex-wrap: wrap; row-gap: 10px; }
.kcap {
  flex: 1 0 100%;
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid var(--vercel-border);
}
.kcap-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
}
.kcap-text {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 240px;
}
.kcap-fig {
  font-size: 13px;
  color: var(--vercel-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.kcap-fig strong { color: var(--vercel-text); font-weight: 600; }
.kcap-none { color: var(--vercel-text); }
.kcap-dot { margin: 0 6px; color: var(--vercel-disabled); }

/* Bar: brand green, amber from 80%, red at the limit (same as .bud-meter). */
.kcap-bar {
  display: inline-block;
  width: 120px;
  max-width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--vercel-pressed);
  overflow: hidden;
  vertical-align: middle;
}
.kcap-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
  background: var(--emerald);
  transition: width 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.kcap-near .kcap-bar span { background: var(--amber); }
.kcap-full .kcap-bar span { background: var(--red); }
.kcap-warn { flex-basis: 100%; font-size: 12.5px; line-height: 1.5; color: var(--red); }

.kcap-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.kcap-btn { height: 30px; padding: 0 12px; font-size: 12.5px; white-space: nowrap; }
.kcap-link {
  background: none;
  border: none;
  padding: 6px 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--vercel-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
}
.kcap-link:hover { color: var(--red); text-decoration-color: currentColor; }
.kcap-link:disabled { opacity: .5; cursor: default; }
.kcap-link:focus-visible { outline: none; box-shadow: var(--vercel-focus); border-radius: var(--radius-sm); }

/* Inline editor */
.kcap-form { display: flex; flex-direction: column; gap: 8px; }
.kcap-lbl { font: 600 12.5px/1.3 var(--font-sans); color: var(--vercel-text); }
.kcap-form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kcap-input-wrap,
.pgmc-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.kcap-input-wrap { flex: 0 1 240px; min-width: 0; }
.kcap-input {
  width: 100%;
  height: 32px;
  padding: 0 104px 0 10px;
  background: var(--vercel-bg);
  border: 1px solid var(--vercel-border-strong);
  border-radius: var(--radius-sm);
  color: var(--vercel-text);
  font: 13px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.kcap-input::-webkit-outer-spin-button,
.kcap-input::-webkit-inner-spin-button,
.pgmc-input-wrap input::-webkit-outer-spin-button,
.pgmc-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.kcap-input:focus { outline: none; border-color: var(--vercel-text); box-shadow: var(--vercel-focus); }
.kcap-input[aria-invalid="true"],
.pgmc-input-wrap input[aria-invalid="true"] { border-color: var(--red); }
.kcap-unit,
.pgmc-unit {
  position: absolute;
  right: 10px;
  font-size: 12px;
  color: var(--vercel-muted);
  pointer-events: none;
}
.kcap-hint { margin: 0; font-size: 12px; line-height: 1.5; color: var(--vercel-muted); font-variant-numeric: tabular-nums; }
.kcap-err,
.pgmc-err { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--red); }

/* Phones: the key row is a grid (app.css); the limit spans both columns. */
@media (max-width: 640px) {
  .key-row.kcap-row { grid-template-areas: "meta action" "dates dates" "cap cap"; }
  .key-row.kcap-row .kcap { grid-area: cap; }
  .kcap-view { align-items: flex-start; }
  .kcap-text { flex-basis: 100%; }
  .kcap-input-wrap { flex: 1 1 100%; }
  .kcap-form-row .kcap-btn { flex: 1; }
}

/* ---- Playground: Max credits for this task ------------------------ */
.pgmc { display: flex; flex-direction: column; gap: 4px; }
/* The input keeps the shared .pg-field input look; this wrapper only adds
   the unit. Reset the uppercase micro-label style .pg-field > span sets. */
.pg-field > .pgmc-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: min(calc(50% - 6px), 100%);
  text-transform: none;
  letter-spacing: 0;
  font-size: inherit;
  font-weight: 400;
}
.pgmc-input-wrap input { width: 100%; padding-right: 64px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .pg-field > .pgmc-input-wrap { width: 100%; } }
.pgmc-help { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--vercel-muted); }

@media (prefers-reduced-motion: reduce) {
  .kcap-bar span { transition: none; }
}
