:root {
  --ds-bg: #f3f6fb;
  --ds-surface: #ffffff;
  --ds-surface-2: #f2f5fb;
  --ds-surface-3: #eef2ff;
  --ds-text: #0b1220;
  --ds-muted: #5b677a;
  --ds-border: #cfd9e8;
  --ds-border-strong: #b7c5da;
  --ds-primary: #2b5cff;
  --ds-primary-2: #1f46d6;
  --ds-danger: #dc2626;
  --ds-success: #16a34a;
  --ds-warning: #f59e0b;
  --ds-shadow: 0 14px 34px rgba(17, 24, 39, 0.10);
  --ds-shadow-sm: 0 6px 16px rgba(17, 24, 39, 0.10);
  --ds-radius: 14px;
  --ds-radius-sm: 10px;

  --sidebar-expanded: 216px;
  --sidebar-collapsed: 64px;
  --topbar-h: 52px;
  --bottombar-h: 28px;
  --content-max: 1320px;
  --shell-pad: 6px;
}

body[data-theme="light"] {
  --ds-bg: #e6ebf5;
  --ds-surface: #ffffff;
  --ds-surface-2: #eef3fb;
  --ds-surface-3: #e8efff;
  --ds-muted: #425168;
  --ds-border: #c2cfe2;
  --ds-border-strong: #aabbd6;
  --ds-shadow: 0 16px 38px rgba(17, 24, 39, 0.14);
  --ds-shadow-sm: 0 8px 20px rgba(17, 24, 39, 0.14);
}

/* Light-only: disable dark palette */
body[data-theme="dark"] {
  --ds-bg: #e6ebf5;
  --ds-surface: #ffffff;
  --ds-surface-2: #eef3fb;
  --ds-surface-3: #e8efff;
  --ds-text: #0b1220;
  --ds-muted: #425168;
  --ds-border: #c2cfe2;
  --ds-border-strong: #aabbd6;
  --ds-primary: #2b5cff;
  --ds-primary-2: #1f46d6;
  --ds-shadow: 0 16px 38px rgba(17, 24, 39, 0.14);
  --ds-shadow-sm: 0 8px 20px rgba(17, 24, 39, 0.14);
}

h1, h2, h3, h4, h5 {
  letter-spacing: -0.02em;
}

.card-header.glass-header {
  background: var(--ds-surface) !important;
  border-bottom: 1px solid var(--ds-border) !important;
  padding: 12px 14px;
}

.card-header .fw-semibold {
  font-size: 14px;
}

html {
  font-size: 14px;
}

@media (min-width: 1200px) {
  html {
    font-size: 13.5px;
  }
}

body[data-theme="dark"] {
  --ds-bg: #e6ebf5;
  --ds-surface: #ffffff;
  --ds-surface-2: #eef3fb;
  --ds-surface-3: #e8efff;
  --ds-text: #0b1220;
  --ds-muted: #425168;
  --ds-border: #c2cfe2;
  --ds-border-strong: #aabbd6;
  --ds-primary: #2b5cff;
  --ds-primary-2: #1f46d6;
  --ds-shadow: 0 16px 38px rgba(17, 24, 39, 0.14);
  --ds-shadow-sm: 0 8px 20px rgba(17, 24, 39, 0.14);
}

.app-body {
  background: var(--ds-bg) !important;
  color: var(--ds-text) !important;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  margin: 0;
}

/* RTL support (Arabic) */
html[dir="rtl"] .app-body {
  direction: rtl;
}

html[dir="rtl"] .dropdown-menu-end {
  right: auto !important;
  left: 0 !important;
}

/* RTL Modal close buttons - move to left side */
html[dir="rtl"] .modal-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .modal-header .btn-close {
  order: -1;
  margin-left: 0;
  margin-right: auto;
}

/* RTL Location type popup close button */
html[dir="rtl"] .location-type-popup__header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .location-type-popup__header .btn,
html[dir="rtl"] .location-type-popup__header .btn-ghost {
  order: -1;
  margin-left: 0;
  margin-right: auto;
}

/* Subtle animated mid-tone background */
.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 14% 12%, rgba(98, 84, 255, 0.14), transparent 60%),
    radial-gradient(740px 420px at 86% 18%, rgba(43, 92, 255, 0.12), transparent 62%),
    radial-gradient(860px 520px at 50% 92%, rgba(147, 51, 234, 0.10), transparent 60%),
    linear-gradient(180deg, #e7ecf6 0%, #dde4f2 100%);
  filter: saturate(1.05);
  animation: appBgShift 12s ease-in-out infinite alternate;
}

@keyframes appBgShift {
  from {
    transform: translate3d(0,0,0) scale(1);
    filter: saturate(1.00);
  }
  to {
    transform: translate3d(0,-12px,0) scale(1.02);
    filter: saturate(1.10);
  }
}

/* Contrast fixes for form controls (dark + light) */
input.form-control,
textarea.form-control,
select.form-select,
.form-select,
.form-control {
  color: var(--ds-text) !important;
}

.form-control::placeholder,
.form-select::placeholder {
  color: var(--ds-muted) !important;
}

body[data-theme="dark"] select.form-select,
body[data-theme="dark"] .form-select {
  background-color: rgba(255,255,255,0.08) !important;
  color: var(--ds-text) !important;
}

body[data-theme="dark"] select.form-select option {
  background-color: #071427 !important;
  color: rgba(255,255,255,0.92) !important;
}

body[data-theme="light"] select.form-select,
body[data-theme="light"] .form-select {
  background-color: #ffffff !important;
  color: #0b1220 !important;
}

body[data-theme="light"] select.form-select option {
  background-color: #ffffff !important;
  color: #0b1220 !important;
}

/* Bootstrap dropdown menus (user menu, etc.) */
.dropdown-menu {
  background: var(--ds-surface) !important;
  border-color: var(--ds-border) !important;
  box-shadow: var(--ds-shadow-sm) !important;
  z-index: 1050; /* above everything including map overlay */
}

.dropdown-item {
  color: var(--ds-text) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--ds-surface-2) !important;
  color: var(--ds-text) !important;
}

.dropdown-divider {
  border-top-color: var(--ds-border) !important;
}

a { color: inherit; }

.app-content {
  background: var(--ds-surface) !important;
  border: 1px solid var(--ds-border-strong) !important;
  border-radius: 12px;
  padding: 0 !important;
  height: calc(100vh - (var(--topbar-h) + var(--bottombar-h) + (var(--shell-pad) * 2)));
  overflow-x: hidden;
  overflow-y: visible; /* allow dropdowns from topbar to be visible over map */
  display: flex;
  flex-direction: column;
  box-shadow: var(--ds-shadow-sm);
}

