/* =================================================================
   Staff Interface — Unfold UI overrides
   CargoSprint brand: #0C2245 (navy), #016C78 (teal), #02C38D (mint)
   ================================================================= */

/* ── Sidebar — use Unfold defaults, just add brand accent ── */
/* Active item highlight uses primary color (handled by Unfold via COLORS config) */
/* Section group headings (only app section titles, not logo/user area) */
#nav-sidebar-apps .font-semibold.text-sm {
    color: #0C2245;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
}
.dark #nav-sidebar-apps .font-semibold.text-sm {
    color: #94a3b8;
}

/* ── Header bar accent ── */
#main > header,
header[class*="border-b"] {
    border-bottom-color: #016C78 !important;
    border-bottom-width: 2px !important;
}

/* ── View buttons — Unfold-compatible styling ── */
.button,
a.button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.375rem;
    border: 1px solid #016C78;
    background: #016C78;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.button:hover,
a.button:hover {
    background: #014e57;
    border-color: #014e57;
    color: #fff;
}

/* ── Icon buttons (upper-right toolbar) ── */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}
.icon-btn:hover {
    background: #f1f5f9;
    color: #016C78;
    border-color: #016C78;
}
.icon-btn--active {
    color: #016C78;
    border-color: #016C78;
}
.dark .icon-btn {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}
.dark .icon-btn:hover {
    background: #334155;
    color: #02C38D;
    border-color: #02C38D;
}

/* ── Export warning modal ── */
#export-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modal-fade-in 0.15s ease-out;
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
#export-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 2rem;
    max-width: 420px;
    width: 90vw;
    text-align: center;
    animation: modal-slide-up 0.2s ease-out;
}
@keyframes modal-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
#export-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #fef3c7;
    margin-bottom: 1rem;
}
#export-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.5rem;
}
#export-modal-body {
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.5;
    margin: 0 0 0.5rem;
}
#export-modal-hint {
    font-size: 0.8125rem;
    color: #94a3b8;
    margin: 0 0 1.5rem;
}
#export-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
#export-modal-cancel {
    padding: 0.5rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
#export-modal-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
#export-modal-confirm {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    background: #f59e0b;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
}
#export-modal-confirm:hover {
    background: #d97706;
}
.dark #export-modal {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.dark #export-modal-title { color: #f1f5f9; }
.dark #export-modal-body { color: #94a3b8; }
.dark #export-modal-hint { color: #64748b; }
.dark #export-modal-icon { background: #422006; }
.dark #export-modal-cancel {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
.dark #export-modal-cancel:hover { background: #3b4f6b; }

/* ── Icon toolbar positioning ── */
#icon-toolbar {
    position: absolute;
    right: 1.5rem;
    top: 0.75rem;
    z-index: 10;
}
/* Ensure the parent content block is positioned for the absolute toolbar */
#content {
    position: relative;
}

/* Export download button (mint green) */
#export-download-btn {
    background: #02C38D !important;
    border-color: #02C38D !important;
    color: #fff !important;
}
#export-download-btn:hover {
    background: #01a577 !important;
}

/* Delete view button (red) */
#delete-view-btn {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
}
#delete-view-btn:hover {
    background: #dc2626 !important;
}

/* ── Filter chips ── */
#active-filter-chips {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

/* ── Two-column layout (customer form) ── */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 768px) {
    .two-column-layout {
        grid-template-columns: 1fr;
    }
}

/* ── View dropdown container ── */
#view-dropdown-container {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
#view-dropdown-container select {
    padding: 0.375rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    background: #fff;
}

/* ── Export progress ── */
#export-progress {
    font-size: 0.8125rem;
    color: #016C78;
}
#export-progress-fill {
    background: #02C38D !important;
}

/* ── Module headers ── */
.module h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0C2245;
    padding: 0.5rem 0.75rem;
}

/* ── Page size selector ── */
#page_size {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

/* ── Tools slide-out panel ── */
#tools-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
#tools-panel-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
#tools-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}
#tools-panel.open {
    transform: translateX(0);
}
#tools-panel-header {
    position: sticky;
    top: 0;
    background: #0C2245;
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}
#tools-panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
}
#tools-panel-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
#tools-panel-close:hover {
    color: #fff;
}
.tools-section {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}
.tools-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.5rem;
}
.tools-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    color: #0C2245;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.tools-link:hover {
    background: #f1f5f9;
    color: #016C78;
}
.tools-link-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #016C78;
    flex-shrink: 0;
}
.tools-link-disabled {
    color: #94a3b8;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem 0.375rem 2.5rem;
}

