/* EvoStock — Base Styles */

@import url("grid-VbT8Bu6.css");
@import url("safety-stock-O22WgRB.css");
@import url("modal-CuLpLkf.css");
@import url("sku-details-qVpkyND.css");
@import url("sku-details-v2-kv6kgl5.css");
@import url("order-gantt-QrYNp5I.css");
@import url("holiday-calendars-rkyozPM.css");
@import url("replenishment-rlG8oUF.css");
@import url("rolling-order-value-D7-oRGM.css");
@import url("constrained-plan-sll9v82.css");
@import url("components/supplier-profile-XRTOWPV.css");

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #dc2626;
    --color-warning: #f59e0b;
    --color-success: #16a34a;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    /* Slate-600: keeps >= 4.5:1 (WCAG AA) even on the tinted grid cells
       (#fef3c7 shortage, #fef2f2 stockout) where slate-500 dropped below AA. */
    --color-text-muted: #475569;
    --color-border: #e2e8f0;
    --color-safety-breach: #fef2f2;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; }

/* Accessible muted text/buttons: Bootstrap's #6c757d only reaches 4.45:1 on the
   light gray page backgrounds (#f8f9fa/#f8fafc). Gray-700 keeps WCAG AA everywhere. */
.text-secondary { color: #495057 !important; }
.btn-outline-secondary { --bs-btn-color: #495057; }
/* Bootstrap's #0d6efd only reaches 3.68:1 on white; blue-600 keeps AA for the
   outline text and for the white label on the hover/active fill. */
.btn-outline-primary {
    --bs-btn-color: #0a58ca;
    --bs-btn-border-color: #0a58ca;
    --bs-btn-hover-bg: #0a58ca;
    --bs-btn-hover-border-color: #0a58ca;
    --bs-btn-active-bg: #0a58ca;
    --bs-btn-active-border-color: #0a58ca;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.iso-date-display {
    position: relative;
    display: block;
    width: 100%;
}

.iso-date-display__input {
    padding-right: 3.5rem;
}

.iso-date-display__picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.iso-date-display__button {
    position: absolute;
    top: 50%;
    right: .5rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: calc(100% - .5rem);
    padding: 0 .5rem;
    border: 0;
    border-radius: calc(var(--bs-border-radius, .375rem) - 1px);
    background: transparent;
    color: var(--color-text-muted);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
}

.iso-date-display__button:hover:not(:disabled),
.iso-date-display__button:focus-visible {
    background: rgba(37, 99, 235, .08);
    color: var(--color-primary);
    outline: none;
}

.iso-date-display__button:disabled {
    cursor: default;
    opacity: .5;
}

/* Header / Nav */
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .navbar-nav .nav-link {
    white-space: nowrap;
}

.app-header .dropdown-menu {
    min-width: 13rem;
}

.app-navbar-tools {
    min-width: 0;
}

.app-header .snapshot-selector {
    min-width: 0;
}

.app-header .snapshot-selector__select {
    width: clamp(18rem, 32vw, 30rem);
    max-width: 100%;
    text-overflow: ellipsis;
}

.app-navbar-tools .small {
    white-space: nowrap;
}

@media (max-width: 1399.98px) {
    .app-header .container-fluid {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }

    .app-header .navbar-nav .nav-link {
        padding-right: .45rem;
        padding-left: .45rem;
    }

    .app-header .snapshot-selector__select {
        width: clamp(16rem, 28vw, 24rem);
    }
}

@media (max-width: 1199.98px) {
    .app-header .snapshot-selector__select {
        width: min(100%, 22rem);
    }
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    max-width: 1440px;
    margin: 0 auto;
    padding: .75rem 1.5rem;
}
.app-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}
.app-nav__links {
    display: flex;
    list-style: none;
    gap: 1rem;
}
.app-nav__links a {
    text-decoration: none;
    color: var(--color-text-muted);
    padding: .25rem .5rem;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
}
.app-nav__links a:hover,
.app-nav__links a.active {
    color: var(--color-primary);
    background: #eff6ff;
}
.app-nav__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .875rem;
    color: var(--color-text-muted);
}
.app-nav__user a { color: var(--color-danger); text-decoration: none; }

.planning-draft-navbar {
    min-height: 2rem;
}

.planning-draft-navbar__status {
    white-space: nowrap;
}

.planning-workspace-filters {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.planning-workspace-filters__toggle {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.planning-workspace-filters__toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    padding-left: 0;
}

.planning-workspace-filters__toggle-switch .form-check-input {
    margin-left: 0;
    flex-shrink: 0;
}

.planning-workspace-filters__toggle-label {
    white-space: nowrap;
    cursor: pointer;
}

.planning-workspace-filters__search {
    flex: 1 1 clamp(12rem, 26vw, 18rem);
    min-width: clamp(11rem, 24vw, 16rem);
}

.planning-workspace-filters__time-range {
    flex-shrink: 1;
    min-width: 0;
}

.planning-workspace-filters__time-range-label {
    white-space: nowrap;
    /* Accessible muted label: #495057 (gray-700) meets WCAG AA (>= 4.5:1) on the
       light body/tertiary backgrounds, unlike Bootstrap's lighter .text-secondary. */
    color: #495057;
}

.planning-workspace-filters__time-range-select {
    width: auto;
    min-width: 5.25rem;
}

.planning-workspace-topbar {
    display: grid;
    gap: .75rem;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--color-border);
    border-radius: .9rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .95));
    box-shadow: 0 14px 32px rgba(15, 23, 42, .05);
}