.app-content-inner {
  padding: 8px;
  padding-top: 0;
  overflow-x: hidden;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
}

 body:has(.home-dashboard) .app-content-inner {
   padding: 0;
   overflow: hidden;
 }

/* On kanban pages, disable outer vertical scroll and rely on per-column scrolling */
.app-content-inner:has(.kanban-page) {
  overflow-y: hidden;
}

/* On Kanban pages, prevent the window itself from scrolling vertically.
   Scrolling should happen only inside .kanban-dropzone (per column). */
body:has(.kanban-page) {
  overflow-y: hidden;
}

/* On Kanban pages, disable vertical scroll on the location content wrapper
   so that only each Kanban column (kanban-dropzone) scrolls. */
body:has(.kanban-page) .loc-content-wrapper {
  height: 100%;
  overflow-y: hidden;
}

.loc-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.loc-content-wrapper {
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Make the first main card in location pages fill the column height */
.loc-content > .card.glass-card:last-child,
.loc-content > .card:last-child {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.loc-content > .card.glass-card:last-child > .card-body,
.loc-content > .card:last-child > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.kanban-page {
  height: 100% !important;
}

.kanban-card {
  height: 100%;
}

@media (min-width: 1200px) {
  .app-content-inner {
    padding: 12px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.role-permission-grid {
  display: grid;
  gap: 12px;
}

.role-permission-group {
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  padding: 12px;
}

.role-permission-item {
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--ds-surface);
  border-color: var(--ds-border-strong) !important;
}

.role-permission-item.active {
  background: rgba(43, 92, 255, 0.08);
  border-color: var(--ds-primary) !important;
  box-shadow: inset 0 0 0 1px rgba(43, 92, 255, 0.12);
}

.role-permission-item .form-check-input {
  width: 2.4rem;
  height: 1.2rem;
}

.role-permission-item .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(43, 92, 255, 0.15);
}

.role-scope-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.role-scope-card {
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-border);
  border-radius: 14px;
}

.role-scope-card.disabled {
  opacity: 0.6;
}

.role-scope-card .form-check-input {
  cursor: pointer;
}

.role-scope-area {
  background: var(--ds-surface);
  border: 1px dashed var(--ds-border);
  border-radius: 10px;
}

.role-scope-area-wrap .form-check-input:disabled + .form-check-label,
.role-scope-area-wrap .form-check-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.role-scope-area .form-check-input {
  cursor: pointer;
}

.role-scope-area .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(43, 92, 255, 0.15);
}

@media (max-width: 991.98px) {
  .role-permission-grid,
  .role-scope-grid {
    gap: 10px;
  }

  .role-scope-card {
    padding: 12px !important;
  }
}

.container-fluid {
  max-width: var(--content-max);
}

/* Align page content with the sidebar/content column (no centered max-width) */
.app-content-inner > .container-fluid {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

/* Ensure the first content block aligns tightly to the content column padding */
.loc-content > :first-child {
  margin-top: 0 !important;
}

.app-content-inner > :first-child {
  margin-top: 0 !important;
}

/* Reduce overall element sizing (Bootstrap defaults are large) */
.btn {
  border-radius: 12px;
}

.btn.btn-sm {
  padding: 6px 10px;
  font-weight: 600;
}

.btn.btn-primary {
  padding: 7px 12px;
}

.form-label {
  color: var(--ds-muted);
  font-weight: 600;
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-expanded) 1fr !important;
  gap: 8px;
  align-items: start;
  padding: var(--shell-pad);
}

.app-shell.no-sidebar {
  grid-template-columns: 1fr !important;
}

@media (max-width: 991.98px) {
  .app-shell {
    grid-template-columns: 1fr !important;
  }

  .app-sidebar {
    position: relative;
    top: auto;
    height: auto;
  }
}

.app-topbar {
  height: var(--topbar-h) !important;
  background: linear-gradient(120deg, #1e293b, #334155, #475569, #1e293b) !important;
  background-size: 240% 240%;
  border-bottom: 1px solid rgba(15,23,42,0.7) !important;
  backdrop-filter: none !important;
  box-shadow: var(--ds-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1100;
  border-radius: 0;
  padding-left: var(--shell-pad);
  padding-right: var(--shell-pad);
  overflow: visible; /* allow dropdown menus to render outside the bar */
}

.app-topbar::after {
  content: "";
  position: absolute;
  inset: 0; /* contained within topbar bounds */
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.04), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.02), transparent 55%);
  transform: rotate(0deg);
  animation: sidebarTitleGlow 15s linear infinite;
  pointer-events: none; /* prevent interaction */
}

.app-topbar > * {
  position: relative;
  z-index: 1;
}

.app-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 20%, #e5e7eb, transparent 55%),
              linear-gradient(135deg, #6366f1, #4f46e5, #0ea5e9);
  box-shadow: 0 0 0 1px rgba(15,23,42,0.35), 0 10px 18px rgba(15,23,42,0.55);
}

.brand-text {
  color: #e5e7eb;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 14px;
}

.btn-topbar {
  border-radius: 999px !important;
  border-color: rgba(148, 163, 184, 0.6) !important;
  color: #e5e7eb !important;
  background: rgba(15, 23, 42, 0.25) !important;
  backdrop-filter: blur(6px);
}

.btn-topbar:hover {
  background: rgba(15, 23, 42, 0.45) !important;
  border-color: rgba(248, 250, 252, 0.7) !important;
}

.topbar-center {
  min-width: 0;
  text-align: center;
  display: flex;
  justify-content: center;
}

.topbar-title {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.topbar-title__kicker {
  color: var(--ds-muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 900;
  white-space: nowrap;
}

.topbar-title__text {
  color: #e5e7eb;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54vw;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  height: calc(var(--topbar-h) * 0.8);
  max-height: 32px;
  width: auto;
  object-fit: contain;
}

.topbar-right .dropdown {
  display: flex;
  align-items: center;
}

.topbar-right .dropdown-toggle {
  border: none !important;
  background: transparent !important;
  outline: none !important;
}

.topbar-right .btn,
.topbar-left .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
}

.topbar-right #userMenuDropdown {
  justify-content: space-between;
}

.topbar-left .btn,
.topbar-right .btn {
  border-radius: 10px;
}

.topbar-left .text-muted {
  color: var(--ds-muted) !important;
}

.brand-text {
  color: var(--ds-text) !important;
  letter-spacing: 0.10em;
  font-size: 13px;
}

.brand-mark {
  box-shadow: none !important;
  background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-2)) !important;
}

.user-avatar {
  background: var(--ds-surface-2) !important;
  border: 1px solid var(--ds-border) !important;
}

