/* =====================================================================
   MaterialManagement - app shell and house style.

   Plain Bootstrap 5 underneath; this file sets the type scale, the softer
   radii, the sidebar, the toast stack, the grid chrome and the soft badges
   (Bootstrap 5.1 has no *-subtle utilities). No theme, no icon font.
   ===================================================================== */

:root {
    --app-sidebar-w: 262px;
    --app-topbar-h: 64px;

    --app-ink: #16202e;
    --app-ink-soft: #5b6779;
    --app-ink-mute: #8a94a4;

    --app-line: #e5e8ee;
    --app-paper: #f4f6f9;
    --app-card: #ffffff;

    --app-brand: #1b3a63;
    --app-brand-2: #12304f;
    --app-brand-soft: #eaf0f8;
    --app-accent: #c2620f;

    --app-radius: 16px;
    --app-radius-sm: 11px;
    --app-shadow: 0 1px 2px rgba(16, 32, 46, .04), 0 12px 28px rgba(16, 32, 46, .06);
    --app-shadow-sm: 0 1px 2px rgba(16, 32, 46, .05);
}

/* ------------------------------------------------------------------
   TYPE - Jakarta for anything that carries weight, Inter for reading,
   JetBrains Mono for numbers that have to line up. Each falls back to a
   real stack, so the app still looks deliberate with no internet.
   ------------------------------------------------------------------ */
body {
    background: var(--app-paper);
    color: var(--app-ink);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    letter-spacing: -.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.page-head h1,
.tile-value,
.brand b {
    font-family: "Plus Jakarta Sans", "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -.025em;
    color: var(--app-ink);
}

h5 {
    font-size: 15.5px;
}

.mono,
.tile-value,
.ranked-value {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
    font-feature-settings: "tnum" 1;
}

.mono {
    font-size: .84em;
    letter-spacing: -.02em;
}

/* Numbers in a grid have to line up column by column. */
.table td,
.table th {
    font-variant-numeric: tabular-nums;
}

.fs-xs {
    font-size: 12.5px;
    line-height: 1.45;
}

.text-uppercase.fs-xs {
    letter-spacing: .07em;
}

/* ------------------------------------------------------------------
   CONTROLS - rounder, a little larger, and bolder labels
   ------------------------------------------------------------------ */
.btn {
    --bs-btn-border-radius: .7rem;
    border-radius: .7rem;
    font-weight: 600;
    padding: .58rem 1.15rem;
    transition: transform .06s ease, box-shadow .15s ease, background-color .15s ease;
}

    .btn:active {
        transform: translateY(1px);
    }

.btn-sm {
    border-radius: .6rem;
    padding: .38rem .8rem;
    font-size: 13px;
}

.btn-lg {
    border-radius: .85rem;
    padding: .8rem 1.4rem;
    font-size: 16px;
}

/* Bootstrap 5.1 compiles button colours in, so these are plain overrides -
   not the --bs-btn-* variables that only exist from 5.3. */
.btn-primary {
    background-color: var(--app-brand);
    border-color: var(--app-brand);
    box-shadow: 0 6px 16px rgba(27, 58, 99, .22);
}

    .btn-primary:hover,
    .btn-primary:focus,
    .btn-primary:active,
    .btn-primary:disabled,
    .btn-check:checked + .btn-primary {
        background-color: var(--app-brand-2);
        border-color: var(--app-brand-2);
    }

    .btn-primary:focus {
        box-shadow: 0 0 0 .22rem rgba(27, 58, 99, .25);
    }

.btn-outline-primary {
    color: var(--app-brand);
    border-color: #c3d1e3;
}

    .btn-outline-primary:hover,
    .btn-outline-primary:active {
        background-color: var(--app-brand);
        border-color: var(--app-brand);
        color: #fff;
    }

    .btn-outline-primary:focus {
        box-shadow: 0 0 0 .22rem rgba(27, 58, 99, .2);
    }

.btn-light {
    background-color: #eef1f6;
    border-color: #eef1f6;
    color: var(--app-ink);
}

    .btn-light:hover,
    .btn-light:active,
    .btn-light:focus {
        background-color: #e2e7f0;
        border-color: #e2e7f0;
        color: var(--app-ink);
    }

.btn-outline-secondary {
    color: var(--app-ink-soft);
    border-color: #d7dce5;
}

    .btn-outline-secondary:hover,
    .btn-outline-secondary:active {
        background-color: var(--app-ink-soft);
        border-color: var(--app-ink-soft);
    }

.btn-link {
    color: var(--app-brand);
    font-weight: 600;
}

.btn.disabled, .btn:disabled {
    opacity: .45;
    box-shadow: none;
}

.form-control,
.form-select {
    border-radius: .7rem;
    border-color: #d7dce5;
    padding: .55rem .85rem;
    font-size: 14.5px;
    color: var(--app-ink);
}

/* A select carries its chevron as a background image on the right, so the
   symmetrical padding above would let a long label run underneath it. */
.form-select {
    padding-right: 2.3rem;
    background-position: right .85rem center;
}

.form-select-sm {
    padding-right: 2rem;
    background-position: right .65rem center;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--app-brand);
        box-shadow: 0 0 0 .2rem rgba(27, 58, 99, .12);
    }

