:root {
  color-scheme: light;
  --ax-bg: #f7f4ef;
  --ax-surface: rgba(255, 253, 248, 0.86);
  --ax-surface-strong: #fffdf8;
  --ax-ink: #171411;
  --ax-muted: #6f6860;
  --ax-line: rgba(23, 20, 17, 0.12);
  --ax-line-strong: rgba(23, 20, 17, 0.18);
  --ax-accent: #2947ff;
  --ax-accent-ink: #ffffff;
  --ax-accent-soft: #e8ebff;
  --ax-positive: #047857;
  --ax-warning: #a16207;
  --ax-danger: #b42318;
  --ax-radius-sm: 12px;
  --ax-radius: 20px;
  --ax-radius-lg: 28px;
  --ax-shadow: 0 24px 70px rgba(36, 29, 18, 0.11);
  --ax-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ax-ink);
  font-family: var(--ax-font);
  background:
    radial-gradient(circle at 22% 10%, rgba(41, 71, 255, 0.14), transparent 34%),
    radial-gradient(circle at 80% 4%, rgba(255, 197, 115, 0.22), transparent 30%),
    var(--ax-bg);
}

button, input, select {
  font: inherit;
}

button { cursor: pointer; }

input, select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ax-ink);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--ax-accent);
  box-shadow: 0 0 0 4px rgba(41, 71, 255, 0.12);
}

label {
  display: grid;
  gap: 8px;
  color: var(--ax-muted);
  font-size: 13px;
  font-weight: 650;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 18px;
  font-size: 22px;
  letter-spacing: -0.035em;
}

small, .muted {
  color: var(--ax-muted);
}

summary {
  color: var(--ax-accent);
  font-weight: 700;
  cursor: pointer;
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.72fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  min-height: 100vh;
  padding: clamp(22px, 5vw, 72px);
}

.auth-page.hidden {
  display: none;
}

.auth-hero {
  display: grid;
  gap: 32px;
  max-width: 780px;
}

.auth-hero h1 {
  max-width: 760px;
  font-size: clamp(46px, 7vw, 92px);
  line-height: 0.92;
}

.lead {
  max-width: 680px;
  color: var(--ax-muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.55;
}

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

.auth-metrics div {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius);
  background: rgba(255, 253, 248, 0.58);
  backdrop-filter: blur(22px);
}

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

.auth-metrics strong {
  margin-bottom: 10px;
  font-size: 20px;
  letter-spacing: -0.035em;
}

.auth-metrics span {
  color: var(--ax-muted);
  line-height: 1.45;
}

.auth-runtime {
  max-width: 320px;
}

.auth-stack {
  display: grid;
  gap: 16px;
}

.login-card {
  display: grid;
  gap: 24px;
  padding: clamp(24px, 4vw, 34px);
  border-radius: var(--ax-radius-lg);
}

.login-card h2 {
  margin-bottom: 8px;
  font-size: 34px;
}

.login-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-note {
  margin: 14px 0 0;
}

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

.dashboard-shell.hidden {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--ax-line);
  background: rgba(247, 244, 239, 0.82);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand.large {
  gap: 14px;
}

.brand.large .brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: var(--ax-accent-ink);
  background: linear-gradient(135deg, var(--ax-accent), #6f7dff);
  box-shadow: 0 18px 34px rgba(41, 71, 255, 0.24);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
  margin: 34px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ax-muted);
  text-align: left;
  text-decoration: none;
  font-weight: 750;
}

.nav-item:hover,
.nav-item.active {
  border-color: var(--ax-line);
  background: var(--ax-surface-strong);
  color: var(--ax-ink);
}

.nav-item.active {
  box-shadow: 0 10px 26px rgba(36, 29, 18, 0.08);
}

.sidebar-card,
.surface {
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius);
  background: var(--ax-surface);
  box-shadow: var(--ax-shadow);
  backdrop-filter: blur(22px);
}

.sidebar-card {
  padding: 18px;
}

.runtime-status {
  margin-top: auto;
}

.main {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin-bottom: 8px;
  color: var(--ax-muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.view {
  display: none;
  gap: 22px;
}

.view.active {
  display: grid;
}

.surface {
  padding: 22px;
}

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

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stack {
  display: grid;
  gap: 14px;
}

.compact-form {
  margin-top: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.inline-form.small {
  grid-template-columns: 100px auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--ax-accent);
  color: var(--ax-accent-ink);
  font-weight: 850;
  box-shadow: 0 16px 34px rgba(41, 71, 255, 0.20);
}

.button:hover {
  transform: translateY(-1px);
}

.button.wide {
  width: 100%;
  justify-content: center;
}

.button.secondary {
  border-color: var(--ax-line);
  background: var(--ax-surface-strong);
  color: var(--ax-ink);
  box-shadow: none;
}

.button.ghost {
  background: transparent;
  color: var(--ax-muted);
  box-shadow: none;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ax-line);
  border-radius: 999px;
  background: var(--ax-surface-strong);
  color: var(--ax-muted);
  font-size: 13px;
  font-weight: 800;
}

.badge.success { color: var(--ax-positive); background: #ecfdf5; }
.badge.warning { color: var(--ax-warning); background: #fffbeb; }
.badge.danger { color: var(--ax-danger); background: #fef3f2; }

.stat-card {
  min-height: 142px;
  display: grid;
  align-content: space-between;
}

.stat-card span {
  color: var(--ax-muted);
  font-weight: 750;
}

.stat-card strong {
  font-size: 34px;
  letter-spacing: -0.04em;
}

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

.result {
  width: 100%;
  min-height: 150px;
  max-height: 440px;
  overflow: auto;
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius-sm);
  background: #14120f;
  color: #f8f4ec;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.result.tall {
  min-height: 440px;
}

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

.data-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ax-line);
}

.data-row:last-child { border-bottom: 0; }

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--ax-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cards-list {
  display: grid;
  gap: 12px;
}

.mini-card {
  padding: 14px;
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius-sm);
  background: rgba(255, 255, 255, 0.52);
}

.mini-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions .button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: none;
  max-width: 420px;
  padding: 14px 16px;
  border: 1px solid var(--ax-line);
  border-radius: var(--ax-radius-sm);
  background: var(--ax-surface-strong);
  box-shadow: var(--ax-shadow);
  font-weight: 750;
}

.toast.visible { display: block; }
.admin-only.hidden { display: none; }

@media (max-width: 1080px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-metrics {
    grid-template-columns: 1fr;
  }

  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--ax-line);
  }
  .runtime-status {
    margin-top: 18px;
  }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .auth-page { padding: 18px; }
  .auth-hero h1 { font-size: 42px; }
  .main, .sidebar { padding: 18px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar-actions { justify-content: space-between; }
  .nav { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
}
