:root {
  color-scheme: light;
  --brand-50: #eef5f7;
  --brand-100: #d6e7ee;
  --brand-300: #7fb0c6;
  --brand-500: #1f5c7a;
  --brand-600: #1b4c65;
  --brand-700: #133746;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --surface-0: #f7f9fb;
  --surface-1: #ffffff;
  --surface-2: #eef2f7;
  --stroke-100: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 12px 24px -16px rgba(15, 23, 42, 0.35);
  --shadow-card: 0 16px 40px -30px rgba(15, 23, 42, 0.4);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --sidebar-width: 260px;
  --tenant-primary: var(--brand-500);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: radial-gradient(circle at 10% 10%, rgba(31, 92, 122, 0.12), transparent 45%),
    radial-gradient(circle at 90% 15%, rgba(15, 118, 110, 0.12), transparent 40%),
    linear-gradient(180deg, #f7f9fb 0%, #eef2f7 100%);
  background-attachment: fixed;
}

.auth-shell {
  justify-content: center;
  align-items: center;
  padding: 3.5rem 1.5rem 4rem;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 10% 15%, rgba(255, 200, 87, 0.18), transparent 45%),
    radial-gradient(circle at 90% 20%, rgba(31, 92, 122, 0.22), transparent 40%),
    linear-gradient(140deg, #f4f0e6 0%, #eef6f9 45%, #e9f2f1 100%);
}

.auth-shell::before,
.auth-shell::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.75;
  pointer-events: none;
}

.auth-shell::before {
  top: -120px;
  right: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(31, 92, 122, 0.35), rgba(31, 92, 122, 0));
}

.auth-shell::after {
  bottom: -160px;
  left: -120px;
  background: radial-gradient(circle at 40% 40%, rgba(15, 118, 110, 0.28), rgba(15, 118, 110, 0));
}

.auth-main {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-content {
  display: flex;
  width: 100%;
}

.auth-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5rem;
  align-items: stretch;
  width: 100%;
}

.auth-hero {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: calc(var(--radius-lg) + 8px);
  padding: 2.5rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-hero h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  margin: 0;
  color: var(--ink-900);
}

.auth-hero p {
  margin: 0;
  color: var(--ink-700);
  font-size: 1rem;
}

.auth-pill {
  background: rgba(31, 92, 122, 0.12);
  color: var(--brand-700);
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  width: fit-content;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

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

.auth-metric-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-700);
}

.auth-metric-label {
  font-size: 0.85rem;
  color: var(--ink-500);
}

.auth-card {
  background: var(--surface-1);
  border-radius: calc(var(--radius-lg) + 8px);
  padding: 2.5rem;
  border: 1px solid var(--stroke-100);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-card-header h2 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.5rem;
  color: var(--ink-900);
}

.auth-card-header p {
  margin: 0;
  color: var(--ink-500);
}

.auth-card-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-500);
}

.auth-form {
  display: grid;
  gap: 1.1rem;
}

.auth-field {
  display: grid;
  gap: 0.4rem;
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.auth-helper {
  font-size: 0.85rem;
  color: var(--ink-500);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(160deg, #0f2231 0%, #123146 55%, #173a4c 100%);
  color: #e5eef3;
  padding: 1.5rem 1.25rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.app-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.app-brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f8fbff;
}

.app-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  margin-right: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.has-tenant .app-brand-logo {
  width: 44px;
  height: 44px;
  margin-right: 0.65rem;
  border-radius: 10px;
}

.app-nav {
  display: grid;
  gap: 0.35rem;
}

.app-nav-section {
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(229, 238, 243, 0.6);
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(248, 251, 255, 0.86);
  transition: background 0.2s ease, color 0.2s ease;
}

.app-nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.app-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--stroke-100);
  backdrop-filter: blur(12px);
}

.app-topbar-title {
  font-weight: 600;
  color: var(--ink-700);
}

.app-topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-tenant-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-tenant-form .form-select {
  min-width: 180px;
  border-radius: 999px;
  padding-left: 0.8rem;
  padding-right: 1.6rem;
  background-color: var(--surface-1);
}

.app-chip {
  background: var(--surface-2);
  color: var(--ink-700);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.app-content {
  padding: 2rem;
  flex: 1;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem 2rem 2rem;
  color: var(--ink-500);
  font-size: 0.85rem;
}

.app-chart-card {
  min-height: 320px;
}

.app-chart-wrap {
  position: relative;
  min-height: 260px;
  width: 100%;
}

.card {
  border: 1px solid var(--stroke-100);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.table {
  margin-bottom: 0;
}

.btn-primary {
  background: var(--tenant-primary);
  border-color: var(--tenant-primary);
}

.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

.btn-outline-primary {
  color: var(--tenant-primary);
  border-color: var(--brand-300);
}

.btn-outline-primary:hover {
  background: var(--brand-50);
  border-color: var(--brand-500);
  color: var(--brand-700);
}

.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--stroke-100);
}

.form-control:focus,
.form-select:focus,
.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(31, 92, 122, 0.2);
  border-color: var(--brand-300);
}

.app-stagger > * {
  animation: riseFade 0.6s ease both;
}

.app-stagger > *:nth-child(2) {
  animation-delay: 0.08s;
}

.app-stagger > *:nth-child(3) {
  animation-delay: 0.16s;
}

.app-stagger > *:nth-child(4) {
  animation-delay: 0.24s;
}

@keyframes riseFade {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    width: 100%;
  }

  .app-content {
    padding: 1.5rem;
  }

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

  .auth-hero,
  .auth-card {
    padding: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-stagger > * {
    animation: none;
  }
}
