:root,
[data-bs-theme=light] {
  --bs-primary: #FEA01E;
  --bs-primary-rgb: 254, 160, 30;
  --bs-primary-text-emphasis: #8a5200;
  --bs-primary-bg-subtle: #fff3e0;
  --bs-primary-border-subtle: #ffd699;

  --bs-secondary: #3097D1;
  --bs-secondary-rgb: 48, 151, 209;
  --bs-secondary-text-emphasis: #145273;
  --bs-secondary-bg-subtle: #e4f3fb;
  --bs-secondary-border-subtle: #a9d5ec;

  --bs-link-color: #FEA01E;
  --bs-link-color-rgb: 254, 160, 30;
  --bs-link-hover-color: #e08c0f;
  --bs-link-hover-color-rgb: 224, 140, 15;
  --bs-focus-ring-color: rgba(254, 160, 30, 0.25);

  --bs-body-font-family: "Vazirmatn", sans-serif;
  --bs-font-sans-serif: "Vazirmatn", sans-serif;
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.6;
}

[data-bs-theme=dark] {
  --bs-primary: #FEA01E;
  --bs-primary-rgb: 254, 160, 30;
  --bs-primary-text-emphasis: #ffc766;
  --bs-primary-bg-subtle: #3a2808;
  --bs-primary-border-subtle: #8a5200;

  --bs-secondary: #3097D1;
  --bs-secondary-rgb: 48, 151, 209;
  --bs-secondary-text-emphasis: #7fc2e6;
  --bs-secondary-bg-subtle: #0d2c3d;
  --bs-secondary-border-subtle: #1c5c80;

  --bs-link-color: #FEA01E;
  --bs-link-hover-color: #ffb84a;
  --bs-link-color-rgb: 254, 160, 30;
  --bs-link-hover-color-rgb: 255, 184, 74;
}

/* Global Persian font + readable type scale */
html,
body,
button,
input,
select,
textarea,
.form-control,
.form-select,
.btn,
.menu,
.card,
.table,
.dropdown-menu,
.modal,
.alert,
.badge,
.app-sidebar,
.app-header,
.app-footer {
  font-family: "Vazirmatn", sans-serif !important;
}

/* Metronic defaults html/body to 13px (12px on mobile) — bump for Persian readability */
html,
body {
  font-size: 15px !important;
  line-height: 1.6;
}

@media (max-width: 991.98px) {
  html,
  body {
    font-size: 14px !important;
  }
}

/* Keep Metronic fs-* utilities proportional to the new root */
.fs-7 {
  font-size: 0.95rem !important;
}

.fs-6 {
  font-size: 1rem !important;
}

.fs-5 {
  font-size: 1.1rem !important;
}

.fs-4 {
  font-size: 1.2rem !important;
}

.fs-3 {
  font-size: 1.35rem !important;
}

.btn {
  font-size: 0.975rem !important;
}

.btn-sm {
  font-size: 0.9rem !important;
}

.form-control,
.form-select,
.form-control-solid,
.form-select-solid {
  font-size: 0.975rem !important;
}

.form-label,
label.fs-6 {
  font-size: 0.975rem !important;
}

.badge {
  font-size: 0.85rem !important;
}

.table {
  font-size: 0.975rem !important;
}

.table thead th {
  font-size: 0.95rem !important;
}

.page-heading {
  font-size: 1.35rem !important;
  line-height: 1.4;
}

.page-title .text-muted {
  font-size: 0.95rem !important;
  line-height: 1.55;
}

.btn-primary {
  --bs-btn-bg: #FEA01E;
  --bs-btn-border-color: #FEA01E;
  --bs-btn-hover-bg: #e08c0f;
  --bs-btn-hover-border-color: #e08c0f;
  --bs-btn-active-bg: #c97c0d;
  --bs-btn-active-border-color: #c97c0d;
  --bs-btn-disabled-bg: #FEA01E;
  --bs-btn-disabled-border-color: #FEA01E;
  --bs-btn-color: #ffffff;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-active-color: #ffffff;
}

.btn-secondary {
  --bs-btn-bg: #3097D1;
  --bs-btn-border-color: #3097D1;
  --bs-btn-hover-bg: #2784b8;
  --bs-btn-hover-border-color: #2784b8;
  --bs-btn-active-bg: #2173a0;
  --bs-btn-active-border-color: #2173a0;
  --bs-btn-disabled-bg: #3097D1;
  --bs-btn-disabled-border-color: #3097D1;
  --bs-btn-color: #ffffff;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-active-color: #ffffff;
}

