:root {
    --dlg-primary: #08264A;
    --dlg-secondary: #1E4F8F;
    --dlg-accent: #1FA2FF;
    --dlg-bg-dark: #020B18;
    --dlg-panel: rgba(12, 32, 70, 0.85);
    --dlg-text: #FFFFFF;
    --dlg-muted: #AAB7D0;
}

body { background: var(--dlg-bg-dark); color: var(--dlg-text); font-family: 'Segoe UI', sans-serif; }
main h1, main h2, main h3, main h4, main h5, main h6 { color: #EAF2FF; }
main p, main li, main td, main th, main label, main small, main span { color: #D6E2F5; }
main .table { --bs-table-color: #EAF2FF; --bs-table-bg: transparent; }
main .table-dark { --bs-table-color: #EAF2FF; --bs-table-bg: rgba(9, 29, 62, 0.92); --bs-table-striped-bg: rgba(20, 48, 92, 0.92); }
main a { color: #7CC7FF; }
main a:hover { color: #AADBFF; }

.navbar-dlg { background: var(--dlg-panel) !important; backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.1); }
.navbar-dlg .nav-link { color: var(--dlg-muted); }
.navbar-dlg .nav-link:hover, .navbar-dlg .nav-link.active { color: var(--dlg-accent); }
.navbar-dlg .navbar-toggler { border-color: rgba(255,255,255,0.25); }
.navbar-dlg .navbar-toggler-icon { filter: invert(1) grayscale(100%) brightness(1.8); }

.nav-dlg-modules { flex-wrap: wrap; gap: 0.25rem 0.15rem; row-gap: 0.35rem; align-items: stretch; }
@media (min-width: 992px) {
    .nav-dlg-modules { gap: 0.2rem; }
}
.nav-dlg-mod-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dlg-muted);
    text-decoration: none;
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
@media (min-width: 992px) {
    .nav-dlg-mod-link {
        flex-direction: column;
        gap: 0.2rem;
        min-width: 3.5rem;
        max-width: 4.25rem;
        padding: 0.4rem 0.35rem;
        text-align: center;
    }
}
.nav-dlg-mod-link:hover {
    color: var(--dlg-accent);
    background: rgba(31, 162, 255, 0.12);
    border-color: rgba(31, 162, 255, 0.25);
}
.nav-dlg-mod-link.active {
    color: var(--dlg-accent);
    background: rgba(31, 162, 255, 0.18);
    border-color: rgba(31, 162, 255, 0.35);
}
.nav-dlg-mod-icon { font-size: 1.35rem; line-height: 1; flex-shrink: 0; }
@media (min-width: 992px) {
    .nav-dlg-mod-icon { font-size: 1.45rem; }
}
.nav-dlg-mod-abbr {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tooltip.dlg-nav-tooltip .tooltip-inner { text-align: left; max-width: 220px; }

.card-dlg { background: var(--dlg-panel); border: 1px solid rgba(255,255,255,0.14); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }

/*
 * DLG dark panels: Bootstrap’s .card applies color: var(--bs-body-color) (default theme ≈ #212529).
 * app.css only sets light colors on main p/span/td/… — not plain divs — so nested value divs inherited
 * near-black text on export shipment docs (e.g. carrier booking read-only) and were unreadable.
 */
main .card.card-dlg {
    color: var(--dlg-text);
}

/* Export shipment documents: in-page #anchors from section hub — keep title clear of viewport edge */
.dlg-shipment-doc-section {
    scroll-margin-top: 1rem;
}

/* Platform settlement (CSS) — workflow accordion
   Bootstrap accordion vars + global `main span` otherwise yield light text on light headers. */
.css-settlement-workflow.accordion {
    --bs-accordion-bg: transparent;
    --bs-accordion-border-color: transparent;
    --bs-accordion-btn-padding-x: 1rem;
    --bs-accordion-btn-padding-y: 0.85rem;
    --bs-accordion-body-padding-x: 1rem;
    --bs-accordion-body-padding-y: 1rem;
    --bs-accordion-btn-bg: #071a3d;
    --bs-accordion-btn-color: #ffffff;
    --bs-accordion-btn-focus-border-color: rgba(31, 162, 255, 0.45);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 0.15rem rgba(31, 162, 255, 0.35);
    --bs-accordion-active-bg: #0c2f63;
    --bs-accordion-active-color: #ffffff;
}
.css-settlement-workflow .accordion-item {
    background: var(--dlg-panel);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
/* Full `main` chain beats Bootstrap accordion + avoids light collapsed headers */
main .css-settlement-workflow.accordion .accordion-item .accordion-header .accordion-button {
    background-color: #071a3d !important;
    background-image: none !important;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: none !important;
    align-items: flex-start;
    border: 0;
}
main .css-settlement-workflow.accordion .accordion-item .accordion-header .accordion-button:not(.collapsed) {
    background-color: #0c2f63 !important;
    color: #ffffff !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.07) !important;
}
main .css-settlement-workflow.accordion .accordion-item .accordion-header .accordion-button.collapsed {
    background-color: #071a3d !important;
    color: #ffffff !important;
}
main .css-settlement-workflow.accordion .accordion-item .accordion-header .accordion-button:focus {
    border-color: rgba(31, 162, 255, 0.5);
    box-shadow: 0 0 0 0.15rem rgba(31, 162, 255, 0.35) !important;
}
main .css-settlement-workflow.accordion .accordion-item .accordion-header .accordion-button::after {
    filter: invert(1) brightness(1.2);
    opacity: 0.95;
}
/* Do not use color:inherit — `main span` breaks it; set every text node explicitly */
main .css-settlement-workflow .accordion-button .flex-grow-1 > span.d-block {
    color: #ffffff !important;
    font-weight: 600;
}
main .css-settlement-workflow .accordion-button .css-step-sub {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    color: #d8e8ff !important;
    margin-top: 0.15rem;
    line-height: 1.35;
    opacity: 1 !important;
}
main .css-settlement-workflow .accordion-button .css-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(31, 162, 255, 0.35) !important;
    color: #f0f8ff !important;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 0.65rem;
    flex-shrink: 0;
}
.css-settlement-workflow .accordion-body {
    background: rgba(5, 18, 42, 0.55);
    border-top: 1px solid rgba(255,255,255,0.1);
}
/* Inner strip above tables — keep dark so h5 / subtitles are not light-on-light */
.css-settlement-workflow .accordion-body .border-bottom.border-secondary {
    background-color: rgba(6, 22, 52, 0.98) !important;
}
/* Inner report headers inside expanded panels: “Paid line items” + grey subtitle — legible on panel bg */
main .css-settlement-workflow .accordion-body h5.text-dlg-soft,
main .css-settlement-workflow .accordion-body h6.text-dlg-soft {
    color: #FFFFFF !important;
}
main .css-settlement-workflow .accordion-body .d-flex.align-items-center.flex-wrap > span.small.text-dlg-muted,
main .css-settlement-workflow .accordion-body h6 span.small.text-dlg-muted {
    color: #E8F0FC !important;
}
main .css-settlement-workflow .accordion-body p.small.text-dlg-muted {
    color: #DCE6F5 !important;
}
.text-dlg-muted { color: #D6E2F5 !important; }
.text-dlg-soft { color: #EAF2FF !important; }
.text-muted { color: #C9D4E8 !important; opacity: 1 !important; }
.kpi-card { min-height: 120px; }
.kpi-label { font-size: 0.95rem; color: #D7E1F2; margin-bottom: 0.35rem; }
.kpi-value { font-size: 2rem; font-weight: 700; color: #FFFFFF; line-height: 1; }
.kpi-card.kpi-compact { min-height: 0; }
.kpi-compact .kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #B8C8E2;
    margin-bottom: 0.2rem;
    line-height: 1.25;
}
.kpi-compact .kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}
.btn-dlg-primary { background: var(--dlg-secondary); border-color: var(--dlg-accent); color: #fff; }
.btn-dlg-primary:hover { background: var(--dlg-accent); color: #fff; }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: rgba(12, 32, 70, 0.92); border: 1px solid rgba(255,255,255,0.18); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.w-login-card { width: 360px; }
.btn-dlg-solid { background: var(--dlg-secondary); border: none; color: #fff; }
.btn-dlg-solid:hover { background: var(--dlg-accent); color: #fff; }

/* HR lanes */
.hr-page .hr-section {
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    border-left-width: 4px;
    background: rgba(10, 26, 58, 0.88);
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.hr-page .hr-section-context { border-left-color: #8b9cb8; background: rgba(18, 32, 58, 0.92); }
.hr-page .hr-section-onboarding { border-left-color: #4da3ff; box-shadow: inset 0 1px 0 rgba(77,163,255,0.12), 0 4px 16px rgba(0,0,0,0.2); }
.hr-page .hr-section-training { border-left-color: #b388ff; box-shadow: inset 0 1px 0 rgba(179,136,255,0.1), 0 4px 16px rgba(0,0,0,0.2); }
.hr-page .hr-section-cert { border-left-color: #e8a54b; box-shadow: inset 0 1px 0 rgba(232,165,75,0.12), 0 4px 16px rgba(0,0,0,0.2); }
.hr-page .hr-section-time { border-left-color: #3ecf8e; box-shadow: inset 0 1px 0 rgba(62,207,142,0.1), 0 4px 16px rgba(0,0,0,0.2); }
.hr-page .hr-section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    color: #EAF2FF;
}
.hr-page .hr-section-title i { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.hr-page .hr-section-onboarding .hr-section-title i { color: #6eb8ff; }
.hr-page .hr-section-training .hr-section-title i { color: #c9a8ff; }
.hr-page .hr-section-cert .hr-section-title i { color: #f0b85c; }
.hr-page .hr-section-time .hr-section-title i { color: #5ed9a8; }
.hr-page .hr-section-context .hr-section-title i { color: #a8b8d4; }
.hr-page .hr-section-hint { font-size: 0.78rem; color: #9eb0cc; margin: -0.5rem 0 0.85rem 0; padding-left: 2.05rem; line-height: 1.35; }

/* Utilities replacing inline styles */
.policy-body-scroll { max-height: 320px; overflow: auto; }
.select-min-200 { min-width: 200px; }
.cell-min-280 { min-width: 280px; }
.dispatch-actions { min-width: 360px; }
.dispatch-actions details > summary {
    cursor: pointer;
    list-style: none;
}
.dispatch-actions details > summary::-webkit-details-marker { display: none; }
.dispatch-actions details > summary::after {
    content: '  +';
    color: #9ec7ef;
}
.dispatch-actions details[open] > summary::after { content: '  -'; }
.panel-alt { min-height: 260px; border-color: rgba(255,255,255,0.18) !important; background: rgba(7,21,44,0.7); }
.panel-alt-soft { border-color: rgba(255,255,255,0.18) !important; background: rgba(7,21,44,0.7); }
.select-max-140 { max-width: 140px; }
.progress-thin { height: 8px; }
.form-min-220 { min-width: 220px; }
.pre-max-12 { max-height: 12rem; }
.pre-max-28 { max-height: 28rem; white-space: pre-wrap; background: rgba(0,0,0,0.35); }

.js-progress-width { width: 0; }

/* Billing action guidance blocks */
.billing-op {
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 12px;
    padding: 0.9rem;
}
.billing-op-record {
    background: rgba(28, 105, 64, 0.25);
    border-color: rgba(98, 209, 147, 0.55);
}
.billing-op-credit {
    background: rgba(19, 82, 128, 0.26);
    border-color: rgba(111, 188, 244, 0.55);
}
.billing-op-invoice {
    background: rgba(96, 62, 132, 0.24);
    border-color: rgba(194, 154, 236, 0.55);
}
.billing-op-fee {
    background: rgba(120, 84, 10, 0.24);
    border-color: rgba(244, 202, 117, 0.55);
}
.billing-op-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.3rem;
}
.billing-info-icon {
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
    color: #d7e8ff;
    cursor: help;
    opacity: 0.95;
}
.billing-info-icon:hover {
    color: #ffffff;
    opacity: 1;
}

/* Click-to-open help (replaces hover tooltips for long copy) */
.dlg-help-icon-btn {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1;
    vertical-align: baseline;
    box-shadow: none !important;
}
.dlg-help-icon-btn:focus-visible {
    outline: 2px solid rgba(127, 199, 255, 0.85);
    outline-offset: 2px;
    border-radius: 4px;
}
.dlg-help-trigger .billing-info-icon {
    cursor: pointer;
}

/* Help overlay: must stay viewport-fixed (no in-flow layout). Use #id for specificity. */
#dlg-help-overlay.dlg-help-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1080;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    margin: 0;
    box-sizing: border-box;
}
#dlg-help-overlay.dlg-help-overlay.is-open {
    display: flex !important;
}
.dlg-help-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 10, 24, 0.72);
    backdrop-filter: blur(2px);
}
.dlg-help-overlay-dialog {
    position: relative;
    z-index: 1;
    width: min(820px, 100%);
    max-height: min(88vh, 920px);
    display: flex;
    flex-direction: column;
    background: rgba(12, 32, 70, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.dlg-help-overlay-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem 0.65rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(8, 38, 74, 0.95);
}
.dlg-help-overlay-title {
    color: #eaf2ff !important;
    font-weight: 600;
    padding-right: 0.5rem;
}
.dlg-help-overlay-body-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem 1.1rem 1.15rem;
    color: #d6e2f5;
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-line;
    -webkit-overflow-scrolling: touch;
}
/* Help copy lives in <template> (inert — never paints in layout). Legacy: */
.dlg-help-source {
    display: none !important;
}

/* Vendor compliance — rows that block dispatch */
main .table-dark tr.compliance-row-dispatch-block {
    --bs-table-accent-bg: rgba(253, 126, 20, 0.14);
    box-shadow: inset 4px 0 0 0 rgba(253, 126, 20, 0.95);
}
main .table-dark tr.compliance-row-dispatch-block td {
    border-color: rgba(253, 126, 20, 0.35);
}

/* Spreadsheet-style data grids: one row per record; scroll horizontally when needed */
.dlg-data-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.dlg-data-grid table {
    width: max(100%, min-content);
}
.dlg-data-grid table thead th,
.dlg-data-grid table tbody td {
    white-space: nowrap;
    vertical-align: middle;
}
.dlg-data-grid table tbody td .btn {
    white-space: nowrap;
}
.dlg-data-grid .dlg-th-sort {
    white-space: nowrap;
}

/* Toolbar above grids (search / rows-per-page) */
.dlg-data-grid-toolbar .form-label {
    color: rgba(214, 226, 245, 0.85);
}

/* Pagination inside dark cards */
.card-dlg .pagination .page-link {
    background: rgba(8, 38, 74, 0.92);
    color: #eaf2ff;
    border-color: rgba(255, 255, 255, 0.22);
}
.card-dlg .pagination .page-link:hover {
    background: rgba(18, 58, 104, 0.98);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}
.card-dlg .pagination .page-item.active .page-link {
    background: rgba(13, 110, 253, 0.55);
    border-color: rgba(13, 110, 253, 0.85);
    color: #fff;
}
.card-dlg .pagination .page-item.disabled .page-link {
    opacity: 0.45;
}

/* Sortable column headers: paired arrows */
.dlg-sort-arrows .bi {
    font-size: 0.5rem;
    line-height: 1;
}
.dlg-sort-arrows .dlg-sort-dn {
    margin-top: -0.18rem;
}
.dlg-sort-idle {
    color: rgba(200, 214, 235, 0.32);
}
.dlg-sort-active {
    color: #7ecbff;
}
.dlg-th-sort:hover .dlg-sort-idle {
    color: rgba(200, 214, 235, 0.58);
}
.dlg-data-grid table.dlg-grid-loading {
    opacity: 0.55;
    transition: opacity 0.12s ease;
}

/* Reporting master registers: icon-only headers, minimal column width with end cushion */
.master-report-scroll.dlg-master-grid {
    max-height: 28rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.dlg-master-grid table thead th.dlg-master-grid-th,
.dlg-master-grid table tbody td.dlg-master-grid-td {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}
.dlg-master-grid table thead th.dlg-master-grid-th {
    position: sticky;
    top: 0;
    z-index: 4;
    width: 1%;
    text-align: center;
    vertical-align: middle;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    white-space: nowrap;
    background-color: #212529;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}
.dlg-master-grid table tbody td.dlg-master-grid-td {
    white-space: nowrap;
    vertical-align: middle;
}
.dlg-master-grid table thead th.dlg-master-grid-th [data-bs-toggle="tooltip"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    cursor: help;
}
.dlg-master-grid table thead th.dlg-master-grid-th .bi {
    font-size: 0.95rem;
    line-height: 1;
    opacity: 0.9;
}

/* Compact icon actions in data grids (e.g. Orders Clone / Edit) */
.dlg-row-icon-btn {
    padding: 0.15rem 0.4rem;
    line-height: 1;
}
.dlg-row-icon-btn .bi {
    font-size: 0.95rem;
    vertical-align: -0.06em;
}

/* DGD Option B: system-prefilled field affordance (not color-only; works on dark cards) */
.dlg-field-prefilled {
    box-shadow: 0 0 0 2px rgba(31, 162, 255, 0.45);
    border-color: rgba(31, 162, 255, 0.55) !important;
}
@media (prefers-color-scheme: light) {
    .dlg-field-prefilled {
        box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.35);
        border-color: rgba(13, 110, 253, 0.5) !important;
    }
}
