/* =====================================================================
   Dynamic SCM — iOS-inspired, minimalist design system
   Light + dark (follows system). Single restrained accent.
   ===================================================================== */

:root {
    /* Accent — iOS system blue, used sparingly */
    --accent: #007aff;
    --accent-press: #0062cc;
    --accent-soft: rgba(0, 122, 255, .10);

    /* Neutrals (light) */
    --bg: #f2f2f7;            /* iOS grouped background */
    --surface: #ffffff;       /* cards / bars */
    --surface-2: #ffffff;
    --fill: #7676801f;        /* iOS secondary fill (inputs) */
    --fill-strong: #76768033;

    --text: #1c1c1e;          /* label */
    --text-2: #3c3c4399;      /* secondary label (~60%) */
    --text-3: #3c3c434d;      /* tertiary label (~30%) */

    --separator: #3c3c431f;   /* hairline */
    --separator-strong: #3c3c4349;

    /* System semantic (iOS) */
    --green: #34c759;
    --orange: #ff9500;
    --red: #ff3b30;
    --yellow: #ffcc00;

    /* Soft semantic fills */
    --green-soft: rgba(52, 199, 89, .14);
    --orange-soft: rgba(255, 149, 0, .16);
    --red-soft: rgba(255, 59, 48, .14);

    /* Shape */
    --r-lg: 20px;    /* grouped cards */
    --r-md: 14px;    /* controls */
    --r-sm: 10px;
    --r-pill: 980px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .05);
    --shadow-pop: 0 10px 40px rgba(0, 0, 0, .14);

    --bar-blur: saturate(180%) blur(20px);
    --bar-bg: rgba(255, 255, 255, .72);

    /* Map Bootstrap tokens so its components inherit our palette */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--separator);
    --bs-secondary-color: var(--text-2);
    --bs-border-radius: var(--r-md);
    --bs-link-color-rgb: 0, 122, 255;
}