.btn-light-primary {
  --bs-btn-color: #8a5200;
  --bs-btn-bg: #fff3e0;
  --bs-btn-border-color: #fff3e0;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: #FEA01E;
  --bs-btn-hover-border-color: #FEA01E;
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: #e08c0f;
  --bs-btn-active-border-color: #e08c0f;
}

.btn-light-secondary {
  --bs-btn-color: #145273;
  --bs-btn-bg: #e4f3fb;
  --bs-btn-border-color: #e4f3fb;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: #3097D1;
  --bs-btn-hover-border-color: #3097D1;
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: #2784b8;
  --bs-btn-active-border-color: #2784b8;
}

.btn-check:checked + .btn-light-primary,
.btn-check:active + .btn-light-primary,
.btn-light-primary:active,
.btn-light-primary.active {
  color: #ffffff !important;
  background-color: #FEA01E !important;
  border-color: #FEA01E !important;
}

.btn-check:checked + .btn-light-secondary,
.btn-check:active + .btn-light-secondary,
.btn-light-secondary:active,
.btn-light-secondary.active {
  color: #ffffff !important;
  background-color: #3097D1 !important;
  border-color: #3097D1 !important;
}

.text-primary {
  color: #FEA01E !important;
}

.text-secondary {
  color: #3097D1 !important;
}

.bg-primary {
  background-color: #FEA01E !important;
}

.bg-secondary {
  background-color: #3097D1 !important;
}

.bg-light-primary {
  background-color: #fff3e0 !important;
}

.bg-light-secondary {
  background-color: #e4f3fb !important;
}

.border-primary {
  border-color: #FEA01E !important;
}

.border-secondary {
  border-color: #3097D1 !important;
}

.badge-light-primary {
  color: #8a5200 !important;
  background-color: #fff3e0 !important;
}

.badge-light-info,
.badge-light-secondary {
  color: #145273 !important;
  background-color: #e4f3fb !important;
}

.link-primary {
  color: #FEA01E !important;
}

.link-primary:hover,
.link-primary:focus {
  color: #e08c0f !important;
}

.form-check-input:checked {
  background-color: #FEA01E;
  border-color: #FEA01E;
}

.form-control:focus,
.form-select:focus {
  border-color: #FEA01E;
  box-shadow: 0 0 0 0.25rem rgba(254, 160, 30, 0.25);
}

/* Sidebar layout */
@media (min-width: 992px) {
  :root {
    --bs-app-sidebar-width-actual: 280px;
  }

  body:not([data-kt-app-sidebar-minimize=on]) {
    --bs-app-sidebar-width: 280px;
  }

  [data-kt-app-sidebar-minimize=on] {
    --bs-app-sidebar-width: 75px;
  }
}

[data-kt-app-layout=light-sidebar] .app-sidebar {
  background-color: #E9EEF2 !important;
  border-inline-end: 1px solid rgba(18, 63, 90, 0.08) !important;
  border-right: 0 !important;
  box-shadow: none;
  overflow: visible;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .app-sidebar-logo {
  border-bottom: 1px solid rgba(18, 63, 90, 0.08) !important;
  padding-inline: 1.25rem !important;
  overflow: visible;
  position: relative;
}

.app-sidebar-logo-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}

.app-sidebar-logo-brand img.app-sidebar-logo-default {
  flex-shrink: 0;
  height: 34px;
  width: auto;
  display: block;
}