/* ── Tools trigger button ── */
#tools-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    background: #016C78;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
#tools-trigger-btn:hover {
    background: #014e57;
}

/* ── Staff modals (shared) ── */
.staff-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}
.staff-modal-inner {
    background: #fff;
    border-radius: 0.75rem;
    max-height: 80vh;
    overflow-y: auto;
    margin: 5vh auto;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.staff-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0.75rem 0.75rem 0 0;
}
.staff-modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #0C2245;
}
.staff-modal-close {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}
.staff-modal-close:hover { color: #0f172a; }
.staff-modal-body { padding: 1.25rem; }
.staff-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.staff-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
}
.staff-btn:hover { background: #f1f5f9; }
.staff-btn-primary {
    background: #016C78;
    border-color: #016C78;
    color: #fff;
}
.staff-btn-primary:hover { background: #014e57; }
.staff-btn-blue {
    background: #016C78;
    border-color: #016C78;
    color: #fff;
}
.staff-btn-blue:hover { background: #014e57; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Bookmarks section on dashboard ── */
.bookmarks-panel {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff;
    overflow: hidden;
}
.bookmarks-panel-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0C2245;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* ── Filter panel — collapsible right-side panel (no overlay) ── */
.filter-panel-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: stretch;
    pointer-events: none;
}
.filter-panel-container > * {
    pointer-events: auto;
}

/* Collapse handle — centered on left edge */
.filter-collapse-handle {
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    color: #64748b;
    box-shadow: -2px 0 8px rgba(0,0,0,0.06);
    transition: color 0.15s, background 0.15s;
    z-index: 2;
}
.filter-collapse-handle:hover {
    background: #f8fafc;
    color: #016C78;
}
.dark .filter-collapse-handle {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
.dark .filter-collapse-handle:hover {
    background: #334155;
    color: #02C38D;
}

/* Panel inner container */
.filter-panel-inner {
    width: 320px;
    max-width: 90vw;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 16px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dark .filter-panel-inner {
    background: #1e293b;
    border-left-color: #334155;
}

/* Slide transition classes */
.filter-panel-hidden {
    opacity: 0;
    transform: translateX(100%);
}
.filter-panel-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Header */
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #016C78;
    background: #f8fafc;
    flex-shrink: 0;
}
.dark .filter-panel-header {
    background: #0f172a;
}

.filter-panel-close {
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.15s, background 0.15s;
}
.filter-panel-close:hover {
    color: #0f172a;
    background: #e2e8f0;
}
.dark .filter-panel-close:hover {
    color: #f1f5f9;
    background: #334155;
}

/* Body */
.filter-panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.filter-panel-scroll {
    flex: 1;
    overflow-y: auto;
}

/* Content area shrinks when filter is open — Unfold uses #main, not #content-main */
body.filter-open #main {
    margin-right: 320px;
    transition: margin-right 0.25s ease;
}
#main {
    transition: margin-right 0.25s ease;
}

/* Horizontal scroll on results table when space is tight */
body.filter-open .result-list-wrapper {
    overflow-x: auto;
}
body.filter-open #result_list {
    overflow-x: auto;
}

/* ── Filter input placeholder — light grey ── */
.filter-panel-container input::placeholder,
.filter-panel-container select::placeholder {
    color: #94a3b8;
    opacity: 1;
}
.dark .filter-panel-container input::placeholder {
    color: #64748b;
}

/* ── Collapsible filter sections ── */
.filter-section {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}
.dark .filter-section {
    border-bottom-color: #334155;
}
.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* ── Active filter chips — Unfold-compatible ── */
#active-filter-chips {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    margin: 0.5rem 0 !important;
}