/* Dark theme applies only when explicitly selected (default is light). */
:root[data-theme="dark"] {
    --accent: #0a84ff;
    --accent-press: #409cff;
    --accent-soft: rgba(10, 132, 255, .18);

    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --fill: #7676803d;
    --fill-strong: #7676805c;

    --text: #f5f5f7;
    --text-2: #ebebf599;
    --text-3: #ebebf54d;

    --separator: #54545899;
    --separator-strong: #545458cc;

    --green-soft: rgba(48, 209, 88, .20);
    --orange-soft: rgba(255, 159, 10, .22);
    --red-soft: rgba(255, 69, 58, .22);

    --shadow-card: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-pop: 0 10px 40px rgba(0, 0, 0, .6);
    --bar-bg: rgba(28, 28, 30, .72);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
code { color: var(--text-2); }
hr { border-color: var(--separator); opacity: 1; }

/* ---------------------------------------------------------------- Auth */
.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
    background:
        radial-gradient(120% 80% at 50% -10%, var(--accent-soft), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 26px;
    box-shadow: var(--shadow-pop);
    padding: 32px 26px;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .logo {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: linear-gradient(160deg, var(--accent), var(--accent-press));
    color: #fff;
    display: grid; place-items: center;
    margin: 0 auto 16px;
    font-size: 30px;
    box-shadow: 0 8px 20px var(--accent-soft);
}
.auth-brand h5 { font-weight: 700; letter-spacing: -0.02em; font-size: 1.5rem; }

/* -------------------------------------------------------------- Shell */
.app-header {
    position: sticky; top: 0; z-index: 1020;
    height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    display: flex; align-items: center; gap: 12px;
    background: var(--bar-bg);
    -webkit-backdrop-filter: var(--bar-blur);
    backdrop-filter: var(--bar-blur);
    border-bottom: 0.5px solid var(--separator);
}
.app-header .title {
    font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .brand-badge {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(160deg, var(--accent), var(--accent-press));
    color: #fff; display: grid; place-items: center; font-size: 17px;
    flex-shrink: 0;
}

.app-body { display: flex; min-height: calc(100vh - 50px); }

.sidebar {
    width: 250px; flex-shrink: 0;
    padding: 16px 12px;
    border-right: 0.5px solid var(--separator);
    background: var(--surface);
    position: sticky;
    top: calc(50px + env(safe-area-inset-top));
    align-self: flex-start;
    height: calc(100vh - 50px - env(safe-area-inset-top));
    overflow-y: auto;
    overscroll-behavior: contain;
}
.sidebar .side-label {
    font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    color: var(--text-3); text-transform: uppercase;
    padding: 4px 12px 10px;
}
.sidebar .nav-link {
    color: var(--text); border-radius: var(--r-md);
    padding: 9px 12px; margin-bottom: 2px;
    display: flex; align-items: center; gap: 12px;
    font-weight: 500; font-size: .95rem;
    transition: background .15s ease;
}
.sidebar .nav-link .bi { font-size: 1.1rem; color: var(--text-2); width: 22px; text-align: center; }
.sidebar .nav-link:hover { background: var(--fill); }
.sidebar .nav-link.active { background: var(--accent); color: #fff; }
.sidebar .nav-link.active .bi { color: #fff; }
.sidebar .nav-link.disabled { color: var(--text-3); cursor: default; }
.sidebar .nav-link.disabled .bi { color: var(--text-3); }
.sidebar .nav-link.disabled:hover { background: transparent; }
.sidebar .nav-link .nav-badge {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--red); color: #fff;
    font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center;
}
.sidebar .nav-link.active .nav-badge { background: #fff; color: var(--accent); }

.content {
    flex: 1; width: 100%; max-width: 1120px; margin: 0 auto;
    padding: 22px 22px 40px;
}

/* iOS "Large Title" */
.page-title {
    font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em;
    margin: 0 0 2px; line-height: 1.15;
}
.page-sub { color: var(--text-2); font-size: .92rem; margin-bottom: 20px; }

/* ------------------------------------------------------------- Cards */
.card {
    background: var(--surface);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    color: var(--text);
}

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.stat {
    position: relative;
    background: var(--surface);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
}
.stat .label {
    color: var(--text-2); font-size: .8rem; font-weight: 600;
    letter-spacing: -0.01em;
    padding-right: 42px;  /* clear the top-right icon */
    min-height: 2.4em;    /* align values across one/two-line labels */
}
.stat .value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-top: 6px; }
.stat .icon {
    position: absolute; top: 14px; right: 14px;
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-size: 1.05rem; float: none;
}

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.quick-action {
    background: var(--surface);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    padding: 18px 14px; text-align: center;
    color: var(--text); text-decoration: none;
    box-shadow: var(--shadow-card);
    font-weight: 600; font-size: .9rem;
    transition: transform .12s ease, background .15s ease;
}
.quick-action:hover { background: var(--fill); color: var(--text); }
.quick-action:active { transform: scale(.97); }
.quick-action .bi {
    font-size: 1.35rem; display: grid; place-items: center;
    width: 46px; height: 46px; margin: 0 auto 10px;
    border-radius: 13px; background: var(--accent-soft); color: var(--accent);
}

/* Dashboard activity lists (recent / upcoming / attention) */
.dash-list { display: flex; flex-direction: column; }
.dash-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 2px; text-decoration: none; color: var(--text);
    border-top: 0.5px solid var(--separator);
}
.dash-row:first-child { border-top: 0; }
.dash-row:hover { background: var(--fill); }
.dash-row .min-w-0 { flex: 1; min-width: 0; }

/* ------------------------------------------------------------ Badges */
.badge { font-weight: 600; letter-spacing: -0.01em; border-radius: var(--r-pill); padding: .32em .7em; }
.badge-soft { background: var(--accent-soft); color: var(--accent); }
.age-normal, .text-bg-success { background: var(--green-soft) !important; color: var(--green) !important; }
.age-warn { background: var(--orange-soft); color: var(--orange); }
.age-crit, .text-bg-danger { background: var(--red-soft) !important; color: var(--red) !important; }
.text-bg-secondary { background: var(--fill-strong) !important; color: var(--text-2) !important; }

/* ------------------------------------------------------- Bottom nav */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
    .sidebar { display: none; }
    .content { padding: 16px 16px calc(78px + env(safe-area-inset-bottom)); }
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bar-bg);
        -webkit-backdrop-filter: var(--bar-blur);
        backdrop-filter: var(--bar-blur);
        border-top: 0.5px solid var(--separator);
    }
    .bottom-nav a {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px; padding: 9px 0 7px;
        color: var(--text-2); text-decoration: none;
        font-size: .64rem; font-weight: 600; letter-spacing: 0;
    }
    .bottom-nav a .bi { font-size: 1.35rem; }
    .bottom-nav a.active { color: var(--accent); }
}

