:root {
  --app-bg: #08101c;
  --app-bg-alt: #0e182a;
  --app-surface: #162235;
  --app-surface-alt: #1d2c44;
  --app-border: #314561;
  --app-primary: #7a8bff;
  --app-secondary: #2fc4b2;
  --app-accent: #ffbe6b;
  --app-success: #39d98a;
  --app-warning: #f4a640;
  --app-danger: #ff7b9c;
  --app-text: #f4eee6;
  --app-text-soft: rgba(244, 238, 230, 0.74);
  --app-font-family: "Inter", "Segoe UI", "SF Pro Text", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 26px;
  --shadow-soft: 0 18px 46px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--app-text);
  font-family: var(--app-font-family);
  background: radial-gradient(circle at 20% 0%, #101d33 0%, var(--app-bg) 45%, #05090f 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

body.auth-gate-open {
  overflow: hidden;
}

.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.app-shell.is-locked {
  display: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 16px;
  background: radial-gradient(circle at 20% 0%, rgba(15, 25, 43, 0.97), rgba(3, 5, 8, 0.98));
  opacity: 0;
  pointer-events: none;
  transition: opacity 170ms ease;
}

.auth-gate.is-open {
  opacity: 1;
  pointer-events: auto;
}

.auth-gate__surface {
  width: min(940px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border: 1px solid rgba(49, 69, 97, 0.45);
  border-radius: var(--radius-xl);
  background: linear-gradient(155deg, rgba(22, 34, 53, 0.99), rgba(13, 24, 39, 0.9));
  box-shadow: var(--shadow-soft);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.auth-gate__surface .status {
  margin: 0;
}
.top-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(49, 69, 97, 0.5);
  border-radius: var(--radius-xl);
  background: linear-gradient(140deg, rgba(22, 34, 53, 0.98), rgba(13, 24, 39, 0.9));
  padding: 18px;
  display: grid;
  gap: 10px;
}

.top-hero::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(122, 139, 255, 0.32), rgba(122, 139, 255, 0));
  pointer-events: none;
}

.top-hero h1 {
  position: relative;
  z-index: 1;
  margin: 2px 0 8px;
  font-size: 30px;
  letter-spacing: -0.25px;
}

.status-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.muted {
  color: var(--app-text-soft);
  margin: 0;
}

.eyebrow {
  margin: 0;
  color: var(--app-text-soft);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.3px;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 260px 1fr;
  align-items: start;
}

.side-panel {
  border: 1px solid rgba(49, 69, 97, 0.5);
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(22, 34, 53, 0.95), rgba(13, 24, 39, 0.84));
  padding: 14px;
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  text-decoration: none;
  color: var(--app-text);
  border: 1px solid rgba(244, 238, 230, 0.2);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 14px;
  display: block;
  transition: all 150ms ease;
  background: rgba(22, 34, 53, 0.32);
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(122, 139, 255, 0.5);
  background: rgba(122, 139, 255, 0.14);
  color: #fff;
}

.side-panel__card {
  border: 1px solid rgba(244, 238, 230, 0.22);
  border-radius: var(--radius-md);
  background: rgba(13, 24, 38, 0.7);
  padding: 12px;
}

.meta-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px dashed rgba(244, 238, 230, 0.14);
  padding-bottom: 8px;
  font-size: 13px;
}

.meta-list li strong {
  color: var(--app-text);
  font-weight: 700;
}

.workspace-content {
  display: grid;
  gap: 14px;
}

.section-card {
  border: 1px solid rgba(49, 69, 97, 0.54);
  background: linear-gradient(150deg, rgba(22, 34, 53, 0.94), rgba(21, 32, 54, 0.86));
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 20px;
}

.section-subtitle {
  margin-top: 4px;
  margin-bottom: 14px;
}

.tag {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(244, 238, 230, 0.26);
  color: var(--app-text-soft);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--app-text-soft);
  font-size: 13px;
}

input,
select {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(49, 69, 97, 0.55);
  background: var(--app-surface-alt);
  color: var(--app-text);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  font-family: var(--app-font-family);
}

input:focus,
select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(122, 139, 255, 0.18);
}

.mfa-setup {
  grid-column: 1 / -1;
  border: 1px dashed rgba(122, 196, 244, 0.35);
  background: rgba(13, 24, 38, 0.62);
  border-radius: var(--radius-md);
  padding: 12px;
}

.mfa-setup-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@media (min-width: 760px) {
  .mfa-setup-grid {
    grid-template-columns: 1fr 1.2fr;
    align-items: center;
  }
}

.mfa-setup-grid img {
  max-width: 190px;
  width: 100%;
  height: auto;
  border: 1px solid rgba(122, 139, 255, 0.35);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}

.mfa-setup-grid a {
  word-break: break-all;
  color: var(--app-secondary);
}

small {
  color: var(--app-text-soft);
}

.actions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  padding: 11px 16px;
  font-size: 15px;
  transition: transform 120ms ease, filter 120ms ease;
  font-family: var(--app-font-family);
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px);
}

.btn {
  color: #fff;
  background: rgba(122, 139, 255, 0.2);
  border: 1px solid rgba(122, 139, 255, 0.35);
}

.btn-primary {
  background: var(--app-primary);
  color: #1a1f2e;
}

.btn-outline {
  background: rgba(47, 196, 178, 0.2);
  border-color: rgba(47, 196, 178, 0.45);
}

