:root {
  --bg: #000000;
  --surface: rgba(8, 8, 9, .68);
  --surface-2: rgba(12, 12, 13, .78);
  --surface-3: rgba(255, 255, 255, .035);
  --input: rgba(0, 0, 0, .58);
  --rule: rgba(255, 255, 255, .13);
  --rule-strong: rgba(255, 255, 255, .24);
  --purple: #9F5BFF;
  --cyan: #00F6FF;
  --yellow: #FFD21F;
  --pink: #F6D2FF;
  --danger: #ff5b5b;
  --warn: #ffd21f;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, .78);
  --ink-3: rgba(255, 255, 255, .58);
  --ink-4: rgba(255, 255, 255, .38);
  --glow-purple: 0 0 18px rgba(159, 91, 255, .24);
  --glow-cyan: 0 0 18px rgba(0, 246, 255, .22);
  --mono: "SFMono-Regular", Consolas, "IBM Plex Mono", monospace;
  --display: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  overflow-x: hidden;
  background: #000;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--body);
  background: #030303;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .105) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .105) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: .74;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, .14);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus { outline: none; }
button:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}
button:disabled { cursor: not-allowed; opacity: .48; }
.hidden { display: none !important; }

.sidebar {
  position: sticky;
  inset: 0 0 auto;
  z-index: 20;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 72px;
  padding: 0 40px;
  border-right: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  background:
    linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px),
    rgba(3, 3, 3, .96);
  background-size: 72px 72px;
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 42px;
  box-shadow: none;
}

.brand {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 12px rgba(0, 246, 255, .34));
}

.brand-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .34em;
}

.brand-sub {
  margin-top: 5px;
  color: var(--ink-4);
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
}

nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 4px;
}

.nav-item {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: var(--ink-2);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  transition: border-color .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}

.nav-item:hover:not(:disabled) {
  color: var(--ink);
  border-color: rgba(159, 91, 255, .28);
  background: rgba(255, 255, 255, .035);
}

.nav-item.active {
  color: var(--ink);
  border-color: transparent;
  border-bottom-color: var(--cyan);
  background: transparent;
  box-shadow: none;
}

.nav-item span {
  color: var(--ink-4);
  font-size: 12px;
}

.sidebar-foot {
  margin-left: auto;
  display: grid;
  gap: 10px;
}

.dev-box {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  width: 220px;
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(159, 91, 255, .28);
  border-radius: 0;
  background: rgba(255, 255, 255, .025);
}

label, .section-title {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
}

input, select {
  width: 100%;
  min-height: 44px;
  color: var(--ink);
  background: var(--input);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 0;
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus {
  border-color: rgba(159, 91, 255, .72);
  box-shadow: none;
}

.main {
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 40px 72px;
  position: relative;
  z-index: 1;
}

.topbar {
  min-height: 38px;
  margin-bottom: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.system-line, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
}

.dot, .status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 28px rgba(0, 246, 255, .36);
}

.status-dot.warn {
  background: var(--pink);
  box-shadow: 0 0 16px rgba(246, 210, 255, .55);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 16px rgba(255, 91, 91, .55);
}

.account-chip {
  max-width: 270px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-4);
}

/* Account / auth / refresh controls, right-aligned inside the top nav bar. */
.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
}

.header-controls label { white-space: nowrap; }
.header-controls #userSub { width: 150px; min-height: 40px; }

/* Pre-auth landing: shown to signed-out users instead of the console. */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-gate-card {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 44px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(3, 3, 3, .92);
  backdrop-filter: blur(14px);
}

.auth-gate-card .brand-logo { width: 46px; height: 46px; }
.auth-gate-card h1 { margin: 6px 0 0; font-size: 46px; line-height: 1.02; }
.auth-gate-card p { margin: 0; color: var(--ink-3); max-width: 42ch; }
.gate-signin { margin-top: 14px; min-height: 44px; }

.btn {
  min-height: 40px;
  padding: 0 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 0;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.btn:hover:not(:disabled) {
  transform: none;
  border-color: rgba(0, 246, 255, .42);
  background: rgba(0, 240, 255, .05);
  box-shadow: none;
}

.btn.primary {
  color: var(--ink);
  font-weight: 700;
  border-color: rgba(159, 91, 255, .78);
  background: rgba(159, 91, 255, .08);
  box-shadow: none;
}

.btn.primary:hover:not(:disabled) {
  color: var(--cyan);
  border-color: rgba(0, 246, 255, .58);
  background: rgba(0, 246, 255, .055);
}

.btn.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 0;
}

.btn.block { width: 100%; }

.btn.danger-action {
  color: #ffd6d6;
  border-color: rgba(255, 91, 91, .42);
  background: rgba(255, 91, 91, .08);
}

.btn.danger-action:hover:not(:disabled) {
  border-color: rgba(255, 91, 91, .72);
  background: rgba(255, 91, 91, .14);
  box-shadow: none;
}