.form-control-sm,
.form-select-sm {
    border-radius: .6rem;
    padding: .35rem .7rem;
    font-size: 13.5px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-ink-soft);
    margin-bottom: .35rem;
}

.form-text {
    font-size: 12px;
    color: var(--app-ink-mute);
}

.form-check-input:checked {
    background-color: var(--app-brand);
    border-color: var(--app-brand);
}

.form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(27, 58, 99, .12);
}

.card {
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.card-header,
.card-footer {
    background: transparent;
    border-color: var(--app-line);
    padding: 1rem 1.15rem;
}

.card-header {
    border-top-left-radius: var(--app-radius);
    border-top-right-radius: var(--app-radius);
}

.modal-content {
    border: 0;
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(16, 32, 46, .28);
}

.modal-header,
.modal-footer {
    border-color: var(--app-line);
    padding: 1.1rem 1.35rem;
}

.modal-body {
    padding: 1.35rem;
}

.modal-title {
    font-size: 18px;
}

.dropdown-menu {
    border-radius: .9rem;
    border-color: var(--app-line);
    box-shadow: var(--app-shadow);
    padding: .35rem;
}

.dropdown-item {
    border-radius: .6rem;
    font-size: 14px;
    padding: .5rem .7rem;
}

.page-link {
    border-radius: .55rem !important;
    margin: 0 2px;
    border-color: transparent;
    color: var(--app-ink-soft);
    font-weight: 600;
}

.page-item.active .page-link {
    background: var(--app-brand);
    border-color: var(--app-brand);
}

/* Soft badges. Bootstrap 5.1 has no *-subtle utilities, so they live here. */
.badge {
    border-radius: 999px;
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: .01em;
    padding: .38em .75em;
}

.badge-soft-success {
    background: #e3f3ea;
    color: #1a7346;
}

.badge-soft-danger {
    background: #fbe7e6;
    color: #ad2b23;
}

.badge-soft-primary {
    background: var(--app-brand-soft);
    color: var(--app-brand);
}

.badge-soft-muted {
    background: #eef0f4;
    color: var(--app-ink-soft);
}

.badge-soft-accent {
    background: #fbeade;
    color: var(--app-accent);
}

/* ------------------------------------------------------------------
   AUTH PAGE
   ------------------------------------------------------------------ */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}

.auth-hero {
    background: var(--app-brand);
    background-image: radial-gradient(circle at 85% 12%, rgba(194, 98, 15, .38), transparent 46%), radial-gradient(circle at 8% 92%, rgba(255, 255, 255, .1), transparent 42%);
    color: #fff;
    padding: 60px 64px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

    .auth-hero h1 {
        color: #fff;
        font-size: 40px;
        line-height: 1.1;
    }

.auth-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--app-card);
}

.auth-card {
    width: 100%;
    max-width: 390px;
}

    .auth-card h2 {
        font-size: 27px;
    }

.auth-logo {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: #fff;
    color: var(--app-brand);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 19px;
}

@media (max-width: 900px) {
    .auth-wrap {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        display: none;
    }
}

