:root {
  --bg: #f8f5f1;
  --bg-soft: #f1ebe4;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --surface-muted: #f6f1ea;
  --line: rgba(63, 45, 31, 0.1);
  --line-strong: rgba(63, 45, 31, 0.18);
  --text: #241a14;
  --text-soft: #625246;
  --text-faint: #8b796b;
  --accent: #b85c38;
  --accent-strong: #96482a;
  --accent-soft: rgba(184, 92, 56, 0.1);
  --success: #3f6b4e;
  --danger: #b04c3a;
  --shadow-lg: 0 22px 50px rgba(47, 31, 20, 0.08);
  --shadow-md: 0 12px 26px rgba(47, 31, 20, 0.06);
  --radius-xl: 7px;
  --radius-lg: 7px;
  --radius-md: 7px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 22%),
    radial-gradient(circle at top right, rgba(184, 92, 56, 0.07), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

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

code,
pre,
input,
button,
select {
  font-family: Consolas, "Courier New", monospace;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.75rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
  height: 50px;
  width: auto;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.28rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 1.1rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 160ms ease, opacity 160ms ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(0.4rem) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-0.4rem) rotate(-45deg);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-soft);
  flex-wrap: wrap;
  margin-left: auto;
}

.topnav a,
.nav-button {
  padding: 0.65rem 0.95rem;
  border-radius: 7px;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.topnav a:hover,
.nav-button:hover {
  color: var(--text);
  background: rgba(184, 92, 56, 0.08);
}

.nav-button {
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.main-shell {
  display: grid;
  gap: 1.5rem;
  flex: 1;
  align-content: start;
  align-items: start;
}

.hero-panel,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 1.5rem;
  padding: 2rem;
  border-radius: 7px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.14rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.eyebrow::before {
  content: "";
  width: 1.8rem;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.hero-text,
.panel-text {
  color: var(--text-soft);
  max-width: 62ch;
  line-height: 1.7;
}

.hero-text code,
.endpoint-chip,
.code-shell code {
  font-size: 0.92em;
}

.endpoint-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: 7px;
  background: var(--surface-muted);
  border: 1px solid rgba(63, 45, 31, 0.08);
  color: var(--text-soft);
}

.price-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.7rem;
  border-radius: 7px;
  background: linear-gradient(180deg, #fffaf6 0%, #f7efe7 100%);
  border: 1px solid rgba(184, 92, 56, 0.16);
}

.price-card-stack {
  display: grid;
  gap: 1rem;
}

.price-card-label {
  font-size: 0.78rem;
  letter-spacing: 0.14rem;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}

.price-unit-label {
  font-size: 0.8rem;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}

.price-card-value {
  margin: 0.2rem 0 0;
  font-size: clamp(2.2rem, 4vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
}

.price-card-value-secondary {
  font-size: clamp(1.6rem, 3vw, 2.5rem);
}

.price-card-meta {
  color: var(--text-soft);
  line-height: 1.6;
}

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

.panel {
  border-radius: 7px;
  padding: 1.6rem;
}

.panel h1,
.panel h2,
.panel h3 {
  margin-top: 0;
  letter-spacing: -0.03em;
}

.panel h3 {
  margin-top: 1.5rem;
}

.panel h2 + .feature-list,
.panel h2 + .panel-text {
  margin-top: 0.45rem;
}

.panel .feature-list + h2,
.panel .panel-text + h2 {
  margin-top: 1.75rem;
}

.auth-panel {
  max-width: 640px;
  margin: 1rem auto 0;
  align-self: start;
}

.auth-form {
  display: grid;
  gap: 0.4rem;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.admin-tab-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.7rem 1rem;
  background: #fffdfa;
  color: var(--text-soft);
  font-weight: 700;
  cursor: pointer;
}

.admin-tab-button.is-active {
  border-color: rgba(184, 92, 56, 0.25);
  background: rgba(184, 92, 56, 0.1);
  color: var(--text);
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.is-active {
  display: block;
}

.admin-user-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr);
  gap: 1rem;
  align-items: end;
}

.admin-selected-meta {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--text-soft);
}

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

.form-block {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
}

.form-block label {
  font-weight: 700;
  color: var(--text);
}

.token-input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(58, 40, 28, 0.03);
}

.token-input:focus {
  outline: none;
  border-color: rgba(184, 92, 56, 0.42);
  box-shadow:
    0 0 0 0.22rem rgba(184, 92, 56, 0.12),
    inset 0 1px 2px rgba(58, 40, 28, 0.03);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.account-action-row {
  margin-top: 1rem;
}

.code-shell + .action-row {
  margin-top: 0.75rem;
}

.gold-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.gold-button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff9f5;
}

.gold-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fffdfa;
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(176, 76, 58, 0.2);
  background: #fff2ef;
  color: var(--danger);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.danger-button:hover {
  border-color: rgba(176, 76, 58, 0.35);
  background: #ffe8e1;
}

.gold-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.status-message {
  margin-top: 1rem;
  min-height: 1.4rem;
  color: var(--success);
  font-weight: 600;
}

.status-message[data-state="error"] {
  color: var(--danger);
}

.code-shell {
  margin-top: 1rem;
  padding: 1.1rem 1.15rem;
  border-radius: 7px;
  overflow-x: auto;
  background: #fcf8f4;
  color: var(--text);
  border: 1px solid rgba(63, 45, 31, 0.09);
}

.response-shell {
  min-height: 320px;
}

.code-shell pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.feature-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-soft);
  line-height: 1.8;
}

.footer-shell {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  color: var(--text-soft);
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f0e7de;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-copy {
  text-align: left;
}

.text-danger {
  color: var(--danger);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-shell[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(47, 36, 27, 0.42);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.modal-card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

@media (max-width: 900px) {
  .hero-panel,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

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

  .page-shell {
    width: min(100% - 1rem, 1180px);
  }

  .admin-user-summary,
  .admin-limit-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 0.75rem, 1180px);
    padding-top: 0.85rem;
    padding-bottom: 1.5rem;
  }

  .topbar,
  .hero-panel,
  .panel {
    border-radius: 7px;
  }

  .hero-panel,
  .panel {
    padding: 1.2rem;
  }

  .topbar {
    gap: 0.85rem;
    padding: 0.8rem 0.85rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-row {
    width: 100%;
  }

  .brand-mark {
    max-width: calc(100% - 3.5rem);
  }

  .nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }

  .topnav {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding-top: 0.2rem;
  }

  .topnav.is-open {
    display: flex;
  }

  .topnav a,
  .topnav form,
  .nav-button {
    width: 100%;
  }

  .topnav a,
  .nav-button {
    display: inline-flex;
    justify-content: flex-end;
    padding: 0.8rem 0.95rem;
    border: 1px solid rgba(63, 45, 31, 0.08);
    background: rgba(255, 255, 255, 0.72);
    text-align: right;
  }

  .topnav form {
    display: flex;
    justify-content: flex-end;
  }

  .hero-copy h1,
  .panel h1,
  .panel h2 {
    line-height: 1.08;
  }

  .price-card {
    padding: 1.25rem;
  }

  .panel-header {
    gap: 0.75rem;
  }

  .endpoint-chip {
    max-width: 100%;
    overflow-x: auto;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .action-row > * {
    width: 100%;
  }

  .feature-list {
    padding-left: 1rem;
  }

  .footer-shell {
    padding: 0.9rem 1rem;
  }

  .modal-card {
    padding: 1.15rem;
  }

  .response-shell {
    min-height: 240px;
  }

  .code-shell {
    margin-left: -0.1rem;
    margin-right: -0.1rem;
    padding: 0.95rem;
  }
}
