/* ==========================================================================
   ERP shell — last-loaded chrome so every list, preview, modal, and CTA
   follows tenant tokens. Loaded at the end of base.html so it wins over
   per-page <style> blocks that still hardcode emerald.
   ========================================================================== */

html body .jalusi-submit-btn,
html body .btn-primary,
html body .primary-btn,
html body .submit-btn,
html body .tenant-btn-primary,
html body .shop-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--erp-btn-pad-y, 9px) var(--erp-btn-pad-x, 20px);
  border-radius: var(--erp-btn-radius, 12px);
  font-size: var(--erp-btn-font, 13px);
  font-weight: var(--erp-btn-weight, 600);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  background-color: var(--erp-btn-primary-bg, var(--tenant-button-bg, #064e3b)) !important;
  background-image: var(--erp-btn-primary-image, none) !important;
  color: var(--erp-btn-primary-fg, var(--tenant-button-text, #ffffff)) !important;
  border: 1px solid color-mix(in srgb, var(--erp-btn-primary-bg, #064e3b) 82%, #000000) !important;
  box-shadow: none;
}

html body .jalusi-cancel-btn,
html body .btn-secondary,
html body .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--erp-btn-pad-y, 9px) var(--erp-btn-pad-x, 20px);
  border-radius: var(--erp-btn-radius, 12px);
  font-size: var(--erp-btn-font, 13px);
  font-weight: var(--erp-btn-weight, 600);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--theme-accent-800, var(--tenant-primary, #064e3b)) !important;
  border: 1px solid var(--theme-accent-300, rgba(16, 185, 129, 0.25)) !important;
}

html body .jalusi-cancel-btn:hover,
html body .btn-secondary:hover,
html body .btn-outline:hover {
  background-color: var(--theme-accent-050, rgba(16, 185, 129, 0.06)) !important;
}

html body .view-btn,
html body .filter-pill,
html body .folder-tab,
html body .tab-btn,
html body .preview-update-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--erp-btn-view-pad-y, 6px) var(--erp-btn-view-pad-x, 14px);
  border-radius: var(--erp-btn-view-radius, 10px);
  font-size: var(--erp-btn-view-font, 12px);
  font-weight: var(--erp-btn-weight, 600);
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
  background-color: var(--theme-accent-100, rgba(16, 185, 129, 0.08)) !important;
  background-image: none !important;
  color: var(--theme-accent-800, var(--tenant-primary, #064e3b)) !important;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15)) !important;
}

html body .view-btn:hover,
html body .filter-pill:hover,
html body .folder-tab:not(.active):hover,
html body .tab-btn:not(.active):hover,
html body .preview-update-btn:hover {
  background-color: var(--theme-accent-200, rgba(16, 185, 129, 0.16)) !important;
  border-color: var(--theme-accent-300, rgba(16, 185, 129, 0.28)) !important;
  color: var(--theme-accent-900, var(--tenant-primary, #064e3b)) !important;
}

html body .danger-btn,
html body .jalusi-danger-btn {
  color: #ffffff !important;
  background-color: #dc2626 !important;
  background-image: none !important;
  border: 1px solid #b91c1c !important;
}

html body .layout-btn.active,
html body .filter-pill.active,
html body .folder-tab.active,
html body .tab-btn.active,
html body .data-list-view-toggle.active {
  background-color: var(--erp-btn-primary-bg, var(--tenant-button-bg, #064e3b)) !important;
  background-image: var(--erp-btn-primary-image, none) !important;
  color: var(--erp-btn-primary-fg, var(--tenant-button-text, #ffffff)) !important;
  border-color: color-mix(in srgb, var(--erp-btn-primary-bg, #064e3b) 82%, #000000) !important;
  box-shadow: none !important;
}

html body .layout-btn:not(.active),
html body .folder-tab:not(.active),
html body .tab-btn:not(.active),
html body .data-list-view-toggle:not(.active) {
  color: var(--theme-accent-800, var(--tenant-primary, #064e3b)) !important;
}

html body .layout-btn:not(.active):hover,
html body .folder-tab:not(.active):hover,
html body .tab-btn:not(.active):hover,
html body .data-list-view-toggle:not(.active):hover {
  background-color: var(--theme-accent-100, rgba(16, 185, 129, 0.08)) !important;
}

html body .section-label,
html body .erp-list-meta-label,
html body .preview-field-label,
html body [class$="-meta-label"] {
  color: var(--theme-accent-800, var(--tenant-primary, #064e3b)) !important;
}

html.dark body .section-label,
html.dark body .erp-list-meta-label,
html.dark body .preview-field-label,
html.dark body [class$="-meta-label"] {
  color: var(--theme-accent, #34d399) !important;
  opacity: 0.7;
}

html body .filter-input,
html body .jalusi-modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
html body .jalusi-modal select,
html body .jalusi-modal textarea {
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2)) !important;
  background-color: var(--theme-accent-050, rgba(16, 185, 129, 0.02)) !important;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
html body .jalusi-modal textarea {
  min-height: 5.5rem;
}

html body .filter-input:focus,
html body .jalusi-modal input:focus,
html body .jalusi-modal select:focus,
html body .jalusi-modal textarea:focus {
  border-color: var(--theme-accent-400, rgba(16, 185, 129, 0.5)) !important;
  box-shadow: 0 0 0 3px var(--theme-accent-100, rgba(16, 185, 129, 0.08)) !important;
  outline: none;
}

html body .jalusi-modal label {
  color: var(--theme-accent-800, var(--tenant-primary, #064e3b)) !important;
}

html body .jalusi-modal {
  border-color: var(--theme-accent-200, rgba(16, 185, 129, 0.15)) !important;
}

html body .stat-card-dark {
  background: linear-gradient(
    145deg,
    var(--tenant-dashboard-stat-bg, #071810) 0%,
    color-mix(in srgb, var(--tenant-dashboard-stat-bg, #071810) 85%, var(--theme-accent, #10b981)) 100%
  ) !important;
  border-color: var(--theme-accent-200, rgba(16, 185, 129, 0.12)) !important;
}

html body .stat-accent-line {
  background: var(--theme-accent, #10b981) !important;
}

html body [style*="linear-gradient(180deg, #10b981"],
html body [style*="linear-gradient(180deg,#10b981"],
html body [style*="linear-gradient(180deg, #10b981,"] {
  background: linear-gradient(180deg, var(--theme-accent, #10b981), var(--theme-accent-800, #064e3b)) !important;
}

html body .erp-chip-select,
html body .erp-chip {
  border-color: var(--theme-accent-200, rgba(16, 185, 129, 0.2)) !important;
  background: var(--theme-accent-100, rgba(16, 185, 129, 0.08)) !important;
}

html body .erp-chip-select:focus {
  border-color: var(--theme-accent-400, rgba(16, 185, 129, 0.5)) !important;
  box-shadow: 0 0 0 3px var(--theme-accent-100, rgba(16, 185, 129, 0.08)) !important;
}

html body .erp-ws-fields dt {
  color: var(--theme-accent-800, rgba(6, 78, 59, 0.6)) !important;
}

html body .erp-drawer-panel {
  border-left: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15));
}

/* Create stays a centered modal; Preview is the right drawer. */
html body .erp-create-root {
  position: fixed !important;
  inset: 0 !important;
  justify-content: center !important;
  align-items: center !important;
  z-index: 100040 !important;
}
html body .erp-create-root:not(.hidden):not([hidden]):not([x-cloak]):not([style*="display: none"]):not([style*="display:none"]),
html body .modal-container:not(.hidden):not([hidden]):not([x-cloak]):not([style*="display: none"]):not([style*="display:none"]):not([data-erp-overlay="persist"]) {
  display: flex !important;
}
html body .erp-create-root > .modal-overlay,
html body .modal-container > .modal-overlay,
/* Nested wrappers (flex + dimmer) still used by some HR templates — demote any dimmer under create-root. */
html body .erp-create-root .modal-overlay,
html body .modal-container .modal-overlay,
/* "FIXED LAYERING" templates use a Tailwind fixed inset-0 dimmer; keep it under the panel. */
html body .erp-create-root > .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel),
html body .modal-container > .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel),
html body .erp-create-root .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel):not(.erp-create-root),
html body .modal-container .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel):not(.modal-container) {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
}
/* Nested centering wrappers must span the overlay; otherwise the panel shrinks to a narrow column. */
html body .erp-create-root > .flex,
html body .modal-container > .flex {
  width: 100% !important;
  max-width: 100% !important;
  position: relative !important;
  z-index: 2 !important;
  pointer-events: none !important;
}
html body .erp-create-root > .flex > *,
html body .modal-container > .flex > * {
  pointer-events: auto !important;
}
html body .erp-create-root > .jalusi-modal,
html body .erp-create-root > [class*="jalusi-modal"],
html body .erp-create-root > .relative,
html body .erp-create-root .jalusi-modal,
html body .modal-container > .jalusi-modal,
html body .modal-container > [class*="jalusi-modal"],
html body .modal-container > .relative,
html body .modal-container .jalusi-modal {
  position: relative !important;
  z-index: 2 !important;
  pointer-events: auto !important;
}

html body .erp-create-root.hidden,
html body .erp-create-root[style*="display: none"],
html body .erp-create-root[style*="display:none"],
html body .modal-container.hidden,
html body .modal-container[hidden],
html body .modal-container[x-cloak],
html body .modal-container[style*="display: none"]:not(.is-open),
html body .modal-container[style*="display:none"]:not(.is-open) {
  display: none !important;
  pointer-events: none !important;
}

html body .erp-list-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

html body .erp-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.1));
  background: var(--tenant-card-bg, #ffffff);
  transition: border-color 0.2s ease;
}

html body .erp-list-item:hover {
  transform: none;
  border-color: var(--theme-accent-300, rgba(16, 185, 129, 0.25));
  box-shadow: none;
}

html.dark body .erp-list-item {
  background: var(--tenant-card-bg, #0a1f14);
}

html body .erp-list-item-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
  flex: 1;
  min-width: 0;
}

html body .erp-list-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tenant-card-text, #111827);
  line-height: 1.35;
}

html.dark body .erp-list-item-title {
  color: #f9fafb;
}

html body .erp-list-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

html body .erp-list-meta-value {
  font-size: 12px;
  font-weight: 500;
  color: #374151;
}

html.dark body .erp-list-meta-value {
  color: #d1fae5;
}

html body .peek-popover a {
  color: var(--theme-accent-700, var(--theme-accent-800, #065f46)) !important;
}

/* Last-loaded overlay safety: closed drawers and pre-Alpine cloak never cover the list. */
html body .erp-preview-root.hidden,
html body .erp-workspace-root.hidden,
html body .erp-preview-root[hidden],
html body .erp-preview-root[x-cloak],
html body .erp-workspace-root[x-cloak],
html body .erp-preview-root[style*="display: none"],
html body .erp-preview-root[style*="display:none"],
html body .erp-workspace-root[style*="display: none"],
html body .erp-workspace-root[style*="display:none"],
html body .fixed.inset-0[x-cloak] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Scrollable pickers inside overflow modals (native <select> dropdowns cannot scroll). */
.erp-scroll-select {
  position: relative;
}
.erp-scroll-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 2.5rem;
  padding: 8px 12px;
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  color: inherit;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
  border-radius: 12px;
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.02));
  cursor: pointer;
}
.erp-scroll-select-trigger:hover,
.erp-scroll-select.is-open .erp-scroll-select-trigger {
  border-color: var(--theme-accent-400, rgba(16, 185, 129, 0.45));
}
.erp-scroll-select-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-scroll-select-trigger-label.is-placeholder {
  color: #6b7280;
}
.erp-scroll-select-chevron {
  flex-shrink: 0;
  color: #6b7280;
  transition: transform 0.15s ease;
}
.erp-scroll-select.is-open .erp-scroll-select-chevron {
  transform: rotate(180deg);
}
.erp-scroll-select-panel {
  margin-top: 4px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
html.dark .erp-scroll-select-panel {
  background: #111827;
}
.erp-scroll-select-search {
  width: 100%;
  border: 0 !important;
  border-bottom: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15)) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 8px 12px;
  font-size: 13px;
  background: transparent !important;
}
.erp-scroll-select-list {
  max-height: 12rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.jalusi-modal select:not([multiple]):not(.filter-input),
.erp-create-root select:not([multiple]):not(.filter-input) {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 2.5rem;
  padding: 8px 36px 8px 12px;
  font-size: 13px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
  border-radius: 12px;
  background-color: var(--theme-accent-050, rgba(16, 185, 129, 0.02));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%236b7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.erp-scroll-select-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.erp-scroll-select-option:hover,
.erp-scroll-select-option.is-selected {
  background: var(--theme-accent-100, rgba(16, 185, 129, 0.12));
}
.erp-scroll-select-option.erp-scroll-dept-hide {
  display: none !important;
}
.erp-scroll-select-check {
  cursor: pointer;
}
.erp-scroll-select-meta {
  color: #6b7280;
  font-size: 11px;
}
.erp-scroll-select-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: #6b7280;
}

.form-hint {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 500;
  color: #6b7280;
}
.form-hint--rule {
  color: #047857;
}
.form-hint--warn {
  color: #b45309;
}
html.dark .form-hint {
  color: #9ca3af;
}
html.dark .form-hint--rule {
  color: #6ee7b7;
}
html.dark .form-hint--warn {
  color: #fbbf24;
}
.jalusi-modal input[type="date"],
.jalusi-modal input[type="datetime-local"],
.jalusi-modal input[type="number"],
.jalusi-modal input[type="tel"],
.jalusi-modal input[type="url"],
.jalusi-modal input[type="email"],
.jalusi-modal select {
  min-height: 2.5rem;
}
.jalusi-modal input::placeholder,
.jalusi-modal textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jalusi-modal textarea::placeholder {
  white-space: normal;
}
.jalusi-modal input[type="number"] {
  padding-right: 0.65rem;
}
.jalusi-modal .erp-product-flags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: 0.5rem 1rem;
  width: 100%;
}
.jalusi-modal .erp-product-flags > label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.18));
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.04));
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.3;
}
.jalusi-modal .erp-product-flags input {
  width: auto;
  min-width: 1rem;
  min-height: 1rem;
  margin: 0;
  accent-color: var(--theme-accent, #10b981);
}
.jalusi-modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.jalusi-modal select,
.jalusi-modal textarea {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
.jalusi-modal .grid > * {
  min-width: 0;
}
/* Two equal columns. Pair is not Tailwind `.grid`, so children need their own shrink. */
.jalusi-modal .erp-field-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem 1rem;
  align-items: start;
  width: 100%;
}
.jalusi-modal .erp-field-pair > * {
  min-width: 0;
  max-width: 100%;
}
.jalusi-modal .erp-field-pair > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.jalusi-modal .erp-field-pair > div > label {
  min-height: 2.6em;
  display: flex;
  align-items: flex-end;
}
.jalusi-modal .erp-field-pair > .form-hint {
  grid-column: 1 / -1;
  margin-top: 0;
}
.jalusi-modal .erp-field-pair input,
.jalusi-modal .erp-field-pair select,
.jalusi-modal .erp-field-pair textarea {
  min-width: 0 !important;
  width: 100%;
  max-width: 100%;
}
.jalusi-modal .erp-field-pair input[type="date"],
.jalusi-modal .erp-field-pair input[type="datetime-local"] {
  min-width: 0 !important;
}
.jalusi-modal .erp-field-pair input[type="date"]::-webkit-datetime-edit,
.jalusi-modal .erp-field-pair input[type="datetime-local"]::-webkit-datetime-edit {
  min-width: 0;
}
@media (max-width: 540px) {
  .jalusi-modal .erp-field-pair {
    grid-template-columns: minmax(0, 1fr);
  }
  .jalusi-modal .erp-field-pair > div > label {
    min-height: 0;
  }
}

/* Overlay cards size their own grids so paired fields never crush each other
   (viewport sm: still 2-col inside a max-w-md/lg modal on desktop). */
html body .jalusi-modal,
html body .erp-drawer-panel {
  container-type: inline-size;
  container-name: erp-overlay;
  min-width: 0;
  max-width: 100%;
}
html body .jalusi-modal form,
html body .jalusi-modal dl,
html body .jalusi-modal .space-y-3,
html body .jalusi-modal .space-y-4 {
  min-width: 0;
  max-width: 100%;
}
html body .jalusi-modal .grid,
html body .jalusi-modal .erp-ws-fields {
  min-width: 0;
  width: 100%;
}
html body .jalusi-modal .grid > *,
html body .jalusi-modal .erp-ws-fields > * {
  min-width: 0;
  max-width: 100%;
}
html body .jalusi-modal dd,
html body .jalusi-modal .erp-ws-fields dd,
html body .jalusi-modal p {
  overflow-wrap: anywhere;
  word-break: break-word;
}
html body .jalusi-modal .grid.grid-cols-2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
html body .jalusi-modal input[type="date"],
html body .jalusi-modal input[type="datetime-local"] {
  min-width: 0;
  max-width: 100%;
}
html body .jalusi-modal .flex:has(> input):has(> button) > input,
html body .jalusi-modal .flex:has(> select):has(> button) > select,
html body .jalusi-modal .flex:has(> .filter-input):has(> button) > .filter-input {
  min-width: 0;
  flex: 1 1 auto;
}
html body .jalusi-modal .flex:has(> input):has(> button) > button,
html body .jalusi-modal .flex:has(> select):has(> button) > button {
  flex-shrink: 0;
}

@container erp-overlay (max-width: 34rem) {
  .erp-field-pair,
  .grid.grid-cols-2,
  .grid.sm\:grid-cols-2,
  .erp-ws-fields {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .erp-field-pair > div > label {
    min-height: 0;
  }
  .flex:has(> input:not([type="checkbox"]):not([type="radio"])):has(> button),
  .flex:has(> select):has(> button) {
    flex-wrap: wrap;
  }
  .flex:has(> input:not([type="checkbox"]):not([type="radio"])):has(> button) > input,
  .flex:has(> select):has(> button) > select,
  .flex:has(> .filter-input):has(> button) > .filter-input {
    flex: 1 1 100%;
  }
}

@container erp-overlay (max-width: 22rem) {
  .erp-picker-with-add {
    flex-wrap: wrap;
  }
  .erp-picker-with-add-field {
    flex: 1 1 100%;
  }
}

/* Plus next to catalog pickers (package / account / client) in form modals. */
.erp-picker-with-add {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.erp-picker-with-add-field {
  flex: 1 1 auto;
  min-width: 0;
}
.erp-picker-add-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-top: 0;
  border-radius: 12px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.04));
  color: var(--theme-accent-700, #059669);
  cursor: pointer;
}
.erp-picker-add-btn:hover {
  border-color: var(--theme-accent-400, rgba(16, 185, 129, 0.45));
  background: var(--theme-accent-soft, rgba(16, 185, 129, 0.12));
}
.erp-inline-create-modal {
  z-index: 100050;
}

/* Shared list-as-home chrome (KPI, cards, chips). Last-loaded so it wins over
   per-page <style> blocks that still lift-on-hover. */
@keyframes erpListCountUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
html body .kpi-animate,
html body .page-enter {
  animation: erpListCountUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
html body .stagger-1 { animation-delay: 0.05s; }
html body .stagger-2 { animation-delay: 0.1s; }
html body .stagger-3 { animation-delay: 0.15s; }
html body .stagger-4 { animation-delay: 0.2s; }
html body .stagger-5 { animation-delay: 0.25s; }

html body .metric-card,
html body .stat-card-dark,
html body .project-card {
  transition: border-color 0.2s ease !important;
}
html body .metric-card:hover,
html body .stat-card-dark:hover,
html body .project-card:hover {
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--theme-accent-300, rgba(16, 185, 129, 0.28)) !important;
}
html body .stat-card-dark.is-active,
html body .stat-card-dark.ring-2 {
  outline: 2px solid color-mix(in srgb, var(--theme-accent, #10b981) 55%, transparent);
  outline-offset: 2px;
}
html body .stat-accent-line {
  width: 20px;
  height: 2px;
  margin-top: 14px;
  border-radius: 2px;
  transition: width 0.3s ease;
}
html body .stat-card-dark:hover .stat-accent-line { width: 40px; }

html body .projects-card-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}
html body .project-card.erp-list-item {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
}
html body .project-card-cover {
  width: 100%;
  flex: 0 0 auto;
  height: 72px;
}
html body .project-card {
  border-radius: 18px;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.1));
  background: var(--tenant-card-bg, #ffffff);
  overflow: hidden;
}
html.dark body .project-card {
  background: var(--tenant-card-bg, #0a1f14);
}
html body .project-card-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--theme-accent, #10b981), var(--theme-accent-800, #064e3b));
}
html body .project-card-body { padding: 16px; }
html body .project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
html body .project-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--tenant-card-text, #111827);
  line-height: 1.35;
}
html.dark body .project-card-name { color: #f9fafb; }
html body .project-card-scope {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}
html body .project-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 12px;
}
html body .project-card-meta-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(6, 78, 59, 0.65);
  margin-bottom: 2px;
}
html.dark body .project-card-meta-label { color: rgba(52, 211, 153, 0.4); }
html body .project-card-meta-value {
  font-size: 12px;
  color: #374151;
  font-weight: 500;
}
html.dark body .project-card-meta-value { color: #d1fae5; }
html body .project-card-account {
  font-size: 11px;
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
html body .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 21, 14, 0.7);
  backdrop-filter: blur(4px);
  z-index: 99999;
}
html body .modal-container {
  position: fixed;
  inset: 0;
  z-index: 99999;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
html body .modal-container > .modal-overlay,
html body .erp-create-root > .modal-overlay,
html body .modal-container .modal-overlay,
html body .erp-create-root .modal-overlay,
html body .modal-container > .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel),
html body .erp-create-root > .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel),
html body .modal-container .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel):not(.modal-container),
html body .erp-create-root .fixed.inset-0:not(.jalusi-modal):not(.erp-drawer-panel):not(.erp-create-root) {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
}
/* Persist Preview: Close/X/Esc only. Dimmer must never steal clicks from the panel. */
html body .modal-container[data-erp-overlay="persist"] > .modal-overlay {
  pointer-events: none !important;
}
/* Teleported persist Preview: do not use x-cloak (Alpine x-show then restores display:none).
   Alpine :class is-open is the only visibility gate. */
html body .modal-container[data-erp-overlay="persist"]:not(.is-open) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
html body .modal-container[data-erp-overlay="persist"].is-open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
  z-index: 100041 !important;
}
html body .erp-create-root.modal-container {
  z-index: 100040 !important;
}
html body .project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
html body .erp-next-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--theme-accent-800, #064e3b);
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.08));
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.18));
  border-radius: 999px;
  padding: 3px 10px;
}
html body .erp-next-action.is-warn {
  color: #b45309;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
}
html body .erp-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.08));
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
  color: var(--theme-accent-800, #064e3b);
  text-decoration: none;
}
html body .erp-filter-chip:hover { border-color: var(--theme-accent-400, rgba(16, 185, 129, 0.4)); }
html body .erp-bulk-bar {
  position: sticky;
  bottom: 16px;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--tenant-card-bg, #fff);
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.2));
}
html body .erp-bulk-bar.is-open { display: flex; }
html body .erp-ws-field-root {
  z-index: 100000;
}
html body .projects-table-wrap { width: 100%; }
html body .projects-table { width: 100%; border-collapse: collapse; }
html body .projects-table thead th {
  text-align: left;
  padding: 14px 18px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9ca3af;
  border-bottom: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.08));
  white-space: nowrap;
}
html body .projects-table tbody tr {
  border-bottom: 1px solid var(--theme-accent-100, rgba(16, 185, 129, 0.05));
}
html body .projects-table tbody td {
  padding: 14px 18px;
  vertical-align: middle;
}
@media (max-width: 500px) {
  html body .projects-table-wrap { overflow: visible; }
  html body .projects-table { display: none; }
  html body .projects-card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 12px; }
}
html body .project-card-budget {
  font-size: 13px;
  font-weight: 700;
  color: var(--theme-accent-700, #059669);
}
html.dark body .project-card-budget { color: #34d399; }
html body .project-card-manager {
  display: flex;
  align-items: center;
  gap: 6px;
}
html body .project-card-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--theme-accent-100, rgba(16, 185, 129, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--theme-accent-800, #064e3b);
  flex-shrink: 0;
}
html body .warning-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}
html.dark body .warning-badge {
  background: #451a03;
  color: #fbbf24;
  border-color: #78350f;
}

/* ===== ERP Modal Premium System (v29) =====
   Production uplift: raise legacy z-50 shells, unify field rhythm / footers /
   control heights, and polish panel chrome without breaking IDs/Alpine. */

/* Raise legacy field/update modals above page chrome (nav, sticky bars). */
html body .fixed.inset-0.z-50[aria-modal="true"],
html body .fixed.inset-0.z-50.overflow-y-auto,
html body .fixed.inset-0[class*="z-[5"][aria-modal="true"],
html body .fixed.inset-0[class*="z-[6"][aria-modal="true"] {
  z-index: 100040 !important;
}

/* Legacy nested dimmers under any full-screen modal root (pre-migration pages). */
html body .fixed.inset-0[aria-modal="true"] > .flex > .fixed.inset-0,
html body .fixed.inset-0.overflow-y-auto > .flex > .fixed.inset-0,
html body .fixed.inset-0[aria-modal="true"] > .flex.min-h-full > .fixed.inset-0,
html body .fixed.inset-0[aria-modal="true"] > .flex.min-h-screen > .fixed.inset-0 {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
  background: rgba(4, 21, 14, 0.7) !important;
  backdrop-filter: blur(4px);
}

/* Legacy flex wrappers: full-bleed center so panels are not a narrow column.
   Exclude Preview drawers (erp-preview-root) — those must stay right-docked. */
html body .fixed.inset-0[aria-modal="true"]:not(.erp-preview-root) > .flex.min-h-full,
html body .fixed.inset-0[aria-modal="true"]:not(.erp-preview-root) > .flex.min-h-screen,
html body .fixed.inset-0.overflow-y-auto:not(.erp-preview-root) > .flex.min-h-full,
html body .fixed.inset-0.overflow-y-auto:not(.erp-preview-root) > .flex.min-h-screen,
html body .fixed.inset-0[aria-modal="true"]:not(.erp-preview-root) > .flex.items-center,
html body .fixed.inset-0.overflow-y-auto:not(.erp-preview-root) > .flex.items-center {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100% !important;
  position: relative !important;
  z-index: 2 !important;
  pointer-events: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 1rem !important;
  box-sizing: border-box !important;
}
html body .fixed.inset-0[aria-modal="true"] > .flex > *,
html body .fixed.inset-0.overflow-y-auto > .flex > * {
  pointer-events: auto !important;
}

/* Preview drawers: keep stretch + right dock even if nested flex uses min-h-full. */
html body .erp-preview-root > .flex.min-h-full,
html body .erp-preview-root > .flex.items-stretch {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100% !important;
  position: relative !important;
  z-index: 2 !important;
  pointer-events: none !important;
  align-items: stretch !important;
  justify-content: flex-end !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}
html body .erp-preview-root > .flex > * {
  pointer-events: auto !important;
}

/* Panel chrome — create/update cards only (never undock Preview drawers). */
html body .jalusi-modal:not(.erp-drawer-panel),
html body .erp-modal-panel:not(.erp-drawer-panel) {
  max-height: min(90vh, 880px) !important;
  overflow-y: auto !important;
  border-radius: 1.5rem !important;
  box-shadow: 0 32px 80px rgba(6, 78, 59, 0.22) !important;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15)) !important;
  background: var(--tenant-card-bg, #fff) !important;
}
html body .jalusi-modal.erp-drawer-panel,
html body .erp-drawer-panel.jalusi-modal {
  max-height: 100vh !important;
  height: 100% !important;
  border-radius: 0 !important;
  overflow-y: auto !important;
}

