:root {
  --saas-bg: #f8fafc;
  --saas-surface: #ffffff;
  --saas-surface-soft: #f8fafc;
  --saas-border: #e2e8f0;
  --saas-text: #020617;
  --saas-muted: #64748b;
  --saas-primary: #2563eb;
  --saas-primary-soft: #dbeafe;
  --saas-success: #16a34a;
  --saas-danger: #dc2626;
  --saas-warning: #d97706;
  --saas-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.saas-theme {
  background: var(--saas-bg);
  color: var(--saas-text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.saas-shell {
  min-height: 100vh;
  display: flex;
  background: var(--saas-bg);
}

.saas-sidebar {
  width: 280px;
  background: #ffffff;
  color: #334155;
  border-right: 1px solid var(--saas-border);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1030;
  transition: transform .25s ease;
}

.saas-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--saas-border);
  margin-bottom: 16px;
}

.saas-sidebar__brand img {
  height: 34px;
  width: auto;
  max-width: 165px;
}

.saas-sidebar__brand h6 {
  margin: 0;
  color: #fff;
  font-size: 0.9rem;
}

.saas-user-badge {
  border: 1px solid var(--saas-border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  margin: 0 6px 16px;
  box-shadow: none;
}

.saas-user-badge__name {
  color: #0f172a;
  font-weight: 700;
  font-size: 0.9rem;
}

.saas-user-badge__meta {
  color: #64748b;
  font-size: 0.78rem;
}

.saas-menu {
  list-style: none;
  margin: 0;
  padding: 0 6px;
}

.saas-menu li + li {
  margin-top: 6px;
}

.saas-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #334155;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: all .2s ease;
  border: 1px solid transparent;
}

.saas-menu a i {
  width: 18px;
  text-align: center;
}

.saas-menu a:hover,
.saas-menu a.active {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: none;
}

.saas-main {
  flex: 1;
  min-width: 0;
}

.saas-topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--saas-border);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.saas-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saas-topbar__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--saas-text);
  margin: 0;
}

.saas-topbar__subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--saas-muted);
}

.saas-topbar .btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--saas-border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
}

.saas-notify-btn {
  position: relative;
}

.saas-notify-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 2px #ffffff;
}

.btn-icon:hover {
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.saas-content {
  padding: 24px;
}

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

.saas-card {
  background: var(--saas-surface);
  border: 1px solid var(--saas-border);
  border-radius: 12px;
  box-shadow: var(--saas-shadow);
}

.saas-card__body {
  padding: 16px;
}

.saas-stat {
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.saas-stat:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.saas-stat::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -24px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
}

.saas-stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

.saas-stat__label {
  font-size: 0.8rem;
  color: var(--saas-muted);
  margin: 0;
}

.saas-stat__value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 6px 0 2px;
}

.saas-stat__hint {
  font-size: 0.8rem;
  color: var(--saas-muted);
}

.saas-stat__icon {
  right: 16px;
  bottom: 14px;
  font-size: 1.35rem;
  color: #7e8ea7;
}

.saas-form-card,
.custom--card {
  border: 1px solid var(--saas-border) !important;
  border-radius: 12px !important;
  box-shadow: var(--saas-shadow) !important;
  background: var(--saas-surface) !important;
}

.form--control,
.form-control,
.select2-container--default .select2-selection--single {
  border-radius: 10px !important;
  border: 1px solid #cbd5e1 !important;
  min-height: 44px;
  box-shadow: none !important;
}

.form--control:focus,
.form-control:focus {
  border-color: #0f172a !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.10) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 44px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 44px !important;
}

.btn,
.btn--base,
.btn--base-outline {
  border-radius: 10px !important;
  font-weight: 600;
}

.btn--base {
  background: var(--saas-primary) !important;
  border-color: var(--saas-primary) !important;
  color: #fff !important;
}

.btn--base-outline {
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  background: #fff !important;
}