.banner {
  margin-bottom: 18px;
  padding: 13px 15px;
  color: var(--ink);
  border: 1px solid rgba(255, 210, 31, .5);
  border-left: 3px solid var(--warn);
  border-radius: 0;
  background: rgba(255, 210, 31, .1);
}

.banner.danger {
  border-color: rgba(255, 91, 91, .52);
  background: rgba(255, 91, 91, .1);
}

.banner.ok {
  border-color: rgba(0, 246, 255, .42);
  background: rgba(0, 246, 255, .08);
}

.page {
  max-width: none;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  margin-bottom: 28px;
}

.page-head > .btn {
  flex: 0 0 auto;
  margin-top: 12px;
}

.hero-head { align-items: stretch; }
h1, h2, h3, p { margin: 0; }

h1 {
  margin-top: 10px;
  font-family: var(--display);
  font-size: clamp(44px, 5vw, 68px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 650;
}

h1 span {
  color: var(--ink);
  background: none;
  background-clip: border-box;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  filter: none;
}

.page-head p {
  max-width: 660px;
  margin-top: 16px;
  color: var(--ink-3);
  font-size: 17px;
  line-height: 1.55;
}

h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
}

.live-card, .metric-card, .panel, .meter-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 0;
  background: rgba(3, 3, 3, .78);
  box-shadow: none;
}

.live-card::before, .metric-card::before, .panel::before, .meter-card::before {
  content: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: none;
}

.live-card > *, .metric-card > *, .panel > *, .meter-card > * {
  position: relative;
  z-index: 1;
}

.live-card {
  min-width: 270px;
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 9px;
}

.live-card > span, .metric-card > span, .panel-code {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.panel-code { color: var(--cyan); }

.live-card strong {
  color: var(--cyan);
  font-size: 30px;
  font-weight: 650;
  text-transform: capitalize;
  text-shadow: none;
}

.live-card strong.danger { color: var(--danger); text-shadow: none; }
.live-card strong.warn { color: var(--yellow); text-shadow: none; }
.live-card small, .metric-card small, .hint, .compact-key small, td small { color: var(--ink-4); }

.console-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 136px;
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 9px;
}

.metric-card strong {
  font-family: var(--display);
  font-size: 38px;
  line-height: 1;
  font-weight: 650;
  color: var(--cyan);
}

.balance-card strong {
  color: var(--yellow);
  text-shadow: none;
}

.console-grid .metric-card:nth-child(1) {
  border-color: rgba(255, 210, 31, .36);
}

.console-grid .metric-card:nth-child(2) {
  border-color: rgba(0, 246, 255, .3);
}

.console-grid .metric-card:nth-child(3) {
  border-color: rgba(159, 91, 255, .3);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 26px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.topup-form {
  display: grid;
  grid-template-columns: minmax(140px, .7fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
}

.topup-form .btn.primary {
  grid-column: 1 / -1;
  justify-self: end;
  min-width: 156px;
  white-space: nowrap;
}

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 8px;
}

.quick-amounts button {
  min-height: 44px;
  color: var(--cyan);
  background: rgba(0, 240, 255, .035);
  border: 1px solid rgba(0, 246, 255, .26);
  border-radius: 0;
}

.quick-amounts button:hover {
  color: var(--yellow);
  border-color: rgba(255, 210, 31, .42);
  background: rgba(255, 210, 31, .055);
  box-shadow: none;
}

.topup-panel {
  border-color: rgba(255, 210, 31, .42);
}

.hint {
  margin-top: 13px;
  font-size: 13px;
}

.state-list {
  display: grid;
  gap: 15px;
}

.state-list div {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 5px 11px;
  align-items: center;
}

.state-list small {
  grid-column: 2;
  color: var(--ink-3);
}

.compact-key-list {
  display: grid;
  gap: 9px;
}

.compact-key {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 0;
  background: rgba(255, 255, 255, .035);
}

.created-key {
  display: grid;
  grid-template-columns: minmax(250px, .72fr) minmax(0, 1.28fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(0, 246, 255, .38);
  border-radius: 0;
  background: rgba(0, 240, 255, .035);
  box-shadow: none;
}

.created-key > div:first-child {
  display: grid;
  gap: 7px;
}

.created-key > div:first-child strong,
.created-key > div:first-child small {
  display: block;
}

.created-key-value {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.created-key code, .created-key-endpoint code, .curl-example {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: auto;
  color: var(--cyan);
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 0;
  padding: 12px;
  font-family: var(--mono);
  font-size: 13px;
}

.created-key-endpoint {
  grid-column: 2;
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
}

.created-key-endpoint span {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.curl-example {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.key-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.35fr) minmax(150px, .72fr) minmax(120px, .55fr) minmax(120px, .55fr);
  gap: 12px;
  align-items: end;
}

.key-form label {
  display: grid;
  gap: 7px;
}

.key-form .btn {
  grid-column: 1 / -1;
  justify-self: end;
  min-width: 128px;
}

.model-picker {
  min-height: 44px;
  max-height: 88px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 0;
  background: rgba(0, 0, 0, .42);
  padding: 7px 8px;
}

.model-picker.compact {
  min-width: 160px;
  max-width: 240px;
  max-height: 72px;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.model-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.model-chip span, .chip-row span {
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--cyan);
  background: rgba(0, 240, 255, .035);
  border: 1px solid rgba(0, 246, 255, .26);
  border-radius: 0;
  font-size: 13px;
}

.model-chip input:checked + span {
  color: var(--yellow);
  background: rgba(255, 210, 31, .06);
  border-color: rgba(255, 210, 31, .46);
  box-shadow: none;
}

.table-wrap { overflow: auto; }

.keys-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

.key-col-name { width: 17%; }
.key-col-status { width: 13%; }
.key-col-models { width: 17%; }
.key-col-usage { width: 15%; }
.key-col-cap { width: 11%; }
.key-col-rate { width: 9%; }
.key-col-actions { width: 150px; }

th, td {
  padding: 13px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
}

td { color: var(--ink-2); }
td:nth-child(5) { white-space: nowrap; }
td strong {
  display: block;
  color: var(--ink);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 220px;
}

.usage-cell {
  display: grid;
  gap: 5px;
  min-width: 110px;
}

.mini-bar, .bar {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 0;
  background: rgba(255, 255, 255, .06);
}

.mini-bar i, .bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
}

.bar {
  height: 10px;
  margin: 16px 0 10px;
}

.bar.warn i { background: var(--yellow); }
.bar.danger i { background: var(--danger); }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-width: 142px;
  white-space: nowrap;
}

.row-actions .btn.small {
  min-width: 62px;
  text-align: center;
}

.editing-row td {
  background: rgba(159, 91, 255, .06);
}

.editing-row input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
}