/* ── Advanced filters page ── */
.adv-filter-grid {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
}
.adv-filter-grid > div:first-child,
.adv-filter-grid > div:nth-child(2),
.adv-filter-grid > div:nth-child(3),
.adv-filter-grid > div:nth-child(4) {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.adv-filter-row select,
.adv-filter-row input[type="text"],
.adv-filter-row input[type="number"],
.adv-filter-row input[type="date"],
.adv-filter-row input[type="datetime-local"] {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}
.adv-filter-row select:focus,
.adv-filter-row input:focus {
    outline: none;
    border-color: #016C78;
    box-shadow: 0 0 0 2px rgba(1, 108, 120, 0.15);
}
.adv-filter-actions {
    margin-top: 1rem !important;
}
.adv-filter-actions .button {
    padding: 0.5rem 1rem !important;
    font-size: 0.8125rem !important;
    border-radius: 0.375rem !important;
}
.adv-filter-actions .button.default {
    background: #016C78 !important;
    border-color: #016C78 !important;
    color: #fff !important;
}
.adv-filter-actions .button.default:hover {
    background: #014e57 !important;
}
.adv-filter-actions .button.default:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.button.row-remove {
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    color: #dc2626 !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.75rem !important;
    border-radius: 0.375rem !important;
}
.button.row-remove:hover {
    background: #fee2e2 !important;
}
.button.add-row {
    background: #f0fdf4 !important;
    border: 1px solid #bbf7d0 !important;
    color: #16a34a !important;
    font-weight: 600 !important;
}

/* ── Utility page form styling (save view, select fields — NOT change form) ── */
.sv-card input[type="text"],
.sv-card input[type="number"],
.sv-card textarea,
.adv-filter-grid input[type="text"],
.adv-filter-grid input[type="number"],
.adv-filter-grid input[type="date"],
.adv-filter-grid input[type="datetime-local"] {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: #fff;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}
.sv-card input:focus,
.sv-card textarea:focus,
.adv-filter-grid input:focus {
    outline: none;
    border-color: #016C78;
    box-shadow: 0 0 0 2px rgba(1, 108, 120, 0.15);
}
.sv-card select {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    background: #fff;
}
.sv-card select:focus {
    outline: none;
    border-color: #016C78;
    box-shadow: 0 0 0 2px rgba(1, 108, 120, 0.15);
}
.sv-card label {
    font-size: 0.8125rem;
    color: #334155;
    font-weight: 500;
}

/* ── Change form — HTML5 native date/time widgets ── */
/* Split datetime container */
.html5-split-datetime {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.html5-split-datetime-inputs {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
/* Native date/time inputs */
input.html5-date,
input.html5-time {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.4375rem 0.625rem;
    font-size: 0.8125rem;
    background: #fff;
    color: #334155;
    max-width: 170px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input.html5-date:focus,
input.html5-time:focus {
    outline: none;
    border-color: #016C78;
    box-shadow: 0 0 0 2px rgba(1, 108, 120, 0.15);
}
input.html5-date:hover,
input.html5-time:hover {
    border-color: #94a3b8;
}
/* Timezone hint */
.html5-tz-hint {
    font-size: 0.6875rem;
    color: #94a3b8;
    font-style: italic;
}

/* Timezone hint on datetime fields via CSS */
.datetime::after {
    content: "Note: You are 4 hours behind server time (UTC)";
    display: block;
    font-size: 0.6875rem;
    color: #94a3b8;
    font-style: italic;
    margin-top: 0.25rem;
}

/* ACH-config time fields (ETSplitDateTimeWidget, marked .datetime-et) store the actual Eastern
   wall-clock time -- there is no UTC offset to warn about -- so suppress the stale "behind server
   time (UTC)" note there. Its own "Time is in Eastern Time" hint is rendered by the widget template.
   Higher specificity (.datetime.datetime-et) beats the .datetime::after rule regardless of order. */
.datetime.datetime-et::after {
    content: none !important;
}

/* Hide any leftover DateTimeShortcuts injections on old widgets */
.datetimeshortcuts { display: none !important; }
.timezonewarning { display: none !important; }

/* Also hide old datetime validation artifacts */
.datetime img[src*="icon_alert"],
.datetime img[src*="warning"],
span.invalid-date,
span.invalid-time {
    display: none !important;
}

/* ── Change form — help text ── */
.help-text,
.helptext,
div.help {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ── Button variants ── */
/* Delete / destructive button — red */
.button-danger,
a.button-danger,
#delete-view-btn {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff !important;
}
.button-danger:hover,
a.button-danger:hover,
#delete-view-btn:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
}

/* Secondary / outline button — for less prominent actions */
.button-secondary,
a.button-secondary {
    background: #fff;
    border: 1px solid #016C78;
    color: #016C78;
}
.button-secondary:hover,
a.button-secondary:hover {
    background: #f0fdfa;
    border-color: #014e57;
    color: #014e57;
}

/* Accent / mint green buttons (Process View, Update View) */
#process-view-btn,
#update-view-btn {
    background: #02C38D !important;
    border-color: #02C38D !important;
    color: #fff !important;
}
#process-view-btn:hover,
#update-view-btn:hover {
    background: #01a577 !important;
    border-color: #01a577 !important;
}

/* Download CSV — green success variant */
#export-download-btn {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: #fff !important;
}
#export-download-btn:hover {
    background: #15803d !important;
    border-color: #15803d !important;
}