.table {
  border-color: var(--saas-border) !important;
  background: var(--saas-surface);
  border-radius: 12px;
  overflow: hidden;
}

.saas-theme .table thead tr th,
.table thead th {
  background: #f8fafc;
  color: #334155;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--saas-border) !important;
}

.saas-theme .table tbody tr td,
.table tbody td {
  border-color: var(--saas-border) !important;
  color: var(--saas-text);
}

.alert {
  border-radius: 12px;
}

.dropdown-menu {
  border: 1px solid var(--saas-border);
  border-radius: 10px;
  box-shadow: var(--saas-shadow);
}

.dropdown-item {
  color: var(--saas-text);
}

.dropdown-item:active {
  background: var(--saas-primary-soft);
  color: #1e3a8a;
}

.account-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--saas-bg);
}

.account-aside {
  position: relative;
  background: linear-gradient(140deg, #0f172a, #1d4ed8);
  color: #e2e8f0;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.account-aside::before,
.account-aside::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.account-aside::before {
  width: 340px;
  height: 340px;
  top: -120px;
  right: -120px;
}

.account-aside::after {
  width: 220px;
  height: 220px;
  bottom: -80px;
  left: -70px;
}

.account-aside h2 {
  font-size: 2rem;
  color: #fff;
  font-weight: 700;
}

.account-aside p {
  color: #cbd5e1;
  max-width: 470px;
}

.account-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}

.account-card {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border: 1px solid var(--saas-border);
  border-radius: 18px;
  box-shadow: var(--saas-shadow);
  padding: 28px;
}

.account-logo {
  margin-bottom: 14px;
}

.account-logo img {
  height: 36px;
  width: auto;
}

.theme-logo {
  height: 36px;
  width: auto;
}

.theme-logo-dark {
  display: none;
}

body.saas-dark .theme-logo-light {
  display: none;
}

body.saas-dark .theme-logo-dark {
  display: inline-block;
}

.saas-kpi-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.saas-sidebar-toggle {
  display: inline-flex;
}

@media (min-width: 992px) {
  body.saas-sidebar-collapsed .saas-sidebar {
    width: 94px;
    padding-inline: 10px;
  }

  body.saas-sidebar-collapsed .saas-sidebar__brand img {
    max-width: 42px;
  }

  body.saas-sidebar-collapsed .saas-user-badge {
    padding: 10px 6px;
  }

  body.saas-sidebar-collapsed .saas-user-badge__name,
  body.saas-sidebar-collapsed .saas-user-badge__meta,
  body.saas-sidebar-collapsed .saas-menu a span {
    display: none;
  }

  body.saas-sidebar-collapsed .saas-menu {
    padding-inline: 2px;
  }

  body.saas-sidebar-collapsed .saas-menu a {
    justify-content: center;
    padding-inline: 0;
    gap: 0;
  }

  body.saas-sidebar-collapsed .saas-menu a i {
    width: auto;
    font-size: 1.05rem;
  }
}

body.saas-dark {
  --saas-bg: #020617;
  --saas-surface: #0b1220;
  --saas-surface-soft: #111a2b;
  --saas-border: #1e293b;
  --saas-text: #e2e8f0;
  --saas-muted: #94a3b8;
  --saas-primary: #3b82f6;
  --saas-primary-soft: #1e3a8a;
  --saas-shadow: 0 1px 2px rgba(2, 6, 23, 0.6);
}

body.saas-dark .saas-shell {
  background: var(--saas-bg);
}

body.saas-dark .saas-sidebar {
  background: #020817;
  border-right-color: #1e293b;
}

body.saas-dark .saas-user-badge {
  background: rgba(17, 35, 68, 0.75);
  border-color: rgba(117, 153, 214, 0.28);
}

body.saas-dark .saas-menu a {
  color: #b9c9e5;
}

body.saas-dark .saas-menu a:hover,
body.saas-dark .saas-menu a.active {
  background: #0f172a;
  border-color: #334155;
}

body.saas-dark .saas-topbar {
  background: rgba(2, 8, 23, 0.92);
  border-bottom-color: #1e293b;
}

body.saas-dark .btn-icon {
  background: #0b1220;
  border-color: #1e293b;
  color: #cbd5e1;
}

body.saas-dark .btn-icon:hover {
  border-color: #475569;
  color: #f8fafc;
}

body.saas-dark .saas-notify-dot {
  box-shadow: 0 0 0 2px #0b1220;
}

body.saas-dark .saas-card,
body.saas-dark .custom--card,
body.saas-dark .saas-form-card,
body.saas-dark .table {
  background: var(--saas-surface) !important;
  border-color: var(--saas-border) !important;
}

body.saas-dark .saas-stat__icon {
  color: #9ab4dd;
}

body.saas-dark .saas-theme .table thead tr th,
body.saas-dark .table thead th {
  background: var(--saas-surface-soft);
  color: #d9e6ff;
}

body.saas-dark .saas-theme .table tbody tr td,
body.saas-dark .table tbody td {
  color: #d8e4fb;
}

body.saas-dark .form--control,
body.saas-dark .form-control,
body.saas-dark .select2-container--default .select2-selection--single {
  background: #0b1220 !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

body.saas-dark .form--control::placeholder,
body.saas-dark .form-control::placeholder {
  color: #8ea8cd;
}

body.saas-dark .input-group-text {
  background: #0b1220;
  color: #cbd5e1;
  border-color: #334155;
}

body.saas-dark .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #dce9ff !important;
}

body.saas-dark .select2-dropdown {
  background: #0b1220;
  border-color: #334155;
}

body.saas-dark .select2-results__option {
  color: #d9e7ff;
}

body.saas-dark .select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: #1e293b;
}

