/* CUSTOM VISIE CSS */

/* -------------------------------------------------------------------------- */
/*  Visie / JDM brand palette - mirrors iq/assets/css/theme.css                */
/*  Prefer these tokens over raw hex values in new styles.                     */
/* -------------------------------------------------------------------------- */
:root,
[data-bs-theme=light] {
  --visie-brand: #3457a2;          /* JDM Power blue - primary */
  --visie-brand-hover: #2a4682;
  --visie-brand-emphasis: #002f57;
  --visie-brand-subtle: #dae1ee;
  --visie-brand-border: #98b7d3;
  --visie-gray: #748194;           /* secondary */
  --visie-success: #00d27a;
  --visie-info: #27bcfd;
  --visie-warning: #f5803e;
  --visie-danger: #e63757;
}

[data-bs-theme=dark] {
  --visie-brand: #94c0ff;
  --visie-brand-hover: #c2d8ff;
  --visie-brand-emphasis: #94c0ff;
  --visie-brand-subtle: rgba(52, 87, 162, 0.2);
  --visie-brand-border: #1a2c51;
  --visie-gray: #c7cdd4;
  --visie-success: #73e6b6;
  --visie-info: #93defe;
  --visie-warning: #fbc6a8;
  --visie-danger: #f4a5b3;
}


.text-visie {
  --ins-text-opacity: 1;
  color: var(--visie-brand) !important;
}
.text-visie:hover {
  --ins-text-opacity: 1;
  color: var(--visie-brand-hover) !important;
}

#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 20vh;
    z-index: 9999;
}

/* Loading Overlay Dark Mode */
[data-bs-theme=dark] #loadingOverlay {
    background-color: rgba(30, 31, 39, 0.95);
    color: #e3e6ef;
}

[data-bs-theme=dark] #loadingOverlay p {
    color: #e3e6ef;
}

/* Select2 Base Styles */
.select2-container .select2-selection--single {
    height: 38px;
    padding: 6px 12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 26px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* Select2 Dark Mode Styles - Only apply when dark theme is active */
/* Main container */
[data-bs-theme=dark] .select2-container--default .select2-selection--single {
    background-color: #1e1f27 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}

/* Selected text */
[data-bs-theme=dark] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #e3e6ef !important;
}

/* Placeholder text */
[data-bs-theme=dark] .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #8791a8 !important;
}

/* Arrow */
[data-bs-theme=dark] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #8791a8 transparent transparent transparent !important;
}

/* Dropdown container */
[data-bs-theme=dark] .select2-container--default .select2-dropdown {
    background-color: #1e1f27 !important;
    border: 1px solid #2a2f3f !important;
}

/* Search box in dropdown */
[data-bs-theme=dark] .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: #252834 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}

[data-bs-theme=dark] .select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #94c0ff !important;
    outline: none;
}

/* Dropdown options */
[data-bs-theme=dark] .select2-container--default .select2-results__option {
    background-color: #1e1f27 !important;
    color: #e3e6ef !important;
}

/* Highlighted option */
[data-bs-theme=dark] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #2a2f3f !important;
    color: #94c0ff !important;
}

/* Selected option */
[data-bs-theme=dark] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #252834 !important;
    color: #94c0ff !important;
}

/* Hover state */
[data-bs-theme=dark] .select2-container--default .select2-results__option:hover {
    background-color: #2a2f3f !important;
}

/* Focus state for main select */
[data-bs-theme=dark] .select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #94c0ff !important;
}

/* Loading/disabled state */
[data-bs-theme=dark] .select2-container--default .select2-results__option[aria-disabled="true"] {
    color: #5a5f73 !important;
}

/* No results message */
[data-bs-theme=dark] .select2-container--default .select2-results__message {
    color: #8791a8 !important;
}

/* Select2 Multiple Selection Dark Mode Styles */
/* Main container for multiple select */
[data-bs-theme=dark] .select2-container--default .select2-selection--multiple {
    background-color: #1e1f27 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}

/* Selected choice tags */
[data-bs-theme=dark] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #252834 !important;
    border: 1px solid #3a4055 !important;
    color: #e3e6ef !important;
}

/* Remove button on choice tags */
[data-bs-theme=dark] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #8791a8 !important;
    border-right-color: #3a4055 !important;
}

[data-bs-theme=dark] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #e3e6ef !important;
    background-color: #2a2f3f !important;
}

/* Search field within multiple select */
[data-bs-theme=dark] .select2-container--default .select2-selection--multiple .select2-search__field {
    color: #e3e6ef !important;
    background-color: transparent !important;
}

/* Placeholder text in multiple select */
[data-bs-theme=dark] .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
    color: #8791a8 !important;
}

/* Focus state for multiple select */
[data-bs-theme=dark] .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #94c0ff !important;
}

