:root {
  --lg-primary-start: #2B73A3;
  --lg-primary-end: #46BCA6;
  --lg-primary-gradient: linear-gradient(135deg, var(--lg-primary-start) 0%, var(--lg-primary-end) 100%);
  --lg-primary-gradient-v: linear-gradient(180deg, var(--lg-primary-start) 0%, var(--lg-primary-end) 100%);
  --lg-sidebar-active: rgba(255, 255, 255, 0.18);
  --lg-white: #ffffff;
  --lg-font-base: 0.875rem;
}

/* ========== Typography — taille pro ========== */
body {
  font-size: var(--lg-font-base);
}

.title-wrapper .title h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-style h6,
.icon-card h6 {
  font-size: 0.95rem;
  font-weight: 600;
}

.main-btn,
.btn {
  font-size: 0.8125rem;
}

.table {
  font-size: 0.8125rem;
}

.form-control,
.form-select {
  font-size: 0.8125rem;
}

.breadcrumb {
  font-size: 0.8125rem;
}

.input-style-1 label {
  font-size: 0.8125rem;
}

.header .header-right .profile-box .profile-info .info h6 {
  font-size: 0.875rem;
  margin-bottom: 0;
}

.header .header-right .profile-box .profile-info .info p {
  font-size: 0.75rem;
  margin-bottom: 0;
}

.sidebar-brand-text {
  font-size: 1.35rem !important;
}

.alert {
  font-size: 0.8125rem;
}

/* ========== Header avatar ========== */
.lg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lg-primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.lg-avatar-sm {
  width: 28px;
  height: 28px;
}

.lg-avatar-initials {
  color: var(--lg-white);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.header .header-right .profile-box .profile-info .info .image.lg-avatar {
  max-width: 40px;
  margin-right: 0;
}

/* ========== Primary buttons & accents ========== */
.main-btn.primary-btn,
.primary-btn,
.btn-primary {
  background: var(--lg-primary-gradient) !important;
  border: none !important;
  color: var(--lg-white) !important;
  transition: transform 0.2s ease, box-shadow 0.25s ease, opacity 0.2s ease;
}

.main-btn.primary-btn:hover,
.primary-btn:hover,
.btn-primary:hover {
  color: var(--lg-white) !important;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(43, 115, 163, 0.35);
  opacity: 0.95;
}

.primary-btn-outline {
  color: var(--lg-primary-start) !important;
  border-color: var(--lg-primary-start) !important;
}

.primary-btn-outline:hover {
  background: var(--lg-primary-gradient) !important;
  color: var(--lg-white) !important;
}

.primary-btn-light {
  background: rgba(43, 115, 163, 0.12) !important;
  color: var(--lg-primary-start) !important;
}

.text-primary,
.login-kicker {
  color: var(--lg-primary-start) !important;
}

.icon-card .icon.primary {
  background: var(--lg-primary-gradient) !important;
  color: var(--lg-white) !important;
}

/* ========== Sidebar gradient ========== */
.sidebar-nav-wrapper {
  background: var(--lg-primary-gradient-v) !important;
  box-shadow: 0 0 30px rgba(43, 115, 163, 0.25) !important;
}

.sidebar-brand-text {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--lg-white);
  letter-spacing: 0.02em;
}

.sidebar-nav-wrapper .navbar-logo {
  margin-bottom: 2rem;
}