body.saas-dark .text-muted {
  color: var(--saas-muted) !important;
}

body.saas-dark .alert-warning {
  background: rgba(180, 95, 0, 0.14);
  border-color: rgba(255, 165, 0, 0.34);
  color: #ffd9a3;
}

body.saas-dark .dropdown-menu {
  background: #0b1220;
  border-color: #1e293b;
}

body.saas-dark .dropdown-header,
body.saas-dark .dropdown-item {
  color: #dbe8ff;
}

body.saas-dark .dropdown-item:hover {
  background: #1e293b;
}

body.saas-dark .dropdown-divider {
  border-top-color: #1e293b;
}

body.saas-dark .btn--base-outline {
  background: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

body.saas-dark .btn--base-outline:hover {
  background: #1e293b !important;
  border-color: #3b82f6 !important;
  color: #f8fafc !important;
}

body.saas-dark .btn--base-outline:disabled,
body.saas-dark .btn--base-outline.disabled {
  background: #0b1220 !important;
  color: #64748b !important;
  border-color: #1f2937 !important;
  opacity: 1 !important;
}

body.saas-dark h1,
body.saas-dark h2,
body.saas-dark h3,
body.saas-dark h4,
body.saas-dark h5,
body.saas-dark h6 {
  color: #e2e8f0;
}

@media (min-width: 768px) {
  .saas-grid > .saas-col-6 {
    grid-column: span 6;
  }

  .saas-grid > .saas-col-12 {
    grid-column: span 12;
  }
}

@media (max-width: 767px) {
  .saas-grid > [class*="saas-col-"] {
    grid-column: span 12 !important;
  }
}

@media (max-width: 1199px) {
  .account-shell {
    grid-template-columns: 1fr;
  }

  .account-aside {
    min-height: 220px;
    padding: 28px;
  }
}

@media (max-width: 991px) {
  .saas-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.35);
  }

  body.saas-sidebar-open .saas-sidebar {
    transform: translateX(0);
  }

  .saas-topbar {
    padding-inline: 14px;
  }

  .saas-content {
    padding: 16px;
  }
}