/* ── Fieldset section headers (teal bar like staging) ── */
fieldset.module.aligned > h2,
fieldset.module.aligned > details > summary h2 {
    background: #016C78;
    color: #fff;
    margin: 0;
    padding: 8px 12px;
    font-weight: 500;
    font-size: 0.8125rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

/* ── Collapsible fieldsets (details/summary) ── */
fieldset details > summary {
    list-style: none;
}
fieldset details > summary::-webkit-details-marker {
    display: none;
}
fieldset details .details-arrow {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 0.625rem;
    margin-right: 0.375rem;
    color: #fff;
}
fieldset details[open] .details-arrow {
    transform: rotate(90deg);
}
fieldset details > summary h2 {
    user-select: none;
    cursor: pointer;
}

/* ── Change-form action buttons (button-3 from old admin) ── */
.button-3,
a.button-3 {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.375rem;
    border: 1px solid #016C78;
    background: #016C78;
    color: #fff !important;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
}
.button-3:hover,
a.button-3:hover {
    background: #014e57;
    border-color: #014e57;
    color: #fff !important;
}
input.button-3[type="button"] {
    display: inline-flex;
    align-items: center;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.375rem;
    border: 1px solid #016C78;
    background: #016C78;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
}
input.button-3[type="button"]:hover {
    background: #014e57;
    border-color: #014e57;
}

/* Action button bar — consistent placement above forms */
.action-button-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

/* ── Multi-select (Groups field) styling ── */
#content select[multiple],
select[name="groups"] {
    width: 100%;
    max-width: 400px;
    min-height: 140px;
    padding: 0.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #fff;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #334155;
}
#content select[multiple]:focus,
select[name="groups"]:focus {
    outline: none;
    border-color: #016C78;
    box-shadow: 0 0 0 2px rgba(1, 108, 120, 0.15);
}
#content select[multiple] option,
select[name="groups"] option {
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 1px;
}
#content select[multiple] option:checked,
select[name="groups"] option:checked {
    background: #016C78 linear-gradient(0deg, #016C78, #016C78);
    color: #fff;
}
#content select[multiple] option:hover,
select[name="groups"] option:hover {
    background: #f0fdfa;
}

/* ================================================================
   DARK MODE — comprehensive overrides
   ================================================================ */

/* ── Filter chips ── */
.dark #active-filter-chips {
    background: #0f172a !important;
    border-color: #334155 !important;
}

/* ── View dropdown ── */
.dark #view-dropdown-container select {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