/* Sidebar */
.app-sidebar {
  background: var(--ds-surface) !important;
  border: 1px solid var(--ds-border-strong) !important;
  padding: 10px !important;
  backdrop-filter: none !important;
  box-shadow: var(--ds-shadow-sm);
  border-radius: 12px;
  height: calc(100vh - (var(--topbar-h) + var(--bottombar-h) + (var(--shell-pad) * 2)));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

 .app-bottombar {
   height: var(--bottombar-h);
   margin: 0;
   padding-left: var(--shell-pad);
   padding-right: var(--shell-pad);
   display: flex;
   align-items: center;
   justify-content: space-between;
   background: linear-gradient(120deg, #1e293b, #334155, #475569, #1e293b) !important;
   background-size: 240% 240%;
   border-top: 1px solid rgba(15,23,42,0.7) !important;
   box-shadow: var(--ds-shadow-sm);
   position: fixed;
   left: 0;
   right: 0;
   bottom: 0;
   z-index: 1100;
 }

 .bottombar-right {
   color: #e5e7eb;
   font-weight: 700;
   letter-spacing: 0.08em;
   font-size: 11px;
 }

.sidebar-section {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
}

.sidebar-footer {
  flex: 0 0 auto;
}

.sidebar-title.sidebar-title--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
}

.sidebar-title__action {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  border-radius: 999px !important;
  display: inline-grid;
  place-items: center;
}

.sidebar-title__action i {
  font-size: 16px;
}

.sidebar-actions .btn {
  border-radius: 12px;
}

.sidebar-actions .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--ds-primary), var(--ds-primary-2)) !important;
  border: 0 !important;
}

.sidebar-actions .btn-primary:hover {
  filter: brightness(0.98);
}

.sidebar-title {
  color: #ffffff !important;
  font-weight: 600;
  /* Pull header to the edges of the sidebar card so it feels attached */
  margin: -10px -10px 6px;
  /* Match sidebar card radius on top only, squared bottom to join menu */
  border-radius: 12px 12px 0 0;
  padding: 10px 12px;
  border: none;
  background: linear-gradient(120deg, #1e293b, #334155, #475569, #1e293b);
  background-size: 240% 240%;
  position: relative;
  overflow: hidden;
  animation: sidebarTitleWave 9s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title::after {
  content: "";
  position: absolute;
  inset: -60px;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.08), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.05), transparent 55%);
  transform: rotate(0deg);
  animation: sidebarTitleGlow 7s linear infinite;
}

.sidebar-title > * {
  position: relative;
  z-index: 1;
}

@keyframes sidebarTitleWave {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes sidebarTitleGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

body[data-theme="light"] .app-sidebar,
body[data-theme="light"] .app-topbar {
  border-color: var(--ds-border-strong) !important;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.sidebar-item:hover {
  background: var(--ds-surface-2);
  border-color: var(--ds-border);
}

.sidebar-item.is-active {
  background: var(--ds-surface-3);
  border-color: rgba(43, 92, 255, 0.30);
}

body[data-theme="dark"] .sidebar-item.is-active {
  background: var(--ds-surface-3);
  border-color: rgba(43, 92, 255, 0.30);
}

.sidebar-item .nav-ico {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: var(--ds-muted);
}

.sidebar-item.is-active .nav-ico {
  color: var(--ds-primary);
}

.sidebar-item .nav-label {
  color: var(--ds-text);
  font-weight: 700;
  font-size: 12px;
}

.sidebar-item.sidebar-item--row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 8px;
  padding: 7px 8px;
}

.sidebar-item__link {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

/* Allow long location names to wrap in the sidebar list */
.sidebar-item__link .nav-label {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.2;
}

.sidebar-item__actions {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  display: inline-flex;
  gap: 4px;
}

.sidebar-item__meta {
  grid-column: 1 / -1;
  grid-row: 2 / 3;
  padding-left: 26px;
  line-height: 1.2;
}

.sidebar-item.sidebar-item--row .btn.btn-sm {
  padding: 4px 6px;
}

.sidebar-footer {
  border-top: 1px solid var(--ds-border);
}

/* Collapsed */
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr !important;
}

.app-shell.sidebar-collapsed .sidebar-title,
.app-shell.sidebar-collapsed .sidebar-actions,
.app-shell.sidebar-collapsed .sidebar-footer,
.app-shell.sidebar-collapsed .sidebar-item .nav-label {
  display: none !important;
}

.app-shell.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: 10px 8px;
}

/* Surfaces */
.glass-card,
.glass-panel,
.glass-modal {
  background: var(--ds-surface) !important;
  border: 1px solid var(--ds-border-strong) !important;
  box-shadow: var(--ds-shadow);
  border-radius: var(--ds-radius);
}

body[data-theme="light"] .glass-card,
body[data-theme="light"] .glass-panel,
body[data-theme="light"] .glass-modal {
  border-color: var(--ds-border-strong) !important;
}

body[data-theme="light"] .glass-card {
  box-shadow: 0 18px 44px rgba(17, 24, 39, 0.10);
}

.glass-card {
  overflow: hidden;
}

.glass-panel {
  box-shadow: var(--ds-shadow-sm);
}

.card.glass-card .card-body {
  padding: 16px;
}

.glass-panel {
  border-radius: var(--ds-radius);
}

/* Modal positioning to appear below topbar */
.modal {
  z-index: 9999; /* Make modal the topmost element */
}

.modal-backdrop {
  z-index: 9998; /* Ensure backdrop is behind modal */
}

.modal-dialog {
  margin-top: calc(var(--topbar-h) + 20px); /* Position below topbar */
  z-index: 10000; /* Ensure dialog is above backdrop */
}

.modal-content.glass-modal {
  border-radius: 16px;
  z-index: 10001; /* Ensure content is above everything */
}

/* Dark modal header with shimmer animation */
.modal-header {
  background: linear-gradient(135deg, #1e293b, #334155);
  border-color: var(--ds-border) !important;
  position: relative;
  overflow: hidden;
}

.modal-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255,255,255,0.08) 25%, 
    rgba(255,255,255,0.15) 50%, 
    rgba(255,255,255,0.08) 75%, 
    transparent 100%);
  animation: modalHeaderShimmer 3s ease-in-out infinite;
}