/* ------------------------------------------------------------------
   APP SHELL
   ------------------------------------------------------------------ */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--app-sidebar-w);
    background: var(--app-brand);
    background-image: linear-gradient(180deg, var(--app-brand) 0%, var(--app-brand-2) 100%);
    color: #c6d3e4;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .2s ease;
}

    .app-sidebar .brand {
        height: var(--app-topbar-h);
        display: flex;
        align-items: center;
        gap: 11px;
        padding: 0 18px;
        border-bottom: 1px solid rgba(255, 255, 255, .1);
        color: #fff;
        flex: 0 0 auto;
    }

        .app-sidebar .brand .brand-mark {
            width: 36px;
            height: 36px;
            border-radius: 11px;
            background: #fff;
            color: var(--app-brand);
            display: grid;
            place-items: center;
            font-weight: 800;
            font-size: 14px;
        }

        .app-sidebar .brand b {
            display: block;
            font-size: 15px;
            font-weight: 700;
            letter-spacing: -.01em;
            line-height: 1.15;
        }

        .app-sidebar .brand span {
            font-size: 11.5px;
            color: #9fb4cf;
        }

.app-nav {
    padding: 14px 12px 24px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.app-nav-head {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: #8ba5c6;
    padding: 16px 12px 7px;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: .7rem;
    color: #c6d3e4;
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

    .app-nav a:hover {
        background: rgba(255, 255, 255, .09);
        color: #fff;
    }

    .app-nav a.active {
        background: #fff;
        color: var(--app-brand);
        font-weight: 700;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    }

.app-nav-ico {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: .6rem;
    background: rgba(255, 255, 255, .1);
    flex: 0 0 auto;
}

.app-nav a.active .app-nav-ico {
    background: var(--app-brand-soft);
    color: var(--app-brand);
}

.app-nav-empty {
    padding: 20px 14px;
    font-size: 13px;
    color: #9fb4cf;
    line-height: 1.5;
}

.app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--app-sidebar-w);
    height: var(--app-topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--app-line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    z-index: 1020;
}

    .app-topbar .topbar-title {
        font-size: 17px;
        font-weight: 700;
        letter-spacing: -.015em;
    }

.app-content {
    margin-left: var(--app-sidebar-w);
    padding: calc(var(--app-topbar-h) + 26px) 26px 48px;
}

.app-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--app-brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    flex: 0 0 auto;
}

    .app-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .app-avatar.has-photo .app-avatar-initial {
        display: none;
    }

/* Page header above the card */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

    .page-head h1 {
        font-size: 26px;
        margin: 0;
    }

    .page-head p {
        margin: 5px 0 0;
        color: var(--app-ink-soft);
        font-size: 14px;
        max-width: 68ch;
    }

.app-denied {
    background: var(--app-card);
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    padding: 46px 30px;
    text-align: center;
}

    .app-denied h2 {
        font-size: 21px;
        margin-bottom: 8px;
    }

    .app-denied p {
        color: var(--app-ink-soft);
        max-width: 46ch;
        margin: 0 auto 18px;
    }

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, .3);
    }

        .app-sidebar.show {
            transform: none;
        }

    .app-topbar {
        left: 0;
    }

    .app-content {
        margin-left: 0;
        padding: calc(var(--app-topbar-h) + 20px) 16px 40px;
    }
}

/* ------------------------------------------------------------------
   TOASTS  (Alert.show)
   ------------------------------------------------------------------ */
#alertContainer {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(370px, calc(100vw - 40px));
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: #fff;
    border: 1px solid var(--app-line);
    border-left: 4px solid var(--bs-secondary);
    border-radius: .9rem;
    padding: 12px 13px;
    box-shadow: 0 12px 34px rgba(16, 32, 46, .16);
    animation: appToastIn .25s cubic-bezier(.2, .8, .3, 1);
}

    .app-toast.is-success {
        border-left-color: var(--bs-success);
    }

    .app-toast.is-danger {
        border-left-color: var(--bs-danger);
    }

    .app-toast.is-warning {
        border-left-color: #d98a08;
    }

    .app-toast.is-info {
        border-left-color: #0b7285;
    }

    .app-toast.is-primary {
        border-left-color: var(--app-brand);
    }

.app-toast-ico {
    flex: 0 0 auto;
    width: 21px;
    height: 21px;
    margin-top: 1px;
}

    .app-toast-ico svg {
        width: 100%;
        height: 100%;
    }

.app-toast.is-success .app-toast-ico {
    color: var(--bs-success);
}

.app-toast.is-danger .app-toast-ico {
    color: var(--bs-danger);
}

