:root {
  --bg: #f1f5f2;
  --bg-accent: #e4ebe5;
  --surface: #ffffff;
  --surface-soft: #f7faf7;
  --border: #d4ddd6;
  --text: #1a2e22;
  --muted: #5a7262;
  --primary: #1a7a42;
  --primary-deep: #145e33;
  --success: #1a7a42;
  --warning: #c48a1a;
  --danger: #c43b3b;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-soft: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card: 0 10px 25px rgba(0,0,0,0.08);
  --sidebar-bg: #112118;
  --sidebar-text: #b4ccbc;
  --sidebar-active: rgba(34,160,80,0.18);
  --topbar-height: 56px;
}

html,
body {
  min-height: 100%;
}

body.public-shell {
  font-family: "Manrope", "Segoe UI", sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

main {
  position: relative;
}

body.is-search-loading .app-main-col {
  opacity: 0.78;
  pointer-events: none;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: row;
}

.app-shell-body {
  flex: 1;
  min-height: 0;
}

.app-right-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main-pad {
  padding: 0.95rem 1rem 1rem;
  flex: 1;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand {
  font-family: "Manrope", "Segoe UI", sans-serif;
  letter-spacing: 0.005em;
  font-weight: 700;
}

.text-muted,
small,
.small {
  color: var(--muted) !important;
}

.app-topbar {
  border: none !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 0 !important;
  position: sticky;
  top: 0;
  left: 0;
  z-index: 1030;
  min-height: var(--topbar-height);
}

.app-sidebar-card {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--sidebar-bg) !important;
  box-shadow: none !important;
  overflow: hidden;
  min-height: 100%;
  max-height: 100vh;
  overflow-y: auto;
}

.app-sidebar-col {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  padding-left: 0;
  padding-right: 0;
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  z-index: 1040;
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

.app-sidebar-nav {
  gap: 0;
  padding: 0.55rem;
  background: var(--sidebar-bg);
}

.app-sidebar-link {
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  margin-bottom: 0.2rem;
  padding: 0.55rem 0.75rem 0.55rem 0.85rem;
  font-weight: 500;
  color: #ffffff;
  background: transparent;
  transition: none;
  font-size: 0.875rem;
}

.app-sidebar-link:last-child {
  margin-bottom: 0;
}

.app-sidebar-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 1.1rem;
  margin-right: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar-icon svg {
  width: 100%;
  height: 100%;
}

.app-sidebar-text {
  white-space: nowrap;
}

.app-sidebar-link::before {
  content: none;
}

.app-sidebar-toggle {
  min-width: 2rem;
  padding: 0.18rem 0.35rem;
  border-radius: 8px;
  line-height: 1;
  color: #ffffff;
  border-color: rgba(255,255,255,0.15);
}

.app-sidebar-toggle:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.app-sidebar-toggle-open,
.app-sidebar-toggle-close {
  font-size: 0.95rem;
}

.app-shell:not(.sidebar-collapsed) .app-sidebar-toggle-open {
  display: none;
}

.app-shell.sidebar-collapsed .app-sidebar-toggle-close {
  display: none;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus {
  border-color: transparent !important;
  background: rgba(255,255,255,0.08) !important;
  color: #ffffff;
  transform: none;
}

.app-sidebar-link:focus-visible {
  outline: 2px solid rgba(34, 160, 80, 0.5);
  outline-offset: 1px;
}

.app-sidebar-link.active,
.app-sidebar-link.active:hover,
.app-sidebar-link.active:focus {
  border-color: transparent !important;
  background: var(--sidebar-active) !important;
  color: #ffffff !important;
  box-shadow: none;
  transform: translateX(0);
  font-weight: 600;
  border-left: 3px solid #22a050 !important;
}

.app-sidebar-link.active::before {
  content: none;
}

.app-sidebar-link.active .app-sidebar-icon,
.app-sidebar-link.active .app-sidebar-icon svg {
  color: #3be078;
}

.app-shell.sidebar-collapsed .app-sidebar-title {
  display: none;
}

.app-shell.sidebar-collapsed .app-sidebar-nav {
  padding: 0.45rem;
}

.app-shell.sidebar-collapsed .app-sidebar-link {
  justify-content: center;
  padding: 0.62rem 0.45rem;
}

.app-shell.sidebar-collapsed .app-sidebar-link::before,
.app-shell.sidebar-collapsed .app-sidebar-text {
  display: none;
}

.app-shell.sidebar-collapsed .app-sidebar-icon {
  margin-right: 0;
}

.app-sidebar-card .card-header {
  border-bottom: none;
  background: var(--sidebar-bg);
  color: #7a9b84;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
  padding: 0.75rem 0.95rem;
}

.app-sidebar-nav .list-group-item {
  border: none !important;
  color: #ffffff !important;
}

.app-sidebar-card,
.app-sidebar-card .card-header,
.app-sidebar-card .app-sidebar-nav {
  background-color: var(--sidebar-bg) !important;
}

/* ── Table sorting ── */
.sortable-th {
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}

.sortable-th:hover {
  background: rgba(0,0,0,0.04);
}

/* ── Clickable table rows ── */
tr[role="button"] {
  cursor: pointer;
}

tr[role="button"]:hover > td {
  background-color: rgba(26, 122, 66, 0.05);
}

tr[role="button"]:focus-visible {
  outline: 2px solid rgba(26, 122, 66, 0.4);
  outline-offset: -2px;
}

/* ── Card links (settings / reports grids) ── */
a.text-decoration-none > .card {
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

a.text-decoration-none:hover > .card {
  border-color: #6db88a;
  box-shadow: 0 4px 12px rgba(26, 122, 66, 0.1);
}

a.text-decoration-none:focus-visible > .card {
  outline: 2px solid rgba(26, 122, 66, 0.4);
  outline-offset: 2px;
}

.sort-indicator {
  font-size: 0.7em;
  opacity: 0.7;
  margin-left: 2px;
}

.sortable-th:not(.sort-asc):not(.sort-desc):hover .sort-indicator::after {
  content: " ⇅";
  font-size: 0.85em;
  opacity: 0.4;
}

/* ── Global sidebar search ── */
.app-global-search-wrap {
  padding-top: 0.35rem;
}

.app-global-search-wrap .form-control {
  border-radius: 8px;
  font-size: 0.875rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ddeee2;
  padding: 0.45rem 0.65rem;
}

.app-global-search-wrap .form-control::placeholder {
  color: #7a9b84;
}

.app-global-search-wrap .form-control:focus {
  background: rgba(255,255,255,0.15);
  border-color: #22a050;
  color: #ffffff;
  box-shadow: none;
}

.app-global-search-results {
  position: fixed;
  z-index: 1050;
  min-width: 680px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 420px;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

.gs-group {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}

.gs-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.gs-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.75rem 0.2rem;
  letter-spacing: 0.04em;
}

.gs-item {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-item:hover {
  background: #f1f5f9;
  color: var(--primary-deep);
}

.gs-empty {
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  color: #888;
}

.app-shell.sidebar-collapsed .app-global-search-wrap {
  display: none;
}

@media (min-width: 768px) {
  .app-sidebar-col {
    width: 190px;
    max-width: 190px;
    flex: 0 0 190px;
  }

  .app-shell.sidebar-collapsed .app-sidebar-col {
    width: 56px;
    max-width: 56px;
    flex: 0 0 56px;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.card-header {
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  background: var(--surface-soft);
  font-weight: 700;
}

.list-group-item {
  border-color: var(--border);
  color: var(--text);
}

.list-group-item.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn {
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--primary-deep);
  background: var(--primary-deep);
}

.btn-outline-primary {
  border-color: #6db88a;
  color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  border-color: var(--primary);
  background: rgba(26, 122, 66, 0.08);
  color: var(--primary-deep);
}

.btn-outline-secondary {
  border-color: #cbd5e1;
  color: #475569;
}

.btn-outline-danger {
  border-color: #fca5a5;
  color: #dc2626;
}

.btn-outline-success {
  border-color: #6db88a;
  color: #1a7a42;
}

.form-label {
  margin-bottom: 0.35rem;
  color: #334155;
  font-weight: 600;
}

.form-control,
.form-select,
textarea.form-control {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  box-shadow: none;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 0.2rem rgba(26, 122, 66, 0.15);
}

input[type="date"].form-control,
input[type="date"].form-select,
input[type="date"] {
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  min-height: calc(1.5em + 0.75rem + 2px);
}

input[type="date"]:hover {
  border-color: #6db88a;
}

input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(26, 122, 66, 0.15);
}

input[type="date"]::-webkit-datetime-edit {
  color: var(--text);
  font-weight: 600;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 4px;
  background-color: rgba(26, 122, 66, 0.1);
  transition: background-color 0.15s ease;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator {
  background-color: rgba(26, 122, 66, 0.2);
}

.ss-date-input {
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: var(--text) !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%231a7a42' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M5 1.8v2.6M11 1.8v2.6M2.8 6.2h10.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}

.ss-date-input:hover {
  border-color: #6db88a !important;
}

.ss-date-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 0.2rem rgba(26, 122, 66, 0.15) !important;
}

.flatpickr-calendar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(0,0,0,0.12);
  overflow: hidden;
}

.flatpickr-months {
  background: var(--primary);
  color: #ffffff;
}

.flatpickr-current-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  color: #ffffff !important;
  fill: #ffffff !important;
  font-weight: 700;
}

.flatpickr-prev-month,
.flatpickr-next-month {
  color: #ffffff !important;
  fill: #ffffff !important;
}

.flatpickr-weekdays {
  background: #f1f5f9;
}

span.flatpickr-weekday {
  color: #475569;
  font-weight: 700;
}

.flatpickr-day {
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
}

.flatpickr-day:hover {
  background: #e0f2fe;
  border-color: #e0f2fe;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.flatpickr-day.today {
  border-color: var(--primary);
  color: var(--primary);
}

.flatpickr-day.today:hover {
  background: #dbeafe;
  border-color: var(--primary);
}

.wo-filter-form {
  position: relative;
  margin-left: 0;
  margin-right: 0;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  box-shadow: none;
}

.wo-filter-form .wo-date-row {
  margin-top: 0.15rem;
  padding: 0.1rem 0;
}

@media (min-width: 768px) {
  .wo-filter-form {
    padding-right: 6.5rem;
  }

  .wo-filter-form .wo-reset-wrap {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
  }
}

.wo-filter-form .date-preset-select {
  border-color: #cbd5e1;
  background-color: #ffffff;
  font-weight: 600;
  color: var(--text);
}

.wo-filter-form .date-range-group {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.wo-filter-form .date-range-group .input-group-text {
  border: 0;
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.wo-filter-form .date-range-group .date-filter-input {
  border: 0;
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
}

.wo-filter-form .date-range-group .date-filter-input:focus {
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.wo-filter-form .date-filter-input::-webkit-calendar-picker-indicator {
  opacity: 0.95;
  border-radius: 6px;
  padding: 2px;
  background-color: rgba(59, 130, 246, 0.1);
}

.wo-totals-center {
  display: flex;
  justify-content: center;
}

.wo-pagination-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wo-pagination-meta {
  white-space: nowrap;
}

.wo-pagination-totals {
  flex: 1 1 auto;
}

.wo-pagination-actions {
  flex: 0 0 auto;
}

.wo-totals-box {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.wo-totals-box strong {
  color: var(--primary);
}

@media (max-width: 767.98px) {
  .wo-pagination-row {
    flex-wrap: wrap;
  }

  .wo-pagination-meta,
  .wo-pagination-totals,
  .wo-pagination-actions {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

.table-responsive {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.table {
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--border);
  padding: 0.42rem 0.68rem !important;
  vertical-align: middle;
}

.table > thead > tr > th {
  border-bottom-width: 1px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table > tbody > tr {
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.table > tbody > tr:nth-child(odd) {
  background-color: #ffffff;
}

.table > tbody > tr:nth-child(even) {
  background-color: #f8fafc;
}

.table > tbody > tr:hover {
  box-shadow: none;
}

.table > tbody > tr:focus-within {
  box-shadow: none;
}

.table > tbody > tr:hover > td {
  background-color: #f1f5f9 !important;
}

.table > tbody > tr:focus-within > td {
  background-color: #e2e8f0 !important;
}

/* Show row actions only for the hovered/focused row. */
.table > tbody > tr > td.text-end:has(.btn, button, form, a) .btn,
.table > tbody > tr > td.text-end:has(.btn, button, form, a) button,
.table > tbody > tr > td.text-end:has(.btn, button, form, a) form,
.table > tbody > tr > td.text-end:has(.btn, button, form, a) a {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.table > tbody > tr:hover > td.text-end:has(.btn, button, form, a) .btn,
.table > tbody > tr:hover > td.text-end:has(.btn, button, form, a) button,
.table > tbody > tr:hover > td.text-end:has(.btn, button, form, a) form,
.table > tbody > tr:hover > td.text-end:has(.btn, button, form, a) a,
.table > tbody > tr:focus-within > td.text-end:has(.btn, button, form, a) .btn,
.table > tbody > tr:focus-within > td.text-end:has(.btn, button, form, a) button,
.table > tbody > tr:focus-within > td.text-end:has(.btn, button, form, a) form,
.table > tbody > tr:focus-within > td.text-end:has(.btn, button, form, a) a {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.badge {
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-content {
  border: 1px solid #cfd8d1;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.modal-footer {
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.alert {
  border-radius: var(--radius-sm);
  border-width: 1px;
}

.nav-tabs {
  border-bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding-bottom: 0.2rem;
}

.nav-tabs .nav-link {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  transition: none;
}

.tab-content > .tab-pane {
  transition: none !important;
  animation: none !important;
  transform: none !important;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  border-color: #6db88a;
  background: #edf7f0;
  color: var(--primary);
}

.nav-tabs .nav-link.active {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(26, 122, 66, 0.25);
}

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-deep);
}

@media (max-width: 992px) {
  .app-topbar .ms-auto {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .app-topbar form .form-select {
    min-width: 180px !important;
  }
}

@media (max-width: 768px) {
  .app-sidebar-col {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .app-sidebar-card {
    max-height: none;
    overflow: visible;
  }

  .container-fluid,
  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .app-sidebar-card {
    border-radius: 0;
  }

  .app-sidebar-title {
    display: inline;
  }

  .app-sidebar-link {
    transform: none !important;
  }

  .app-topbar {
    padding: 0.8rem !important;
  }

  .table > :not(caption) > * > * {
    padding: 0.34rem 0.5rem !important;
  }
}