/* DataTables Dark Mode Styles - Only apply when dark theme is active */
/* Table headers and footers */
[data-bs-theme=dark] #distTable thead tr,
[data-bs-theme=dark] #distTable tfoot tr,
[data-bs-theme=dark] #manufTable thead tr,
[data-bs-theme=dark] #manufTable tfoot tr,
[data-bs-theme=dark] #salesTable thead tr,
[data-bs-theme=dark] #salesTable tfoot tr,
[data-bs-theme=dark] #commsTable thead tr,
[data-bs-theme=dark] #commsTable tfoot tr,
[data-bs-theme=dark] #monthlyManufTable thead tr,
[data-bs-theme=dark] #monthlyManufTable tfoot tr,
[data-bs-theme=dark] #monthlyDistTable thead tr,
[data-bs-theme=dark] #monthlyDistTable tfoot tr,
[data-bs-theme=dark] #monthlyAccountTable thead tr,
[data-bs-theme=dark] #monthlyAccountTable tfoot tr,
[data-bs-theme=dark] #accountPerformanceTable thead tr,
[data-bs-theme=dark] #accountPerformanceTable tfoot tr {
    background-color: #252834 !important;
}
[data-bs-theme=dark] #distTable thead th,
[data-bs-theme=dark] #distTable tfoot th,
[data-bs-theme=dark] #manufTable thead th,
[data-bs-theme=dark] #manufTable tfoot th,
[data-bs-theme=dark] #salesTable thead th,
[data-bs-theme=dark] #salesTable tfoot th,
[data-bs-theme=dark] #commsTable thead th,
[data-bs-theme=dark] #commsTable tfoot th,
[data-bs-theme=dark] #monthlyManufTable thead th,
[data-bs-theme=dark] #monthlyManufTable tfoot th,
[data-bs-theme=dark] #monthlyDistTable thead th,
[data-bs-theme=dark] #monthlyDistTable tfoot th,
[data-bs-theme=dark] #monthlyAccountTable thead th,
[data-bs-theme=dark] #monthlyAccountTable tfoot th,
[data-bs-theme=dark] #accountPerformanceTable thead th,
[data-bs-theme=dark] #accountPerformanceTable tfoot th {
    color: #e3e6ef !important;
    border-color: #2a2f3f !important;
}
/* Table body rows */
[data-bs-theme=dark] #distTable tbody tr,
[data-bs-theme=dark] #manufTable tbody tr,
[data-bs-theme=dark] #salesTable tbody tr,
[data-bs-theme=dark] #commsTable tbody tr,
[data-bs-theme=dark] #monthlyManufTable tbody tr,
[data-bs-theme=dark] #monthlyDistTable tbody tr,
[data-bs-theme=dark] #monthlyAccountTable tbody tr,
[data-bs-theme=dark] #accountPerformanceTable tbody tr {
    background-color: #1e1f27 !important;
    color: #e3e6ef !important;
}
/* Hover state for rows */
[data-bs-theme=dark] #distTable tbody tr:hover,
[data-bs-theme=dark] #manufTable tbody tr:hover,
[data-bs-theme=dark] #salesTable tbody tr:hover,
[data-bs-theme=dark] #commsTable tbody tr:hover,
[data-bs-theme=dark] #monthlyManufTable tbody tr:hover,
[data-bs-theme=dark] #monthlyDistTable tbody tr:hover,
[data-bs-theme=dark] #monthlyAccountTable tbody tr:hover,
[data-bs-theme=dark] #accountPerformanceTable tbody tr:hover {
    background-color: #252834 !important;
}
/* Table cells */
[data-bs-theme=dark] #distTable tbody td,
[data-bs-theme=dark] #manufTable tbody td,
[data-bs-theme=dark] #salesTable tbody td,
[data-bs-theme=dark] #commsTable tbody td,
[data-bs-theme=dark] #monthlyManufTable tbody td,
[data-bs-theme=dark] #monthlyDistTable tbody td,
[data-bs-theme=dark] #monthlyAccountTable tbody td,
[data-bs-theme=dark] #accountPerformanceTable tbody td {
    color: #e3e6ef !important;
    border-color: #2a2f3f !important;
}
/* Links in tables */
[data-bs-theme=dark] #distTable a,
[data-bs-theme=dark] #manufTable a,
[data-bs-theme=dark] #salesTable a,
[data-bs-theme=dark] #commsTable a,
[data-bs-theme=dark] #monthlyManufTable a,
[data-bs-theme=dark] #monthlyDistTable a,
[data-bs-theme=dark] #monthlyAccountTable a,
[data-bs-theme=dark] #accountPerformanceTable a {
    color: #94c0ff !important;
}
[data-bs-theme=dark] #distTable a:hover,
[data-bs-theme=dark] #manufTable a:hover,
[data-bs-theme=dark] #salesTable a:hover,
[data-bs-theme=dark] #commsTable a:hover,
[data-bs-theme=dark] #monthlyManufTable a:hover,
[data-bs-theme=dark] #monthlyDistTable a:hover,
[data-bs-theme=dark] #monthlyAccountTable a:hover,
[data-bs-theme=dark] #accountPerformanceTable a:hover {
    color: #c2d8ff !important;
}
/* DataTables wrapper elements */
[data-bs-theme=dark] .dataTables_wrapper {
    color: #e3e6ef !important;
}
/* Search input */
[data-bs-theme=dark] .dataTables_wrapper .dataTables_filter input {
    background-color: #252834 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}
[data-bs-theme=dark] .dataTables_wrapper .dataTables_filter input:focus {
    border-color: #94c0ff !important;
    outline: none;
}
/* Info text */
[data-bs-theme=dark] .dataTables_wrapper .dataTables_info {
    color: #8791a8 !important;
}
/* Pagination */
[data-bs-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button {
    background-color: #252834 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}
[data-bs-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: #2a2f3f !important;
    border-color: #94c0ff !important;
    color: #94c0ff !important;
}
[data-bs-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background-color: #3457a2 !important;
    border-color: #3457a2 !important;
    color: #ffffff !important;
}
[data-bs-theme=dark] .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    background-color: #1e1f27 !important;
    border-color: #2a2f3f !important;
    color: #5a5f73 !important;
}
/* DataTables buttons */
[data-bs-theme=dark] .dt-buttons .btn-light {
    background-color: #252834 !important;
    border-color: #2a2f3f !important;
    color: #e3e6ef !important;
}
[data-bs-theme=dark] .dt-buttons .btn-light:hover {
    background-color: #2a2f3f !important;
    border-color: #94c0ff !important;
    color: #94c0ff !important;
}
/* Length menu select */
[data-bs-theme=dark] .dataTables_wrapper .dataTables_length select {
    background-color: #252834 !important;
    border: 1px solid #2a2f3f !important;
    color: #e3e6ef !important;
}
/* Sorting icons */
[data-bs-theme=dark] table.dataTable thead th.sorting:before,
[data-bs-theme=dark] table.dataTable thead th.sorting:after,
[data-bs-theme=dark] table.dataTable thead th.sorting_asc:before,
[data-bs-theme=dark] table.dataTable thead th.sorting_asc:after,
[data-bs-theme=dark] table.dataTable thead th.sorting_desc:before,
[data-bs-theme=dark] table.dataTable thead th.sorting_desc:after {
    opacity: 0.5;
}

#distTable thead tr,
#distTable tfoot tr,
#manufTable thead tr,
#monthlyManufTable thead tr,
#monthlyManufTable tfoot tr,
#monthlyDistTable thead tr,
#monthlyDistTable tfoot tr,
#monthlyAccountTable thead tr,
#monthlyAccountTable tfoot tr,
#accountPerformanceTable thead tr,
#accountPerformanceTable tfoot tr,
#acctMgrTable thead tr,
#acctMgrTable tfoot tr,
#manufTable tfoot tr {
    background-color: #f9fafd !important;
}

/* Commission Analysis Table - Force highlight colors */
#commsTable tbody tr.table-info {
    background-color: #dae1ee !important;
    opacity: 0.7 !important;
}

#commsTable tbody tr.table-info:hover {
    background-color: #c5d1e6 !important;
}

/* Dark mode support */
[data-bs-theme=dark] #commsTable tbody tr.table-info {
    background-color: rgba(52, 87, 162, 0.35) !important;
    color: #e3e6ef !important;
}

[data-bs-theme=dark] #commsTable tbody tr.table-info:hover {
    background-color: rgba(52, 87, 162, 0.5) !important;
}


/* MAPPING STYLES */
#map {
    height: 700px;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-card {
    margin-bottom: 20px;
}

.info-window-content {
    padding: 10px;
    min-width: 250px;
}

.info-window-content h6 {
    margin: 0 0 10px 0;
    color: #344050;
    font-size: 16px;
    font-weight: 600;
}

.info-window-content .info-row {
    margin: 5px 0;
    font-size: 13px;
}

.info-window-content .label {
    color: #748194;
    font-weight: 500;
}

.info-window-content .value {
    color: #344050;
    font-weight: 600;
}

.info-window-content .btn-sm {
    margin-top: 10px;
    width: 100%;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

.loading-overlay.hidden {
    display: none;
}

.legend {
    background: white;
    padding: 10px;
    margin: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 12px;
}

.legend-item {
    margin: 5px 0;
    display: flex;
    align-items: center;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}


/* MAPS */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#map {
    height: 700px;
    width: 100%;
}

.filter-card {
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.form-range::-webkit-slider-thumb {
    background: #3457a2;
}

.form-range::-moz-range-thumb {
    background: #3457a2;
}



/* Chat Message Styles */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f9fafd;
}

.message-avatar i {
    width: 20px;
    height: 20px;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #d8e2ef;
}

.user-message .message-text {
    background-color: #dae1ee;
    color: black;
    font-weight: 600;
}

.user-message .message-avatar {
    background: #edf2f9;
    color: white;
    border: 1px solid #d8e2ef;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.assistant-message .message-text {
    background: white;
}

.error-message .message-text {
    background: #fbdbe1;
    border-color: #f5afbc;
}

.message-timestamp {
    display: block;
    margin-top: 8px;
    font-size: 11px;
}

/* Typing Indicator */
.typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b6c1d2;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Follow-up Suggestions */
.follow-up-suggestions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #d8e2ef;
}

.follow-up-btn {
    font-size: 13px;
    padding: 6px 12px;
}

/* Table Styles */
/* overflow-x, NOT overflow: hidden. This rule is loaded after app.css and so
   overrides Bootstrap's own .table-responsive { overflow-x: auto }, which is
   the entire point of that class - a table wider than its container was being
   clipped at the card edge with no way to reach the rest of it, everywhere in
   the app. The rounded corners the rule was written for survive the change:
   border-radius clips painted content for any overflow value except visible. */
.table-responsive {
    border-radius: 8px;
    overflow-x: auto;
}

.table-responsive table {
    margin-bottom: 0;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #d8e2ef;
}

/* Example Questions */
.example-question {
    cursor: pointer;
    transition: all 0.2s;
}

