:root {
  --app-primary: #1f5f8b;
  --app-primary-dark: #174967;
  --app-surface: #ffffff;
  --app-background: #f3f6f9;
  --app-border: #dce3e8;
  --app-radius: 12px;
  --app-shadow: 0 4px 18px rgba(31, 45, 61, 0.08);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--app-background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overflow-x: hidden;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 123, 255, 0.3);
  outline-offset: 2px;
}

.main-header {
  min-height: 56px;
  border-bottom: 1px solid var(--app-border);
}

.main-header .nav-link,
.main-header .btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content-wrapper {
  overflow-x: hidden;
  background: var(--app-background);
}

.content-header {
  padding-top: 12px;
  padding-bottom: 8px;
}

.card,
.small-box {
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  overflow: hidden;
}

.card-header {
  border-bottom-color: var(--app-border);
}

.card-title {
  line-height: 1.45;
}

.btn {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 600;
}

.btn-sm {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.form-control,
.custom-select,
.select2-container .select2-selection--single {
  min-height: 42px;
  border-radius: 8px;
  border-color: #cbd5dc;
}

textarea.form-control {
  min-height: 96px;
}

.select2-container {
  width: 100% !important;
}

.select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
}

.select2-container .select2-selection--single .select2-selection__arrow {
  height: 40px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

.table-responsive > .table {
  margin-bottom: 0;
}

.table td,
.table th {
  vertical-align: middle;
}

.table td:last-child .btn {
  margin: 2px;
}

.dataTables_wrapper .row {
  align-items: center;
}

.dataTables_wrapper .dataTables_filter input {
  min-height: 40px;
  border: 1px solid #cbd5dc;
  border-radius: 8px;
  padding: 6px 10px;
}

.dataTables_wrapper .dt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-content {
  border: 0;
  border-radius: var(--app-radius);
  box-shadow: 0 16px 45px rgba(31, 45, 61, 0.22);
}

.main-footer {
  border-top-color: var(--app-border);
}

.login-page {
  min-height: 100dvh;
  padding: 20px;
  background: linear-gradient(145deg, #eef4f8 0%, #dce9f1 100%);
}

.login-box {
  width: min(100%, 400px);
}

.login-box .card {
  border-radius: 16px;
}

@media (max-width: 767.98px) {
  .main-header {
    padding-inline: 8px;
  }

  .main-header .navbar-nav .nav-link {
    padding-inline: 12px;
  }

  .content-header,
  .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .content .container-fluid {
    padding-left: 0;
    padding-right: 0;
  }

  .card {
    margin-bottom: 14px;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .card-header .card-title,
  .card-header .float-right {
    float: none !important;
  }

  .card-header .float-right {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
  }

  .form-control,
  .custom-select,
  .select2-search__field {
    font-size: 16px !important;
  }

  .form-group.row > label {
    padding-bottom: 5px;
  }

  .table-responsive > .table:not(.table-compact-mobile) {
    min-width: 680px;
  }

  .dataTables_wrapper > .row:first-child > div,
  .dataTables_wrapper > .row:last-child > div {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    text-align: left !important;
    margin-bottom: 8px;
  }

  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_filter label,
  .dataTables_wrapper .dataTables_filter input {
    display: block;
    width: 100% !important;
    margin-left: 0;
  }

  .dataTables_wrapper .pagination {
    flex-wrap: wrap;
    justify-content: center !important;
  }

  .modal-dialog {
    margin: 10px;
    min-height: calc(100dvh - 20px);
    display: flex;
    align-items: center;
  }

  .modal-content {
    max-height: calc(100dvh - 20px);
  }

  .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .small-box .inner h3 {
    font-size: clamp(1.35rem, 6vw, 2rem);
    overflow-wrap: anywhere;
  }

  .main-footer {
    padding: 14px 12px;
    text-align: center;
  }
}

@media (max-width: 575.98px) {
  .dashboard-stat {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .btn-mobile-block {
    width: 100%;
  }

  .login-page {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