.planning-workspace-topbar__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
    gap: 1rem 1.5rem;
}

.planning-workspace-topbar__title {
    margin: 0;
}

.planning-workspace-topbar__description {
    margin: .2rem 0 0;
    max-width: 46rem;
    line-height: 1.45;
}

.planning-workspace-topbar__title-block {
    min-width: 0;
}

.planning-workspace-topbar__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.planning-workspace-topbar__sections {
    display: grid;
    grid-template-columns: auto auto;
    gap: 1rem 2rem;
    align-items: start;
    justify-content: end;
    max-width: 100%;
}

.planning-workspace-topbar__section {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    max-width: 100%;
}

.planning-workspace-topbar__section-label {
    color: var(--color-text);
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.2;
    padding-top: .25rem;
    white-space: nowrap;
}

.planning-workspace-topbar__views {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    justify-content: flex-start;
    width: auto;
    max-width: 100%;
}

.planning-workspace-topbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    justify-content: flex-end;
    width: auto;
    max-width: 100%;
}

.planning-workspace-topbar__header-side {
    display: grid;
    gap: .8rem;
    justify-items: end;
    min-width: 0;
}

.planning-workspace-topbar__details--actions {
    position: relative;
}

.planning-workspace-topbar__details-card--actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.planning-workspace-topbar__snapshot-action {
    min-width: 0;
}