/* ── Advanced filter grid ── */
.dark .adv-filter-grid {
    background: #0f172a;
    border-color: #334155;
}
.dark .adv-filter-grid > div:first-child,
.dark .adv-filter-grid > div:nth-child(2),
.dark .adv-filter-grid > div:nth-child(3),
.dark .adv-filter-grid > div:nth-child(4) {
    color: #94a3b8;
    border-bottom-color: #334155;
}
.dark .adv-filter-row select,
.dark .adv-filter-row input[type="text"],
.dark .adv-filter-row input[type="number"],
.dark .adv-filter-row input[type="date"],
.dark .adv-filter-row input[type="datetime-local"] {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .button.row-remove {
    background: #450a0a !important;
    border-color: #7f1d1d !important;
    color: #fca5a5 !important;
}
.dark .button.row-remove:hover {
    background: #7f1d1d !important;
}
.dark .button.add-row {
    background: #052e16 !important;
    border-color: #166534 !important;
    color: #86efac !important;
}

/* ── Tools panel ── */
.dark #tools-panel {
    background: #1e293b;
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.dark .tools-section {
    border-bottom-color: #334155;
}
.dark .tools-section-title {
    color: #94a3b8;
}
.dark .tools-link {
    color: #e2e8f0;
}
.dark .tools-link:hover {
    background: #334155;
    color: #02C38D;
}
.dark .tools-link-icon {
    color: #02C38D;
}
.dark .tools-link-disabled {
    color: #64748b;
}

/* ── Staff modals ── */
.dark .staff-modal-inner {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.dark .staff-modal-header {
    background: #0f172a;
    border-bottom-color: #334155;
}
.dark .staff-modal-header h3 {
    color: #f1f5f9;
}
.dark .staff-modal-close {
    color: #94a3b8;
}
.dark .staff-modal-close:hover {
    color: #f1f5f9;
}
.dark .staff-modal-body {
    color: #e2e8f0;
}
.dark .staff-modal-footer {
    border-top-color: #334155;
}
.dark .staff-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .staff-btn:hover {
    background: #475569;
}

/* ── Bookmarks panel ── */
.dark .bookmarks-panel {
    background: #1e293b;
    border-color: #334155;
}
.dark .bookmarks-panel-header {
    background: #0f172a;
    border-bottom-color: #334155;
    color: #f1f5f9;
}

/* ── Module headers ── */
.dark .module h2 {
    color: #f1f5f9;
}

/* ── Page size selector ── */
.dark #page_size {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

/* ── Export progress ── */
.dark #export-progress {
    color: #02C38D;
}

/* ── Save-view card ── */
.dark .sv-card input[type="text"],
.dark .sv-card input[type="number"],
.dark .sv-card textarea {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .sv-card select {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.dark .sv-card label {
    color: #e2e8f0;
}

/* ── Date/time inputs ── */
.dark input.html5-date,
.dark input.html5-time {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.dark input.html5-date:hover,
.dark input.html5-time:hover {
    border-color: #64748b;
}

/* ── Multi-select (Groups) ── */
.dark #content select[multiple],
.dark select[name="groups"] {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.dark #content select[multiple] option:hover,
.dark select[name="groups"] option:hover {
    background: #334155;
}

/* ── Secondary button ── */
.dark .button-secondary,
.dark a.button-secondary {
    background: #1e293b;
    border-color: #02C38D;
    color: #02C38D;
}
.dark .button-secondary:hover,
.dark a.button-secondary:hover {
    background: #0f2a2e;
    border-color: #02C38D;
    color: #02C38D;
}

/* ── Help text ── */
.dark .help-text,
.dark .helptext,
.dark div.help {
    color: #64748b;
}

/* ── Timezone hint ── */
.dark .html5-tz-hint {
    color: #64748b;
}
.dark .datetime::after {
    color: #64748b;
}

/* ── Icon toast ── */
.icon-toast {
    color: #016C78;
    background: #e0f7f4;
}
.dark .icon-toast {
    color: #02C38D;
    background: #0c3a3f;
}

/* ── Sidebar logo — navy text invisible on dark bg ── */
.dark [class*="logo"] img[src*="CargoSprint"],
.dark aside img[src*="CargoSprint"],
.dark nav img[src*="CargoSprint"] {
    filter: brightness(0) invert(1) brightness(0.95);
}

/* ── Progress bar track (dark) ── */
.dark #export-progress span[style*="background:#ddd"] {
    background: #334155 !important;
}

/* ══════════════════════════════════════════════════════════════
   EP-2884 v2: Sticky layout for changelist views
   ══════════════════════════════════════════════════════════════
   Scroll model: the viewport scrolls (#main has no overflow).
   Four tiers stick in order:
     0. Title bar (breadcrumb, Bookmarks, +, Notifications) z-index:20
     1. Toolbar (Select Fields, Views, filter chips)        z-index:15
     2. Column headers (thead)                              z-index:10
     3. Horizontal scrollbar mirror (bottom)                z-index:30
   JS sets CSS custom property --toolbar-h on #result_list
   (= title bar height + toolbar height).
   ────────────────────────────────────────────────────────────── */

/* ── Tier 0: Title bar (Unfold header with breadcrumbs + action buttons) ── */
#main > .border-b:first-child,
#main > div.bg-white.border-b.px-4:first-child {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 0 !important; /* remove mb-6, toolbar sits directly below */
}
.dark #main > .border-b:first-child,
.dark #main > div.border-b.px-4:first-child {
    /* dark mode already handled by Unfold's dark:bg-base-900 class */
}

/* ── Tier 1: Toolbar ── */
#sticky-toolbar-wrapper {
    position: sticky;
    top: var(--title-bar-h, 64px); /* stacks below title bar */
    z-index: 15;
    background: #fff;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e2e8f0;
}
.dark #sticky-toolbar-wrapper {
    background: #0f172a;
    border-bottom-color: #334155;
}