@keyframes modalHeaderShimmer {
  0% { 
    left: -100%;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% { 
    left: 200%;
    opacity: 0;
  }
}

/* Enhanced contrast for admin modals - light background with dark text */
.modal-content.glass-modal {
  background: #ffffff !important;
  color: #1e293b !important;
}

.location-type-popup {
  background: #ffffff !important;
  color: #1e293b !important;
  border-color: var(--ds-border-strong) !important;
  max-height: 80vh !important;
  overflow: hidden !important;
}

.location-type-popup .location-type-popup__header {
  background: #0f172a;
  color: #ffffff;
  border-bottom-color: rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.location-type-popup .location-type-popup__header .fw-semibold {
  color: #ffffff;
  font-weight: 600;
}

.location-type-popup .location-type-popup__header .btn,
.location-type-popup .location-type-popup__header .btn-ghost {
  color: #ffffff !important;
  border-color: rgba(255,255,255,0.18) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.location-type-popup .section-title {
  color: #0f172a;
}

.location-type-popup .glass-panel {
  background: #ffffff !important;
  border-color: var(--ds-border) !important;
}

.location-type-popup .location-type-popup__body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: calc(80vh - 52px) !important;
}

body:has(.location-type-popup.is-open) {
  overflow: hidden;
}

.modal-body {
  background: #ffffff !important;
  color: #1e293b !important;
}

.modal-body .form-label {
  color: #1e293b !important;
  font-weight: 600 !important;
}

.modal-body .form-control,
.modal-body .form-select {
  background: #f8fafc !important;
  border: 2px solid #cbd5e1 !important;
  color: #1e293b !important;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
  background: #ffffff !important;
  border-color: #3b82f6 !important;
  color: #1e293b !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.modal-body .form-control::placeholder {
  color: #64748b !important;
}

.modal-body .form-check-label {
  color: #1e293b !important;
  font-weight: 500 !important;
}

.modal-body .form-check-input {
  background-color: #ffffff !important;
  border: 2px solid #cbd5e1 !important;
}

.modal-body .form-check-input:checked {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

.modal-body .form-text {
  color: #64748b !important;
}

.modal-body .text-muted {
  color: #64748b !important;
}

.modal-body .border {
  border-color: #e2e8f0 !important;
  background: #f8fafc !important;
}

.modal-body h6 {
  color: #1e293b !important;
  font-weight: 700 !important;
}

.modal-body .badge {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

.modal-footer {
  border-color: var(--ds-border) !important;
}

.modal-title {
  color: #f8fafc !important;
}

 .global-loading-overlay {
   position: fixed;
   inset: 0;
   z-index: 200000;
   display: flex;
   align-items: center;
   justify-content: center;
   background: rgba(15, 23, 42, 0.35);
   backdrop-filter: blur(6px);
 }

 .global-loading-inner {
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 18px 22px;
   border-radius: 16px;
   background: rgba(15, 23, 42, 0.72);
   border: 1px solid rgba(255, 255, 255, 0.14);
   box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
 }

 .global-loading-logo {
   width: 84px;
   height: auto;
   animation: globalLoadingPulse 0.9s ease-in-out infinite;
   filter: drop-shadow(0 12px 28px rgba(0,0,0,0.35));
 }

 @keyframes globalLoadingPulse {
   0%, 100% { transform: scale(1); opacity: 0.92; }
   50% { transform: scale(1.06); opacity: 1; }
 }

 html.is-global-loading,
 html.is-global-loading body {
   overflow: hidden !important;
 }

 html.is-global-loading * {
   cursor: progress !important;
 }

.btn-close-white {
  filter: none !important;
}

body[data-theme="dark"] .btn-close-white {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.page-hero {
  background: transparent !important;
}

.hero-kicker {
  color: var(--ds-muted) !important;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 12px;
}

.hero-title {
  color: var(--ds-text) !important;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 22px;
}

@media (min-width: 1200px) {
  .hero-title {
    font-size: 24px;
  }
}

.page-hero {
  padding: 0 2px 10px;
}

.hero-kicker {
  font-size: 11px;
}

.badge-glow {
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--ds-border);
  background: var(--ds-surface-2);
  color: var(--ds-text);
}

/* Kanban boards (work orders + PM) */
.kanban-page {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

.kanban-page .kanban-card {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  margin-bottom: 0;
}

.kanban-card__body {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
}

.kanban-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.9) rgba(15, 23, 42, 0.18);
}

 .kanban-scroll::-webkit-scrollbar {
   height: 10px;
 }

 .kanban-scroll::-webkit-scrollbar-track {
   background: rgba(15, 23, 42, 0.18);
   border-radius: 999px;
 }

 .kanban-scroll::-webkit-scrollbar-thumb {
   background: rgba(148, 163, 184, 0.9);
   border-radius: 999px;
 }

 .kanban-scroll::-webkit-scrollbar-thumb:hover {
   background: rgba(203, 213, 225, 0.95);
 }

.kanban-board {
  display: flex;
  gap: 0px;
  overflow-x: visible;
  overflow-y: hidden;
  padding-bottom: 4px;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

.kanban-col {
  flex: 1 1 270px;
  min-width: 270px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  margin: 2px;
}

.kanban-col:first-child {
  margin-left: 0;
}

.kanban-col:last-child {
  margin-right: 0;
}

.loc-content-wrapper .kanban-col {
  flex: 1 1 270px;
  min-width: 270px;
  max-width: 400px;
}

.kanban-col > .glass-panel:first-child {
  background: linear-gradient(120deg, #1e293b, #334155, #475569, #1e293b) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  border: 2px solid #475569 !important;
  border-bottom: none !important;
  border-radius: 12px 12px 0 0 !important;
  margin-bottom: 0 !important;
}

.kanban-col > .glass-panel:first-child::after {
  content: "";
  position: absolute;
  inset: -60px;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.04), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.02), transparent 55%);
  transform: rotate(0deg);
  animation: sidebarTitleGlow 15s linear infinite;
}

.kanban-col > .glass-panel:first-child > * {
  position: relative;
  z-index: 1;
}

.kanban-col > .glass-panel:first-child .fw-semibold {
  color: #e5e7eb !important;
  font-weight: 600;
  font-size: 14px;
}

.kanban-col > .glass-panel:first-child .small {
  color: #cbd5e1 !important;
}

.kanban-dropzone {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: #f8fafc !important;
  border: 2px solid #475569 !important;
  border-top: none !important;
  border-radius: 0 0 12px 12px !important;
  padding: 12px !important;
  margin-top: 0 !important;
}

.loc-content-wrapper .kanban-dropzone {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: #f8fafc !important;
  border: 2px solid #475569 !important;
  border-top: none !important;
  border-radius: 0 0 12px 12px !important;
  padding: 12px !important;
  margin-top: 0 !important;
}

/* Remove duplicate kanban styling - already handled above */

body[data-theme="dark"] .badge-glow {
  border-color: var(--ds-border);
  background: var(--ds-surface-2);
  color: var(--ds-text);
}

.kpi-grid {
  gap: 10px;
}

.kpi {
  padding: 12px 12px;
}

.kpi-value {
  font-size: 22px;
}

.kpi-label {
  font-size: 11px;
  letter-spacing: .10em;
}

.kpi-meta {
  font-size: 12px;
}

.kpi {
  box-shadow: var(--ds-shadow-sm);
}

/* List group redesign */
.list-group-item {
  background: transparent;
  border-color: var(--ds-border) !important;
  color: var(--ds-text);
  padding: 10px 0;
}

.list-group-flush>.list-group-item {
  border-width: 0 0 1px;
}

/* Make map always visible and not clipped by card styles */
#map.map-canvas,
#modalMap.map-canvas {
  width: 100%;
}

.map-canvas {
  border-radius: 0 0 var(--ds-radius) var(--ds-radius);
}

/* Leaflet tiles sometimes appear washed; ensure proper stacking */
.leaflet-pane,
.leaflet-control {
  z-index: 1;
}

/* Leaflet fixes (map not showing / tiles hidden) */
.leaflet-container {
  background: #dbe7f5;
  border-radius: inherit;
}

.leaflet-control-attribution {
  font-size: 11px;
}

.map-canvas {
  min-height: 440px;
  height: 440px;
}

@media (min-width: 1200px) {
  .map-canvas {
    min-height: 500px;
    height: 500px;
  }
}

.hero-subtitle {
  color: var(--ds-muted) !important;
}

.text-muted {
  color: var(--ds-muted) !important;
}

.fw-semibold {
  color: var(--ds-text);
}

.btn-primary {
  background-color: var(--ds-primary) !important;
  border-color: var(--ds-primary) !important;
  box-shadow: 0 10px 18px rgba(43, 92, 255, 0.18);
}

.btn-primary:hover {
  background-color: var(--ds-primary-2) !important;
  border-color: var(--ds-primary-2) !important;
}

.btn-ghost {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--ds-text) !important;
}