.planning-workspace-topbar__view {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    flex: 0 0 5.5rem;
    gap: .5rem;
    min-height: 4.9rem;
    width: 5.5rem;
    padding: .7rem .65rem;
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    background: #fff;
    color: var(--color-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.planning-workspace-topbar__view:hover {
    border-color: rgba(37, 99, 235, .35);
    color: var(--color-primary);
}

.planning-workspace-topbar__view--active {
    border-color: rgba(37, 99, 235, .4);
    background: rgba(37, 99, 235, .08);
    color: rgb(30, 64, 175);
}

.planning-workspace-topbar__view--disabled {
    opacity: .55;
}

.planning-workspace-topbar__view-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .9rem;
    background: linear-gradient(180deg, rgba(226, 232, 240, .9), rgba(241, 245, 249, .95));
    font-size: 1.15rem;
    font-weight: 700;
    justify-content: center;
}

.planning-workspace-topbar__view-label {
    line-height: 1.2;
}

.planning-workspace-topbar__view-badge {
    position: absolute;
    top: -.45rem;
    right: -.3rem;
    min-width: 1.45rem;
    height: 1.45rem;
    padding: 0 .35rem;
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 999px;
    background: rgb(248, 250, 252);
    color: rgb(51, 65, 85);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.3rem;
}

.planning-workspace-topbar__action,
.planning-workspace-topbar__action-widget,
.planning-workspace-topbar__action-widget .toolbar__export,
.planning-workspace-topbar__action-widget .toolbar__unconstrained-orders,
.planning-workspace-topbar__action-widget .snapshot-selector {
    width: 100%;
}

.planning-workspace-topbar__action {
    flex: 0 0 6.25rem;
    width: 6.25rem;
}

.planning-workspace-topbar__action-button {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: .45rem;
    min-height: 4.9rem;
    width: 100%;
    min-width: 0;
    padding: .85rem .75rem;
    border-radius: 1rem;
    text-align: center;
    line-height: 1.2;
}

.planning-workspace-topbar__snapshot-action.snapshot-selector {
    display: block !important;
}

.planning-workspace-topbar__snapshot-action .snapshot-selector__select--hidden {
    display: none !important;
}

.planning-workspace-topbar__action-button::before {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .9rem;
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(148, 163, 184, .25);
    font-size: 1rem;
    font-weight: 700;
}

.planning-workspace-topbar__action-button[data-planning-topbar-action="create-snapshot"]::before {
    content: '+';
}

.planning-workspace-topbar__action-button[data-planning-topbar-action="generate-plan"]::before {
    content: 'R';
}

.planning-workspace-topbar__action-button[data-planning-topbar-action="export-excel"]::before {
    content: 'X';
}

.planning-workspace-topbar__counter {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, .86);
}

.planning-workspace-topbar__counter-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.1rem;
    line-height: 1;
}

.planning-workspace-topbar__counter-link:hover {
    background: rgba(37, 99, 235, .1);
    color: var(--color-primary);
}

.planning-workspace-topbar__counter-link--disabled {
    opacity: .35;
}

.planning-workspace-topbar__counter-label {
    min-width: 3.5rem;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
}

.planning-workspace-topbar__details {
    position: relative;
}

.planning-workspace-topbar__details summary {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    cursor: pointer;
    color: var(--color-primary);
    list-style: none;
}

.planning-workspace-topbar__details summary::-webkit-details-marker {
    display: none;
}

.planning-workspace-topbar__details-card {
    position: absolute;
    top: calc(100% + .5rem);
    left: 0;
    z-index: 20;
    min-width: 18rem;
    padding: .75rem .85rem;
    border: 1px solid var(--color-border);
    border-radius: .8rem;
    background: #fff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, .12);
}

.planning-workspace-topbar__details-card--freshness {
    min-width: 15rem;
}

.planning-workspace-topbar__freshness-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .55rem;
    justify-content: space-between;
    align-items: center;
}

.planning-workspace-topbar__freshness-row + .planning-workspace-topbar__freshness-row {
    margin-top: .45rem;
}