.pill {
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.pill.ok {
  color: var(--cyan);
  border-color: rgba(0, 246, 255, .38);
  background: rgba(0, 246, 255, .08);
}

.pill.danger {
  color: #ffd7d7;
  border-color: rgba(255, 91, 91, .42);
  background: rgba(255, 91, 91, .09);
}

.meters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.usage-meters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meter-card {
  min-height: 196px;
  padding: 24px;
}

.meter-value {
  margin-top: 20px;
  font-family: var(--display);
  font-size: 44px;
  font-weight: 650;
}

.meter-value span {
  color: var(--yellow);
}

.meter-card:nth-child(2) .meter-value span {
  color: var(--cyan);
}

.meter-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-4);
  font-size: 13px;
}

.usage-stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  padding-top: 12px;
  color: var(--ink-4);
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-family: var(--mono);
  font-size: 12px;
}

.usage-stat-line span:first-child {
  color: var(--cyan);
}

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

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 0;
  background: rgba(255, 255, 255, .03);
}

.empty-row {
  min-height: 76px;
  display: grid;
  place-items: center;
  color: var(--ink-4);
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 0;
  background: rgba(0, 0, 0, .16);
}

@keyframes glow-line-move {
  0% { background-position: 0% 0; }
  100% { background-position: 220% 0; }
}

@media (max-width: 980px) {
  .sidebar {
    position: sticky;
    min-height: auto;
    padding: 14px 16px 0;
    flex-wrap: wrap;
    gap: 12px 18px;
    border-bottom: 1px solid rgba(159, 91, 255, .22);
  }

  .brand {
    min-height: 44px;
  }

  .sidebar nav {
    order: 3;
    width: calc(100% + 32px);
    min-height: 46px;
    margin: 0 -16px;
    padding: 0 8px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
  }

  .nav-item {
    min-height: 46px;
    justify-content: center;
    padding: 0 8px;
  }

  .nav-item.disabled { display: none; }

  .sidebar-foot {
    margin-left: auto;
  }

  .main {
    margin-left: 0;
    padding: 22px 16px 40px;
  }

  .topbar, .page-head, .split {
    display: grid;
    grid-template-columns: 1fr;
  }

  .console-grid, .meters, .key-form {
    grid-template-columns: 1fr;
  }

  .created-key, .created-key-endpoint {
    grid-template-columns: 1fr;
  }

  .created-key-endpoint, .curl-example {
    grid-column: auto;
  }

  .topup-form {
    grid-template-columns: 1fr;
  }

  .topup-form .btn.primary {
    justify-self: stretch;
  }
}

@media (max-width: 620px) {
  .brand-name { font-size: 11px; }
  .brand-sub { font-size: 9px; }
  .brand-logo { width: 34px; height: 34px; }
  .topbar { margin-bottom: 28px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .account-chip { max-width: 180px; }
  h1 { font-size: 42px; }
  .page-head p { font-size: 16px; }
  .quick-amounts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 20px; }
}
