:root {
  color-scheme: dark;
  --bg: #0B1219;
  --surface: #132029;
  --surface-2: #192A36;
  --border: rgba(255, 255, 255, 0.12);
  --text: #F8FAFC;
  --muted: #A9BAC8;
  --accent: #E5A93C;
  --accent-ink: #081018;
  --danger: #EF4444;
  --success: #10B981;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 18, 25, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(0.85rem + var(--safe-top)) 1rem 0.85rem;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dev-card {
  border-color: rgba(229, 169, 60, 0.45);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
}

.search-wrap {
  flex: 1 1 240px;
  max-width: 360px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 0.85rem;
}

.dev-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.dev-row .field-input {
  flex: 1 1 220px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.field-input, .field-textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.field-input:focus-visible, .field-textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.4);
}

.helper-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.inline-alert {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
}

.inline-alert.is-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FECACA;
}

.welcome-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 12px;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.welcome-box h3 {
  margin: 0;
  font-size: 1rem;
  color: #6EE7B7;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.tenants-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tenant-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.tenant-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.9rem;
}

.tenant-name {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.tenant-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(16, 185, 129, 0.18);
  color: #6EE7B7;
}

.tenant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 8, 12, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
}

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

.modal-panel {
  width: 100%;
  max-width: 680px;
  max-height: 100%;
  overscroll-behavior-y: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.audit-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.audit-action {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.audit-summary {
  font-size: 0.9rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.audit-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  width: min(92vw, 440px);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-item {
  background: #1C3140;
  border: 1px solid rgba(229, 169, 60, 0.45);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}