.planning-workspace-topbar__freshness-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.snapshot-selector__select--hidden {
    width: 0;
    min-width: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.planning-workspace-topbar__status-dot {
    width: .65rem;
    height: .65rem;
    border-radius: 999px;
    background: currentColor;
    color: rgb(22, 163, 74);
}

.planning-workspace-topbar__status-dot--success {
    color: rgb(22, 163, 74);
}

.planning-workspace-topbar__status-dot--warning {
    color: rgb(234, 179, 8);
}

.planning-workspace-topbar__status-dot--danger {
    color: rgb(220, 38, 38);
}

@media (max-width: 768px) {
    .planning-workspace-topbar__header {
        grid-template-columns: 1fr;
    }

    .planning-workspace-topbar__views {
        justify-content: flex-start;
        width: 100%;
    }

    .planning-workspace-topbar__header-side {
        justify-items: start;
        width: 100%;
    }

    .planning-workspace-topbar__sections {
        grid-template-columns: 1fr;
        align-items: stretch;
        width: 100%;
    }

    .planning-workspace-topbar__section {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: start;
        width: 100%;
    }

    .planning-workspace-topbar__actions {
        justify-content: flex-start;
        width: 100%;
    }

    .planning-workspace-topbar__view,
    .planning-workspace-topbar__action {
        flex-basis: calc(50% - .3rem);
        width: calc(50% - .3rem);
    }

    .planning-workspace-topbar__details-card {
        position: static;
        margin-top: .5rem;
        min-width: 0;
    }

}

@media (max-width: 1100px) {
    .planning-workspace-topbar__header {
        grid-template-columns: 1fr;
    }

    .planning-workspace-topbar__header-side,
    .planning-workspace-topbar__sections {
        justify-items: start;
        align-items: stretch;
        width: 100%;
    }

    .planning-workspace-topbar__section {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .planning-workspace-topbar__views,
    .planning-workspace-topbar__actions {
        justify-content: flex-start;
    }
}

/* Main */
.app-main {
    flex: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

body.dashboard-layout {
    height: 100vh;
    overflow: hidden;
}

body.order-gantt-layout {
    height: 100vh;
    overflow: hidden;
}

body.dashboard-layout .app-main--dashboard,
body.order-gantt-layout .app-main--dashboard {
    max-width: none;
    width: 100%;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

body.order-gantt-layout .app-main--dashboard {
    overflow: hidden;
}

body.dashboard-layout .app-main--dashboard .dashboard,
body.order-gantt-layout .app-main--dashboard .dashboard {
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    grid-template-columns: minmax(0, 1fr);
    height: 100%;
    width: 100%;
    min-height: 0;
    min-width: 0;
}

.planning-sku-details-host {
    position: relative;
}

body.order-gantt-layout .app-main--dashboard .dashboard.order-gantt {
    grid-template-rows: auto auto minmax(0, 1fr);
}

body.order-gantt-layout .app-main--dashboard .dashboard {
    height: 100%;
}

body.dashboard-layout .app-main--dashboard .dashboard > turbo-frame#stock-grid,
body.order-gantt-layout .app-main--dashboard .dashboard > turbo-frame#order-gantt-frame {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

body.order-gantt-layout .app-main--dashboard .dashboard > turbo-frame#order-gantt-frame {
    overflow: hidden;
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-shell,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    min-height: clamp(24rem, 62vh, 48rem);
    min-width: 0;
    overflow: hidden;
}

body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell {
    min-height: 0;
    overflow: hidden;
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-shell > turbo-frame#stock-grid,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell > turbo-frame#order-gantt-frame {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell > turbo-frame#order-gantt-frame {
    overflow: hidden;
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-shell[data-loading="true"] > turbo-frame#stock-grid,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell[data-loading="true"]:not([data-loading-visibility="hidden"]) > turbo-frame#order-gantt-frame {
    opacity: .4;
    filter: saturate(.85);
    pointer-events: none;
}

body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell[data-loading="true"][data-loading-visibility="hidden"] > turbo-frame#order-gantt-frame {
    visibility: hidden;
    pointer-events: none;
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-shell[data-initial-loading="true"] > turbo-frame#stock-grid,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-shell[data-initial-loading="true"] > turbo-frame#order-gantt-frame {
    visibility: hidden;
}

[data-nested-scroll-restoring="true"] {
    visibility: hidden;
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-loading,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-loading {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, .72);
    backdrop-filter: blur(2px);
}

body.dashboard-layout .app-main--dashboard .dashboard .dashboard-grid-loading__content,
body.order-gantt-layout .app-main--dashboard .dashboard .dashboard-grid-loading__content {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.15rem;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 20px 45px rgba(15, 23, 42, .08);
    color: var(--color-text);
    font-size: .95rem;
    font-weight: 600;
}

.dashboard-grid-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.dashboard-grid-card__table {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    max-height: none;
}

.dashboard-grid-card__pagination {
    flex-shrink: 0;
}

.dashboard-grid-card__virtual-status {
    flex-shrink: 0;
    padding: .75rem 1rem;
    border-top: 1px solid rgba(148, 163, 184, .2);
    background: rgba(248, 250, 252, .9);
}

.pagination__loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-width: 1.9rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--bs-secondary-color, #6c757d);
}

.pagination__loading-dot {
    display: inline-block;
    animation: pagination-loading-dot 1.2s ease-in-out infinite;
}

.pagination__loading-dot:nth-child(2) {
    animation-delay: .2s;
}

.pagination__loading-dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes pagination-loading-dot {
    0%, 80%, 100% {
        opacity: .2;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-1px);
    }
}

