/* Shared readability refinements. Layout, permissions and saved density stay unchanged. */
#dashboard-pending-additives .stat-info { min-width: 0; }
#dashboard-pending-additives .stat-value { font-size: clamp(1.3rem, 1.65vw, 1.6rem); line-height: 1.35; overflow-wrap: normal; }
.dashboard-pending-basis { color: var(--text-muted); font-size: .8rem; line-height: 1.45; margin-top: 5px; }
.dashboard-pending-group { margin: 20px 0 28px; }
.dashboard-pending-group-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.dashboard-pending-group-header h3 { font-size: 1rem; margin: 0; }
.dashboard-pending-group-header p { margin: 0; font-size: .92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dashboard-pending-group-note { color: var(--text-muted); font-size: .85rem; margin: 5px 0 0; }
.dashboard-pending-group .dashboard-pending-table-wrap { margin: 10px 0 0; }

:root {
    --font-outfit: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    --bg-dark: #0f1724;
    --bg-card: #182334;
    --bg-modal: #182334;
    --bg-card-hover: #1e2c40;
    --bg-sidebar: #131d2c;
    --bg-input: #111c2c;
    --bg-input-focus: #152238;
    --bg-dropdown: #182334;
    --text-main: #f1f5fb;
    --text-muted: #b6c3d5;
    --text-dim: #a2b1c7;
    --border-color: #344258;
    --border-table-row: #2d3c50;
    --bg-table-container: #182334;
    --bg-table-header: #1d2b3e;
    --bg-table-header-sticky: #1d2b3e;
    --bg-table-row: #182334;
    --bg-table-row-hover: #21324a;
    --surface-subtle: #1d2b3e;
    --surface-hover: #26384e;
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 12%);
    --shadow-md: 0 2px 8px rgb(0 0 0 / 12%);
    background-image: none;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.light-theme {
    --bg-dark: #f3f5f8;
    --bg-card: #ffffff;
    --bg-modal: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --bg-input-focus: #ffffff;
    --bg-dropdown: #ffffff;
    --text-main: #192638;
    --text-muted: #4c5c72;
    --text-dim: #57687d;
    --border-color: #d8e0ea;
    --border-table-row: #e1e7ef;
    --bg-table-container: #ffffff;
    --bg-table-header: #f3f6fa;
    --bg-table-header-sticky: #f3f6fa;
    --bg-table-row: #ffffff;
    --bg-table-row-hover: #f1f6fb;
    --surface-subtle: #f5f7fa;
    --surface-hover: #eaf0f6;
    --shadow-sm: 0 1px 3px rgb(25 38 56 / 4%);
    --shadow-md: 0 2px 8px rgb(25 38 56 / 4%);
}

.sidebar, .glass-card, .stat-card, .login-card {
    backdrop-filter: none;
}

/* Keep hidden dialogs out of the paint/compositing tree. An opacity-zero,
 * full-viewport backdrop still leaves a filtered overlay in every page. */
.modal-overlay:not(.active) {
    display: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Data workspaces keep a stable paint surface during pointer movement and
 * scrolling. Hover colors and sticky headers remain; only animation and
 * offscreen paint skipping are removed. */
.view-panel { animation: none; }
.data-table tbody tr,
.data-table tbody tr > th,
.data-table tbody tr > td { transition: none !important; }
.table-responsive {
    content-visibility: visible;
    contain-intrinsic-size: none;
}

.glass-card, .stat-card {
    border-radius: 12px;
}

.sidebar-logo-text {
    color: var(--text-main);
    background: none;
    -webkit-text-fill-color: currentColor;
    font-size: 1.25rem;
    letter-spacing: -.025em;
}

.sidebar-section-title {
    color: var(--text-muted);
    opacity: 1;
    font-size: .7rem;
    letter-spacing: .08em;
}

.nav-item {
    border-radius: 8px;
    gap: 12px;
}

.nav-item.active {
    background: var(--color-info-bg);
    border-color: var(--color-info-border);
    box-shadow: none;
}

.nav-item.active i {
    text-shadow: none;
}

.view-title h1 {
    font-size: 1.75rem;
    letter-spacing: -.035em;
}

.view-title p { line-height: 1.6; }
.card-title { letter-spacing: -.015em; }

.form-label, .stat-label {
    text-transform: none;
    letter-spacing: 0;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.4;
}

.form-input, .form-select, .search-input {
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
}

.form-input:focus, .form-select:focus, .search-input:focus {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
    border-radius: 8px;
    line-height: 1.35;
}

.btn-primary, .btn-primary:hover { box-shadow: none; }
.btn-primary:hover, .stat-card:hover { transform: none; }
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-color); }
.stat-icon { font-size: 1.75rem; opacity: .75; }
.stat-value { font-variant-numeric: tabular-nums; letter-spacing: -.035em; }