.example-question:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Scrollbar Styling */
#chatMessages::-webkit-scrollbar {
    width: 8px;
}

#chatMessages::-webkit-scrollbar-track {
    background: #edf2f9;
}

#chatMessages::-webkit-scrollbar-thumb {
    background: #b6c1d2;
    border-radius: 4px;
}

#chatMessages::-webkit-scrollbar-thumb:hover {
    background: #9da9bb;
}

/* Markdown Styles in Messages */
.message-text h1, .message-text h2, .message-text h3, 
.message-text h4, .message-text h5, .message-text h6 {
    margin-top: 0;
    margin-bottom: 8px;
    font-weight: 600;
}

.message-text p {
    margin-bottom: 8px;
}

.message-text ul, .message-text ol {
    margin-bottom: 8px;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 4px;
}

.message-text code {
    background: #f9fafd;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 90%;
}

.message-text pre {
    background: #f9fafd;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
}

.message-text blockquote {
    border-left: 3px solid #b6c1d2;
    padding-left: 12px;
    margin: 8px 0;
    color: #5e6e82;
}

.message-text strong {
    font-weight: 600;
}

.user-message .message-text strong {
    font-weight: 700;
}

/* Icon sizing */
.icon-xs {
    width: 14px;
    height: 14px;
}

/* MoM Scrollable Cards */
.mom-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(128,128,128,0.3) transparent;
}
.mom-scroll-container::-webkit-scrollbar {
    height: 6px;
}
.mom-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.mom-scroll-container::-webkit-scrollbar-thumb {
    background-color: rgba(128,128,128,0.3);
    border-radius: 3px;
}
.mom-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(128,128,128,0.5);
}
.mom-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mom-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ==========================================================================
   VISIE DASHBOARD DESIGN SYSTEM
   --------------------------------------------------------------------------
   Shared presentation layer for the analytics dashboards. Everything is
   scoped to `.visie-dash` on <body>, so a page opts in by adding that class
   and nothing here leaks onto pages that have not been converted yet.

       <body class="visie-dash">

   Rolled out first on dashboard-account.php and dashboard-manuf.php.

   Browser support: uses CSS custom properties, sticky positioning and one
   `:has()` rule (the closed-section border, flagged below). `:has()` needs
   Chrome/Edge 105+, Safari 15.4+, Firefox 121+ - anything older simply skips
   that one border and the rest of the page is unaffected.
   ========================================================================== */

.visie-dash { --dash-sticky: calc(var(--ins-topbar-height, 60px) + var(--ins-topbar-color-line-height, 6px)); }
.visie-dash .min-w-0 { min-width: 0; }
.visie-dash .icon-sm { width: 16px; height: 16px; }
.visie-dash .icon-xs { width: 14px; height: 14px; }
.visie-dash .icon-xxs { width: 12px; height: 12px; }