.sidebar-nav-wrapper .sidebar-nav .divider hr {
  background: rgba(255, 255, 255, 0.25) !important;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item a,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children > a,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children > a.collapsed {
  color: rgba(255, 255, 255, 0.85) !important;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item a .icon,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children > a .icon {
  color: var(--lg-white) !important;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item.active > a,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item.active > a.collapsed,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item:hover > a,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item:hover > a.collapsed {
  color: var(--lg-white) !important;
  background: var(--lg-sidebar-active);
  border-radius: 8px;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item.active > a .icon,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item:hover > a .icon {
  color: var(--lg-white) !important;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children ul li a {
  color: rgba(255, 255, 255, 0.8) !important;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children ul li a.active,
.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children ul li a:hover {
  color: var(--lg-white) !important;
  font-weight: 600;
}

.sidebar-nav-wrapper .sidebar-nav ul .nav-item.nav-item-has-children > a::after {
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

/* ========== Modals & cards animations ========== */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal.show .modal-dialog {
  animation: lg-fade-flow 0.35s ease;
}

.card-style,
.icon-card {
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card-style:hover,
.icon-card:hover {
  box-shadow: 0 8px 24px rgba(43, 115, 163, 0.1);
}

@keyframes lg-fade-flow {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes lg-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: lg-fade-in-up 0.5s ease forwards;
}

/* ========== Login page ========== */
.auth-body {
  background: #f4f6f8;
  min-height: 100vh;
}

.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.auth-body .login-page .login-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  align-items: stretch;
  width: 100%;
  max-width: 920px;
  min-height: min(560px, calc(100vh - 3rem));
  background: var(--lg-white);
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.auth-body .login-page .login-side {
  display: none;
  min-height: 0;
  background-color: #2b73a3;
  background-image: var(--login-side-image);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-body .login-page .login-card {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  width: 100%;
  background: var(--lg-white);
  padding: 2.5rem 2.75rem 2.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 768px) {
  .auth-body .login-page .login-layout {
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  }

  .auth-body .login-page .login-side {
    display: block;
    grid-column: 1;
    grid-row: 1;
    min-height: 520px;
  }

  .auth-body .login-page .login-card {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 767.98px) {
  .auth-body .login-page .login-side {
    display: none !important;
  }
}

.login-brand--mobile {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #e9eef1;
}

@media (min-width: 768px) {
  .login-brand--mobile {
    display: none;
  }
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--lg-primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lg-white);
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.login-brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: #1a2142;
}

.login-brand-sub {
  font-size: 0.8rem;
  color: #6c757d;
  margin: 0.15rem 0 0;
}

.login-form-head h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1.75rem;
  color: #5d657b;
  text-align: center;
}

.login-form-head p {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 1.25rem;
}

.login-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-field {
  margin-bottom: 1.1rem;
}

.login-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a2142;
  margin-bottom: 0.4rem;
}

.login-field input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-field input:focus {
  outline: none;
  border-color: var(--lg-primary-start);
  box-shadow: 0 0 0 3px rgba(43, 115, 163, 0.15);
}

.login-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 10px !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.login-alert {
  margin-bottom: 1rem;
  border-radius: 8px;
  animation: lg-fade-in-up 0.3s ease;
}

/* ========== Charts ========== */
.chart-box {
  position: relative;
  height: 280px;
  max-height: 320px;
  overflow: hidden;
}

.chart-box canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* ========== Confirm modal ========== */
#lgConfirmModal .modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(43, 115, 163, 0.18);
}

#lgConfirmModal .modal-title {
  font-size: 1rem;
  color: #1a2142;
}

#lgConfirmModal .modal-body p {
  font-size: 0.875rem;
  line-height: 1.5;
}

.bc-qty-input.is-invalid {
  border-color: #dc3545;
}

/* ========== Tableaux listes ========== */
.table .col-num {
  width: 3rem;
  text-align: center;
  color: #6c757d;
  font-variant-numeric: tabular-nums;
}

.table .col-actions {
  width: 3.5rem;
  text-align: center;
  white-space: nowrap;
}

.table-entity-link {
  color: var(--lg-primary-start, #2B73A3);
  font-weight: 600;
  text-decoration: none;
}

.table-entity-link:hover {
  color: var(--lg-primary-end, #46BCA6);
  text-decoration: underline;
}

.btn.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
}

.btn-action-view {
  color: var(--lg-primary-start, #2B73A3);
  background: rgba(43, 115, 163, 0.08);
  border-color: rgba(43, 115, 163, 0.15);
}

.btn-action-view:hover {
  color: #fff;
  background: var(--lg-primary-start, #2B73A3);
}

.btn-action-edit {
  color: #6f42c1;
  background: rgba(111, 66, 193, 0.08);
  border-color: rgba(111, 66, 193, 0.15);
}

.btn-action-edit:hover {
  color: #fff;
  background: #6f42c1;
}

.btn.btn-icon.text-danger {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.08);
  border-color: rgba(220, 53, 69, 0.15);
}

.btn.btn-icon.text-danger:hover {
  color: #fff;
  background: #dc3545;
}

/* ========== Formulaires create centrés ========== */
.form-page-centered {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.form-page-centered .card-style h6 {
  margin-bottom: 1rem;
}

.form-page-centered textarea.form-control {
  min-height: auto;
}

.form-page-centered .validation-step-row {
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.form-page-centered #validation-steps-section p.text-muted {
  font-size: 0.78rem;
  line-height: 1.35;
}

.form-compact-lines .table {
  font-size: 0.78rem;
}

.form-compact-lines .table th,
.form-compact-lines .table td {
  padding: 0.35rem 0.4rem;
  vertical-align: middle;
}

.grand-total-dual {
  font-weight: 600;
  line-height: 1.4;
}

/* ========== Theme toggle ========== */
.theme-toggle-btn {
  border: none;
  background: rgba(43, 115, 163, 0.1);
  color: var(--lg-primary-start);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: rgba(43, 115, 163, 0.18);
}

.theme-toggle-btn i {
  font-size: 1.15rem;
}

.theme-toggle-btn--login {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
}

.header.is-scrolled {
  box-shadow: 0 0 30px rgba(200, 208, 216, 0.3);
}

/* ========== Dark theme overrides ========== */
[data-bs-theme="dark"] body {
  background: #0f172a;
  color: #cbd5e1;
}

[data-bs-theme="dark"] .auth-body {
  background: #0f172a;
}

[data-bs-theme="dark"] .card-style,
[data-bs-theme="dark"] .icon-card {
  background: #1e293b;
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.35), 0 0 2px 0 rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

[data-bs-theme="dark"] .card-style:hover,
[data-bs-theme="dark"] .icon-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* Headings & labels (main.css uses #1A2142 — must override in dark) */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6,
[data-bs-theme="dark"] .h1,
[data-bs-theme="dark"] .h2,
[data-bs-theme="dark"] .h3,
[data-bs-theme="dark"] .h4,
[data-bs-theme="dark"] .h5,
[data-bs-theme="dark"] .h6 {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .main-wrapper p,
[data-bs-theme="dark"] .card-style p,
[data-bs-theme="dark"] .modal-body p {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .text-dark {
  color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .input-style-1 label,
[data-bs-theme="dark"] .input-style-2 label,
[data-bs-theme="dark"] .input-style-3 label,
[data-bs-theme="dark"] .select-style-1 label,
[data-bs-theme="dark"] .select-style-2 label,
[data-bs-theme="dark"] .form-label {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .input-style-1 input,
[data-bs-theme="dark"] .input-style-1 textarea,
[data-bs-theme="dark"] .input-style-2 input,
[data-bs-theme="dark"] .input-style-2 textarea,
[data-bs-theme="dark"] .input-style-3 input,
[data-bs-theme="dark"] .input-style-3 textarea {
  background: rgba(15, 23, 42, 0.85);
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .input-style-1 input:focus,
[data-bs-theme="dark"] .input-style-1 textarea:focus,
[data-bs-theme="dark"] .input-style-2 input:focus,
[data-bs-theme="dark"] .input-style-2 textarea:focus,
[data-bs-theme="dark"] .input-style-3 input:focus,
[data-bs-theme="dark"] .input-style-3 textarea:focus {
  background: #1e293b;
  border-color: var(--lg-primary-end, #46bca6);
}

[data-bs-theme="dark"] .input-style-1 input.light-bg,
[data-bs-theme="dark"] .input-style-1 textarea.light-bg,
[data-bs-theme="dark"] .input-style-2 input.light-bg,
[data-bs-theme="dark"] .input-style-2 textarea.light-bg,
[data-bs-theme="dark"] .input-style-3 input.light-bg,
[data-bs-theme="dark"] .input-style-3 textarea.light-bg {
  background: rgba(15, 23, 42, 0.85);
}

[data-bs-theme="dark"] .input-style-1 input.light-bg:focus,
[data-bs-theme="dark"] .input-style-1 textarea.light-bg:focus,
[data-bs-theme="dark"] .input-style-2 input.light-bg:focus,
[data-bs-theme="dark"] .input-style-2 textarea.light-bg:focus,
[data-bs-theme="dark"] .input-style-3 input.light-bg:focus,
[data-bs-theme="dark"] .input-style-3 textarea.light-bg:focus {
  background: #1e293b;
}

[data-bs-theme="dark"] .select-style-1 .select-position select,
[data-bs-theme="dark"] .select-style-2 .select-position select {
  background: rgba(15, 23, 42, 0.85);
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .select-style-1 .select-position select.light-bg,
[data-bs-theme="dark"] .select-style-2 .select-position select.light-bg {
  background: rgba(15, 23, 42, 0.85);
}

[data-bs-theme="dark"] .select-style-1 .select-position select.light-bg:focus,
[data-bs-theme="dark"] .select-style-2 .select-position select.light-bg:focus {
  background: #1e293b;
}

[data-bs-theme="dark"] .select-style-1 .select-position::after,
[data-bs-theme="dark"] .select-style-2 .select-position::before,
[data-bs-theme="dark"] .select-style-2 .select-position::after {
  border-color: #94a3b8;
}

[data-bs-theme="dark"] .form-check-label {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .header {
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .header.is-scrolled {
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .header .header-left .header-search form input {
  background: rgba(15, 23, 42, 0.6);
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .header .header-left .header-search form input:focus {
  background: #0f172a;
  border-color: var(--lg-primary-end);
}

[data-bs-theme="dark"] .header .header-right button svg path {
  fill: #cbd5e1;
}

[data-bs-theme="dark"] .header .header-right .profile-box .profile-info .info h6 {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .header .header-right .profile-box .profile-info .info p {
  color: #94a3b8;
}

[data-bs-theme="dark"] .title-wrapper .title h2 {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .breadcrumb-item,
[data-bs-theme="dark"] .breadcrumb-item a {
  color: #94a3b8;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .text-muted {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .login-layout {
  background: #1e293b;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .login-card {
  background: #1e293b;
  box-shadow: none;
}

[data-bs-theme="dark"] .login-brand {
  border-bottom-color: #334155;
}

[data-bs-theme="dark"] .login-brand-title,
[data-bs-theme="dark"] .login-form-head h2 {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .login-brand-sub,
[data-bs-theme="dark"] .login-form-head p {
  color: #94a3b8;
}

[data-bs-theme="dark"] .login-field label {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .login-field input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .theme-toggle-btn {
  background: rgba(70, 188, 166, 0.15);
  color: #7dd3c0;
}

[data-bs-theme="dark"] .theme-toggle-btn:hover {
  background: rgba(70, 188, 166, 0.25);
}

[data-bs-theme="dark"] .form-page-centered .validation-step-row {
  background: #0f172a;
}

[data-bs-theme="dark"] .main-wrapper .footer {
  color: #94a3b8;
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: #334155;
}

[data-bs-theme="dark"] .table thead th {
  color: #94a3b8;
}

[data-bs-theme="dark"] .modal-content {
  background: #1e293b;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  border-color: #334155;
}

[data-bs-theme="dark"] #lgConfirmModal .modal-title {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .btn-link:not(.table-entity-link) {
  color: #7dd3c0;
}