.data-table th {
    text-transform: none;
    letter-spacing: 0;
    font-size: .8rem;
    line-height: 1.4;
}

.data-table td { line-height: 1.5; }
.data-table .numeric { font-variant-numeric: tabular-nums; }
.workspace-search-match { color: var(--primary); }

/* References remain readable at narrow column widths instead of being truncated. */
.order-cell-stack strong, .order-reference {
    font-size: .9rem;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    font-variant-numeric: tabular-nums;
}

.order-so-cell > strong { color: var(--primary); font-size: .95rem; }
.order-cell-stack > span:not(.badge) {
    color: var(--text-muted);
    font-size: .78rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

.workspace-density-label, .workspace-orders-tools > label,
.workspace-report-shortcuts > label, .workspace-preset-controls > label {
    font-size: .84rem;
    font-weight: 600;
}

button:focus-visible, a:focus-visible, summary:focus-visible,
.order-master-row:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

@media (max-width: 640px) {
    .form-input, .form-select, .search-input { font-size: 1rem; }
    .view-title h1 { font-size: 1.5rem; }
    .order-reference, .order-so-cell > strong { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .app-header, .stat-card, .glass-card, .nav-item, .btn {
        animation: none;
        transition: none;
    }
}

/* Shared workspace rhythm: keep data prominent across lists, planning and reports. */
button, input, select, textarea { font-family: inherit; }
.glass-card { box-shadow: none; }
.main-content:not(:has(#order-detail-view.active)) .app-header { margin-bottom: 20px; }
.workspace-header-tools { margin-bottom: 18px; }
:where(.view-panel:not(#order-detail-view)) .card-header { margin-bottom: 18px; }
:where(.view-panel:not(#order-detail-view)) .card-title { font-size: 1.05rem; font-weight: 650; }
:where(.view-panel:not(#order-detail-view)) > .glass-card { margin-bottom: 20px; }
.workspace-heading, .master-registry-heading h2, .pending-risk-intro-copy h2,
.customer-report-heading .section-title, .custom-report-hero h2, .dq-hero h2 {
    font-size: 1.4rem;
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: -.025em;
}
.eyebrow, .workspace-eyebrow, .master-registry-kicker, .report-eyebrow,
.report-step, .customer-report-eyebrow, .dq-eyebrow {
    font-size: .73rem;
    letter-spacing: .07em;
    font-weight: 650;
}
.badge { padding: 4px 9px; font-size: .76rem; line-height: 1.4; letter-spacing: 0; border-radius: 6px; }
.table-container { border-radius: 9px; }
:where(.view-panel:not(#order-detail-view)) .data-table th { padding: 12px 16px; border-bottom-width: 1px; }
:where(.view-panel:not(#order-detail-view)) .data-table td { padding: 13px 16px; font-variant-numeric: tabular-nums; }
:where(.view-panel:not(#order-detail-view)) .table-controls { gap: 14px; margin-bottom: 18px; }
:where(.view-panel:not(#order-detail-view)) .form-input,
:where(.view-panel:not(#order-detail-view)) .form-select,
:where(.view-panel:not(#order-detail-view)) .multiselect-btn {
    font-size: .9rem;
    min-height: var(--workspace-control-height, 42px);
}
.multiselect-menu { box-shadow: var(--shadow-md); border-color: var(--border-color); }
.multiselect-item { font-size: .86rem; line-height: 1.45; }
.form-input::placeholder, .search-input::placeholder { color: var(--text-dim); opacity: 1; }
.workspace-presets { background: var(--bg-card); box-shadow: none; }
.workspace-presets-toggle { font-size: .88rem; }
.workspace-order-navigation, .workspace-presets { border-radius: 10px; }

/* Dashboard: one quiet card language for queues and performance. */
.attention-card, .stat-card, .shipment-summary-card,
.pending-risk-summary-card, .customer-report-stat, .dq-stat {
    border-radius: 12px;
    box-shadow: none;
}
.attention-card { min-height: 110px; padding: 18px; gap: 12px; }
.attention-card:hover { transform: none; box-shadow: none; border-color: var(--primary); }
.attention-icon { width: 36px; height: 36px; border-radius: 9px; font-size: 1rem; }
.attention-label { font-size: .84rem; font-weight: 550; text-transform: none; letter-spacing: 0; }
.attention-value { font-size: 1.85rem; font-variant-numeric: tabular-nums; margin-top: 8px; }
.performance-heading { margin-top: 26px; }
.stats-grid { gap: 14px; margin-bottom: 22px; }
.stat-card { padding: 19px; gap: 12px; align-items: flex-start; }
.stat-info { min-width: 0; }
.stat-card .stat-label { font-size: .84rem; line-height: 1.45; font-weight: 550; margin-bottom: 9px; }
.stat-card .stat-value { font-size: 1.6rem; line-height: 1.25; overflow-wrap: anywhere; }
.stat-card .stat-icon { flex-shrink: 0; font-size: 1.3rem; margin-top: 3px; }
.stat-card:hover .stat-icon { transform: none; }
.dashboard-grid { gap: 20px; margin-bottom: 22px; }
.dashboard-grid > .glass-card { margin-bottom: 0; padding: 22px; }
.workspace-kpi-definition { font-size: .77rem; line-height: 1.5; }
.attention-pic-filter { font-size: .8rem; }
.attention-pic-filter select, .schedule-filter-select { border-radius: 8px; font-size: .86rem; }

/* Reference data: compact categories, clear records and aligned actions. */
.master-registry-card { padding: 22px; }
.master-record-count { border-color: var(--border-color); background: var(--surface-subtle); border-radius: 9px; padding: 10px 14px; }
.master-record-count span { text-transform: none; letter-spacing: 0; font-size: .78rem; }
.master-tabs { padding: 6px; gap: 5px; border-radius: 10px; margin-bottom: 18px; }
.master-tab { min-height: 40px; font-size: .81rem; border-radius: 7px; font-weight: 550; }
.master-tab.active { background: var(--color-info-bg); border-color: var(--color-info-border); box-shadow: none; font-weight: 650; }
.master-table-context { font-size: .8rem; }
.master-toolbar-actions .btn, .master-excel-controls .btn { font-size: .83rem; min-height: 40px; }
#master-data-table .supplier-price-master-row small,
.supplier-price-source-details summary, .supplier-price-source-refs { font-size: .8rem; line-height: 1.5; }
.supplier-price-source-label { font-size: .76rem; font-weight: 600; }

/* Planning and follow-up retain their useful status colours without decorative effects. */
.pending-risk-intro, .schedule-controls-card { padding: 20px 22px; }
.pending-risk-summary-copy > span, .shipment-summary-label { font-size: .84rem; text-transform: none; letter-spacing: 0; }
.pending-risk-summary-copy > strong, .shipment-summary-copy > strong { font-variant-numeric: tabular-nums; }
.pending-risk-summary-card, .shipment-summary-card { padding: 17px 18px; }
.pending-risk-section { border-radius: 12px; box-shadow: none; }
#schedule-view .shipment-card { border-radius: 10px; box-shadow: none; }
#schedule-view .shipment-card:hover { transform: none; border-color: var(--primary); box-shadow: none; }
#schedule-view .shipment-workflow-board { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
#schedule-view .column-header { min-height: 64px; }
#schedule-view .shipment-card-references { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
#schedule-view .shipment-card-references > div { min-width: 0; }
#schedule-view .shipment-card-references dt { margin-bottom: 5px; color: var(--text-muted); font-size: .72rem; font-weight: 550; }
#schedule-view .shipment-card-references dd { margin: 0; color: var(--text-main); font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.4; letter-spacing: -.025em; overflow-wrap: anywhere; }
#schedule-view .shipment-card-badges { justify-content: flex-start; flex-wrap: wrap; margin-top: 10px; }
#schedule-view .shipment-card-parties { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 8px; margin-top: 10px; padding: 0 4px; }
#schedule-view .shipment-card-parties strong { min-width: 0; color: var(--text-main); font-size: .86rem; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
#schedule-view .shipment-card-parties strong:last-child { text-align: right; }
#schedule-view .shipment-card-parties > i { font-size: .65rem; line-height: 1.9; color: var(--text-muted); }
@media (max-width: 760px) {
    #schedule-view .shipment-workflow-board { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
    #schedule-view .shipment-card-references { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #schedule-view .shipment-card-references > div:first-child { grid-column: 1 / -1; }
}
.shipment-card-reference > strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.shipment-card-reference > span, .shipment-card-customer span, .shipment-card-supplier { font-size: .8rem; }
.followup-composer { padding: 22px; }
.followup-composer::before { background: var(--primary); height: 2px; }
.followup-composer-icon { color: var(--primary); border-color: var(--color-info-border); background: var(--color-info-bg); border-radius: 9px; }
.followup-queue-toolbar .eyebrow { color: var(--primary); font-size: .73rem; letter-spacing: .07em; }
.followup-field > label, .followup-label-row label { font-size: .83rem; font-weight: 550; }
.followup-summary-item small, #reminder-results-label { font-size: .8rem; }
.followup-search input { font-size: .88rem; border-radius: 8px; }
.followup-view-tab { font-size: .86rem; padding-top: 12px; padding-bottom: 13px; }
.reminder-card { border-radius: 9px; box-shadow: none; }
.reminder-card:hover { transform: none; box-shadow: none; }

/* Reporting and data review use the same restrained surfaces as order detail. */
.custom-report-hero { padding: 20px 22px; gap: 18px; margin-bottom: 20px; border-radius: 12px; border-color: var(--border-color); background: var(--bg-card); box-shadow: none; }
.custom-report-hero::after { display: none; }
.custom-report-hero h2 { margin: 0; }
.report-mode-switch { border-radius: 9px; padding: 4px; background: var(--surface-subtle); }
.report-mode-btn { border-radius: 6px; min-height: 38px; font-weight: 600; }
.report-mode-btn.active { box-shadow: none; }
.report-builder-card { padding: 22px; }
.report-builder-heading .card-title { line-height: 1.4; }
.custom-report-any-filter-builder { border-radius: 10px; background: var(--surface-subtle); }
.report-filter-chip { border-radius: 6px; font-size: .8rem; }
.report-compact-btn, .report-example-btn { font-size: .82rem; }
.customer-report-stat dt, .customer-report-meta,
.customer-report-filter-help, .customer-report-scope { font-size: .8rem; }
.customer-report-ref { font-size: .95rem; font-variant-numeric: tabular-nums; }
.customer-report-recipient-panel { border-radius: 10px; }
.dq-filters.glass-card, .dq-worklist.glass-card { border-radius: 12px; }
.dq-scan-status, .dq-scope-note, .dq-stat-caption,
.dq-record-sub, .dq-category-label { font-size: .78rem; }
.dq-badge { font-size: .74rem; }
.dq-description, .dq-recommendation { font-size: .82rem; }
.dq-issue-title { font-size: .92rem; }
#abnormal-inputs-view .form-label { font-size: .82rem; }
.dq-table.data-table th { text-transform: none; letter-spacing: 0; font-size: .79rem; }
.operations-panel, .operations-dialog { box-shadow: none; }

/* Compact remains a deliberate user setting; narrow screens retain usable controls. */
.workspace-compact :where(.view-panel:not(#order-detail-view)) .data-table th { padding-top: 9px; padding-bottom: 9px; }
.workspace-compact :where(.view-panel:not(#order-detail-view)) .data-table td { padding-top: 8px; padding-bottom: 8px; }
.workspace-compact .master-registry-card, .workspace-compact .report-builder-card,
.workspace-compact .dashboard-grid > .glass-card { padding-top: 16px; padding-bottom: 16px; }

/* Density changes spacing, never the amount of information or its type size.
 * Match the desktop table breakpoint; narrow/coarse-pointer layouts retain
 * their existing touch targets and stacked record cards. */
@media (min-width: 761px) and (pointer: fine) {
    .workspace-compact .main-content:not(:has(#order-detail-view.active)) .app-header { margin-bottom: 12px; }
    .workspace-compact .workspace-header-tools { margin-bottom: 12px; padding-bottom: 8px; }
    .workspace-compact :where(.view-panel:not(#order-detail-view)) .card-header { margin-bottom: 12px; }
    .workspace-compact :where(.view-panel:not(#order-detail-view)) .table-controls { gap: 10px; margin-bottom: 12px; }

    /* A smaller minimum alone cannot shrink controls with fixed heights or
     * generous padding. Keep horizontal icon/select clearance unchanged. */
    .workspace-compact .view-panel:not(#order-detail-view) :is(input.form-input:not([type="hidden"]), input.search-input, select.form-input:not([multiple]), select.form-select:not([multiple]), .multiselect-btn) {
        height: 36px;
        min-height: 36px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .workspace-compact :where(.view-panel:not(#order-detail-view)) :is(.master-toolbar-actions, .master-excel-controls) .btn {
        min-height: 36px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    /* Table-cell height is a minimum, so long references still grow naturally. */
    .workspace-compact #orders-view .orders-table .order-main-row > td:not(.col-select-row) {
        height: 52px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .workspace-compact #orders-view .order-cell-stack { gap: 2px; }
    .workspace-compact #orders-view .orders-table .order-status-row > .order-status-band-cell {
        padding-top: 4px;
        padding-bottom: 6px;
    }

    .workspace-compact #dashboard-view .attention-grid,
    .workspace-compact #dashboard-view .stats-grid { gap: 10px; }
    .workspace-compact #dashboard-view .attention-card { min-height: 88px; padding: 12px; gap: 10px; }
    .workspace-compact #dashboard-view .attention-value { margin-top: 4px; }
    .workspace-compact #dashboard-view .performance-heading { margin-top: 18px; }
    .workspace-compact #dashboard-view .stat-card { padding: 12px; gap: 10px; }
    .workspace-compact #dashboard-view .stat-label { margin-bottom: 5px; }
    .workspace-compact #dashboard-view .stats-grid { margin-bottom: 14px; }
    .workspace-compact #dashboard-view .dashboard-grid { gap: 12px; margin-bottom: 14px; }
    .workspace-compact #dashboard-view .dashboard-grid > .glass-card { padding: 16px; }
}

@media (max-width: 700px) {
    .custom-report-hero { flex-direction: column; align-items: stretch; padding: 18px; }
    .report-mode-switch { align-self: flex-start; max-width: 100%; }
    .report-mode-btn { white-space: normal; }
    .master-registry-card, .report-builder-card, .dashboard-grid > .glass-card,
    .pending-risk-intro, .schedule-controls-card, .followup-composer { padding: 18px; }
    .master-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    :where(.view-panel:not(#order-detail-view)) .data-table th,
    :where(.view-panel:not(#order-detail-view)) .data-table td { padding-left: 12px; padding-right: 12px; }
    :where(.view-panel:not(#order-detail-view)) .form-input,
    :where(.view-panel:not(#order-detail-view)) .form-select { font-size: 1rem; }
}