.btn-ghost:hover {
  background: var(--ds-surface-2) !important;
  border-color: var(--ds-border) !important;
}

.btn-outline-light {
  color: var(--ds-text) !important;
  border-color: var(--ds-border) !important;
  background: transparent !important;
}

.btn-outline-light:hover {
  background: var(--ds-surface-2) !important;
}

.btn-outline-light.danger {
  color: var(--ds-danger) !important;
}

input.form-control,
textarea.form-control,
select.form-select {
  border-radius: 12px;
  border-color: var(--ds-border) !important;
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
}

input.form-control:focus,
textarea.form-control:focus,
select.form-select:focus {
  border-color: rgba(43, 92, 255, 0.45) !important;
  box-shadow: 0 0 0 4px rgba(43, 92, 255, 0.10) !important;
}

table.table {
  color: var(--ds-text);
}

/* Professional tables */
.table {
  --bs-table-bg: transparent;
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--ds-border-strong) !important;
}

/* Symmetric header background: apply once on the row, keep cells transparent */
.table thead tr {
  background: linear-gradient(135deg, rgba(15,23,42,0.94), rgba(88,28,135,0.92)) !important;
}

.table thead th {
  background: transparent !important;
  color: rgba(255,255,255,0.94) !important;
  border-bottom-color: rgba(15,23,42,0.65) !important;
}

/* Light purple body */
.table tbody tr {
  background: rgba(109, 40, 217, 0.06);
}

.table tbody tr:nth-child(even) {
  background: rgba(109, 40, 217, 0.09);
}

/* Bootstrap tables often paint cells, so force background on td/th too */
.table tbody td,
.table tbody th {
  background: rgba(109, 40, 217, 0.06) !important;
}

.table.table-striped > tbody > tr:nth-of-type(even) > * {
  background: rgba(109, 40, 217, 0.09) !important;
}

.table tbody td,
.table tbody th {
  color: rgba(11, 18, 32, 0.95) !important;
  border-bottom-color: rgba(167, 139, 250, 0.35) !important;
}

/* Add comfortable horizontal padding inside cells */
.table th,
.table td {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

/* Extra left padding for first column so text is not against border */
.table th:first-child,
.table td:first-child {
  padding-left: 1.35rem !important;
}

/* Compact controls for WO/PM toolbars */
.btn-xs {
  padding: 4px 8px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
  height: 30px !important;
}

.form-select-xs {
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  padding-left: 10px !important;
  padding-right: 28px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
  height: 30px !important;
}

.kanban-toolbar {
  flex-wrap: nowrap !important;
}

.kanban-toolbar .form-select {
  width: auto;
  min-width: 140px;
}

@media (max-width: 991.98px) {
  .kanban-toolbar {
    flex-wrap: wrap !important;
  }
}

.table tbody .text-muted {
  color: rgba(11, 18, 32, 0.72) !important;
}

.table-responsive {
  border-radius: 12px;
}

.nav-tabs.nav-tabs-dark {
  border-bottom-color: var(--ds-border) !important;
}

.nav-tabs.nav-tabs-dark {
  border-bottom-color: var(--ds-border) !important;
}

.nav-tabs.nav-tabs-dark .nav-link {
  color: var(--ds-muted) !important;
  border-radius: 12px 12px 0 0;
}

.nav-tabs.nav-tabs-dark .nav-link.active {
  color: var(--ds-text) !important;
  background: var(--ds-surface) !important;
  border-color: var(--ds-border) !important;
}

/* Table styling with dark animated headers */
.table-dark {
  --bs-table-bg: transparent !important;
  --bs-table-border-color: rgba(255,255,255,0.08) !important;
}

.table-dark thead th {
  background: linear-gradient(120deg, #1e293b, #334155, #475569, #1e293b) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  color: #e5e7eb !important;
  font-weight: 600;
  border: 1px solid rgba(15,23,42,0.9) !important;
}

.table-dark thead th:first-child {
  border-radius: 8px 0 0 0 !important;
}

.table-dark thead th:last-child {
  border-radius: 0 8px 0 0 !important;
}

.table-dark thead th::after {
  content: "";
  position: absolute;
  inset: -60px;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.04), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.02), transparent 55%);
  transform: rotate(0deg);
  animation: sidebarTitleGlow 15s linear infinite;
}

.table-dark thead th > * {
  position: relative;
  z-index: 1;
}

.table-dark tbody {
  background: #f8fafc !important;
}

.table-dark tbody tr {
  background: #f8fafc !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

.table-dark tbody tr:hover {
  background: #f1f5f9 !important;
}

.table-dark tbody td {
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
  border-right: 1px solid #cbd5e1 !important;
}

.table-dark tbody td:last-child {
  border-right: none !important;
}

.table-dark tbody .text-muted {
  color: #64748b !important;
}

.table-dark tbody .fw-semibold {
  color: #0f172a !important;
}

/* Ensure this applies to all location pages */
.loc-content .table-dark {
  margin-bottom: 0;
  border-radius: 12px;
  overflow: hidden;
}

.loc-content .table-responsive {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

/* Card container styling for tables */
.loc-content .card.glass-card {
  border-radius: 12px;
  overflow: hidden;
}

.loc-content .card.glass-card .table-responsive {
  border-radius: 0 0 12px 12px;
}

.wo-card,
.pm-card {
  border-radius: 14px;
  border: 1px solid var(--ds-border) !important;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.06);
  padding: 0 !important;
  margin-bottom: 8px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
}

/* Card Header */
.wo-card-header,
.pm-card-header {
  position: relative;
  overflow: hidden;
  padding: 6px 8px;
}

.wo-card-header::after,
.pm-card-header::after {
  content: "";
  position: absolute;
  inset: -60px;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,0.04), transparent 52%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.02), transparent 55%);
  transform: rotate(0deg);
  animation: sidebarTitleGlow 15s linear infinite;
}