.snapshot-selector__select {
    min-width: 22rem;
    max-width: min(32rem, 42vw);
}

@media (max-width: 991.98px) {
    .snapshot-selector__select {
        min-width: 0;
        max-width: 100%;
    }
}

body.dashboard-layout .app-main--dashboard .dashboard .stock-grid,
body.order-gantt-layout .app-main--dashboard .dashboard .stock-grid {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

body.order-gantt-layout .app-main--dashboard .dashboard .stock-grid {
    overflow: visible;
}

body.dashboard-layout .app-main--dashboard .dashboard .stock-grid .table-responsive,
body.order-gantt-layout .app-main--dashboard .dashboard .stock-grid .table-responsive {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    max-height: none;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: .75rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

body.order-gantt-layout .app-footer {
    display: block;
}

/* Flash Messages */
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .875rem;
}
.flash--success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash--danger, .flash--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash--warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.flash--info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: inherit;
    opacity: .6;
}
.flash button:hover { opacity: 1; }

/* Legacy Buttons */
.btn-legacy {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    transition: all .15s;
}
.btn-legacy:hover { box-shadow: var(--shadow); }
.btn--primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn--sm { padding: .25rem .75rem; font-size: .8125rem; }
.btn--full { width: 100%; justify-content: center; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .25rem;
    color: var(--color-text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 70px);
    flex-grow: 1;
}
.login-card {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-card h1 { font-size: 1.75rem; margin-bottom: .25rem; }
.login-subtitle { color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: .875rem; }
.login-form { text-align: left; }
.login-actions {
    display: grid;
    gap: .75rem;
}
.login-divider {
    color: var(--color-text-muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.login-dev-actions {
    display: grid;
    gap: .5rem;
}

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card__header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card__body { padding: 1.5rem; }

/* Tables */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
th, td {
    padding: .5rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
th {
    font-weight: 600;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Stock Grid */
.stock-grid {
    overflow-x: auto;
}
.stock-grid table { min-width: 800px; }
.stock-grid th.date-col,
.stock-grid td.date-col {
    min-width: 80px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.stock-grid td.cell--below-safety {
    color: var(--color-danger);
    font-weight: 700;
}

.stock-grid td.cell--below-safety .metric-stack__value {
    color: var(--color-danger);
}

.stock-grid td.cell--stockout {
    background: var(--color-safety-breach);
}

.stock-grid td.cell--stockout-overstock {
    background: repeating-linear-gradient(
        -45deg,
        #fecaca,
        #fecaca 4px,
        #bfdbfe 4px,
        #bfdbfe 8px
    );
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar__search {
    flex: 1;
    min-width: 200px;
}
.toolbar__search input {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
}
.toolbar__filters {
    display: flex;
    gap: .5rem;
    align-items: center;
}

/* Pagination */
.pagination {
    display: flex;
    gap: .25rem;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.pagination a,
.pagination span {
    padding: .375rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .8125rem;
    text-decoration: none;
    color: var(--color-text);
}
.pagination a:hover { background: #f1f5f9; }
.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .125rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 500;
}
.badge--ok { background: #dcfce7; color: #166534; }
.badge--warning { background: #fef9c3; color: #854d0e; }
.badge--error { background: #fee2e2; color: #991b1b; }
.badge--stale { background: #fef9c3; color: #854d0e; }
.badge--syncing { background: #dbeafe; color: #1e40af; animation: pulse-badge 1.5s ease-in-out infinite; }

/* Pulse a halo (box-shadow) rather than the badge's own opacity: fading the
   element alpha-blends both text and background toward the page, dropping
   text/background contrast below AA at the low point. The halo keeps the badge
   fully opaque so contrast stays constant while the "syncing" cue still reads. */
@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(30, 64, 175, .35); }
    50% { box-shadow: 0 0 0 4px rgba(30, 64, 175, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .badge--syncing { animation: none; }
}

/* Freshness bar */
.freshness-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .8125rem;
}

.toolbar--dashboard-actions {
    align-items: center;
}

.toolbar--dashboard-actions .freshness-bar {
    flex: 1 1 34rem;
    min-width: min(100%, 24rem);
}

.toolbar--dashboard-actions .toolbar__actions {
    flex: 0 0 auto;
}

/* Settings page */
.settings-grid {
    display: grid;
    gap: 1.5rem;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
}
.spinner--sm {
    width: .8em;
    height: .8em;
    border-width: 1.5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Sync progress */
.sync-progress {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-primary);
    font-weight: 500;
    font-size: .875rem;
    padding: .5rem 0;
}

.sync-progress-bar {
    max-width: 20rem;
}

.sync-progress-bar .progress-bar {
    min-width: 3rem;
}

/* Syncing button state */
.btn--syncing {
    opacity: .7;
    cursor: not-allowed;
    pointer-events: none;
}
.btn--syncing .spinner {
    margin-right: .25rem;
}

/* Fullscreen mode */
body.dashboard-fullscreen .app-header,
body.dashboard-fullscreen .app-main--dashboard .dashboard > h1,
body.dashboard-fullscreen .app-main--dashboard .planning-workspace-topbar,
body.dashboard-fullscreen .app-main--dashboard .replenishment-topbar,
body.dashboard-fullscreen .app-main--dashboard .freshness-bar,
body.dashboard-fullscreen .app-footer {
    display: none !important;
}

body.dashboard-fullscreen .app-main--dashboard {
    max-width: none;
    width: 100%;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding-top: .5rem;
}

body.dashboard-fullscreen.order-gantt-layout .app-main--dashboard {
    margin: 0;
    padding: .5rem 0 0 !important;
}

body.dashboard-fullscreen .app-main--dashboard .dashboard {
    grid-template-rows: auto auto 1fr;
}

body.dashboard-fullscreen.order-gantt-layout .app-main--dashboard .dashboard.order-gantt {
    grid-template-rows: auto minmax(0, 1fr);
}

body.dashboard-fullscreen .app-main--dashboard .toolbar__search-form,
body.dashboard-fullscreen .app-main--dashboard .order-gantt__toolbar-form {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: .5rem 0 .75rem;
    margin-bottom: .75rem !important;
    background: var(--bs-body-bg, #f8f9fa);
}

.btn-fullscreen {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .35rem .6rem;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--color-text-muted);
    transition: color .15s, border-color .15s;
}
.btn-fullscreen:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-nav { flex-wrap: wrap; gap: .5rem; }
    .app-nav__links { order: 3; width: 100%; }
    .toolbar { flex-direction: column; }
    .toolbar__search { min-width: 100%; }
    .toolbar--dashboard-actions {
        align-items: stretch;
    }

    .toolbar--dashboard-actions .toolbar__actions {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-end;
    }

    .planning-workspace-filters__search {
        min-width: 100%;
    }

    .planning-workspace-filters__time-range-label {
        display: none;
    }
}