/* --- Numbers line up in columns ------------------------------------------ */
.visie-dash .num,
.visie-dash .kpi-value,
.visie-dash table td,
.visie-dash table th { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* --- Sticky in-page section navigation ----------------------------------- */
.visie-dash .dash-subnav {
    position: sticky;
    top: var(--dash-sticky);
    z-index: 900;
    background-color: var(--ins-secondary-bg, #fff);
    background-clip: padding-box;
    border: 1px solid var(--ins-border-color);
    border-radius: .5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.visie-dash .dash-subnav-scroll { scrollbar-width: none; -ms-overflow-style: none; }
.visie-dash .dash-subnav-scroll::-webkit-scrollbar { display: none; }
/* Authored as an <a> on the scrolling dashboards and as a <button> where the
   bar drives a Bootstrap tab set instead of scroll position (alerts.php) - the
   UA button chrome is reset here so both spellings render identically. */
.visie-dash .dash-nav-link {
    display: inline-flex; align-items: center; gap: .35rem;
    white-space: nowrap;
    font-size: .8125rem; font-weight: 600; line-height: 1;
    color: var(--ins-secondary-color);
    text-decoration: none;
    padding: .42rem .6rem;
    border: 0;
    background: none;
    border-radius: .375rem;
    transition: background-color .15s ease, color .15s ease;
}
.visie-dash .dash-nav-link:hover { background: var(--ins-tertiary-bg); color: var(--ins-emphasis-color); }
.visie-dash .dash-nav-link.active { background: var(--visie-brand-subtle); color: var(--visie-brand); }
.visie-dash .dash-section { scroll-margin-top: calc(var(--dash-sticky) + 68px); }
/* On a phone the links overflow and the scrollbar is hidden, so the last
   visible one is sliced clean at the edge ("Manufact") and reads as a
   truncated label rather than as more to scroll. A fade says "keeps going". */
@media (max-width: 575.98px) {
    .visie-dash .dash-subnav-scroll {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
                mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    }
}

/* --- Section headings ----------------------------------------------------- */
.visie-dash .section-eyebrow {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    font-weight: 700; color: var(--ins-secondary-color);
}
/* Every dashboard sets the eyebrow beside a right-aligned period or note in a
   no-wrap flex row. On a phone the two squeeze each other into narrow
   columns, so let the note drop to its own line under the eyebrow. */
@media (max-width: 575.98px) {
    .visie-dash .d-flex:has(> .section-eyebrow) { flex-wrap: wrap; row-gap: .2rem; }
}
.visie-dash .card-header h5,
.visie-dash .card-header .card-title { font-size: 1rem; }
.visie-dash .card-header .header-sub { font-size: .75rem; color: var(--ins-secondary-color); }

/* --- Collapse chevron ----------------------------------------------------- */
.visie-dash .section-toggle { line-height: 1; padding: .25rem .45rem; }
.visie-dash .section-toggle i { transition: transform .2s ease; }
.visie-dash .section-toggle.collapsed i { transform: rotate(180deg); }

/* --- KPI cards ------------------------------------------------------------ */
.visie-dash .kpi-card { position: relative; overflow: hidden; height: 100%; }
.visie-dash .kpi-card::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 4px;
    background: var(--kpi-accent, var(--ins-border-color));
}
.visie-dash .kpi-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; color: var(--ins-secondary-color);
}
/* The value is sized off the card, not the viewport. A seven-figure total at
   1.6rem is ~130px, which is the whole content box of a half-width card on a
   phone, so it wrapped mid-number ("$2,704,37" / "5"). The body is a size
   container and the value scales with it down to a floor that keeps it a
   headline; wide cards still land on the 1.6rem cap. Browsers without
   container units skip the second declaration and keep the flat 1.6rem.
   Layout does the rest: on the dashboards the dollar card and Full-Year
   History run full width below `sm` (col-12 col-sm-6 col-xl-3), and only the
   short percentage cards share a row. */
.visie-dash .kpi-value {
    font-size: 1.6rem;
    font-size: clamp(1.2rem, 16cqi, 1.6rem);
    font-weight: 700; line-height: 1.1;
}
/* Equal-height cards mean the body has slack; the sparkline absorbs it so it
   always sits flush to the bottom edge regardless of how much text is above. */
.visie-dash .kpi-card .card-body { display: flex; flex-direction: column; container-type: inline-size; }
.visie-dash .kpi-spark {
    flex: 0 0 auto;
    height: 40px;
    margin: auto -12px -4px -12px;
}
.visie-dash .kpi-meta { font-size: .78rem; }
.visie-dash .kpi-help {
    border: 0; background: none; padding: 0; line-height: 1;
    color: var(--ins-secondary-color); opacity: .5; cursor: help;
}
.visie-dash .kpi-help:hover { opacity: 1; }

/* --- Metric tiles --------------------------------------------------------- */
.visie-dash .metric-tile {
    border: 1px solid var(--ins-border-color); border-radius: .5rem;
    padding: .85rem; height: 100%; background: var(--ins-secondary-bg, #fff);
}
.visie-dash .metric-tile .metric-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: .5rem; font-size: .78rem; padding: .28rem 0;
}
.visie-dash .metric-tile .metric-row + .metric-row { border-top: 1px dashed var(--ins-border-color); }
.visie-dash .metric-tile .metric-row .label { color: var(--ins-secondary-color); }

/* --- Insight notes (replace the stack of full-colour alerts) -------------- */
.visie-dash .insight {
    display: flex; gap: .6rem; align-items: flex-start;
    border: 1px solid var(--ins-border-color); border-left-width: 4px;
    border-radius: .5rem; padding: .6rem .8rem;
    background: var(--ins-tertiary-bg);
    font-size: .82rem; line-height: 1.55;
}
.visie-dash .insight > i { flex: 0 0 auto; margin-top: .15rem; }
.visie-dash .insight-success { border-left-color: var(--visie-success); }
.visie-dash .insight-info    { border-left-color: var(--visie-brand); }
.visie-dash .insight-warning { border-left-color: var(--visie-warning); }
.visie-dash .insight-danger  { border-left-color: var(--visie-danger); }

/* Filled variant - the tint carries the same hue as the left border instead of
   the neutral surface. Reserved for a standing note the reader must not skim
   past (what unit the page is in, for instance); a page full of these reads as
   a page of alerts, which is what .insight replaced. */
.visie-dash .insight-filled.insight-success { background: rgba(0,210,122,.12);  border-color: rgba(0,210,122,.35); }
.visie-dash .insight-filled.insight-info    { background: rgba(52,87,162,.10);  border-color: rgba(52,87,162,.30); }
.visie-dash .insight-filled.insight-warning { background: rgba(245,128,62,.12); border-color: rgba(245,128,62,.35); }
.visie-dash .insight-filled.insight-danger  { background: rgba(230,55,87,.12);  border-color: rgba(230,55,87,.35); }
.visie-dash .insight-filled { border-left-width: 4px; }
.visie-dash .insight-filled.insight-success { border-left-color: var(--visie-success); }
.visie-dash .insight-filled.insight-info    { border-left-color: var(--visie-brand); }
.visie-dash .insight-filled.insight-warning { border-left-color: var(--visie-warning); }
.visie-dash .insight-filled.insight-danger  { border-left-color: var(--visie-danger); }
/* The same tints sit too flat on the dark surface - lift them a step. */
[data-bs-theme=dark] .visie-dash .insight-filled.insight-success { background: rgba(0,210,122,.18); }
[data-bs-theme=dark] .visie-dash .insight-filled.insight-info    { background: rgba(148,192,255,.14); }
[data-bs-theme=dark] .visie-dash .insight-filled.insight-warning { background: rgba(245,128,62,.18); }
[data-bs-theme=dark] .visie-dash .insight-filled.insight-danger  { background: rgba(230,55,87,.20); }

/* --- Month-over-month strip ----------------------------------------------- */
.visie-dash .mom-card {
    min-width: 118px; border-radius: .5rem;
    border: 1px solid var(--ins-border-color);
    padding: .4rem .55rem; scroll-snap-align: start;
}
.visie-dash .mom-card.lvl-up-strong   { background: rgba(0,210,122,.16);  border-color: rgba(0,210,122,.45); }
.visie-dash .mom-card.lvl-up          { background: rgba(0,210,122,.07);  border-color: rgba(0,210,122,.28); }
.visie-dash .mom-card.lvl-down        { background: rgba(245,128,62,.10); border-color: rgba(245,128,62,.34); }
.visie-dash .mom-card.lvl-down-strong { background: rgba(230,55,87,.13);  border-color: rgba(230,55,87,.42); }
.visie-dash .mom-card.lvl-base        { background: var(--ins-secondary-bg, #fff); }
.visie-dash .mom-card.lvl-none        { background: var(--ins-tertiary-bg); border-style: dashed; }
.visie-dash .mom-card.is-latest       { box-shadow: inset 0 0 0 2px var(--visie-brand); }
.visie-dash .mom-scroll-btn {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 28px; height: 28px; padding: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.visie-dash .mom-scroll-btn.prev { left: -6px; }
.visie-dash .mom-scroll-btn.next { right: -6px; }
.visie-dash .mom-legend { font-size: .68rem; }
.visie-dash .mom-legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--ins-border-color); }

/* --- Wide matrix table: pin the first column ------------------------------ */
.visie-dash .sticky-first-col td:first-child,
.visie-dash .sticky-first-col th:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--ins-secondary-bg, #fff);
    box-shadow: 1px 0 0 var(--ins-border-color);
}
.visie-dash .sticky-first-col thead th:first-child,
.visie-dash .sticky-first-col tfoot th:first-child { background: var(--ins-secondary-bg); z-index: 3; }
.visie-dash .sticky-first-col tbody tr:hover td:first-child { background: var(--ins-tertiary-bg); }

/* Two-tier headers - a rowspan name column beside grouped year bands, as on the
   manufacturer matrix in admin-montana-growth.php - have no first-column cell in
   their second row, so `th:first-child` there resolves to the first data heading
   instead. Pinned, that heading slides left and parks on top of the name column.
   Only the first header row owns the pinned cell; the second row scrolls with
   the columns it labels, and reverts to the tint its siblings carry. */
.visie-dash .sticky-first-col thead tr + tr th:first-child {
    position: static;
    background: transparent;
    box-shadow: none;
}

/* A DataTable initialises on the <table>, so its wrapper lands INSIDE whatever
   .table-responsive the markup put around it - which means the search box, the
   export buttons, the row count and the pager all sit in the scrolling region
   and slide away the moment the reader scrolls right on a wide matrix. Moving
   the scroller inwards, onto the layout cell that holds only the table, leaves
   those controls anchored. The outer .table-responsive stays as the no-JS
   fallback and simply never overflows once this is in play, so there is no
   second scrollbar.

   It also puts the scroll container directly around the table, which is what
   .sticky-first-col above needs: a sticky cell pins to its nearest scrolling
   ancestor, so with the scroller further out the pinned column would track the
   wrong box. Worked example: the month matrix on manufacturer-mtm.php, 21
   columns wide. */
.visie-dash .dt-container .dt-layout-table > div { overflow-x: auto; }

/* --- Section headers -------------------------------------------------------
   The theme strips .card-header to `padding: 0 0 10px 0` with no background,
   so a bg-* utility lands as an unpadded full-bleed band. This restores
   padding and caps the panel below with a light, defined tint.
   Tune the whole page's header shade with --dash-head-bg. */
.visie-dash { --dash-head-bg: rgba(52, 87, 162, .07); }
[data-bs-theme=dark] .visie-dash { --dash-head-bg: rgba(148, 192, 255, .08); }

.visie-dash .section-header {
    padding: .6rem .9rem;
    background-color: var(--dash-head-bg);
    border: 1px solid var(--ins-theme-card-border-color, var(--ins-border-color)) !important;
    border-bottom: 0 !important;
    border-radius: var(--ins-border-radius) var(--ins-border-radius) 0 0;
}
/* Join the header to the panel underneath so they read as one section. The
   panel is usually wrapped in a .collapse, but a section that never closes -
   the Manufacturer Movers card on alerts.php - puts it straight after the
   header, so both spellings are matched. */
.visie-dash .section-header + .card-body,
.visie-dash .section-header + .tab-content,
.visie-dash .section-header + .panel-grid,
.visie-dash .section-header + .collapse > .card-body,
.visie-dash .section-header + .collapse > .tab-content,
.visie-dash .section-header + .collapse > .panel-grid {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
/* .card-body draws its own outline from the theme; these two do not, so they
   need one or the header ends up the only bordered part of the section. */
.visie-dash .section-header + .tab-content,
.visie-dash .section-header + .panel-grid,
.visie-dash .section-header + .collapse > .tab-content,
.visie-dash .section-header + .collapse > .panel-grid {
    border: 1px solid var(--ins-theme-card-border-color, var(--ins-border-color));
    border-top: 0;
}
/* Collapsed, the header stands alone - close it off. Two ways in: a chevron
   button inside the header drives the collapse (needs :has(); browsers without
   it simply keep the open-state border, which is cosmetic only), or the whole
   header is itself the trigger and Bootstrap puts .collapsed straight on it -
   as on the Rock cards in stride/rock-history.php. Author such a header with
   class="collapsed" when its body starts closed; the plugin keeps it in step
   from then on. */
.visie-dash .section-header:has(.section-toggle.collapsed),
.visie-dash .section-header.collapsed {
    border-bottom: 1px solid var(--ins-theme-card-border-color, var(--ins-border-color)) !important;
    border-radius: var(--ins-border-radius);
}

/* --- Manufacturer brand mark ------------------------------------------------
   A cross-reference tool crosses into one manufacturer's catalog, and the page
   header is where the reader confirms which one before typing anything - so the
   logo stands in for the maker's name in the heading rather than sitting beside
   it, and the alt text carries that word for anyone the image never reaches.

   The files in assets/images/manuf/ are dark ink on transparent, so they sit
   straight on the page in light mode and disappear in dark mode. The artwork is
   not filtered to fix that - inverting turns Keystone's red to cyan, and
   flattening to white throws the brand colour away - so the dark theme sets the
   mark on a white plate instead, the usual way a vendor logo is carried on a
   dark surface, with its colours left exact. The plate is painted on the <img>
   itself: a transparent PNG shows its own element background through, so no
   wrapper is needed to hold it.

   Sized by height with width auto - these logos differ in aspect ratio, so
   constraining the width would leave a tall mark towering over a wide one. */
.manuf-brand {
    display: inline-block;
    /* Reboot puts border-box on everything, which would spend the dark theme's
       plate padding out of the set height instead of around it. */
    box-sizing: content-box;
    height: 36px;
    width: auto;
    max-width: 220px;
    vertical-align: middle;
}
[data-bs-theme=dark] .manuf-brand {
    padding: .25rem .45rem;
    border-radius: .375rem;
    background-color: #fff;
}
@media (max-width: 575.98px) {
    .manuf-brand { height: 26px; }
}

/* --- Scope bands ------------------------------------------------------------
   Most dashboards describe one subject the whole way down, so their sections
   need no marking. When a page mixes scopes - a rep's own Rocks sitting
   directly above the whole team's growth targets, on stride/index.php - the
   reader has to see the switch before they start reading numbers off cards
   that otherwise look identical. A scope band rails the section on the left
   and tints it; the .scope-badge in the heading names the scope, so the signal
   never rests on colour alone. Badge the sections either side of a band too -
   an unmarked section next to a marked one reads as an oversight rather than
   as the default.

   Drawn in --visie-info on purpose: every other hue in this system already
   means a status (green on track, red at risk, orange behind pace), and a
   status hue wrapped round a whole section reads as a verdict on everything
   inside it.

   To emphasise a section without claiming its scope changed, reach for
   .dash-feature below instead. */
.visie-dash .scope-band {
    --scope-accent: var(--visie-info);
    --scope-tint: rgba(39, 188, 253, .06);
    border: 1px solid var(--ins-border-color);
    border-left: 4px solid var(--scope-accent);
    border-radius: .5rem;
    padding: .9rem 1rem .35rem;
    background-color: var(--scope-tint);
}
[data-bs-theme=dark] .visie-dash .scope-band { --scope-tint: rgba(39, 188, 253, .08); }

/* Declares its own --scope-accent rather than leaning on an ancestor: the pill
   is used both inside a band and on its own in a page header, and an undefined
   custom property resolves to nothing - which paints white text on no
   background at all. The fallback in the var() call is a second belt. */
.visie-dash .scope-badge {
    --scope-accent: var(--visie-info);
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .2rem .45rem;
    border-radius: .25rem;
    font-size: .62rem; font-weight: 700; line-height: 1.4;
    text-transform: uppercase; letter-spacing: .07em;
    white-space: nowrap;
    color: #fff;
    background-color: var(--scope-accent, var(--visie-info));
}
.visie-dash .scope-badge i { width: 11px; height: 11px; }
/* The dark palette lightens every accent, so the pill needs dark type on it. */
[data-bs-theme=dark] .visie-dash .scope-badge { color: #10161f; }

/* The page's own subject - no band, just the pill, so the banded section is
   the one that stands out. */
.visie-dash .scope-badge-self { --scope-accent: var(--visie-brand); }

/* --- Featured panel ---------------------------------------------------------
   A different job from a scope band above. A band says "the subject changed
   here"; a feature says "of all the panels on this page, read this one". Same
   scope, different weight - so it takes the brand hue rather than the band's
   --visie-info, and it is capped at one per page. A second featured panel
   cancels the first out: if everything is emphasised, nothing is.

   Three parts, and all three are needed or the emphasis reads as a stray bit
   of colour: .dash-feature on the .card, .is-feature on the .section-eyebrow
   above it, and .is-feature on its .dash-nav-link so the subnav points at the
   same panel. Worked example: the Sub-Region Breakdown on dashboard-jdm-se.php.
   Pair it with a short badge naming why the panel matters - colour alone does
   not survive a greyscale print or a reader who cannot separate the hues. */
.visie-dash .dash-feature {
    border: 1px solid var(--visie-brand-border) !important;
    border-left: 4px solid var(--visie-brand) !important;
    border-radius: var(--ins-border-radius);
    box-shadow: 0 .5rem 1.5rem rgba(52, 87, 162, .16) !important;
}
[data-bs-theme=dark] .visie-dash .dash-feature { box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .45) !important; }

/* The header carries a deeper cut of the same tint every other section header
   uses, so the panel reads as louder rather than as a different component. */
.visie-dash .dash-feature > .section-header {
    background-color: rgba(52, 87, 162, .12);
    border: 0 !important;
}
[data-bs-theme=dark] .visie-dash .dash-feature > .section-header { background-color: rgba(148, 192, 255, .14); }
.visie-dash .dash-feature > .section-header h5 { color: var(--visie-brand-emphasis); }
/* The card already draws the outline, so the body must not draw a second one
   inboard of it. */
.visie-dash .dash-feature > .collapse > .card-body,
.visie-dash .dash-feature > .card-body { border: 0 !important; }

/* The eyebrow and the nav pill both take the brand hue, so the pointer and the
   panel it points at are recognisably the same thing. */
.visie-dash .section-eyebrow.is-feature { color: var(--visie-brand); }
.visie-dash .dash-nav-link.is-feature { color: var(--visie-brand); font-weight: 600; }
.visie-dash .dash-nav-link.is-feature:hover,
.visie-dash .dash-nav-link.is-feature.active { background: var(--visie-brand-subtle); }

/* A directional rail across the top of a metric tile - the panel's own colour
   coding, set per tile through --tile-accent. Only worth it where the tiles
   are the point of the panel; on a dense indicator grid it is four more
   colours competing with the numbers they sit above. */
.visie-dash .metric-tile.tile-railed { position: relative; overflow: hidden; padding-top: 1rem; }
.visie-dash .metric-tile.tile-railed::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: var(--tile-accent, var(--ins-secondary-color));
}
.visie-dash .metric-tile .tile-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }

/* --- Tab panes read as panels, not as bare page -----------------------------
   The theme paints .card transparent and hangs the surface off .card-body, so
   anything else sitting directly under a .section-header - a tab pane, or a
   plain .row of side-by-side panels - lands on bare page unless it carries a
   surface of its own. Put .panel-grid on such a row (see the Trends and
   Accounts sections of manuf-business-review.php) to give it the same one. */
.visie-dash .tab-content,
.visie-dash .panel-grid {
    background-color: var(--ins-secondary-bg, #fff);
    border-bottom-left-radius: var(--ins-border-radius);
    border-bottom-right-radius: var(--ins-border-radius);
}
.visie-dash .panel-head {
    background-color: var(--ins-tertiary-bg, #f6f7fb);
    border-bottom: 1px solid var(--ins-border-color);
    min-height: 66px;
}
.visie-dash .panel-head h6 { font-size: .85rem; }

/* --- Sortable column headings --------------------------------------------- */
.visie-dash th[data-table-sort] { cursor: pointer; white-space: nowrap; }
.visie-dash th[data-table-sort]:hover { color: var(--visie-brand); }

/* --- Tabs inside cards -----------------------------------------------------
   These sit on the tinted .section-header, so each tab carries the panel
   background to read as a segmented control rather than dissolving into it. */
.visie-dash .card-tabs .nav-link {
    font-size: .82rem; font-weight: 600; padding: .4rem .75rem;
    color: var(--ins-secondary-color); border-radius: .375rem;
    background-color: var(--ins-secondary-bg, #fff);
    border: 1px solid var(--ins-theme-card-border-color, var(--ins-border-color));
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.visie-dash .card-tabs .nav-link:hover {
    color: var(--visie-brand);
    border-color: var(--visie-brand-border);
}
.visie-dash .card-tabs .nav-link.active {
    background-color: var(--ins-secondary-bg, #fff);
    color: var(--visie-brand);
    border-color: var(--visie-brand);
    box-shadow: 0 1px 4px rgba(52, 87, 162, .18);
}

/* --- Back to top -----------------------------------------------------------
   All 45 pages carrying this button write it the same way - .btn.btn-primary
   with a Lucide arrow-up inside - so both fixes below are made here rather
   than in the markup.

   padding:0 is load-bearing. .btn ships --ins-btn-padding-x: 1.1rem, and
   17.6px a side inside a fixed 40px circle leaves a ~3px content box: the
   arrow is pushed out of the button and the control reads as a bare coloured
   disc. The icon is sized here too instead of relying on the .icon-sm the
   markup puts on the <i> (Lucide carries the class onto the <svg> it swaps
   in), so the button cannot be left iconless by a class that is out of scope.

   The colour is overridden through the --ins-btn-* variables rather than by
   changing 45 files' btn-primary: in this theme primary is #00d27a, and a
   loud green disc floating over a dashboard full of green KPI accents reads
   as one of them. A muted brand blue sits back where a utility control
   belongs. Setting the variables keeps hover and active consistent.
   --------------------------------------------------------------------------*/
.visie-dash .back-to-top {
    position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 1000;
    width: 40px; height: 40px; padding: 0; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    --ins-btn-color: #fff;
    --ins-btn-bg: #5b7fc7;
    --ins-btn-border-color: #5b7fc7;
    --ins-btn-hover-color: #fff;
    --ins-btn-hover-bg: #3457a2;
    --ins-btn-hover-border-color: #3457a2;
    --ins-btn-active-color: #fff;
    --ins-btn-active-bg: #2a4682;
    --ins-btn-active-border-color: #2a4682;
}
.visie-dash .back-to-top.show { display: inline-flex; }
.visie-dash .back-to-top svg { width: 18px; height: 18px; }

/* Dark mode: the same blue against a dark surface is heavier than it looks in
   light mode, so lift it a step rather than letting it sink into the page. */
[data-bs-theme=dark] .visie-dash .back-to-top {
    --ins-btn-bg: #6f90d2;
    --ins-btn-border-color: #6f90d2;
    --ins-btn-hover-bg: #88a5dd;
    --ins-btn-hover-border-color: #88a5dd;
    --ins-btn-active-bg: #5b7fc7;
    --ins-btn-active-border-color: #5b7fc7;
}

/* --- Dumbbell comparison rows ----------------------------------------------
   A ranked "before -> after" comparison, one row per entity: a hollow dot for
   the prior period, a filled dot for the current one, and a segment between
   them whose length is the change. Half the rows of paired bars and no label
   collisions at any list length, which is what makes long chains readable.
   Positions are set inline as percentages of the widest row. */
.visie-dash .dumbbell-scroll { max-height: 560px; overflow-y: auto; }
.visie-dash .db-row {
    display: grid;
    grid-template-columns: minmax(120px, 230px) 1fr minmax(120px, auto) 74px;
    align-items: center;
    gap: .75rem;
    padding: .32rem .3rem;
    border-radius: .375rem;
}
.visie-dash .db-row + .db-row { border-top: 1px dashed var(--ins-border-color); }
.visie-dash .db-row:hover { background: var(--ins-tertiary-bg); }
.visie-dash .db-name {
    font-size: .8rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.visie-dash .db-name a { text-decoration: none; }

/* The track is the full data range; the baseline shows how far along it sits. */
.visie-dash .db-track { position: relative; height: 18px; min-width: 60px; }
.visie-dash .db-track::before {
    content: ""; position: absolute; left: 0; right: 0; top: 50%;
    height: 1px; background: var(--ins-border-color);
}
.visie-dash .db-seg {
    position: absolute; top: 50%; height: 3px; transform: translateY(-50%);
    border-radius: 2px; background: var(--ins-secondary-color);
}
.visie-dash .db-dot {
    position: absolute; top: 50%; width: 10px; height: 10px;
    margin-left: -5px; transform: translateY(-50%);
    border-radius: 50%; box-sizing: border-box;
}
.visie-dash .db-dot.prev {
    background: var(--ins-secondary-bg, #fff);
    border: 2px solid var(--ins-secondary-color);
}
.visie-dash .db-dot.curr {
    background: var(--ins-secondary-color);
    border: 2px solid var(--ins-secondary-color);
}
.visie-dash .db-row.is-up .db-seg,
.visie-dash .db-row.is-up .db-dot.curr { background: var(--visie-brand); border-color: var(--visie-brand); }
.visie-dash .db-row.is-down .db-seg,
.visie-dash .db-row.is-down .db-dot.curr { background: var(--visie-danger); border-color: var(--visie-danger); }

.visie-dash .db-values { font-size: .76rem; white-space: nowrap; text-align: right; }
.visie-dash .db-delta { font-size: .72rem; text-align: right; }

/* The rollup carries everything below the cut so the chain total still ties. */
.visie-dash .db-row.db-rollup {
    margin-top: .35rem;
    border-top: 1px solid var(--ins-border-color);
    background: var(--ins-tertiary-bg);
}
.visie-dash .db-row.db-rollup .db-name { font-style: italic; color: var(--ins-secondary-color); }
/* Nothing is plotted for the rollup, so drop the baseline too - an empty
   axis rule reads as a missing bar rather than as a deliberate omission. */
.visie-dash .db-row.db-rollup .db-track::before { display: none; }

.visie-dash .db-legend { font-size: .7rem; }
.visie-dash .db-legend .db-key {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    box-sizing: border-box; vertical-align: -1px;
}
.visie-dash .db-legend .db-key.prev { background: var(--ins-secondary-bg, #fff); border: 2px solid var(--ins-secondary-color); }
.visie-dash .db-legend .db-key.curr { background: var(--visie-brand); }

/* Narrow screens: the track is the first thing worth losing - the numbers
   and the change badge still carry the whole story. */
@media (max-width: 575.98px) {
    .visie-dash .db-row { grid-template-columns: 1fr auto 64px; }
    .visie-dash .db-track { display: none; }
}

/* --- Inline year sparkline --------------------------------------------------
   A server-rendered <svg> trend for tables long enough that one chart instance
   per row would cost more than the picture is worth (analysis-trend.php runs to
   a hundred manufacturers). It draws in currentColor, so it takes the colour of
   the cell it sits in and needs no dark-mode rule of its own.

   Deliberately unlabelled and aria-hidden: it sits beside the same numbers in
   the row, so it is a shape cue rather than the only way to read the value.
   ------------------------------------------------------------------------- */
.visie-dash .yr-spark {
    display: block;
    margin: 0 auto;
    color: var(--visie-brand);
    overflow: visible;
}

/* --- Highlighted table rows -------------------------------------------------
   Marks a subset of rows as belonging together - the manufacturers making up
   80% of commission revenue on analysis.php, for instance. The tint is the same
   one the section headers use, so it reads as "grouped" rather than as a status.

   Never let the tint be the only signal: put a badge in the row as well. A
   colour-only marking is gone in greyscale, in a print, and for a reader who
   cannot separate the hues.

   :not(:hover) keeps the row out of the way of .table-hover - without it this
   rule and Bootstrap's hover background tie on specificity, and whichever
   stylesheet loads last silently wins.
   ------------------------------------------------------------------------- */
.visie-dash tr.core-row:not(:hover) > td { background-color: rgba(52, 87, 162, .06); }
[data-bs-theme=dark] .visie-dash tr.core-row:not(:hover) > td { background-color: rgba(148, 192, 255, .08); }

/* --- Chart tokens -----------------------------------------------------------
   Colours the chart configs read at runtime through getComputedStyle, so a
   chart and the legend swatch printed beside it cannot drift apart.

   The diverging pair is blue<->red, NOT green<->red. Green and red collapse to
   effectively one hue under deuteranopia (OKLab dE 2.5, a hard fail on every
   step of either ramp), while this pair clears it at dE 14.5 light / 14.2 dark.
   Both poles also sit inside their mode's lightness band and clear 3:1 against
   the surface they are drawn on.

   Reach for these for POLARITY - which side of a baseline a value sits on -
   never for good/bad. The green/red status colours still carry that, and a page
   that uses both needs to say which is which (see the "Reading the colours"
   panel in the help modal on analysis-seasonality.php, the first page to use
   these tokens).
   ------------------------------------------------------------------------- */
.visie-dash {
    --vz-diverge-pos: #3457a2;
    --vz-diverge-mid: #98a2b3;
    --vz-diverge-neg: #e63757;
}
[data-bs-theme=dark] .visie-dash {
    --vz-diverge-pos: #5580cc;
    --vz-diverge-mid: #5c6675;
    --vz-diverge-neg: #e2566f;
}

/* --- Expandable data rows ---------------------------------------------------
   Parent rows that open a child table underneath them - an account into its
   manufacturers on commissions.php, a manufacturer into its months. The whole
   row is the hit target, so the pointer has to be on the row rather than on the
   chevron cell alone, and the row that is currently open keeps the section-head
   tint so it stays tied to the block it opened.

   Both states are theme tokens on purpose: these rules replaced three <style>
   blocks that scripts injected with a hard-coded #f8f9fa, which is invisible
   against the dark surface.

   .shown is set by DataTables' own child-row handling and the chevron rotates
   with it, so the tint is never the only signal that a row is open.
   ------------------------------------------------------------------------- */
.visie-dash tr.has-children { cursor: pointer; }
.visie-dash tr.has-children:hover > td { background-color: var(--ins-tertiary-bg); }
.visie-dash tr.has-children.shown > td { background-color: var(--dash-head-bg); }

/* --- A form control sized to its own content --------------------------------
   .form-select and .form-control are width:100%, so one dropped into a flex row
   - a view switcher beside a panel title, say - claims the whole line and shoves
   everything after it onto the next one. Bootstrap's .w-auto is the usual answer
   and is NOT in this theme's build: it ships .w-0/25/50/75/100 only, so reaching
   for .w-auto silently does nothing and the control still goes full width.

   min-width holds the field steady while its option labels change - the row
   counts on the OCAL Cross view switcher are rewritten on every render, and
   without it the control breathed in and out beside the heading.
   ------------------------------------------------------------------------- */
.visie-dash .form-select.field-inline,
.visie-dash .form-control.field-inline { width: auto; min-width: 10.5rem; }

/* --- Soft buttons: a label you can read in both themes ----------------------
   app.css builds .btn-soft-* out of two tokens: the label takes the flat accent
   (--ins-success and friends) and the fill takes that accent's subtle tint.
   The tint is theme-aware; the label is not. On the dark surface the tint
   composites down to roughly #222a40 while the label stays at its light-mode
   #3457a2, so a soft button's own text sits at about 2.1:1 against it - the
   control is legible only by its shape. btn-soft-primary misses in the other
   direction and fails in LIGHT mode: #00d27a on #d9f8eb is about 1.9:1.

   The theme already ships the colour that belongs on those tints -
   --ins-*-text-emphasis is darkened for light and lightened for dark - so only
   the resting label token is redirected here. The fill, the hover swap to a
   solid accent, focus rings and every other button style are untouched, and
   because .btn-soft-* declares its tokens on one class this needs no
   !important. Scoped to .visie-dash so pages that have not been converted keep
   exactly the buttons they have today.
   ------------------------------------------------------------------------- */
.visie-dash .btn-soft-primary   { --ins-btn-color: var(--ins-primary-text-emphasis); }
.visie-dash .btn-soft-secondary { --ins-btn-color: var(--ins-secondary-text-emphasis); }
.visie-dash .btn-soft-success   { --ins-btn-color: var(--ins-success-text-emphasis); }
.visie-dash .btn-soft-info      { --ins-btn-color: var(--ins-info-text-emphasis); }
.visie-dash .btn-soft-warning   { --ins-btn-color: var(--ins-warning-text-emphasis); }
.visie-dash .btn-soft-danger    { --ins-btn-color: var(--ins-danger-text-emphasis); }

/* --- Flagged data rows ------------------------------------------------------
   A row whose answer came back but did not survive validation - a crossed OCAL
   part whose trade size, material or 4X/XP variant disagrees with what the
   customer asked for, on tools/ocal/index.php. Warning-tinted, not danger:
   the number is usable, it just has to be read before it is ordered.

   Same rules as .core-row above. The tint is never the only signal - every
   flagged row also carries a badge naming what disagrees, so it survives a
   greyscale print and a reader who cannot separate the hues. And the
   :not(:hover) guard keeps .table-hover readable on these rows instead of
   tying with it on specificity.

   Lifted a step on dark, where the light-mode alpha sits flat against #1e1f27.
   ------------------------------------------------------------------------- */
.visie-dash tr.flagged-row:not(:hover) > td { background-color: rgba(245, 128, 62, .07); }
[data-bs-theme=dark] .visie-dash tr.flagged-row:not(:hover) > td { background-color: rgba(245, 128, 62, .14); }

/* --- Row-level disclosure chevron -------------------------------------------
   A per-row twin of .section-toggle, for a button that opens a detail row
   directly under its own - the alternates-and-search drawer on
   tools/ocal/index.php. Driven off aria-expanded rather than a .collapsed
   class, because that row is toggled by hand rather than by Bootstrap's
   collapse plugin: hanging the arrow off the same attribute a screen reader
   announces is what stops the two drifting apart, and means the open state is
   carried by shape as well as by the drawer appearing.
   ------------------------------------------------------------------------- */
.visie-dash .row-toggle i { transition: transform .2s ease; }
.visie-dash .row-toggle[aria-expanded="true"] i { transform: rotate(180deg); }

/* --- Editable quantity cell -------------------------------------------------
   A number input sitting inside a dense table column. The UA spinner arrows eat
   a third of the field at this size and fire on scroll-over, so they are
   dropped and the field is sized to the widest quantity anyone types - wide
   enough for six figures, narrow enough that the column does not push the
   description off the right edge. Right-aligned with .num beside it so the
   figures still stack in a column.
   ------------------------------------------------------------------------- */
.visie-dash input.qty-input {
    width: 5rem;
    -moz-appearance: textfield;
}
.visie-dash input.qty-input::-webkit-outer-spin-button,
.visie-dash input.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- File drop target -------------------------------------------------------
   The "drop it, or paste a screenshot" panel that fronts a file-to-text step -
   the BOM upload on tools/ocal/index.php. Pair it with the border utilities
   that draw the outline (border border-2 border-dashed rounded-3); everything
   here is the surface, the state colours and the height.

   The colours are tokens rather than the utilities' defaults on purpose: a
   plain .border-dashed draws in --ins-border-color, which against the recessed
   --ins-tertiary-bg fill is close to invisible on the dark surface, so the
   drop target read as an empty gap. --visie-brand-border on hover and the full
   --visie-brand while a file is over it give the three states real separation
   in both themes.

   min-height keeps it level with the paste box it sits beside, so the two
   columns do not jump as file chips are added and removed.
   ------------------------------------------------------------------------- */
.visie-dash .file-drop {
    border-color: var(--ins-border-color) !important;
    background-color: var(--ins-tertiary-bg);
    transition: border-color .15s ease, background-color .15s ease;
    min-height: 260px;
}
.visie-dash .file-drop:hover { border-color: var(--visie-brand-border) !important; }
.visie-dash .file-drop.dragging {
    border-color: var(--visie-brand) !important;
    background-color: var(--visie-brand-subtle);
}
.visie-dash .file-drop kbd { font-size: .7rem; padding: .1rem .3rem; }

/* --- Empty / placeholder state ----------------------------------------------
   The oversized icon above an empty-state message. Held down to a whisper so it
   reads as a mark on the page rather than as content competing with the line
   that tells the reader what to do next - which is the part that matters, and
   is why an empty state here never just says "No data".
   ------------------------------------------------------------------------- */
.visie-dash .empty-state-icon { width: 48px; height: 48px; opacity: .35; }

/* --- Print ----------------------------------------------------------------- */
@media print {
    .visie-dash .dash-subnav,
    .visie-dash .back-to-top,
    .visie-dash .mom-scroll-btn { display: none !important; }
    .visie-dash .collapse { display: block !important; height: auto !important; }
}

/* --- SweetAlert2 dialogs (assets/js/visie-notify.js) -------------------------
   Only dialogs opened through the notify helpers carry .visie-swal, so these
   rules leave the plain Swal.fire() calls elsewhere in the app untouched.

   The popup takes its colours from theme tokens instead of fixed hex: the stock
   SweetAlert2 card is white and unreadable on the dark surface, and its own
   greys ignore the skin the user picked. Buttons are real .btn elements
   (buttonsStyling:false in the helper), which is why none are coloured here.

   Only :root tokens work here. --ins-modal-bg / --ins-modal-color are declared
   on .modal in app.css, so outside a Bootstrap modal they resolve to nothing,
   the whole declaration is invalid, and background-color falls back to
   transparent - the popup shows the backdrop straight through it. Same trap for
   any other --ins-<component>-* variable.

   The title is --ins-body-color, not --ins-emphasis-color: in this theme's light
   mode emphasis is rgba(106,108,111,.75), which is *lighter* than body text, so
   a title set with it reads washed out.

   SweetAlert2 injects its own stylesheet from JS, so it lands after this file
   and wins every tie on specificity. Anything that has to stick is written as
   .visie-swal .swal2-x (two classes) rather than left to .form-control.

   The popup's own 2em padding is dropped: the children below carry 1.5rem side
   margins, and the two were stacking into a 56px gutter.
   ------------------------------------------------------------------------- */
.visie-swal {
    background-color: var(--ins-secondary-bg);
    color: var(--ins-body-color);
    border: 1px solid var(--ins-border-color);
    border-radius: 0.5rem;
    box-shadow: var(--ins-box-shadow-lg);
    padding: 0 0 1rem;
}
.visie-swal .swal2-icon {
    font-size: 0.8rem;              /* the icon is sized in em, so this scales all of it */
    margin: 1.5rem auto 0.25rem;
}
/* SweetAlert2 ships pastel icon colours of its own (#f8bb86, #f27474, #a5dc86)
   that belong to no skin here. The ring and the marks inside are coloured
   separately, so both have to be pointed at the tokens. */
.visie-swal .swal2-icon.swal2-warning  { color: var(--ins-warning); border-color: var(--ins-warning); }
.visie-swal .swal2-icon.swal2-error    { color: var(--ins-danger);  border-color: var(--ins-danger); }
.visie-swal .swal2-icon.swal2-success  { color: var(--ins-primary); border-color: var(--ins-primary); }
.visie-swal .swal2-icon.swal2-info,
.visie-swal .swal2-icon.swal2-question { color: var(--ins-info);    border-color: var(--ins-info); }
.visie-swal .swal2-icon.swal2-error [class^='swal2-x-mark-line'] { background-color: var(--ins-danger); }
.visie-swal .swal2-icon.swal2-success [class^='swal2-success-line'] { background-color: var(--ins-primary); }
.visie-swal .swal2-icon.swal2-success .swal2-success-ring { border-color: var(--ins-primary); opacity: 0.3; }
.visie-swal .visie-swal-title {
    color: var(--ins-body-color);
    font-size: 1.125rem;
    font-weight: 600;
    padding: 1.25rem 1.5rem 0.25rem;
}
/* The message is the content of an error or confirm dialog, so it stays at body
   colour. Only the field caption below is muted. */
.visie-swal .visie-swal-text {
    color: var(--ins-body-color);
    font-size: 0.9375rem;
    margin: 0.25rem 1.5rem 0;
    padding: 0;
}
.visie-swal .visie-swal-label {
    color: var(--ins-secondary-color);
    font-size: 0.8125rem;
    justify-content: flex-start;
    margin: 0.9rem 1.5rem 0.35rem;
}
/* Restated from .form-control, which SweetAlert2's later stylesheet overrides:
   its own rule makes the field a flex box with no vertical padding, 18px text
   and a pale blue focus glow that belongs to no skin here. These values are the
   theme's real input - 36px tall, 13px text - so the dialog field matches every
   other field in the app. */
.visie-swal .swal2-input.form-control {
    display: block;
    width: auto;
    height: auto;
    margin: 0 1.5rem;
    padding: 0.45rem 0.77rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ins-body-color);
    background-color: var(--ins-secondary-bg);
    border: 1px solid var(--ins-border-color);
    border-radius: var(--ins-border-radius);
    box-shadow: none;
}
.visie-swal .swal2-input.form-control:focus {
    border-color: var(--ins-secondary-color);
    box-shadow: none;
    outline: 0;
}
.visie-swal .visie-swal-invalid {
    background: transparent;
    color: var(--ins-danger);
    font-size: 0.8125rem;
    justify-content: flex-start;
    margin: 0.5rem 1.5rem 0;
    padding: 0;
}
.visie-swal .swal2-actions {
    gap: 0.5rem;
    margin: 1.5rem 1.5rem 0.25rem;
    padding: 0;
}
/* A message dialog leads with a centred icon, so its centred title reads right.
   A form dialog has no icon and a left-aligned label and field under the title,
   so a centred title there just looks misaligned - promptText adds this class. */
.visie-swal-form .visie-swal-title,
.visie-swal-form .visie-swal-text {
    text-align: left;
}
.visie-swal .swal2-loader {
    border-color: var(--ins-primary) transparent var(--ins-primary) transparent;
}
.visie-swal .swal2-close {
    color: var(--ins-secondary-color);
    box-shadow: none;
}
.visie-swal .swal2-close:hover { color: var(--ins-danger); }

/* No z-index rule here on purpose: SweetAlert2's container is 1060 and
   .app-topbar is 1001, so toasts already clear the chrome. Raising it would be
   the one selector in this block that is not scoped to .visie-swal, and it
   would move every existing Swal toast in the app along with it. */
.visie-swal.visie-swal-toast {
    padding: 0.75rem 1rem;
    box-shadow: var(--ins-box-shadow);
}
.visie-swal.visie-swal-toast .visie-swal-title {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0;
}
.visie-swal.visie-swal-toast .visie-swal-text {
    font-size: 0.8125rem;
    margin: 0.15rem 0 0;
}
