:root {
  color-scheme: dark;
  --bg: #07090f;
  --panel: #10151d;
  --panel-2: #151c27;
  --text: #ebeff5;
  --muted: #95a0b3;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ed2f2f;
  --accent-soft: rgba(237, 47, 47, 0.18);
  --good: #29c273;
  --warn: #f4b942;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, rgba(237, 47, 47, 0.12), transparent 30%), var(--bg);
  color: var(--text);
  overflow: hidden;
}

.shell {
  height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar,
.panel,
.tenant-card,
.hint-card {
  background: rgba(16, 21, 29, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.topbar {
  border-radius: 22px;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

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

h1 {
  font-size: 28px;
}

.topbar-actions,
.tenant-actions,
.subscription-actions,
.with-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.layout {
  margin-top: 20px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.auth-panel,
.create-panel,
.tenant-panel {
  border-radius: 22px;
  padding: 22px;
}

.create-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.tenant-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.dashboard {
  display: grid;
  gap: 18px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.dashboard-home {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.dashboard-home > .panel {
  min-height: 0;
  align-self: stretch;
}

.panel-header {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.panel-header p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.create-panel .form-grid {
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 14px;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

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

.primary {
  background: linear-gradient(135deg, #f53a3a, #b91414);
  color: #fff;
}

.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}

#tenant-archived-toggle.active-toggle {
  background: rgba(244, 185, 66, 0.16);
  color: #ffe1a0;
  border-color: rgba(244, 185, 66, 0.38);
}

.danger {
  background: rgba(237, 47, 47, 0.18);
  color: #ffb3b3;
  border: 1px solid rgba(237, 47, 47, 0.4);
}

.success {
  background: rgba(41, 194, 115, 0.18);
  color: #bff5d9;
  border: 1px solid rgba(41, 194, 115, 0.38);
}

.warning {
  background: rgba(244, 185, 66, 0.16);
  color: #ffe1a0;
  border: 1px solid rgba(244, 185, 66, 0.38);
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 12px;
  border: 1px solid var(--line);
}

.pill.success,
.pill.warning,
.pill.danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pill.success::before,
.pill.warning::before,
.pill.danger::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.pill.success::before {
  background: #29c273;
}

.pill.warning::before {
  background: #f4b942;
}

.pill.danger::before {
  background: #ed2f2f;
}

.pill.muted {
  color: var(--muted);
}

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

.tenant-list.compact {
  align-content: start;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.client-search-row {
  margin-bottom: 14px;
  flex-shrink: 0;
}

.tenant-card {
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.tenant-card.compact {
  padding: 12px 14px;
}

.tenant-card.compact.active {
  border-color: rgba(237, 47, 47, 0.55);
  box-shadow: 0 20px 40px rgba(237, 47, 47, 0.12);
}

.tenant-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.tenant-card p,
.meta-list,
.subscription-summary {
  color: var(--muted);
}

.tenant-name-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 16px;
  font-weight: 700;
}

.tenant-name-button:hover {
  transform: none;
  color: #fff;
}

.tenant-list-row,
.tenant-list-row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tenant-list-row-actions {
  flex-shrink: 0;
}

.small-button {
  padding: 8px 12px;
  font-size: 12px;
}

.tenant-detail {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 100%;
}

.tenant-detail-page {
  border-radius: 22px;
  padding: 22px;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.detail-page-topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.detail-page-topbar-left,
.detail-page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tenant-detail.empty-detail {
  display: grid;
  place-items: center;
}

.empty-detail-copy {
  max-width: 420px;
  text-align: center;
  color: var(--muted);
}

.detail-topbar,
.detail-actions,
.detail-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-topbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.detail-grid .full-span {
  grid-column: 1 / -1;
}

.detail-section {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.detail-metadata {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-note-card {
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 8px;
}

.detail-note-card p,
.field-hint,
.section-heading p {
  color: var(--muted);
  line-height: 1.5;
}

.detail-note-card a {
  color: #fff;
}

.billing-import-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.billing-import-form input[type="file"] {
  flex: 1 1 320px;
}

.detail-actions {
  margin-top: 18px;
}

.hint-card {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

code {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.mfa-row {
  display: grid;
  gap: 10px;
}

.user-card {
  display: grid;
  gap: 14px;
}

.user-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.user-card-header p {
  margin-top: 6px;
  color: var(--muted);
}

.user-card-form {
  display: grid;
  gap: 14px;
}

.user-detail-grid {
  align-items: end;
}

.checkbox-field {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.user-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.launch-link {
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.backup-run-card {
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 12px;
}

.backup-run-header,
.backup-run-actions,
.backup-run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.backup-run-header,
.backup-run-meta {
  justify-content: space-between;
}

.backup-run-actions {
  justify-content: flex-start;
}

.backup-run-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.backup-run-empty {
  color: var(--muted);
  font-size: 13px;
}

.backup-action-row {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(16, 21, 29, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    overflow: visible;
  }

  .layout {
    overflow: visible;
  }

  .dashboard-home,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .create-panel,
  .tenant-panel,
  .tenant-list.compact,
  .tenant-detail-page {
    position: static;
    height: auto;
    overflow: visible;
  }

  .create-panel .form-grid {
    overflow: visible;
  }

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

  .detail-page-topbar-left,
  .detail-page-actions {
    width: 100%;
  }
}