.btn-ghost {
  background: rgba(244, 238, 230, 0.12);
  border-color: rgba(244, 238, 230, 0.24);
  color: #f6efe8;
}

.status-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(57, 217, 138, 0.45);
  color: #ecfde8;
  font-size: 12px;
  background: rgba(57, 217, 138, 0.16);
}

.status-chip--ok {
  border-color: rgba(57, 217, 138, 0.45);
  background: rgba(57, 217, 138, 0.16);
}

.status-chip--warn {
  border-color: rgba(244, 166, 64, 0.55);
  background: rgba(244, 166, 64, 0.14);
  color: #ffeab5;
}

.status-chip--err {
  border-color: rgba(255, 123, 156, 0.5);
  background: rgba(255, 123, 156, 0.14);
  color: #ffd4de;
}

.quick-grid {
  margin-top: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.mini-card {
  border: 1px solid rgba(49, 69, 97, 0.54);
  background: linear-gradient(150deg, rgba(22, 34, 53, 0.94), rgba(21, 32, 54, 0.86));
  border-radius: var(--radius-md);
  padding: 12px;
}

.mini-value {
  font-size: 28px;
  margin: 8px 0 0;
  letter-spacing: 0.2px;
  color: var(--app-text);
}

.kpi-grid {
  margin-top: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 860px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.alerts-panel {
  margin-top: 12px;
}

.alerts-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.model-mix {
  margin-top: 12px;
}

.model-mix-list {
  margin-top: 8px;
  border: 1px solid rgba(49, 69, 97, 0.36);
  border-radius: 14px;
  background: rgba(13, 22, 38, 0.7);
  overflow: hidden;
}

.model-mix-list > .model-mix-empty {
  margin: 0;
  padding: 12px;
}

.model-mix-item {
  display: grid;
  grid-template-columns: minmax(140px, 250px) 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px dashed rgba(244, 238, 230, 0.13);
}

.model-mix-item:last-child {
  border-bottom: 0;
}

.model-mix-name {
  font-weight: 700;
}

.model-mix-share {
  justify-self: end;
  color: var(--app-text-soft);
  white-space: nowrap;
}

.model-mix-requests {
  justify-self: end;
  color: var(--app-text);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(244, 238, 230, 0.14);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--app-primary), var(--app-secondary));
}

.table-wrap {
  margin-top: 8px;
  border: 1px solid rgba(49, 69, 97, 0.36);
  border-radius: 14px;
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--app-text);
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(49, 69, 97, 0.32);
  text-align: left;
}

.admin-table th {
  color: var(--app-sub);
  font-weight: 600;
}

.admin-table thead {
  background: rgba(15, 27, 43, 0.35);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table .muted {
  color: var(--app-sub);
}

.admin-table .badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid rgba(84, 150, 255, 0.45);
}

.table-action-btn {
  white-space: nowrap;
  padding: 8px 12px;
  min-width: 88px;
  font-size: 13px;
}

.billing-plan-input {
  width: 100%;
  min-width: 95px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 12px;
  background: var(--app-surface);
}

.billing-plan-select {
  width: 110px;
}

.billing-plan-save-btn {
  min-width: 92px;
}

.alert-item {
  border: 1px solid rgba(244, 238, 230, 0.2);
  border-left: 4px solid var(--app-text-soft);
  background: rgba(13, 24, 38, 0.7);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.alert-item--warning {
  border-left-color: var(--app-warning);
}

.alert-item--critical {
  border-left-color: var(--app-danger);
}

.alert-item--info {
  border-left-color: var(--app-secondary);
}

.alert-item__title {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--app-text);
}

.alert-item__message {
  margin: 0;
  color: var(--app-text-soft);
  font-size: 14px;
}

.alert-item__details {
  margin: 6px 0 0;
  color: var(--app-text-soft);
  font-size: 12px;
  word-break: break-word;
}

.log-wrap {
  border: 1px solid rgba(49, 69, 97, 0.36);
  border-radius: 16px;
  background: rgba(13, 22, 38, 0.7);
  min-height: 160px;
  max-height: 340px;
  overflow: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 238, 230, 0.2) rgba(22, 34, 53, 0.4);
}

.log-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(244, 238, 230, 0.13);
}

.log-time {
  color: var(--app-secondary);
  white-space: nowrap;
  min-width: 100px;
  font-size: 12px;
}

.log-text {
  color: var(--app-text);
  font-size: 14px;
  margin: 0;
}

.profile-controls {
  align-items: flex-start;
  flex-wrap: wrap;
}

.profile-controls .actions {
  margin-top: 0;
}

.profile-json-grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .profile-json-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.json-preview {
  margin: 0;
  border: 1px solid rgba(49, 69, 97, 0.36);
  border-radius: 14px;
  background: rgba(13, 22, 38, 0.7);
  padding: 10px;
  min-height: 120px;
  max-height: 190px;
  overflow: auto;
  color: var(--app-text-soft);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  white-space: pre;
}

.user-profile-table-wrap {
  margin-top: 12px;
}

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

@media (min-width: 860px) {
  .profile-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.status {
  margin: 0;
  min-height: 20px;
}

.status[data-kind="ok"] {
  color: var(--app-success);
}

.status[data-kind="err"] {
  color: var(--app-danger);
}

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

  .side-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }
}

@media (min-width: 860px) {
  .app-shell {
    padding: 28px;
  }

  .top-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}