/* -------------------------------------------------------------- Forms */
.form-label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: .35rem; }
.form-text { color: var(--text-2); }
.form-control, .form-select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--separator-strong);
    border-radius: var(--r-md);
    padding: .7rem .85rem;
    font-size: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: var(--text-3); }
.form-control:focus, .form-select:focus {
    background: var(--surface);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.form-control.is-invalid, .was-validated .form-control:invalid { border-color: var(--red); }
.invalid-feedback { color: var(--red); }

.input-group-text {
    background: var(--fill); color: var(--text-2);
    border: 1px solid var(--separator-strong); border-right: 0;
    border-radius: var(--r-md) 0 0 var(--r-md);
}
.input-group > .form-control { border-radius: 0; }
.input-group > :last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-group > .input-group-text:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }

/* iOS switch */
.form-switch .form-check-input {
    width: 2.9em; height: 1.65em; border: none;
    background-color: var(--fill-strong);
    background-image: none;
    box-shadow: inset 0 0 0 2px transparent;
}
.form-switch .form-check-input:checked { background-color: var(--green); }
.form-switch .form-check-input:focus { box-shadow: 0 0 0 4px var(--accent-soft); }
.form-check-input { border-color: var(--separator-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-label { color: var(--text); }

/* -------------------------------------------------------------- Buttons */
.btn { border-radius: var(--r-md); font-weight: 600; letter-spacing: -0.01em; padding: .6rem 1.05rem; transition: transform .12s ease, filter .15s ease; }
.btn:active { transform: scale(.975); }
.btn-brand, .btn-primary { background: var(--accent); border: none; color: #fff; }
.btn-brand:hover, .btn-primary:hover { background: var(--accent-press); color: #fff; }
.btn-light {
    background: var(--fill); border: none; color: var(--text);
}
.btn-light:hover { background: var(--fill-strong); color: var(--text); }
.btn-outline-secondary {
    border: 1px solid var(--separator-strong); color: var(--text-2); background: var(--surface);
}
.btn-outline-secondary:hover { background: var(--fill); color: var(--text); border-color: var(--separator-strong); }
.btn-outline-danger { border: 1px solid var(--red); color: var(--red); background: transparent; }
.btn-outline-danger:hover { background: var(--red); color: #fff; }
.btn-outline-success { border: 1px solid var(--green); color: var(--green); background: transparent; }
.btn-outline-success:hover { background: var(--green); color: #fff; }
.btn-outline-warning { border: 1px solid var(--orange); color: var(--orange); background: transparent; }
.btn-outline-warning:hover { background: var(--orange); color: #fff; }
.btn-link { color: var(--accent); font-weight: 600; }
.btn-sm { padding: .4rem .7rem; border-radius: var(--r-sm); }

.sticky-actions {
    position: sticky; bottom: 14px; z-index: 20;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--surface);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    padding: 12px 14px; margin-top: 20px;
}
.sticky-actions .btn { flex: 0 0 auto; }
/* Keep the save bar clear of the mobile bottom navigation. */
@media (max-width: 991.98px) {
    .sticky-actions { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* -------------------------------------------------------------- Tables */
.table-wrap {
    background: var(--surface);
    border: 0.5px solid var(--separator);
    border-radius: var(--r-lg);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-card);
}
.table-wrap .table { min-width: max-content; }
.table td .btn, .table td form { white-space: nowrap; }
.table {
    margin: 0; color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
}
.table > :not(caption) > * > * { background: transparent; color: var(--text); border-bottom-color: var(--separator); padding: .8rem 1rem; }
.table thead th {
    background: transparent;
    font-size: .74rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-2); font-weight: 600; border-bottom: 0.5px solid var(--separator);
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding: .55rem .8rem; }

/* -------------------------------------------------------------- Alerts */
.alert { border: none; border-radius: var(--r-md); font-size: .92rem; }
.alert-success { background: var(--green-soft); color: var(--green); }
.alert-danger { background: var(--red-soft); color: var(--red); }
.alert-warning { background: var(--orange-soft); color: var(--orange); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------- Dropdown / misc */
.dropdown-menu {
    background: var(--surface); border: 0.5px solid var(--separator);
    border-radius: var(--r-md); box-shadow: var(--shadow-pop);
    --bs-dropdown-link-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--fill);
    --bs-dropdown-link-hover-color: var(--text);
    padding: 6px;
}
.dropdown-item { border-radius: var(--r-sm); }
.dropdown-item-text { color: var(--text-2); }
.offcanvas { background: var(--surface); color: var(--text); }
.offcanvas-bottom { border-top-left-radius: 20px; border-top-right-radius: 20px; }
.offcanvas-header { border-bottom: 0.5px solid var(--separator); }

.pagination { --bs-pagination-color: var(--accent); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--separator); --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-hover-bg: var(--fill); }
.page-link { border-radius: var(--r-sm) !important; margin: 0 2px; }

.text-muted { color: var(--text-2) !important; }

/* ---------------------------------------------------- Item picker */
.item-picker { position: relative; }
.ip-results {
    display: none; position: absolute; z-index: 1050; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--surface); border: 0.5px solid var(--separator);
    border-radius: var(--r-md); box-shadow: var(--shadow-pop);
    max-height: 260px; overflow-y: auto; padding: 6px;
}
.ip-results.show { display: block; }
.ip-option {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    background: transparent; border: 0; border-radius: var(--r-sm);
    padding: 9px 10px; color: var(--text); cursor: pointer;
}
.ip-option:hover { background: var(--accent-soft); }
.ip-option.ip-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ip-opt-text { display: flex; flex-direction: column; min-width: 0; }
.ip-opt-main { font-weight: 600; }
.ip-opt-sub { font-size: .78rem; color: var(--text-2); }
.ip-opt-thumb {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 9px; overflow: hidden;
    background: var(--fill); display: grid; place-items: center;
}
.ip-opt-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ip-opt-thumb-empty { color: var(--text-3); font-size: 1rem; }
.ip-selected-thumb {
    flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px; overflow: hidden;
    background: var(--fill); display: grid; place-items: center; border: 0.5px solid var(--separator);
}
.ip-selected-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ip-empty { padding: 12px; text-align: center; color: var(--text-2); font-size: .85rem; }

/* ---------------------------------------------------- PO line rows */
.po-line { border: 0.5px solid var(--separator); border-radius: var(--r-md); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.po-line .line-no { font-size: .72rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; }
.line-remove {
    width: 30px; height: 30px; flex-shrink: 0; border: none; border-radius: 50%;
    background: var(--fill); color: var(--text-2);
    display: grid; place-items: center; cursor: pointer; font-size: .8rem;
    transition: background .12s ease, color .12s ease;
}
.line-remove:hover { background: var(--red-soft); color: var(--red); }

/* ---------------------------------------------------- Status pills */
.status-pill { font-weight: 600; border-radius: var(--r-pill); padding: .3em .75em; font-size: .78rem; display: inline-block; }
.st-draft { background: var(--fill-strong); color: var(--text-2); }
.st-submitted { background: var(--accent-soft); color: var(--accent); }
.st-acknowledged { background: var(--accent-soft); color: var(--accent); }
.st-in_planning { background: var(--orange-soft); color: var(--orange); }
.st-partially_supplied, .st-partially_fulfilled { background: var(--orange-soft); color: var(--orange); }
.st-completed { background: var(--green-soft); color: var(--green); }
.st-cancelled { background: var(--red-soft); color: var(--red); }
.st-not_planned { background: var(--fill-strong); color: var(--text-2); }
.st-dispatched { background: var(--accent-soft); color: var(--accent); }
.st-partially_received { background: var(--orange-soft); color: var(--orange); }
.st-received { background: var(--green-soft); color: var(--green); }
.st-discrepancy { background: var(--red-soft); color: var(--red); }
.st-closed { background: var(--green-soft); color: var(--green); }
.st-return_pending { background: var(--orange-soft); color: var(--orange); }
.st-received_by_dynamic { background: var(--accent-soft); color: var(--accent); }
.st-under_rework { background: var(--orange-soft); color: var(--orange); }
.st-ready_for_resupply { background: var(--accent-soft); color: var(--accent); }
.st-resupplied { background: var(--accent-soft); color: var(--accent); }
.st-scrapped { background: var(--red-soft); color: var(--red); }

/* ---------------------------------------------------- iOS list rows */
.ios-list { padding: 0; overflow: hidden; }
.ios-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; color: var(--text); text-decoration: none;
    border-bottom: 0.5px solid var(--separator);
    transition: background .12s ease;
}
.ios-row:last-child { border-bottom: 0; }
.ios-row:hover { background: var(--fill); color: var(--text); }
.ios-row:active { background: var(--fill-strong); }
.row-thumb {
    width: 46px; height: 46px; flex-shrink: 0; border-radius: 11px;
    background: var(--fill); display: grid; place-items: center; overflow: hidden;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-thumb .bi { font-size: 1.3rem; color: var(--text-3); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; letter-spacing: -0.01em; }
.row-sub { font-size: .82rem; color: var(--text-2); }
.row-chev { color: var(--text-3); font-size: .9rem; flex-shrink: 0; }

/* ---------------------------------------------------- Spec grid (key/value) */
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 18px; }
.spec .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); font-weight: 600; }
.spec .v { font-weight: 600; margin-top: 2px; }

/* ---------------------------------------------------- Planning item stat blocks */
.plan-po-card { overflow: hidden; }            /* keep full-bleed rows inside the rounded card */
.plan-items { margin: 8px -16px 0; }           /* cancel the card's 1rem padding so rows span edge-to-edge */
.plan-item {
    display: block; padding: 12px 16px; color: var(--text); text-decoration: none;
    border-top: 0.5px solid var(--separator);
}
.plan-item:first-child { border-top: 0; }
.plan-item:hover { background: var(--fill); }
.plan-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.plan-item-head .part-thumb {
    width: 48px; height: 48px; flex-shrink: 0; border-radius: 11px; overflow: hidden;
    background: var(--fill); display: grid; place-items: center;
}
.plan-item-head .part-thumb img { width: 100%; height: 100%; object-fit: cover; }
.plan-item-head .part-thumb .bi { font-size: 1.25rem; color: var(--text-3); }
.plan-item-head .part-thumb.img-zoom { cursor: zoom-in; }
.tbl-thumb { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; overflow: hidden; background: var(--fill); display: grid; place-items: center; }
.tbl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tbl-thumb .bi { font-size: .95rem; color: var(--text-3); }
.tbl-thumb.img-zoom { cursor: zoom-in; }
.plan-item-head .part-thumb.img-zoom:hover { box-shadow: 0 0 0 2px var(--accent); }

/* Image lightbox */
.lightbox-overlay {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,.82); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    align-items: center; justify-content: center; padding: 24px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img { max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); object-fit: contain; }
.lightbox-close {
    position: absolute; top: 18px; right: 22px; width: 42px; height: 42px; border-radius: 50%;
    border: none; background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
}
.lightbox-close .bi { font-size: 1.1rem; line-height: 1; }
.lightbox-close:hover { background: rgba(255,255,255,.25); }
.plan-item-head .plan-item-main { flex: 1; min-width: 0; }
.plan-item-head .part { font-weight: 700; letter-spacing: -0.01em; }
.plan-item-head .row-chev { color: var(--text-3); font-size: .85rem; }
.qty-stats { display: flex; gap: 8px; }
.qty-stats .qs { flex: 1; padding: 8px 12px; min-width: 0; border: 1px solid var(--separator); border-radius: 12px; background: var(--fill); }
.qs-label { font-size: .74rem; color: var(--text-2); font-weight: 600; margin-bottom: 1px; }
.qs-val { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.qs-val span { font-size: .78rem; color: var(--text-2); font-weight: 600; }
.qs-val.green { color: var(--green); }
.qs-val.blue { color: var(--accent); }
.qs-val.orange { color: var(--orange); }
/* Planning fulfillment progress */
.plan-progress { margin-top: 12px; }
.pp-track { height: 7px; border-radius: 99px; background: var(--fill); overflow: hidden; }
.pp-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s ease; }
.pp-fill.done { background: var(--green); }
.pp-fill.over { background: var(--orange); }
.pp-label { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: .74rem; color: var(--text-2); font-weight: 600; }
.pp-over { color: var(--orange); }
.pp-done { color: var(--green); }
.plan-sched { margin-top: 10px; padding-top: 10px; border-top: 0.5px dashed var(--separator); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.plan-sched-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); margin-right: 4px; }
.sched-chip { font-size: .8rem; background: var(--fill); border-radius: var(--r-pill); padding: 4px 12px; color: var(--text); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.sched-chip b { font-weight: 700; color: inherit; }
.sched-chip .bi { font-size: .7rem; }
.sched-chip .sched-rmk { margin-left: 6px; padding-left: 8px; border-left: 1px solid currentColor; opacity: .85; font-size: .74rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.sched-chip.sched-due { background: var(--red-soft); color: var(--red); }
.sched-chip.sched-today { background: var(--orange-soft); color: var(--orange); }
.sched-chip.sched-upcoming { background: var(--green-soft); color: var(--green); }

/* Status dot (date timing indicator) */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.status-dot.dot-upcoming { background: var(--green); }
.status-dot.dot-today { background: var(--orange); animation: dot-pulse-orange 1.4s infinite; }
.status-dot.dot-due { background: var(--red); animation: dot-pulse-red 1.4s infinite; }
@keyframes dot-pulse-orange {
    0%   { box-shadow: 0 0 0 0 rgba(255,149,0,.55); }
    70%  { box-shadow: 0 0 0 6px rgba(255,149,0,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,149,0,0); }
}
@keyframes dot-pulse-red {
    0%   { box-shadow: 0 0 0 0 rgba(255,59,48,.55); }
    70%  { box-shadow: 0 0 0 6px rgba(255,59,48,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); }
}

/* ---------------------------------------------------- Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 14px; bottom: 0; width: 2px; background: var(--separator); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }

.coming-soon {
    font-size: .6rem; background: var(--fill); color: var(--text-3);
    border-radius: 6px; padding: 1px 7px; margin-left: auto; font-weight: 600;
}

/* Hairline helpers rendered crisply on retina */
@media (min-resolution: 2dppx) {
    .app-header, .bottom-nav, .sidebar, .card, .stat, .quick-action,
    .table-wrap, .sticky-actions { border-width: 0.5px; }
}

@media (max-width: 575.98px) {
    .hide-xs { display: none !important; }
    .page-title { font-size: 1.55rem; }
    .content { padding-left: 16px; padding-right: 16px; }
}