/* ── Tier 2: Column headers (frozen clone, position:fixed) ── */
/* position:sticky on thead th breaks inside SimpleBar overflow containers.
   JS in changelist_generic.html clones the thead into #frozen-header and
   positions it fixed below the toolbar, scroll-synced horizontally. */
#frozen-header {
    position: fixed;
    z-index: 10;
    overflow: hidden;
    pointer-events: auto;
    border-bottom: 2px solid #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
#frozen-header table {
    table-layout: fixed;
    border-collapse: collapse;
}
#frozen-header th {
    background: #f1f5f9;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark #frozen-header {
    border-bottom-color: #475569;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.dark #frozen-header th {
    background: #1e293b;
    color: #e2e8f0;
}

/* Hide SimpleBar's native horizontal scrollbar — our fixed mirror replaces it */
.simplebar-track.simplebar-horizontal {
    display: none !important;
}

/* ── Tier 3: Horizontal scrollbar mirror (fixed at bottom of viewport) ── */
#sticky-hscroll-mirror {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.06);
}
.dark #sticky-hscroll-mirror {
    background: #1e293b;
    border-top-color: #475569;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.3);
}

/* ── Scrollbar styling (light) ── */
#sticky-hscroll-mirror::-webkit-scrollbar { height: 14px; }
#sticky-hscroll-mirror::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 7px; }
#sticky-hscroll-mirror::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; }
#sticky-hscroll-mirror::-webkit-scrollbar-thumb:hover { background: #64748b; }
.overflow-x-auto::-webkit-scrollbar { height: 14px; }
.overflow-x-auto::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 7px; }
.overflow-x-auto::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; }
.overflow-x-auto::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ── Dark mode scrollbar visibility ── */
.dark #sticky-hscroll-mirror::-webkit-scrollbar { height: 14px; }
.dark #sticky-hscroll-mirror::-webkit-scrollbar-track { background: #334155; border-radius: 7px; }
.dark #sticky-hscroll-mirror::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; }
.dark #sticky-hscroll-mirror::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
.dark .overflow-x-auto::-webkit-scrollbar { height: 14px; }
.dark .overflow-x-auto::-webkit-scrollbar-track { background: #334155; border-radius: 7px; }
.dark .overflow-x-auto::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; }
.dark .overflow-x-auto::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ── Sticky breadcrumb — Home always visible (#6) ── */
div.breadcrumbs {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--breadcrumbs-bg, #f8f8f8);
}

/* =================================================================
   TabularInline — visible inputs + prominent Add button
   Unfold's default flat styling strips input borders, which makes
   empty rows look unclickable and mis-aligned. Restore visible
   borders + a proper Add button so add-a-row is discoverable.
   ================================================================= */

/* Force visible borders on every input in a tabular inline. */
.inline-group table td input[type="text"],
.inline-group table td input[type="email"],
.inline-group table td input[type="url"],
.inline-group table td input[type="tel"],
.inline-group table td input[type="number"],
.inline-group table td input[type="date"],
.inline-group table td input[type="datetime-local"],
.inline-group table td textarea,
.inline-group table td select {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 10px;
    background: #ffffff;
    min-width: 140px;
    font-size: 13px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.inline-group table td input[type="text"]:hover,
.inline-group table td input[type="email"]:hover,
.inline-group table td input[type="url"]:hover,
.inline-group table td input[type="tel"]:hover,
.inline-group table td input[type="number"]:hover,
.inline-group table td textarea:hover,
.inline-group table td select:hover {
    border-color: #94a3b8;
}
.inline-group table td input[type="text"]:focus,
.inline-group table td input[type="email"]:focus,
.inline-group table td input[type="url"]:focus,
.inline-group table td input[type="tel"]:focus,
.inline-group table td input[type="number"]:focus,
.inline-group table td textarea:focus,
.inline-group table td select:focus {
    border-color: #02C38D;
    box-shadow: 0 0 0 2px rgba(2, 195, 141, 0.20);
    outline: none;
}

/* Cell padding — give rows breathing room so inputs don't touch borders. */
.inline-group table td,
.inline-group table th {
    padding: 8px 10px !important;
    vertical-align: middle;
}

/* Column header row — subtle contrast so accountants can see what field they're editing. */
.inline-group table thead th {
    background: #f1f5f9;
    color: #0C2245;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e2e8f0;
}

/* Alternating row bg — helps read multi-column rows. */
.inline-group table tbody tr.form-row:nth-child(even):not(.empty-form) {
    background: #fafbfc;
}

/* Server-rendered pin button (templates/unfold/admin/edit_inline/tabular.html
   renders <a class="inline-add-proxy"> inside <div class="inline-add-pin">
   AFTER the [data-simplebar] wrapper, guaranteed OUTSIDE the horizontal
   scroll). This is the button users see + click. inline-add-relocate.js
   forwards its click to the hidden JS-injected .add-row anchor. */
.inline-group a.inline-add-proxy,
.inline-group a.inline-add-proxy:link,
.inline-group a.inline-add-proxy:visited {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 10px 20px !important;
    background: #02C38D !important;
    color: #ffffff !important;
    border-radius: 999px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(2, 195, 141, 0.25) !important;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
    cursor: pointer;
}
.inline-group a.inline-add-proxy:hover {
    background: #016C78 !important;
    box-shadow: 0 2px 6px rgba(1, 108, 120, 0.35) !important;
    transform: translateY(-1px);
}

/* Hide the JS-injected jQuery-formset add-row. Django's stock jQuery-formset
   applies its `addCssClass` (default "add-row") to the WRAPPING TR, not the
   anchor — the injected markup is:
       <tr class="add-row"><td colspan="N"><a href="#">Add another Foo</a></td></tr>
   Earlier attempt used `a.add-row` which never matched, so the old button
   stayed visible next to the server-rendered pin. Correct selector: tr.add-row.

   Formset library needs the anchor in the DOM (its click handler is wired
   to it), but users should NEVER see it — they see the server-rendered
   .inline-add-proxy pin above. Hide the ROW entirely with display:none;
   inline-add-relocate.js forwards proxy clicks via .click() on the hidden
   anchor which works regardless of visibility. */
.inline-group tr.add-row {
    display: none !important;
}
/* Belt + suspenders: any jQuery-formset variant that puts the class on the
   anchor instead of the tr, and any variant that omits the class entirely
   (falling back to <tr><td><a href="#">) — kill both. */
.inline-group a.add-row {
    display: none !important;
}
/* Add-button relocation container. inline-add-relocate.js moves the JS-injected
   anchor OUT of the horizontally-scrollable table wrapper into a .inline-add-pin
   sibling div sitting between the wrapper and the fieldset bottom. Ankit
   2026-08-27 asked for RIGHT-aligned but OUTSIDE the scroll wrapper — so the
   button is always visible, in the top-right visual position it naturally
   occupied before, just no longer inside the scroll box. */
/* Bigger visual gap + clearer boundary so the pin reads as OUTSIDE the scroll
   box even before the SimpleBar scrollbar visibility fix (9eda11f) lands.
   Ankit 2026-08-27 flagged it looked "still inside the scroll" because
   without a visible scrollbar you can't tell where the scroll box ends. */
.inline-group .inline-add-pin {
    padding: 14px 4px 8px 4px;
    margin-top: 14px;
    text-align: right;
    /* No border — the visual break comes from the margin above. Adding a
       border made it look like a header row inside the same container. */
}

/* Horizontal scrollbar — always visible so users see the table CAN be scrolled.
   Unfold wraps the tabular table in `<div data-simplebar>` which activates the
   SimpleBar JS library (unfold/js/simplebar/simplebar.js). SimpleBar HIDES the
   native scrollbar and overlays its own DOM (.simplebar-track.simplebar-horizontal
   > .simplebar-scrollbar). ::-webkit-scrollbar rules never render — SimpleBar
   took the wheel. Target SimpleBar's actual classes and force them permanently
   visible + themed. `data-simplebar-auto-hide="false"` on the wrapper already
   asks SimpleBar to keep the bar visible, but SimpleBar still renders it very
   thin + low-contrast; the rules below make it obvious.  */
.inline-group .simplebar-track.simplebar-horizontal {
    height: 14px !important;
    background: #e2e8f0 !important;
    border-radius: 7px !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* SimpleBar sometimes anchors the track slightly outside the wrapper's
       bottom border — bring it inward so it's flush with the table. */
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
}
.inline-group .simplebar-track.simplebar-horizontal .simplebar-scrollbar {
    background: #64748b !important;
    height: 10px !important;
    top: 2px !important;
    border-radius: 5px !important;
    min-width: 40px;
}
/* SimpleBar renders the actual thumb visual via a ::before on the scrollbar
   element (it's how they achieve rounded thumbs). Force it opaque + themed
   too — otherwise it stays 0-opacity until the user starts scrolling. */
.inline-group .simplebar-track.simplebar-horizontal .simplebar-scrollbar:before {
    background: #64748b !important;
    opacity: 1 !important;
    border-radius: 5px !important;
}
.inline-group .simplebar-track.simplebar-horizontal:hover .simplebar-scrollbar:before,
.inline-group .simplebar-track.simplebar-horizontal .simplebar-scrollbar.simplebar-visible:before {
    background: #475569 !important;
    opacity: 1 !important;
}
/* Vertical scrollbars inside inlines rarely matter, but the same treatment
   for consistency + so users get a familiar scrollbar look everywhere. */
.inline-group .simplebar-track.simplebar-vertical {
    width: 12px !important;
    background: #e2e8f0 !important;
    border-radius: 6px !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.inline-group .simplebar-track.simplebar-vertical .simplebar-scrollbar:before {
    background: #64748b !important;
    opacity: 1 !important;
    border-radius: 5px !important;
}
/* Native-scrollbar fallback for the rare case an inline uses .overflow-x-auto
   WITHOUT SimpleBar (e.g. custom read-only inlines that skip Unfold's wrapper). */
.inline-group .overflow-x-auto:not([data-simplebar]) {
    scrollbar-color: #94a3b8 #e2e8f0;
    scrollbar-width: thin;
}
.inline-group .overflow-x-auto:not([data-simplebar])::-webkit-scrollbar {
    height: 12px !important;
    display: block !important;
}
.inline-group .overflow-x-auto:not([data-simplebar])::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 6px;
}
.inline-group .overflow-x-auto:not([data-simplebar])::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
}

/* Empty-state text — "No contacts on file yet" when the inline has zero data rows.
   Unfold marks the empty-form template tbody with class="template". Data tbodies get
   class="has_original". So "no data rows" == "no tbody.has_original inside the inline".
   Uses :has() (Chromium 105+, Firefox 121+, Safari 15.4+) — degrades to just an empty
   table on older browsers, which is fine because the Add button is now visible. */
.inline-group.contact-inline .tabular-table:not(:has(tbody.has_original))::after,
.inline-group[data-inline-type="tabular"] .tabular-table:not(:has(tbody.has_original))::after {
    content: "No contacts on file yet. Click + Add another Contact below to add one.";
    display: block;
    padding: 16px 20px;
    margin: 12px 0;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    font-style: italic;
    font-size: 13px;
    text-align: center;
}

/* Dark-mode variants for all of the above. */
.dark .inline-group table td input[type="text"],
.dark .inline-group table td input[type="email"],
.dark .inline-group table td input[type="url"],
.dark .inline-group table td input[type="tel"],
.dark .inline-group table td input[type="number"],
.dark .inline-group table td input[type="date"],
.dark .inline-group table td input[type="datetime-local"],
.dark .inline-group table td textarea,
.dark .inline-group table td select {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}
.dark .inline-group table thead th {
    background: #0f172a;
    color: #cbd5e1;
    border-bottom-color: #334155;
}
.dark .inline-group table tbody tr.form-row:nth-child(even):not(.empty-form) {
    background: #1a2436;
}
.dark .inline-group.contact-inline .tabular-table:not(:has(tbody.has_original))::after,
.dark .inline-group[data-inline-type="tabular"] .tabular-table:not(:has(tbody.has_original))::after {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}