.app-sidebar-logo-brand .app-sidebar-logo-title {
  color: #123F5A !important;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  padding-top: 0.35rem;
  display: flex;
  align-items: center;
  white-space: normal;
  word-wrap: break-word;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .app-sidebar-toggle {
  z-index: 110;
  cursor: pointer;
  background-color: #ffffff !important;
  color: #3097D1 !important;
  border: 1px solid rgba(48, 151, 209, 0.35);
  box-shadow: 0 4px 12px rgba(18, 63, 90, 0.08);
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu {
  font-weight: 500;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-heading {
  color: #7e8b96 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  font-size: 0.9rem !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link {
  color: #123F5A !important;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link .menu-title {
  color: #123F5A !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  line-height: 1.45;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link .menu-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link .menu-icon .svg-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link .menu-icon i,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link .menu-icon .ki-duotone {
  color: #7e8b96 !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active),
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.hover > .menu-link:not(.active) {
  background-color: rgba(48, 151, 209, 0.1) !important;
  color: #3097D1 !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active) .menu-title,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.hover > .menu-link:not(.active) .menu-title {
  color: #3097D1 !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active) .menu-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active) .menu-icon .svg-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active) .menu-icon i,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link:hover:not(.active) .menu-icon .ki-duotone,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.hover > .menu-link:not(.active) .menu-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.hover > .menu-link:not(.active) .menu-icon .ki-duotone {
  color: #3097D1 !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.here > .menu-link {
  background-color: rgba(254, 160, 30, 0.12) !important;
  color: #FEA01E !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active .menu-title,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.here > .menu-link .menu-title {
  color: #FEA01E !important;
  font-weight: 700 !important;
}

[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active .menu-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active .menu-icon .svg-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active .menu-icon i,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item .menu-link.active .menu-icon .ki-duotone,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.here > .menu-link .menu-icon,
[data-kt-app-layout=light-sidebar] .app-sidebar .menu .menu-item.here > .menu-link .menu-icon .ki-duotone {
  color: #FEA01E !important;
}

/* Auth aside */
.auth-brand-aside {
  background-color: #123F5A;
  background-image:
    linear-gradient(160deg, rgba(18, 63, 90, 0.94) 0%, rgba(48, 151, 209, 0.55) 55%, rgba(254, 160, 30, 0.3) 100%),
    url("../assets/media/misc/auth-bg.png");
  background-size: cover;
  background-position: center;
}

/* Subtle logo watermark — avoid stacking contexts that break Bootstrap modals */
#kt_app_content {
  position: relative;
}

#kt_app_content::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("../images/logo.png");
  background-repeat: no-repeat;
  background-position: center 42%;
  background-size: min(28rem, 52vw);
  opacity: 0.055;
}

.auth-form-pane {
  position: relative;
}

.auth-form-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("../images/logo.png");
  background-repeat: no-repeat;
  background-position: center 38%;
  background-size: min(18rem, 55vw);
  opacity: 0.05;
}

/* Header / toolbar / footer */
.app-header {
  border-bottom: 1px solid rgba(18, 63, 90, 0.08);
}

.app-toolbar {
  border-bottom: 1px solid rgba(18, 63, 90, 0.06);
}

.app-header-mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.app-header-mobile-brand span {
  color: #123F5A;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.page-heading {
  color: #123F5A !important;
  font-family: "Vazirmatn", sans-serif !important;
}

.app-footer {
  border-top: 1px solid rgba(18, 63, 90, 0.08);
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-footer .app-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-footer .app-footer-copyright,
.auth-footer-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #7e8b96;
  text-align: center !important;
  width: 100%;
  margin: 0 auto;
}

.card .card-header {
  border-bottom-color: rgba(18, 63, 90, 0.08);
}

.card-header.border-0.pt-6 > .card-title > h2,
.card-header.border-0.pt-6 > .card-title > h3,
.card-header.border-0.pt-6 > .card-title > .card-label {
  color: #123F5A;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0;
}

.card-toolbar .btn.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.card-footer {
  border-top-color: rgba(18, 63, 90, 0.08);
  background-color: transparent;
}

.page-meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  border-radius: 0.475rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #145273 !important;
  background-color: #e4f3fb !important;
}

.modal-header h2,
.modal-header .modal-title {
  color: #123F5A;
  font-size: 1.2rem !important;
  font-weight: 700;
}

.table thead th {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 700 !important;
  color: #5e6a74 !important;
  vertical-align: middle;
}

.table tbody td {
  vertical-align: middle;
  font-size: 0.975rem;
}

.nav-line-tabs .nav-item .nav-link.active {
  border-bottom-color: #FEA01E !important;
  color: #FEA01E !important;
}

/* Select2 (Metronic) brand alignment */
.select2-container--bootstrap5 .select2-selection {
  font-family: "Vazirmatn", sans-serif !important;
}

.select2-container--bootstrap5 .select2-selection--single {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.select2-container--bootstrap5 .select2-selection--single .select2-selection__rendered {
  color: #123F5A;
  font-size: 0.975rem;
  font-weight: 500;
  padding-inline: 1rem;
  line-height: 1.5;
}

.select2-container--bootstrap5 .select2-results__option {
  font-size: 0.975rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.select2-container--bootstrap5 .select2-dropdown {
  border-color: #FEA01E;
  font-family: "Vazirmatn", sans-serif !important;
}

.select2-container--bootstrap5 .select2-results__option--highlighted {
  background-color: #FEA01E !important;
  color: #ffffff !important;
}

.select2-container--bootstrap5.select2-container--focus .select2-selection,
.select2-container--bootstrap5.select2-container--open .select2-selection {
  border-color: #FEA01E !important;
  box-shadow: 0 0 0 0.25rem rgba(254, 160, 30, 0.25) !important;
}

.select2-container--bootstrap5 .select2-search__field:focus {
  border-color: #FEA01E !important;
  box-shadow: 0 0 0 0.25rem rgba(254, 160, 30, 0.25) !important;
}

.select2-container--bootstrap5 .select2-selection--single .select2-selection__placeholder {
  color: #a1a5b7;
}

/* User account menu logout alignment */
.menu-sub-dropdown .btn.menu-link {
  justify-content: flex-start;
  text-align: start;
}

/* Jalali datepicker (Metronic + brand) */
jdp-container {
  --jdp-primary: #FEA01E;
  --jdp-color-0: #ffffff;
  --jdp-color-1: #f5f8fa;
  --jdp-color-2: #e4e6ef;
  --jdp-color-3: #b5b5c3;
  --jdp-color-4: #7e8299;
  --jdp-color-5: #123F5A;
  --jdp-red: #f1416c;
  font-family: "Vazirmatn", sans-serif !important;
  border-radius: 0.625rem !important;
  box-shadow: 0 8px 24px rgba(18, 63, 90, 0.12) !important;
  border: 1px solid rgba(18, 63, 90, 0.08);
  z-index: 11000 !important;
}

jdp-container .jdp-day,
jdp-container .jdp-day-name,
jdp-container .jdp-year,
jdp-container .jdp-month,
jdp-container .jdp-btn-today,
jdp-container .jdp-btn-empty,
jdp-container .jdp-btn-close {
  font-family: "Vazirmatn", sans-serif !important;
}

jdp-container .jdp-btn-today,
jdp-container .jdp-btn-empty,
jdp-container .jdp-btn-close {
  background: #FEA01E !important;
  color: #ffffff !important;
  font-weight: 600;
}

jdp-container .jdp-btn-empty {
  background: #e4f3fb !important;
  color: #145273 !important;
}

jdp-container .jdp-day.selected {
  background-color: #FEA01E !important;
}

/* Avoid native year <select> exploding off-screen; years use +/- controls */
jdp-container .jdp-year input {
  max-width: 4.5rem;
  font-weight: 700;
  font-size: 1rem !important;
}

jdp-container .jdp-years,
jdp-container .jdp-months {
  align-items: center;
}

jdp-container .jdp-day.today {
  border-color: #3097D1 !important;
}

jdp-container .jdp-day:not(.disabled-day):hover {
  background: rgba(254, 160, 30, 0.18) !important;
}

input[data-jdp] {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M8 2v3M16 2v3M3.5 9h17M5 5h14a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2Z' stroke='%237e8299' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  padding-inline-start: 1rem;
  padding-inline-end: 2.75rem;
}

[dir="rtl"] input[data-jdp],
html[lang="fa"] input[data-jdp] {
  background-position: right 1rem center;
  padding-inline-start: 2.75rem;
  padding-inline-end: 1rem;
}

/* Metronic table headers should stay sentence-case for Persian */
.table thead th.text-uppercase {
  text-transform: none !important;
  letter-spacing: 0 !important;
}

/* ApexCharts: prevent stretched x-axis tooltip / mis-sized overlays in RTL */
[dir="rtl"] .apexcharts-canvas,
html[dir="rtl"] .apexcharts-canvas {
  direction: ltr;
}

.apexcharts-tooltip {
  direction: rtl;
  text-align: right;
  max-width: 280px;
  white-space: normal;
}

/* Metronic incorrectly sets background to the box-shadow CSS variable */
.apexcharts-xaxistooltip.apexcharts-theme-light {
  background: #fff !important;
  border: 1px solid #e4e6ef !important;
  box-shadow: 0 0.5rem 1.5rem 0.5rem rgba(0, 0, 0, 0.075) !important;
  color: #181c32 !important;
  max-width: max-content;
  white-space: nowrap;
}

#kt_reports_savings_trend,
#kt_reports_allocation_trend,
#kt_reports_status_by_company,
#kt_reports_count_by_company {
  overflow: hidden;
  direction: ltr;
}

/* Reports page: Metronic spacing + readable KPI labels */
.kt-reports-page .card .card-label {
  font-size: 1.15rem !important;
  line-height: 1.45;
}

.kt-reports-page .card .symbol-label .ki-duotone {
  line-height: 1;
}

.kt-reports-page .card-header {
  min-height: auto;
}

.kt-reports-page .fs-2x {
  font-size: 1.65rem !important;
  letter-spacing: -0.02em;
}

.apexcharts-legend-text,
.apexcharts-text,
.apexcharts-tooltip,
.apexcharts-tooltip-title,
.apexcharts-xaxis text,
.apexcharts-yaxis text {
  font-family: "Vazirmatn", sans-serif !important;
}

.apexcharts-legend {
  padding: 0 !important;
}

.apexcharts-tooltip.apexcharts-theme-light {
  border: 1px solid #e4e6ef !important;
  box-shadow: 0 0.5rem 1.5rem 0.5rem rgba(0, 0, 0, 0.075) !important;
  border-radius: 0.475rem !important;
}