.wo-card-header > *,
.pm-card-header > * {
  position: relative;
  z-index: 1;
}

.wo-card-title,
.pm-card-title {
  color: #ffffff !important;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
  margin: 0;
}

.wo-card-qr {
  color: rgba(255, 255, 255, 0.8) !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
  padding: 4px 6px !important;
  font-size: 12px !important;
}

.wo-card-qr:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Priority-based header colors */
.wo-card--low .wo-card-header,
.pm-card--low .pm-card-header {
  background: linear-gradient(120deg, #16a34a, #22c55e, #16a34a) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
}

.wo-card--medium .wo-card-header,
.pm-card--medium .pm-card-header {
  background: linear-gradient(120deg, #2563eb, #3b82f6, #2563eb) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
}

.wo-card--high .wo-card-header,
.pm-card--high .pm-card-header {
  background: linear-gradient(120deg, #ca8a04, #eab308, #ca8a04) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
}

.wo-card--critical .wo-card-header,
.pm-card--critical .pm-card-header {
  background: linear-gradient(120deg, #dc2626, #ef4444, #dc2626) !important;
  background-size: 240% 240%;
  animation: sidebarTitleWave 20s ease-in-out infinite;
}

/* Card Body */
.wo-card-body,
.pm-card-body {
  padding: 8px;
  flex: 1 1 auto;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9, #e2e8f0) !important;
}

.wo-card-description {
  font-size: 11px;
  color: var(--ds-text-muted);
  margin-bottom: 6px;
  line-height: 1.2;
}

.wo-card-meta,
.pm-card-meta {
  margin-bottom: 8px;
  padding: 6px;
  background: rgba(17, 24, 39, 0.02);
  border-radius: 6px;
  border: 1px solid rgba(17, 24, 39, 0.05);
}

.wo-meta-row,
.pm-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  font-size: 11px;
}

.wo-meta-row:last-child,
.pm-meta-row:last-child {
  margin-bottom: 0;
}

.meta-label {
  color: var(--ds-muted);
  font-weight: 500;
}

.meta-value {
  color: var(--ds-text);
  font-weight: 600;
  text-align: right;
}

.wo-card-details,
.pm-card-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 6px;
}

.wo-detail-item,
.pm-detail-item {
  font-size: 10px;
  color: var(--ds-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  background: rgba(17, 24, 39, 0.01);
  border-radius: 3px;
  border: 1px solid rgba(17, 24, 39, 0.03);
}

.wo-detail-item i,
.pm-detail-item i {
  font-size: 9px;
  color: var(--ds-muted);
  min-width: 10px;
}

/* Card Footer */
.wo-card-footer,
.pm-card-footer {
  padding: 4px 8px;
  background: rgba(17, 24, 39, 0.02) !important;
  border-top: 1px solid var(--ds-border) !important;
}

.wo-card-badges,
.pm-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Logo wave animations */
.topbar-logo {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.topbar-logo:hover {
  transform: scale(1.05);
}

.topbar-logo::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(59, 130, 246, 0.3) 25%, 
    rgba(139, 92, 246, 0.3) 50%, 
    rgba(59, 130, 246, 0.3) 75%, 
    transparent 100%);
  animation: waveMove 3s ease-in-out infinite;
}

.topbar-left .topbar-logo::before {
  animation-delay: 0s;
}

.topbar-right .topbar-logo::before {
  animation-delay: 1.5s;
}

@keyframes waveMove {
  0% {
    left: -100%;
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

/* Alternative wave effect for variety */
.topbar-logo::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, 
    transparent 0%, 
    rgba(16, 185, 129, 0.2) 30%, 
    rgba(6, 182, 212, 0.2) 70%, 
    transparent 100%);
  animation: waveMove2 4s ease-in-out infinite;
}

.topbar-left .topbar-logo::after {
  animation-delay: 2s;
}

.topbar-right .topbar-logo::after {
  animation-delay: 3.5s;
}

@keyframes waveMove2 {
  0% {
    left: -100%;
    transform: skewX(-20deg);
    opacity: 0;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    left: 100%;
    transform: skewX(-20deg);
    opacity: 0;
  }
}

/* PM assigned user label */
.pm-assigned-user {
  font-size: 11px;
  font-weight: 600;
  color: var(--ds-text);
}
/* Dashboard Widgets */
.dashboard-widget {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%, #f3f4f6 100%);
  background-size: 300% 300%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  height: 100%;
  animation: gradientShift 8s ease-in-out infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.dashboard-widget:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #9ca3af;
}

.widget-header {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.widget-header--dark {
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  color: #f1f5f9;
}

.widget-header--dark::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.widget-title {
  font-weight: 600;
  font-size: 12px;
  margin: 0;
  z-index: 1;
  position: relative;
}

.widget-icon {
  font-size: 14px;
  opacity: 0.8;
  z-index: 1;
  position: relative;
}

.widget-body {
  padding: 16px;
}

.widget-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
  margin-bottom: 4px;
}

.widget-subtitle {
  font-size: 12px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-counter {
  text-align: center;
  padding: 8px 4px;
}

.mini-value {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
  margin-bottom: 2px;
}

.mini-label {
  font-size: 10px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.widget-list {
  max-height: 300px;
  overflow-y: auto;
}

.list-item {
  padding: 12px 0;
  border-bottom: 1px solid #d1d5db;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
  font-size: 14px;
}

.list-item-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-pending {
  background-color: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.badge-approved {
  background-color: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
}

.badge-ongoing {
  background-color: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.badge-on-hold {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.badge-completed {
  background-color: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.badge-verified {
  background-color: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
}

/* Chart containers */
.dashboard-widget canvas {
  max-height: 200px;
  filter: contrast(1.1) brightness(1.05);
}

/* Make layout more compact to fill empty space */
.dashboard-container {
  min-height: 100vh;
}

/* Remove extra margins to fill space */
.row.g-3.mb-4:last-child {
  margin-bottom: 0 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .widget-header {
    padding: 12px 16px;
  }
  
  .widget-body {
    padding: 16px;
  }
  
  .widget-value {
    font-size: 28px;
  }
  
  .widget-title {
    font-size: 13px;
  }
  
  .widget-icon {
    font-size: 16px;
  }
}

.wo-export-btn,
.pm-export-btn {
  color: #cbd5e1 !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 6px !important;
  padding: 4px 6px !important;
  font-size: 12px !important;
  transition: all 0.2s ease !important;
}

.wo-export-btn:hover,
.pm-export-btn:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-1px);
}

.wo-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--ds-border);
  white-space: nowrap;
}

.wo-badge--assigned {
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.35) !important;
}

.wo-badge--unassigned {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35) !important;
}

.wo-badge--overdue {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45) !important;
}

.wo-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wo-meta__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wo-card--needs-assign {
  outline: 2px dashed rgba(245, 158, 11, 0.55);
  outline-offset: 2px;
}

/* Removed overdue dashed border - Late flag is sufficient */

/* Work Orders dark theme kanban boards */
.wo-board .kanban-col:nth-child(1) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(2) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(3) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(4) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(5) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(6) > .glass-panel:first-child,
.wo-board .kanban-col:nth-child(n+6) > .glass-panel:first-child {
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%) !important;
  border: 1px solid #4b5563 !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.wo-board .kanban-col:nth-child(1) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(2) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(3) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(4) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(5) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(6) > .glass-panel:first-child .fw-semibold,
.wo-board .kanban-col:nth-child(n+6) > .glass-panel:first-child .fw-semibold {
  color: #f3f4f6 !important;
}

.wo-board .kanban-col:nth-child(1) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(2) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(3) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(4) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(5) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(6) > .glass-panel:first-child .small,
.wo-board .kanban-col:nth-child(n+6) > .glass-panel:first-child .small {
  color: #d1d5db !important;
}

/* PM Orders dark theme kanban boards */
.pm-board .kanban-col:nth-child(1) > .glass-panel:first-child,
.pm-board .kanban-col:nth-child(2) > .glass-panel:first-child,
.pm-board .kanban-col:nth-child(3) > .glass-panel:first-child,
.pm-board .kanban-col:nth-child(4) > .glass-panel:first-child,
.pm-board .kanban-col:nth-child(5) > .glass-panel:first-child,
.pm-board .kanban-col:nth-child(n+5) > .glass-panel:first-child {
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%) !important;
  border: 1px solid #4b5563 !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.pm-board .kanban-col:nth-child(1) > .glass-panel:first-child .fw-semibold,
.pm-board .kanban-col:nth-child(2) > .glass-panel:first-child .fw-semibold,
.pm-board .kanban-col:nth-child(3) > .glass-panel:first-child .fw-semibold,
.pm-board .kanban-col:nth-child(4) > .glass-panel:first-child .fw-semibold,
.pm-board .kanban-col:nth-child(5) > .glass-panel:first-child .fw-semibold,
.pm-board .kanban-col:nth-child(n+5) > .glass-panel:first-child .fw-semibold {
  color: #f3f4f6 !important;
}

.pm-board .kanban-col:nth-child(1) > .glass-panel:first-child .small,
.pm-board .kanban-col:nth-child(2) > .glass-panel:first-child .small,
.pm-board .kanban-col:nth-child(3) > .glass-panel:first-child .small,
.pm-board .kanban-col:nth-child(4) > .glass-panel:first-child .small,
.pm-board .kanban-col:nth-child(5) > .glass-panel:first-child .small,
.pm-board .kanban-col:nth-child(n+5) > .glass-panel:first-child .small {
  color: #d1d5db !important;
}

/* Work Orders dropzone borders to match dark theme */
.wo-board .kanban-col:nth-child(1) .kanban-dropzone,
.wo-board .kanban-col:nth-child(2) .kanban-dropzone,
.wo-board .kanban-col:nth-child(3) .kanban-dropzone,
.wo-board .kanban-col:nth-child(4) .kanban-dropzone,
.wo-board .kanban-col:nth-child(5) .kanban-dropzone,
.wo-board .kanban-col:nth-child(6) .kanban-dropzone,
.wo-board .kanban-col:nth-child(n+6) .kanban-dropzone {
  border-color: #4b5563 !important;
}

/* PM Orders dropzone borders to match dark theme */
.pm-board .kanban-col:nth-child(1) .kanban-dropzone,
.pm-board .kanban-col:nth-child(2) .kanban-dropzone,
.pm-board .kanban-col:nth-child(3) .kanban-dropzone,
.pm-board .kanban-col:nth-child(4) .kanban-dropzone,
.pm-board .kanban-col:nth-child(5) .kanban-dropzone,
.pm-board .kanban-col:nth-child(n+5) .kanban-dropzone {
  border-color: #4b5563 !important;
}
.wo-card--low {
  background: linear-gradient(135deg, rgba(34,197,94,0.16), rgba(34,197,94,0.06)) !important;
  border-color: rgba(34,197,94,0.55) !important;
}

.wo-card--medium {
  background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(59,130,246,0.08)) !important;
  border-color: rgba(59,130,246,0.55) !important;
}

