html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #fafbfc;
    /* Engineering squared-paper grid, matching the DreamMRP marketing site. */
    background-image:
        linear-gradient(#EAEDF2 1px, transparent 1px),
        linear-gradient(90deg, #EAEDF2 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Xero-inspired color scheme */
:root {
    --xero-blue: #13B5EA;
    --xero-dark-blue: #1273EB;
    --xero-navy: #2E3A4B;
    --xero-light-gray: #F5F7FA;
}

a, .btn-link {
    color: var(--xero-dark-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.btn-primary {
    color: #fff;
    background-color: var(--xero-blue);
    border-color: var(--xero-blue);
}

.btn-primary:hover {
    background-color: var(--xero-dark-blue);
    border-color: var(--xero-dark-blue);
}

.btn-xero-blue {
    background-color: var(--xero-blue);
    border-color: var(--xero-blue);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.btn-xero-blue:hover {
    background-color: var(--xero-dark-blue);
    border-color: var(--xero-dark-blue);
    color: white;
}

.btn-outline-primary {
    border-color: var(--xero-dark-blue);
    color: var(--xero-dark-blue);
}

.btn-outline-primary:hover {
    background-color: var(--xero-dark-blue);
    color: white;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

/* Inactive nav tabs: same text colour as the active tab, solid page-grey fill (so the squared
   grid doesn't show through), and keep the rounded tab outline. Scoped to :not(.active) so the
   active tab keeps Bootstrap's distinct white "lifted" appearance. */
.nav-tabs .nav-link:not(.active) {
    color: var(--bs-nav-tabs-link-active-color, #495057);
    background-color: #fafbfc;
    border-color: #dee2e6;
}

.nav-tabs .nav-link:not(.active):hover,
.nav-tabs .nav-link:not(.active):focus {
    color: var(--bs-nav-tabs-link-active-color, #495057);
    border-color: #dee2e6;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* MRP job status grid - pulsing animation for Pending icon */
@keyframes mrp-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

.mrp-job-pulse {
    animation: mrp-pulse 1.5s ease-in-out infinite;
}

/* MRP Run Successful success banner animation */
@keyframes mrp-success-fade-in {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.mrp-success-banner {
    animation: mrp-success-fade-in 0.45s ease-out forwards;
}

/* Job row that has completed — fade to grey */
.mrp-job-row-done {
    opacity: 0.4;
    transition: opacity 0.6s ease;
}

/* Run Dream MRP button — lift on hover */
.mrp-run-btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border-radius: 0.5rem;
}

.mrp-run-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(19, 181, 234, 0.45) !important;
}

/* Navigation action cards — lift on hover */
.mrp-nav-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mrp-nav-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

/* View-mode field label — smaller, muted caption above a read-only value */
.field-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.1rem;
}

/* Edit mode modal body — grey background so white input fields stand out */
.modal-body-edit-mode {
    background-color: #f0f2f4;
}

/* Pin the top navbar to a known height so a full-screen document modal can sit exactly
   below it (keeping the main menu visible and clickable while the modal is open). */
:root {
    --app-navbar-height: 3.75rem;
}
.navbar.bg-white {
    /* Fixed height so the navbar is identical on every page and the popup's top edge
       (top: var(--app-navbar-height)) lines up exactly with its bottom — no bounce. */
    height: var(--app-navbar-height);
}
/* Below the navbar-expand-lg breakpoint (992px) the collapsed menu previously rendered outside
   the navbar's fixed-height box: it had no background of its own (page content showed through =
   "transparent") and appeared as a flex-wrap line disconnected from the toggler (looked
   left-shifted). Do NOT change the navbar's own height here — --app-navbar-height is used to
   position every .doc-modal-below-nav modal, and letting the navbar grow would misplace them.
   Instead, anchor the collapse panel as an absolutely-positioned dropdown directly below the
   (still fixed-height) navbar, with its own solid white background. */
@media (max-width: 991.98px) {
    .navbar.bg-white {
        position: relative;
    }
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background-color: #fff;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1050;
    }
}
.doc-modal-below-nav {
    top: var(--app-navbar-height);
    height: calc(100% - var(--app-navbar-height));
}
/* Keep the full-screen document modal BELOW the sticky navbar (z-index 1050) so the navbar's
   Help / Settings dropdown flyouts (children of the navbar's stacking context) remain visible
   and clickable while the modal is open. Higher specificity (.modal.doc-modal-below-nav) beats
   Bootstrap's default .modal z-index. Still sits above page content and #blazor-error-ui (1000). */
.modal.doc-modal-below-nav {
    z-index: 1045;
}

/* Shared full-screen document modal (parent/child screens — PurchaseOrders is canonical):
   full-screen shell but cap the readable content width and centre it so fields don't stretch
   on wide monitors. padding-inline gives the same left/right indent as the main grid page. */
.doc-modal-cap {
    max-width: 1400px;
    width: 100%;
    margin-inline: auto;
    /* Match the main page's horizontal inset: .content px-4 (1.5rem) + container-fluid gutter
       (0.75rem) = 2.25rem each side. (The title block adds ps-3 on top, like the main page.) */
    padding-inline: 2.25rem;
}

/* Make the popup resemble the main grid page: the whole surface carries the engineering
   squared-paper grid, and the header (title + buttons) sits on it with no white bar / divider. */
.doc-modal-surface {
    background-color: #fbfcfd;
    background-image:
        linear-gradient(#EAEDF2 1px, transparent 1px),
        linear-gradient(90deg, #EAEDF2 1px, transparent 1px);
    background-size: 40px 40px;
}
/* Let doc-modal-cap own the horizontal indent so the header and body line up with the main page. */
.doc-modal-surface .modal-header,
.doc-modal-surface .modal-body {
    padding-inline: 0;
}
.doc-modal-surface .modal-header {
    background-color: transparent;
    border-bottom: 0;
    /* Gap from the navbar to the title, matching the main page (.content padding + container margin). */
    padding-top: 2rem;
}

/* Header buttons must not be see-through (the grid would run through them). Give every
   outline/borderless button a solid page-grey fill at rest; hover still fills with colour. */
.doc-modal-surface .modal-header .btn[class*="btn-outline-"]:not(:hover):not(:focus),
.doc-modal-surface .modal-header .dropdown > .btn:not(:hover):not(:focus) {
    background-color: #fbfcfd;
}

/* Body sits on the surface grid above — no background of its own in view mode. */
.doc-modal-view-body {
    background-color: transparent;
}

/* White section card for grouped content (details / lines) in view mode. */
.doc-section {
    background-color: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

/* Totals row under a view-mode lines table. */
.doc-lines-total td {
    border-top: 2px solid var(--bs-border-color, #dee2e6);
}

/* Dense detail grid — inline label:value cells, auto-fitting columns. */
.doc-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.35rem 1.75rem;
}
.doc-detail-grid .doc-detail-cell {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}
.doc-detail-grid .field-label {
    margin-bottom: 0;
    white-space: nowrap;
}
.doc-detail-grid .doc-detail-value {
    font-size: 0.95rem;
}
.doc-detail-grid .doc-detail-wide {
    grid-column: 1 / -1;
}
/* Fixed 4-column variant (Purchase Orders view). */
.doc-detail-grid--4col {
    grid-template-columns: repeat(4, 1fr);
}

/* ── Grouped field layout for document popups (Items, Purchase Orders, Work Orders,
   Contacts, Users, Accounts/Tax Codes, Sales Orders/Forecasts, Demand) ──
   View and Edit render the same grid skeleton so every field keeps its position when
   toggling modes; captions use .field-label in both. */

/* Sub-group heading separating field groups inside one card (Purchasing, Planning…). */
.doc-subhead {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--xero-navy);
    margin: 1.5rem 0 0.25rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.doc-subhead i {
    color: var(--xero-blue);
}

/* Icon in a doc-section card title. */
.doc-section-icon {
    color: var(--xero-blue);
}

/* Read-only caption+value cell (view mode, and locked fields in edit mode). */
.doc-field-value {
    font-size: 0.95rem;
    min-height: 1.5rem;
    padding-top: 0.15rem;
    margin-bottom: 0;
}

/* Checked-state icon for boolean values in view mode (bi-check-square-fill). */
.doc-check-on {
    color: var(--xero-blue);
}

/* Edit mode: tint the section card so the white inputs read as the entry points. */
.doc-section-edit {
    background-color: var(--xero-light-gray);
}

.doc-section-edit .form-control:not(:disabled):not([readonly]),
.doc-section-edit .form-select:not(:disabled) {
    border-color: #becbd9;
}

/* Edit mode: rows mix inputs/selects with read-only text and switches — give every
   non-input cell the same height as a Bootstrap control and centre its content
   vertically so all values sit on one line. */
.doc-section-edit .field-label {
    margin-bottom: 0.25rem;
}

.doc-section-edit .doc-field-value {
    min-height: calc(1.5em + 0.75rem + 2px); /* Bootstrap .form-control height */
    display: flex;
    align-items: center;
    padding-top: 0;
}

.doc-section-edit .form-switch {
    min-height: calc(1.5em + 0.75rem + 2px);
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding-left: 0;
    margin-bottom: 0;
}

.doc-section-edit .form-switch .form-check-input {
    float: none;
    margin-left: 0;
    margin-top: 0;
    flex-shrink: 0;
}

/* Edit mode info bar — Xero-blue tint, calmer than Bootstrap warning yellow */
.alert-edit-mode {
    background-color: rgba(19, 181, 234, 0.1);
    border-color: #13B5EA;
    color: #0c5f78;
}

/* Tabular numbers for financial data columns */
.font-tabular {
    font-variant-numeric: tabular-nums;
}

/* Invisible decimal-place padding for column alignment (MrpNumberFormatter) */
.decimal-pad {
    visibility: hidden;
}

/* Work Order Progress Slider */
.wo-progress-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    border: none;
    padding: 0;
    display: block;
}

.wo-progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #198754;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    margin-top: -7px;
}

.wo-progress-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
}

.wo-progress-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #198754;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.wo-progress-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
}

.wo-progress-slider::-moz-range-progress {
    height: 6px;
    border-radius: 3px 0 0 3px;
    background: #198754;
}

/* ================================================================
   Blazor error banner — hidden by default in ALL layouts.
   MainLayout.razor.css has a scoped copy ([b-xxxx]) that only
   applies to MainLayout. This global rule covers HelpLayout and
   any other layout that includes the #blazor-error-ui div.
   ================================================================ */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ================================================================
   Knowledge Base article body — styles for Markdown-rendered HTML.
   .kb-article wraps a MarkupString so Blazor scoped CSS cannot
   reach inner elements; all rules must live in this global file.
   ================================================================ */

.kb-article {
    font-size: 1rem;        /* Bootstrap body default */
    line-height: 1.5;       /* Bootstrap body default */
    color: var(--bs-body-color);
}

/* Section headings  (## in markdown → h2)
   Sized as Bootstrap h5 (.h5) to match the category headers on the Help index. */
.kb-article h2 {
    font-size: 1.25rem;     /* Bootstrap h5 */
    font-weight: 500;       /* Bootstrap heading weight */
    line-height: 1.2;
    color: var(--bs-heading-color);
    margin-top: 1.5rem;     /* Bootstrap mt-4 — matches .h5.mt-4 on the Help index */
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--bs-border-color);
}

/* Sub-section headings  (### → h3)
   Sized as Bootstrap h6 / body — same as card titles on the Help index. */
.kb-article h3 {
    font-size: 1rem;        /* Bootstrap h6 / body */
    font-weight: 600;
    line-height: 1.2;
    color: var(--bs-heading-color);
    margin-top: 1.25rem;
    margin-bottom: 0.35rem;
}

/* Deeper headings (rarely used in articles) */
.kb-article h4,
.kb-article h5,
.kb-article h6 {
    font-size: 0.875rem;    /* Bootstrap .small — same as card description text on the Help index */
    font-weight: 600;
    line-height: 1.2;
    color: var(--bs-secondary-color);
    margin-top: 1rem;
    margin-bottom: 0.25rem;
}

/* First h2 sits close to the intro — less top gap needed.
   Use :first-of-type so the rule applies even when a paragraph
   (or other element) precedes the first section heading. */
.kb-article h2:first-of-type {
    margin-top: 1rem;
}

/* Paragraphs */
.kb-article p {
    margin-bottom: 0.85rem;
}

/* Images — never overflow the article container */
.kb-article img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 0.85rem;
}

/* Lists */
.kb-article ul,
.kb-article ol {
    padding-left: 1.5rem;
    margin-bottom: 0.85rem;
}

.kb-article li {
    margin-bottom: 0.3rem;
}

.kb-article li > ul,
.kb-article li > ol {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* Tables */
.kb-article table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.kb-article thead th {
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--bs-border-color);
    background-color: var(--bs-tertiary-bg);
    text-align: left;
    vertical-align: bottom;
    white-space: nowrap;
}

.kb-article tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
    vertical-align: top;
}

.kb-article tbody tr:last-child td {
    border-bottom: none;
}

/* Inline code */
.kb-article code {
    font-family: var(--bs-font-monospace);
    font-size: 0.85em;
    color: var(--bs-code-color);
    background-color: var(--bs-tertiary-bg);
    padding: 0.125em 0.35em;
    border-radius: var(--bs-border-radius-sm);
}

/* Code block */
.kb-article pre {
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.875rem 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.kb-article pre code {
    background-color: transparent;
    padding: 0;
    color: var(--bs-body-color);
    font-size: 0.8125rem;
    border-radius: 0;
}

/* Blockquotes — rendered for notes or callout paragraphs */
.kb-article blockquote {
    border-left: 3px solid var(--xero-blue);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: var(--bs-secondary-color);
    background-color: var(--bs-tertiary-bg);
    border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0;
}

.kb-article blockquote p {
    margin-bottom: 0;
}

/* Links */
.kb-article a {
    color: var(--xero-dark-blue);
}

.kb-article a:hover {
    text-decoration: underline;
}

/* Horizontal rule */
.kb-article hr {
    border: 0;
    border-top: 1px solid var(--bs-border-color);
    margin: 1.5rem 0;
}

/* Strong */
.kb-article strong {
    font-weight: 600;
}

/* Shared CSV drag-and-drop upload zone (Home, SalesForecasts, ItemConfiguration) */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: #0d6efd;
    background-color: #e7f1ff;
}

.drop-zone-active {
    border-color: #0d6efd;
    background-color: #cfe2ff;
    border-style: solid;
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone svg {
    color: #6c757d;
}

.drop-zone:hover svg {
    color: #0d6efd;
}