:root {
  --app-bg: #0d1324;
  --app-bg-soft: #f3f6ff;
  --app-surface: #ffffff;
  --app-surface-alt: #f8faff;
  --app-muted: #60708a;
  --app-text: #172338;
  --app-primary: #3a6dff;
  --app-primary-dark: #2955d8;
  --app-sidebar: #0f1a33;
  --app-sidebar-soft: #1b2a4d;
  --app-border: #dfe7f4;
  --app-radius: 16px;
  --app-shadow: 0 14px 36px rgba(14, 31, 64, 0.08);
  --app-shadow-soft: 0 8px 22px rgba(14, 31, 64, 0.05);
}

* {
  box-sizing: border-box;
}

body.app-body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--app-text);
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(58, 109, 255, 0.22), transparent 55%),
    radial-gradient(800px 500px at 90% 0%, rgba(106, 196, 255, 0.16), transparent 45%),
    linear-gradient(180deg, #ecf2ff 0%, var(--app-bg-soft) 100%);
}

body,
.app-content-shell,
.card,
.app-navbar,
.app-subnav,
.app-panel,
.form-control,
.form-select,
.btn,
.app-nav-link {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

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

.app-shell-main {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.app-sidebar {
  width: 280px;
  background: linear-gradient(180deg, var(--app-sidebar) 0%, #16254a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.1rem;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
  padding: 0.5rem 0.4rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  margin-bottom: 1rem;
}

.app-sidebar-brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.app-sidebar-brand small {
  font-size: 0.72rem;
  opacity: 0.72;
  margin-top: 0.15rem;
}

.app-brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.68);
  flex: 0 0 38px;
}

.app-sidebar-nav {
  display: grid;
  gap: 0.3rem;
  margin-bottom: auto;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  padding: 0.7rem 0.85rem;
  color: inherit;
  transition: all 0.2s ease;
}

.app-sidebar .app-nav-link {
  color: rgba(255, 255, 255, 0.9);
}

.app-sidebar .app-nav-link:hover,
.app-sidebar .app-nav-link.active {
  background: linear-gradient(90deg, rgba(73, 123, 255, 0.3), rgba(46, 186, 255, 0.22));
  color: #fff;
}

.app-sidebar-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.app-header {
  z-index: 1030;
}

.app-navbar {
  min-height: 68px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(207, 220, 241, 0.8);
}

.app-brand {
  color: #1f2f4a;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.app-brand:hover,
.app-brand:focus {
  color: #1f2f4a;
}

.app-profile-btn {
  border: 1px solid #cfdbef;
  background: #fff;
  border-radius: 999px;
  width: auto;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.4rem 0 0.2rem;
}

.app-profile-wrap {
  position: relative;
}

.app-profile-btn::after {
  display: none;
}

.app-profile-btn:hover,
.app-profile-btn:focus {
  border-color: #a9c4f7;
  background: #eef4ff;
}

.app-avatar-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.app-avatar-fallback {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #2f4a77;
  background: linear-gradient(135deg, #d8e6ff 0%, #c5e8ff 100%);
}

.app-profile-chevron {
  font-size: 0.74rem;
  color: #60708a;
  margin-right: 0.1rem;
}

.app-profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  z-index: 1080;
  list-style: none;
  margin: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #d9e4f8;
  border-radius: 12px;
  box-shadow: var(--app-shadow-soft);
  padding-top: 0.3rem;
}

.app-profile-menu[hidden] {
  display: none !important;
}

.app-profile-menu-head {
  padding-top: 0.45rem;
  padding-left: 0.9rem;
  padding-right: 0.9rem;
  padding-bottom: 0.35rem;
}

.app-profile-name {
  font-size: 1rem;
}

.app-profile-link {
  display: block;
  width: 100%;
  border-radius: 9px;
  padding: 0.5rem 0.7rem;
  color: #2a3f63;
  text-decoration: none;
  font-weight: 600;
}

.app-profile-link:hover,
.app-profile-link:focus {
  background: #edf4ff;
  color: #1f4d99;
}

.app-theme-toggle {
  border: 1px solid #cfdbef;
  background: #fff;
  color: #2f4a77;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.app-theme-toggle:hover,
.app-theme-toggle:focus {
  color: #20427b;
  border-color: #a9c4f7;
  background: #eef4ff;
}

.app-toggler {
  border: 1px solid #cbd9ef;
  color: #314e84;
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
}

.app-main {
  min-height: calc(100vh - 68px);
}

.app-content-shell {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(212, 224, 241, 0.8);
  border-radius: 22px;
  box-shadow: var(--app-shadow);
  padding: 1.1rem;
}

.app-content-shell-public {
  max-width: 980px;
  margin-inline: auto;
}

.app-public-page .app-main,
.app-auth-page .app-main {
  min-height: calc(100vh - 130px);
}

.app-footer {
  border-top: 1px solid var(--app-border);
  color: var(--app-muted);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(5px);
}

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-soft);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(14, 31, 64, 0.1);
}

.card-header {
  border-bottom: 1px solid #e6edf8;
  background: #f6f9ff;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: #f6faff;
  --bs-table-hover-bg: #edf4ff;
  border-color: #e4ecf8;
}

.table thead th {
  background: #f2f7ff;
  color: #27406a;
  border-bottom: 1px solid #d9e4f5;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.btn {
  border-radius: 11px;
  font-weight: 650;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(120deg, var(--app-primary) 0%, #4e7bff 58%, #57c2ff 100%);
  border: none;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(120deg, var(--app-primary-dark) 0%, #406cf8 62%, #44b6f6 100%);
  transform: translateY(-1px);
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.btn-outline-light:hover,
.btn-outline-light:focus {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.68);
}

.monitor-btn {
  background: #eef4ff;
  border: 1px solid #d4e4ff;
  color: #27519d;
}

.monitor-btn:hover,
.monitor-btn:focus {
  background: #e3eeff;
  color: #1f4281;
}

.form-control,
.form-select {
  border-radius: 11px;
  border-color: #d3deef;
  min-height: 43px;
  background-color: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: #83acff;
  box-shadow: 0 0 0 0.2rem rgba(58, 109, 255, 0.16);
}

.alert {
  border-radius: 12px;
  border: none;
  box-shadow: var(--app-shadow-soft);
}

.badge {
  font-weight: 700;
}

.offcanvas.app-offcanvas {
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
}

.offcanvas .app-nav-link {
  color: #23406f;
  border: 1px solid #dce8fb;
  background: #fff;
}

.offcanvas .app-nav-link:hover,
.offcanvas .app-nav-link.active {
  color: #1d4aa0;
  border-color: #bcd2ff;
  background: #eaf2ff;
}

.app-subnav {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-soft);
  border-radius: var(--app-radius);
  padding: 1rem;
}

.app-pills {
  gap: 0.5rem;
  padding-bottom: 0.15rem;
}

.app-pills .nav-link {
  white-space: nowrap;
  border-radius: 999px;
  color: #2f4364;
  background: #eef4ff;
  border: 1px solid #dce8ff;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
}

.app-pills .nav-link.active {
  background: linear-gradient(90deg, #2f67ff 0%, #4b7eff 100%);
  border-color: transparent;
  color: #fff;
}

.app-subnav-modern {
  padding: 1.1rem 1.1rem 0.95rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.app-subnav-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-subnav-title {
  margin: 0;
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #1e293f;
}

.app-subnav-subtitle {
  margin: 0.2rem 0 0;
  color: #5f6b7a;
  font-size: 0.95rem;
}

.app-subnav-cta {
  border-radius: 14px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
}

.app-subnav-pills {
  scrollbar-width: thin;
  scrollbar-color: #c8d6ef transparent;
}

.app-subnav-pills::-webkit-scrollbar {
  height: 6px;
}

.app-subnav-pills::-webkit-scrollbar-thumb {
  background: #c8d6ef;
  border-radius: 999px;
}

.app-subnav-pills .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.52rem 0.88rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.app-subnav-pills .nav-link:hover {
  transform: translateY(-1px);
}

.app-page {
  display: grid;
  gap: 1rem;
}

.app-panel {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-soft);
  padding: 1rem;
}

.app-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
}

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

.app-form-shell {
  max-width: 680px;
  margin-inline: auto;
}

.app-form-shell-sm {
  max-width: 460px;
  margin-inline: auto;
}

.app-message-truncate {
  max-width: 150px;
}

.app-icon-xl {
  font-size: 3rem;
}

body[data-theme='dark'] {
  --app-bg-soft: #0d1324;
  --app-surface: #16213b;
  --app-surface-alt: #1a2746;
  --app-muted: #a7b6d1;
  --app-text: #e7efff;
  --app-border: #2b3d65;
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(58, 109, 255, 0.24), transparent 55%),
    radial-gradient(800px 500px at 90% 0%, rgba(106, 196, 255, 0.12), transparent 45%),
    linear-gradient(180deg, #090f1e 0%, #0c1325 100%);
}

body[data-theme='dark'] .app-navbar {
  background: rgba(15, 24, 44, 0.78);
  border-bottom-color: rgba(76, 102, 148, 0.6);
}

body[data-theme='dark'] .app-brand,
body[data-theme='dark'] .app-brand:hover,
body[data-theme='dark'] .app-brand:focus {
  color: #e7efff;
}

body[data-theme='dark'] .app-theme-toggle,
body[data-theme='dark'] .app-toggler {
  background: #1a2a4a;
  border-color: #355186;
  color: #d8e7ff;
}

body[data-theme='dark'] .app-profile-btn {
  background: #1a2a4a;
  border-color: #355186;
}

body[data-theme='dark'] .app-profile-btn:hover,
body[data-theme='dark'] .app-profile-btn:focus {
  background: #213963;
  border-color: #4c71b2;
}

body[data-theme='dark'] .app-avatar-fallback {
  color: #d9e7ff;
  background: linear-gradient(135deg, #355186 0%, #2b6eb0 100%);
}

body[data-theme='dark'] .app-profile-menu {
  background: #172744;
  border-color: #2d416b;
  color: #e7efff;
}

body[data-theme='dark'] .app-profile-chevron {
  color: #b7c9ea;
}

body[data-theme='dark'] .app-profile-menu .dropdown-divider {
  border-color: #2d416b;
}

body[data-theme='dark'] .app-profile-link {
  color: #dce8ff;
}

body[data-theme='dark'] .app-profile-link:hover,
body[data-theme='dark'] .app-profile-link:focus {
  background: #22365c;
  color: #ffffff;
}

body[data-theme='dark'] .app-theme-toggle:hover,
body[data-theme='dark'] .app-theme-toggle:focus,
body[data-theme='dark'] .app-toggler:hover,
body[data-theme='dark'] .app-toggler:focus {
  background: #213963;
  border-color: #4c71b2;
}

body[data-theme='dark'] .app-content-shell,
body[data-theme='dark'] .card,
body[data-theme='dark'] .app-subnav,
body[data-theme='dark'] .app-panel,
body[data-theme='dark'] .offcanvas.app-offcanvas {
  background: linear-gradient(180deg, #16213b 0%, #1b2948 100%);
  border-color: #2d416b;
  color: #e7efff;
}

body[data-theme='dark'] .card-header,
body[data-theme='dark'] .table thead th {
  background: #1c2c4d;
  color: #d7e5ff;
  border-color: #2d416b;
}

body[data-theme='dark'] .table {
  --bs-table-striped-bg: #1a2a49;
  --bs-table-hover-bg: #23355a;
  border-color: #2d416b;
  color: #e7efff;
}

body[data-theme='dark'] .text-muted,
body[data-theme='dark'] .app-subtitle,
body[data-theme='dark'] .app-subnav-subtitle {
  color: #a7b6d1 !important;
}

body[data-theme='dark'] .form-control,
body[data-theme='dark'] .form-select {
  background-color: #12203a;
  border-color: #324a79;
  color: #e8f0ff;
}

body[data-theme='dark'] .form-control::placeholder,
body[data-theme='dark'] .form-select::placeholder {
  color: #91a4c8;
}

body[data-theme='dark'] .form-control:focus,
body[data-theme='dark'] .form-select:focus {
  border-color: #5c86dd;
  box-shadow: 0 0 0 0.2rem rgba(92, 134, 221, 0.2);
}

body[data-theme='dark'] .app-pills .nav-link,
body[data-theme='dark'] .offcanvas .app-nav-link {
  background: #1a2c4d;
  color: #dce8ff;
  border-color: #334a79;
}

body[data-theme='dark'] .app-pills .nav-link.active,
body[data-theme='dark'] .offcanvas .app-nav-link.active,
body[data-theme='dark'] .offcanvas .app-nav-link:hover {
  background: linear-gradient(90deg, #315fcf 0%, #3e7ae2 100%);
  border-color: transparent;
  color: #fff;
}

body[data-theme='dark'] .app-footer {
  background: rgba(15, 24, 44, 0.75);
  border-top-color: #2d416b;
  color: #9fb2d8;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 991px) {
  .app-content-shell {
    border-radius: 18px;
    padding: 0.95rem;
  }
}

@media (max-width: 767px) {
  .app-subnav-title {
    font-size: 1.4rem;
  }

  .app-subnav-subtitle {
    font-size: 0.85rem;
  }

  .app-subnav-cta {
    width: 100%;
  }
}