.app-toast.is-warning .app-toast-ico {
    color: #d98a08;
}

.app-toast.is-info .app-toast-ico {
    color: #0b7285;
}

.app-toast.is-primary .app-toast-ico {
    color: var(--app-brand);
}

.app-toast-body {
    flex: 1 1 auto;
    font-size: 13.5px;
    line-height: 1.45;
}

    .app-toast-body b {
        display: block;
        font-size: 13.5px;
        font-weight: 700;
        margin-bottom: 1px;
    }

    .app-toast-body span {
        color: var(--app-ink-soft);
    }

.app-toast-x {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border: 0;
    background: none;
    color: var(--app-ink-mute);
    padding: 0;
    cursor: pointer;
}

    .app-toast-x svg {
        width: 100%;
        height: 100%;
    }

.app-toast.is-leaving {
    animation: appToastOut .2s ease forwards;
}

@keyframes appToastIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes appToastOut {
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-toast, .app-toast.is-leaving {
        animation: none;
    }

    .btn:active {
        transform: none;
    }
}

/* ------------------------------------------------------------------
   TABLE - skeleton, empty state, rights matrix
   ------------------------------------------------------------------ */
.table {
    margin-bottom: 0;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: #f6f9fd;
    color: inherit;
}

    .table > :not(caption) > * > * {
        padding: .8rem .9rem;
    }

    .table thead th {
        font-size: 10.5px;
        font-weight: 700;
        letter-spacing: .09em;
        text-transform: uppercase;
        color: var(--app-ink-mute);
        background: #fafbfd;
        border-bottom: 1px solid var(--app-line);
        white-space: nowrap;
    }

    .table tbody td {
        border-color: #eef1f5;
        vertical-align: middle;
    }

.app-skeleton {
    display: inline-block;
    height: 11px;
    border-radius: 5px;
    background: linear-gradient(90deg, #eceef2 25%, #f6f7f9 37%, #eceef2 63%);
    background-size: 400% 100%;
    animation: appShimmer 1.2s ease-in-out infinite;
}

@keyframes appShimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.app-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--app-ink-soft);
    font-size: 13.5px;
}

    .app-empty b {
        display: block;
        color: var(--app-ink);
        font-size: 15.5px;
        font-weight: 700;
        margin-bottom: 4px;
    }

tr.no-hover:hover > * {
    background: transparent;
}

.app-page-ico {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: .6rem;
    background: var(--app-brand-soft);
    color: var(--app-brand);
    flex: 0 0 auto;
}

/* Rights matrix */
.matrix-group td {
    background: #f7f9fc !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--app-ink-mute);
}

.matrix-group .btn-link {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--app-brand);
}

.matrix-box {
    width: 1.15em;
    height: 1.15em;
    cursor: pointer;
}

.matrix-legend {
    font-size: 12.5px;
    color: var(--app-ink-soft);
}

/* Row actions must not wrap when the grid is scrolled sideways. */
.table th.text-end,
.table td.text-end {
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   ITEM GRIDS - the requirement lines and the dispatch lines
   ------------------------------------------------------------------ */
.item-grid {
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius-sm);
    /* The material type-ahead has to escape the scroll box. */
    overflow: visible;
}

    .item-grid > table {
        margin-bottom: 0;
    }

        .item-grid > table > thead th {
            background: #f7f9fc;
        }

.material-pick {
    position: relative;
}

.material-ac {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1080;
    margin-top: 3px;
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: var(--app-radius-sm);
    box-shadow: var(--app-shadow);
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
}

    .material-ac.show {
        display: block;
    }

.material-ac-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 11px;
    font-size: 13.5px;
    cursor: pointer;
}

    .material-ac-item:hover,
    .material-ac-item.hi {
        background: var(--app-brand-soft);
    }

.dup-warn {
    line-height: 1.3;
}

/* A quantity above what is pending is wrong before the server says so. */
.form-control.is-invalid {
    border-color: var(--bs-danger);
    box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .12);
}

.input-group-text {
    border-radius: .6rem 0 0 .6rem;
    background: #f4f6f9;
    border-color: #d7dce5;
}

.input-group > .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* The material column carries a name and its type-ahead - it must not collapse
   when the modal falls back to a narrower size on a small screen. */
.item-grid th:first-child,
.item-grid td:first-child {
    min-width: 230px;
}