html body .erp-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--theme-accent-100, rgba(16, 185, 129, 0.1));
}
html body .erp-modal-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
html body .erp-modal-accent {
  width: 4px;
  min-height: 1.25rem;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    var(--theme-accent, #10b981),
    var(--theme-accent-800, #064e3b)
  );
  flex-shrink: 0;
  margin-top: 2px;
}
html body .erp-modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #111827;
  line-height: 1.3;
}
html.dark body .erp-modal-title { color: #f9fafb; }
html body .erp-modal-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: #6b7280;
  line-height: 1.4;
}
html body .erp-modal-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  background: var(--theme-accent-050, rgba(16, 185, 129, 0.06));
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}
html body .erp-modal-close:hover {
  color: #374151;
  background: var(--theme-accent-100, rgba(16, 185, 129, 0.12));
}

/* Form rhythm + sticky-feel footer row */
html body .jalusi-modal form.erp-modal-form,
html body .jalusi-modal form.space-y-4,
html body .jalusi-modal form.space-y-3 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
html body .jalusi-modal form.space-y-4 > :not([hidden]) ~ :not([hidden]),
html body .jalusi-modal form.space-y-3 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 0; /* gap handles spacing when we also set display:flex */
}
html body .erp-modal-footer,
html body .jalusi-modal form > .flex.gap-3:last-child,
html body .jalusi-modal form > .flex.pt-2:last-child,
html body .jalusi-modal form > .flex.justify-end:last-child {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--theme-accent-100, rgba(16, 185, 129, 0.1));
}
html body .jalusi-modal form > .flex.gap-3:last-child > .jalusi-submit-btn,
html body .jalusi-modal form > .flex.gap-3:last-child > .jalusi-cancel-btn,
html body .erp-modal-footer > .jalusi-submit-btn,
html body .erp-modal-footer > .jalusi-cancel-btn {
  flex: 1 1 auto;
  min-width: 7rem;
}