.wo-card--high {
  background: linear-gradient(135deg, rgba(234,179,8,0.24), rgba(234,179,8,0.10)) !important;
  border-color: rgba(234,179,8,0.70) !important;
}

.wo-card--critical {
  background: linear-gradient(135deg, rgba(239,68,68,0.26), rgba(239,68,68,0.12)) !important;
  border-color: rgba(239,68,68,0.80) !important;
}

/* PM order priority colors (mirror WO styles) */
.pm-card--low {
  background: linear-gradient(135deg, rgba(34,197,94,0.16), rgba(34,197,94,0.06)) !important;
  border-color: rgba(34,197,94,0.55) !important;
}

.pm-card--medium {
  background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(59,130,246,0.08)) !important;
  border-color: rgba(59,130,246,0.55) !important;
}

.pm-card--high {
  background: linear-gradient(135deg, rgba(234,179,8,0.24), rgba(234,179,8,0.10)) !important;
  border-color: rgba(234,179,8,0.70) !important;
}

.pm-card--critical {
  background: linear-gradient(135deg, rgba(239,68,68,0.26), rgba(239,68,68,0.12)) !important;
  border-color: rgba(239,68,68,0.80) !important;
}

.wo-dropzone,
.pm-dropzone {
  background: rgba(255,255,255,0.45);
  border: 1px dashed var(--ds-border-strong) !important;
}

body[data-theme="dark"] .wo-dropzone,
body[data-theme="dark"] .pm-dropzone {
  background: rgba(255,255,255,0.03);
}

.wo-dropzone.is-over,
.pm-dropzone.is-over {
  border-color: rgba(43, 92, 255, 0.55) !important;
  box-shadow: inset 0 0 0 2px rgba(43, 92, 255, 0.10);
}

.wo-card.is-dragging,
.pm-card.is-dragging {
  opacity: 0.85;
  transform: rotate(0.4deg);
}

