:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #111827;
  --ink-2: #344054;
  --muted: #667085;
  --line: #d9e2ef;
  --line-soft: #edf1f7;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #0f8f63;
  --success-soft: #e8f7f0;
  --warn: #a15c00;
  --warn-soft: #fff4de;
  --danger: #b42318;
  --danger-soft: #feeceb;
  --sidebar: #0f172a;
  --sidebar-2: #111c33;
  --sidebar-muted: #94a3b8;
  --shadow: 0 16px 44px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.09), transparent 32%),
    linear-gradient(180deg, #f7f9fd 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

button.secondary,
button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink-2);
}

button.secondary:hover,
button.ghost:hover {
  border-color: #b8c7dc;
  background: var(--surface-2);
  color: var(--ink);
}

button.ghost {
  width: 100%;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.68);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  color: var(--ink-2);
}

code {
  color: #175cd3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

pre {
  overflow: auto;
  margin: 0;
  border: 1px solid #22314f;
  border-radius: 10px;
  background: #0b1220;
  color: #d8e6ff;
  padding: 16px;
  font-size: 12px;
  line-height: 1.65;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.shell.auth-only {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.shell.auth-only .sidebar {
  display: none;
}

.shell.auth-only .content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(100vh - 48px);
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 22px 16px;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.12), transparent 28%),
    var(--sidebar);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.brand-mark {
  width: 42px;
  height: 42px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 184, 205, 0.22);
  object-fit: contain;
}

.brand h1,
.topbar h2,
.auth-panel h2,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.brand-copy {
  min-width: 0;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 20px;
}

.nav-item {
  position: relative;
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  border-color: transparent;
  background: transparent;
  color: #cbd5e1;
  padding: 0 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 750;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: none;
}

.nav-item.active {
  background: rgba(37, 99, 235, 0.2);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.24);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  width: 3px;
  height: 22px;
  border-radius: 999px;
  background: #60a5fa;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.sidebar-footer span {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-footer .ghost {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.content {
  min-width: 0;
  padding: 26px clamp(20px, 3vw, 36px) 40px;
}

.auth-panel,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  gap: 18px;
  max-width: 720px;
  margin: 8vh auto;
  padding: 28px;
}

.shell.auth-only .auth-panel {
  width: min(720px, 100%);
  margin: 0;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand .brand-mark {
  box-shadow: 0 14px 34px rgba(20, 184, 205, 0.18);
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  font-size: 18px;
  line-height: 1.15;
}

.auth-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 4px;
}

.auth-tabs button {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.auth-tabs button:hover {
  background: #fff;
  color: var(--ink);
  transform: none;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -26px calc(clamp(20px, 3vw, 36px) * -1) 22px;
  padding: 18px clamp(20px, 3vw, 36px);
  border-bottom: 1px solid rgba(217, 226, 239, 0.78);
  background: rgba(244, 246, 251, 0.82);
  backdrop-filter: blur(14px);
}

.topbar h2 {
  margin-top: 3px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  padding: 8px 12px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  font-size: 13px;
  font-weight: 700;
}

.tab {
  display: none;
}

.tab.active {
  display: grid;
  gap: 18px;
}

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

.metric {
  position: relative;
  display: grid;
  gap: 8px;
  overflow: hidden;
  padding: 18px;
}

.metric::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -30px;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric strong {
  font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: -0.02em;
}

.panel {
  display: grid;
  gap: 16px;
  overflow: hidden;
  padding: 20px;
}

.onboarding-panel {
  overflow: visible;
}

.panel-head {
  padding-bottom: 2px;
}

.panel h3 {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.panel > table,
.panel > .table-wrap {
  margin: 0 -20px -20px;
}

.panel > table {
  display: block;
  overflow-x: auto;
}

.panel > button {
  justify-self: start;
}

.onboarding-grid,
.recharge-guide,
.model-card-grid {
  display: grid;
  gap: 12px;
}

.onboarding-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.setup-step,
.recharge-guide div,
.model-card {
  display: grid;
  align-content: start;
  gap: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcff;
  padding: 16px;
}

.setup-step span {
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 900;
}

.setup-step strong,
.recharge-guide strong,
.model-card strong {
  color: var(--ink);
  font-size: 15px;
}

.setup-step p,
.recharge-guide span,
.model-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.setup-step button {
  justify-self: start;
  margin-top: 2px;
}

.setup-step.is-done {
  border-color: rgba(15, 143, 99, 0.26);
  background: var(--success-soft);
}

.setup-step.is-done span {
  color: var(--success);
}

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

.notice-box {
  border: 1px solid #c9d8f2;
  border-radius: 8px;
  background: #f3f7ff;
  color: var(--ink-2);
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

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

.model-card {
  min-height: 142px;
}

.model-card .model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

td button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.muted,
.eyebrow {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.secret-box {
  border: 1px solid #b6d7ff;
  border-radius: 8px;
  background: #eef6ff;
  color: #0b4b8f;
  padding: 13px;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.secret-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.secret-wrap .secret-box {
  min-width: 0;
  user-select: all;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 420px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: #101828;
  color: #fff;
  box-shadow: 0 20px 52px rgba(15, 23, 42, 0.24);
  padding: 13px 15px;
  font-size: 13px;
}

.status-approved,
.status-active,
.status-success,
.status-succeeded {
  color: var(--success) !important;
  font-weight: 800;
}

.status-pending,
.status-processing,
.status-queued {
  color: var(--warn) !important;
  font-weight: 800;
}

.status-rejected,
.status-failed,
.status-deleted,
.status-frozen,
.status-inactive,
.status-cancelled {
  color: var(--danger) !important;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .onboarding-grid,
  .model-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: static;
    margin: 0 0 18px;
    padding: 0;
    border-bottom: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .metrics,
  .auth-grid,
  .form-row,
  .recharge-guide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 18px 14px 30px;
  }

  .topbar,
  .actions,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .onboarding-grid,
  .model-card-grid {
    grid-template-columns: 1fr;
  }

  .user-pill {
    width: 100%;
  }
}