/* Control normalization inside modals */
html body .jalusi-modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
html body .jalusi-modal select,
html body .jalusi-modal textarea {
  min-height: 2.625rem;
  border-radius: 0.75rem !important;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.22)) !important;
  padding: 0.625rem 0.875rem !important;
  font-size: 0.875rem !important;
  line-height: 1.35 !important;
  background: #fff !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
html body .jalusi-modal textarea {
  min-height: 5.5rem;
}
html body .jalusi-modal label,
html body .jalusi-modal .section-label {
  display: block;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
  margin-bottom: 0.375rem !important;
  color: var(--theme-accent-800, #064e3b) !important;
}

/* Subtle enter motion for create roots (respect reduced motion). */
@media (prefers-reduced-motion: no-preference) {
  html body .erp-create-root:not(.hidden) > .jalusi-modal,
  html body .modal-container:not(.hidden) > .jalusi-modal,
  html body .erp-create-root.modal-container > .jalusi-modal {
    animation: erp-modal-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  html body .erp-create-root:not(.hidden) > .modal-overlay,
  html body .modal-container:not(.hidden) > .modal-overlay {
    animation: erp-overlay-in 160ms ease-out;
  }
}
@keyframes erp-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes erp-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Topbar chip stays 32px even when a View More page restyles .profile-avatar. */
html body .profile-avatar {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  flex-shrink: 0;
}
html body .profile-avatar.w-10 {
  width: 2.5rem !important;
  height: 2.5rem !important;
  max-width: 2.5rem !important;
}

/* Compact identity photo on detail / View More field rows. */
html body .erp-detail-photo,
html body img.erp-detail-photo {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15));
}
html body .erp-detail-photo-fallback {
  width: 48px;
  height: 48px;
  max-width: 48px;
  border-radius: 50%;
  background: var(--theme-accent-100, rgba(16, 185, 129, 0.08));
  color: var(--theme-accent-800, #064e3b);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--theme-accent-200, rgba(16, 185, 129, 0.15));
  letter-spacing: 0.02em;
}