/* Dashboard (Home) */
.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 2px 14px;
}

.dashboard-kicker {
  color: var(--ds-muted);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 800;
}

.dashboard-title {
  font-size: 30px;
  font-weight: 900;
  color: var(--ds-text);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

@media (min-width: 1200px) {
  .dashboard-title {
    font-size: 34px;
  }
}

.dashboard-subtitle {
  color: var(--ds-muted);
  margin-top: 6px;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 14px;
}

/* Home map full-bleed layout with overlay widgets */
.home-dashboard {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.home-map-wrapper {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  height: 100%;
  min-height: 0;
}

.home-map-wrapper .map-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0 !important;
}

.home-map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
  z-index: 10; /* above Leaflet panes (z-index:1) */
  pointer-events: none; /* let map receive clicks by default */
  overflow: hidden; /* prevent overlay from expanding beyond map */
  background: transparent; /* ensure no weird background */
}

/* Right-side vertical KPI rail */
.home-kpi-column {
  position: absolute;
  right: 14px;
  bottom: 12px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 10px;
  width: 230px;
  max-height: calc(100% - 24px); /* stay within overlay */
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.home-kpi-item {
  background: rgba(15,23,42,0.6);
  border-radius: 16px;
  padding: 10px 14px;
  color: #f9fafb;
  border: 1px solid rgba(148,163,184,0.5);
  backdrop-filter: blur(16px) saturate(20%);
  box-shadow: none; /* remove shadow */
}

.home-kpi-label {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.85;
}

.home-kpi-value {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

/* Map search bar (top-right) */
.home-map-search-bar {
  position: absolute;
  right: 14px;
  top: 14px;
  pointer-events: auto;
  background: rgba(15,23,42,0.72);
  border-radius: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(148,163,184,0.5);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: none;
}

.home-map-search-bar .form-control {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(148,163,184,0.3);
  color: #f9fafb;
  font-size: 12px;
  border-radius: 8px;
  width: 200px;
}

.home-map-search-bar .form-control::placeholder {
  color: rgba(249,250,251,0.5);
}

.home-map-search-bar .form-control:focus {
  background: rgba(255,255,255,0.15);
  border-color: rgba(148,163,184,0.6);
  box-shadow: 0 0 0 0.2rem rgba(148,163,184,0.25);
  color: #f9fafb;
}

/* Map layer switcher (bottom-left) */
.home-map-layer-switcher {
  position: absolute;
  left: 14px;
  bottom: 12px;
  pointer-events: auto;
  background: rgba(15,23,42,0.72);
  border-radius: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(148,163,184,0.5);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: none;
}

.home-map-layer-switcher .form-select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(148,163,184,0.3);
  color: #f9fafb;
  font-size: 12px;
  border-radius: 8px;
}

.home-map-layer-switcher .form-select:focus {
  background: rgba(255,255,255,0.15);
  border-color: rgba(148,163,184,0.6);
  box-shadow: 0 0 0 0.2rem rgba(148,163,184,0.25);
  color: #f9fafb;
}

.home-map-layer-switcher .form-select option {
  background: rgba(15,23,42,0.95);
  color: #f9fafb;
}
.home-kpi-chart {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0; /* prevent growing */
  max-height: 160px; /* cap height */
}

.home-kpi-chart canvas {
  max-width: 100%;
  max-height: 120px !important;
  height: auto !important;
}

/* List widget */
.home-kpi-list-items {
  margin-top: 6px;
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.home-kpi-list-item {
  font-size: 11px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.2);
}

.home-kpi-list-title {
  font-weight: 600;
  color: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-kpi-list-meta {
  font-size: 10px;
  color: rgba(249,250,251,0.7);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 991.98px) {
  .home-dashboard {
    height: auto;
  }

  .home-map-wrapper .map-canvas {
    height: 420px;
  }

  .home-kpi-column {
    flex-direction: row;
    width: 100%;
    max-height: none;
    margin: 0 10px 10px;
    gap: 8px;
  }

  .home-kpi-item {
    flex: 1 0 45%;
  }
}

/* Glass-style overlay widgets */
.kpi.kpi--overlay {
  background: rgba(15, 23, 42, 0.68);
  border-color: rgba(148, 163, 184, 0.8);
  color: #e5e7eb;
  backdrop-filter: blur(12px) saturate(135%);
}

body[data-theme="light"] .kpi.kpi--overlay {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(148, 163, 184, 0.9);
  color: var(--ds-text);
}

.home-overlay-card {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.9);
  backdrop-filter: blur(12px) saturate(135%);
}

body[data-theme="light"] .home-overlay-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(148, 163, 184, 0.95);
}

/* === Kanban layout overrides (ensure fixed-height board with per-column scroll) === */
.loc-content-wrapper .kanban-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.loc-content-wrapper .kanban-card {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.loc-content-wrapper .kanban-card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.loc-content-wrapper .kanban-scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.loc-content-wrapper .kanban-board {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.loc-content-wrapper .kanban-col {
  display: flex;
  flex-direction: column;
  min-width: 270px;
  flex: 1 1 270px;
}

.loc-content-wrapper .kanban-dropzone {
  flex: 1 1 auto;
  min-height: 0;
  /* Fixed viewport-based height: extra cards scroll inside this area */
  height: calc(100vh - (var(--topbar-h) + (var(--shell-pad) * 2) + 160px));
  overflow-y: auto;
}

@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-main,
.dashboard-side {
  min-width: 0;
}

/* Stronger contrast for cards in light mode */
body[data-theme="light"] .glass-card,
body[data-theme="light"] .glass-panel {
  border-color: var(--ds-border-strong) !important;
}

/* KPI tiles */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Medium variant for location dashboard (smaller tiles) */
.kpi-grid.kpi-grid--md {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.kpi-grid.kpi-grid--md .kpi {
  padding: 10px 10px;
}

.kpi-grid.kpi-grid--md .kpi-value {
  font-size: 18px;
}

.kpi-grid.kpi-grid--md .kpi-label {
  font-size: 10px;
}

.kpi {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  padding: 12px 12px;
  box-shadow: var(--ds-shadow-sm);
}

.kpi-label {
  color: var(--ds-muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 800;
}

.kpi-value {
  font-weight: 900;
  font-size: 22px;
  line-height: 1.1;
  margin-top: 2px;
}

.kpi-meta {
  color: var(--ds-muted);
  font-size: 12px;
}

/* Home list */
.list-group-item {
  background: transparent;
  color: var(--ds-text);
  border-color: var(--ds-border) !important;
  padding: 10px 0;
}

.list-group-flush>.list-group-item {
  border-width: 0 0 1px;
}

/* Map should feel embedded */
.card.glass-card .map-canvas {
  border-radius: 0 0 var(--ds-radius) var(--ds-radius);
}
