:root {
  color-scheme: dark;
  --bg: #070912;
  --panel: rgba(16, 21, 38, 0.7);
  --panel-strong: rgba(22, 30, 56, 0.86);
  --text: #f5f7fb;
  --muted: #a6b0c3;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #35c8ff;
  --accent-2: #8f5cff;
  --accent-3: #4dffb5;
  --danger: #ff5c8a;
  --success: #4dffb5;
  --warning: #ffd166;
  --code: rgba(255, 255, 255, 0.07);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 12%, rgba(53, 200, 255, 0.17), transparent 30%),
    radial-gradient(circle at 84% 8%, rgba(143, 92, 255, 0.2), transparent 28%),
    linear-gradient(180deg, rgba(7, 9, 18, 0.15), #070912 70%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 54px;
  animation: page-in 0.55s ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(16, 21, 38, 0.54);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.topbar > div:first-child {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.topbar p,
label,
.api-key-box span,
.result span,
.meta dt,
.history-item small,
.table-row span,
.stat span,
.balance span {
  color: var(--muted);
}

.topbar p {
  margin-top: 8px;
}

.app-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.app-nav a,
.nav-link,
.header-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.app-nav a:hover,
.nav-link:hover,
.header-pill:hover {
  color: var(--text);
  border-color: rgba(53, 200, 255, 0.5);
  background: rgba(53, 200, 255, 0.11);
  transform: translateY(-2px);
}

.account-strip {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.balance,
.panel,
.stat,
.table-row,
.auth-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.balance {
  min-width: 170px;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: right;
}

.balance span,
.balance strong {
  display: block;
}

.balance strong {
  margin-top: 4px;
  font-size: 26px;
}

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

.panel {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 22px;
  margin-bottom: 18px;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.panel::before,
.auth-card::before,
.stat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(53, 200, 255, 0.09), transparent 38%, rgba(143, 92, 255, 0.08));
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.panel:hover,
.stat:hover,
.auth-card:hover,
.table-row:hover {
  transform: translateY(-2px);
  border-color: rgba(53, 200, 255, 0.42);
  background: var(--panel-strong);
}

.panel:hover::before,
.auth-card:hover::before,
.stat:hover::before {
  opacity: 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.account-panel {
  grid-column: 1 / -1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(77, 255, 181, 0.24);
  border-radius: 999px;
  color: var(--success);
  background: rgba(77, 255, 181, 0.08);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.auth-shell {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 18px;
  align-items: stretch;
}

.auth-card {
  position: relative;
  overflow: hidden;
  min-height: 100%;
  padding: 28px;
  border-radius: 28px;
}

.auth-copy {
  display: grid;
  align-content: center;
}

.auth-copy h2 {
  max-width: 440px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

.auth-copy p {
  margin-top: 16px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

form {
  display: grid;
  gap: 11px;
}

label {
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 14px;
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select option {
  background: #11182d;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(53, 200, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(53, 200, 255, 0.12);
  background: rgba(255, 255, 255, 0.1);
}

textarea {
  resize: vertical;
  min-height: 164px;
}

button {
  border: 0;
  padding: 12px 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101d;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  box-shadow: 0 16px 36px rgba(53, 200, 255, 0.18);
}

button.secondary {
  width: auto;
  min-width: 92px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  box-shadow: none;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 44px rgba(143, 92, 255, 0.22);
}

button.secondary:hover {
  border-color: rgba(53, 200, 255, 0.5);
  background: rgba(53, 200, 255, 0.11);
}

button.danger-button {
  background: linear-gradient(135deg, #ff5c8a, #ff8b5c);
  color: #19050c;
  box-shadow: 0 16px 36px rgba(255, 92, 138, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.api-key-box,
.payment-result,
.result,
.history {
  margin-top: 16px;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.captcha-question {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0;
}

.captcha-refresh {
  min-width: 88px;
}

.hidden {
  display: none !important;
}

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.meta div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.meta dt {
  font-size: 13px;
  font-weight: 800;
}

.meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.account-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.account-form {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.account-form h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.account-form p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.danger-zone {
  border-color: rgba(255, 92, 138, 0.25);
  background: rgba(255, 92, 138, 0.06);
}

code,
pre,
.payment-result {
  display: block;
  width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(4, 8, 18, 0.54);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

pre {
  margin: 8px 0 0;
  min-height: 84px;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  margin-bottom: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: rgba(53, 200, 255, 0.38);
  background: rgba(255, 255, 255, 0.065);
}

.history-item small {
  font-size: 12px;
}

.nav-link {
  background: rgba(255, 255, 255, 0.06);
}

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

.stat {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 22px;
}

.stat span {
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(130px, 0.8fr) minmax(100px, 0.5fr) minmax(120px, 0.6fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.table-row.compact {
  grid-template-columns: minmax(180px, 1.5fr) minmax(110px, 0.7fr);
}

.table-row span {
  display: block;
  font-size: 12px;
  overflow-wrap: anywhere;
}

mark {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

mark.pending {
  background: rgba(255, 209, 102, 0.14);
  color: var(--warning);
}

mark.completed {
  background: rgba(77, 255, 181, 0.14);
  color: var(--success);
}

mark.expired {
  background: rgba(255, 92, 138, 0.14);
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 15px;
  background: rgba(16, 21, 38, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  backdrop-filter: blur(18px);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 92, 138, 0.42);
  background: rgba(79, 20, 38, 0.92);
}

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

@media (max-width: 900px) {
  .auth-shell,
  .auth-grid,
  .grid,
  .stats-grid,
  .meta,
  .account-actions {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-strip {
    width: 100%;
  }

  .balance {
    flex: 1;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1240px);
    padding-top: 14px;
  }

  .topbar,
  .panel,
  .auth-card {
    border-radius: 20px;
  }

  .table-row,
  .table-row.compact {
    grid-template-columns: 1fr;
  }

  .account-strip {
    flex-direction: column;
  }
}
