/* Expiry ladder pages (/expiry, /expiry/progress, /expiry/shelf, /expiry/report, /expiry/settings), count dates and date checks. */

/* --- Summary line ---------------------------------------------------------------------------------------------------- */
.exp-summary { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-4); color: var(--text-secondary); font-size: var(--text-sm); }
.exp-summary-num { display: block; font-size: var(--text-xl); font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* --- Group tabs + table ---------------------------------------------------------------------------------------------- */
.exp-tabs { margin-bottom: var(--space-2); flex-wrap: wrap; }
.exp-search { max-width: 420px; margin-bottom: var(--space-3); }
.exp-search-line { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.exp-tab-offer { font-weight: 700; color: var(--danger); margin-left: 2px; }
.ra-chip.active .exp-tab-offer { color: inherit; }
.exp-group-line { margin: var(--space-2) 0 var(--space-3); font-size: var(--text-sm); }
.exp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.exp-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); cursor: pointer; }
.exp-check input { width: auto; }
.exp-table td { vertical-align: top; }
.exp-table td.num .cell-sub { white-space: nowrap; }
.exp-table tr.exp-ticked td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.exp-table tr.exp-blocked td { opacity: .65; }
.exp-stepup { margin-top: 4px; font-size: var(--text-xs); font-weight: 600; color: var(--accent-soft-text); background: var(--accent-soft-bg);
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); }
.exp-block { margin-top: 4px; font-size: var(--text-xs); color: var(--danger-soft-text); display: flex; align-items: center; gap: 4px; }
.exp-pct { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.exp-pct input { width: 64px; min-width: 64px; flex: none; text-align: right; }   /* the table must not squeeze it (was 26 px at 1280 px wide) */
.exp-neg { color: var(--danger) !important; }
.exp-approve-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
    margin-top: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }

/* --- Groups settings ------------------------------------------------------------------------------------------------- */
.exp-groups td { vertical-align: middle; }
.exp-groups tr.exp-inactive td { opacity: .55; }
.exp-window { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--text-sm); }

/* --- Progress -------------------------------------------------------------------------------------------------------- */
.exp-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4);
    font-size: var(--text-xs); color: var(--text-secondary); }
.exp-flow-step { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: var(--space-2) var(--space-3);
    border: 1px dashed var(--border); border-radius: var(--radius-md); }
.exp-flow-step strong { color: var(--text-primary); font-size: var(--text-sm); }
.exp-flow-step span:last-child { grid-column: 2; }
.exp-dot { width: 10px; height: 10px; border-radius: 50%; grid-row: span 2; }
.exp-dot.s1 { background: var(--warning); }
.exp-dot.s2 { background: var(--accent); }
.exp-dot.s3 { background: var(--text-muted); }

.exp-offers { display: grid; gap: var(--space-3); }
.exp-offer { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); display: grid; gap: var(--space-3); }
.exp-offer.behind { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.exp-offer.done { opacity: .85; }
.exp-offer-head, .exp-shelf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.exp-offer-price { text-align: right; font-size: var(--text-sm); white-space: nowrap; }
.exp-offer-tag { display: inline-block; background: var(--danger); color: #fff; font-weight: 800; padding: 2px 10px; border-radius: var(--radius-full);
    font-size: var(--text-sm); white-space: nowrap; }

.exp-stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; counter-reset: step; }
.exp-stepper li { position: relative; padding: 8px 10px 8px 34px; border-radius: var(--radius-md); background: var(--bg-canvas); font-size: var(--text-sm);
    color: var(--text-muted); display: flex; flex-direction: column; min-width: 0; }
.exp-stepper li::before { counter-increment: step; content: counter(step); position: absolute; left: 8px; top: 9px; width: 18px; height: 18px; border-radius: 50%;
    display: grid; place-items: center; font-size: 11px; font-weight: 700; border: 1.5px solid var(--border); background: var(--bg-surface); }
.exp-stepper li small { font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-stepper li.done { color: var(--text-primary); background: var(--success-soft-bg); }
.exp-stepper li.done::before { content: "✓"; background: var(--success); border-color: var(--success); color: #fff; }
.exp-stepper li.current { color: var(--text-primary); background: var(--accent-soft-bg); font-weight: 600; }
.exp-stepper li.current::before { border-color: var(--accent); color: var(--accent-soft-text); }

.exp-offer-body { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); }
.exp-offer-body > div:first-child { flex: 1 1 320px; display: grid; gap: 6px; }
.exp-meta { font-size: var(--text-sm); }
.exp-progress { height: 10px; border-radius: var(--radius-full); background: var(--bg-canvas); border: 1px solid var(--border); overflow: hidden; }
.exp-progress-bar { height: 100%; background: var(--accent); border-radius: var(--radius-full); }
.exp-offer.behind .exp-progress-bar { background: var(--danger); }
.exp-note { font-size: var(--text-xs); color: var(--text-secondary); }
.exp-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; justify-content: flex-end; }

@media (max-width: 640px) {
    .exp-stepper { grid-template-columns: 1fr; }
    .exp-actions { justify-content: flex-start; }
}

/* --- Shelf (employees, phone first) ---------------------------------------------------------------------------------- */
.exp-section-title { font-size: var(--text-md); margin: var(--space-2) 0 var(--space-3); display: flex; align-items: center; gap: 8px; }
.exp-shelf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-3); }
.exp-shelf-card { background: var(--bg-surface); border: 1px solid var(--border); border-left: 4px solid var(--danger); border-radius: var(--radius-lg);
    padding: var(--space-4); display: grid; gap: var(--space-3); }
.exp-shelf-date { font-size: var(--text-lg); line-height: 1.3; background: var(--danger-soft-bg); color: var(--danger-soft-text); border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3); }
.exp-shelf-date strong { font-variant-numeric: tabular-nums; }
.exp-shelf-steps { margin: 0; padding-left: 1.2em; font-size: var(--text-sm); color: var(--text-secondary); display: grid; gap: 4px; }
.exp-shelf-form { display: grid; gap: var(--space-2); }
.exp-shelf-form label { display: grid; gap: 4px; font-size: var(--text-sm); }
.exp-shelf-form .exp-check { display: inline-flex; }
.exp-shelf-form input[type=number], .exp-shelf-form input[data-num] { font-size: var(--text-lg); max-width: 160px; }
.exp-live-list { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.exp-live-row { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); background: var(--bg-surface); }

/* --- Report ---------------------------------------------------------------------------------------------------------- */
.exp-bars { display: grid; gap: 8px; margin: var(--space-3) 0; }
.exp-bar-row { display: grid; grid-template-columns: 70px 1fr 90px; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.exp-bar-track { position: relative; height: 22px; background: var(--bg-canvas); border-radius: var(--radius-sm); display: grid; gap: 2px; padding: 2px 0; }
.exp-bar { height: 8px; border-radius: 3px; }
.exp-bar.waste, .exp-swatch.waste { background: var(--danger); }
.exp-bar.saved, .exp-swatch.saved { background: var(--accent); }
.exp-bar-baseline { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed var(--text-secondary); }
.exp-bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.exp-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-xs); color: var(--text-secondary); }
.exp-swatch { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.exp-swatch.baseline { background: none; border-top: 2px dashed var(--text-secondary); height: 0; }

/* --- Count date checks + count screen -------------------------------------------------------------------------------- */
.exp-checks { display: grid; gap: var(--space-3); }
.exp-check-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); display: grid; gap: var(--space-3); }
.exp-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.exp-compare-title { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin-bottom: 4px; }
.exp-date-row { display: flex; justify-content: space-between; gap: var(--space-3); padding: 3px 6px; border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.exp-date-row.diff { background: var(--warning-soft-bg); color: var(--warning-soft-text); font-weight: 600; }

.cnt-dates { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-canvas); }
.cnt-dates-title { font-weight: 600; font-size: var(--text-sm); }
.cnt-dates-title .hint { font-weight: 400; margin-left: 4px; }
.cnt-date-row { display: grid; grid-template-columns: 1fr 90px auto; gap: var(--space-2); align-items: center; }
.cnt-dates-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2); }
.cnt-dates-off { color: var(--warning-soft-text); font-weight: 600; }

/* --- Restock Alerts notice ------------------------------------------------------------------------------------------- */
.ra-expiry { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; font-size: var(--text-xs); line-height: 1.35; padding: 6px 8px;
    border-radius: var(--radius-md); background: var(--danger-soft-bg); color: var(--danger-soft-text); }
.ra-expiry svg { flex-shrink: 0; margin-top: 1px; }
/* Why a product is on the list (e.g. "Expiry offer over: fill the shelf with the newer packs"). */
.ra-note { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; font-size: var(--text-xs); line-height: 1.35; padding: 6px 8px;
    border-radius: var(--radius-md); background: var(--accent-soft-bg); color: var(--accent-soft-text); }
.ra-note svg { flex-shrink: 0; margin-top: 1px; }
/* Scan & Restock card and list: the running offer's date. */
.restock-expiry { margin: 8px 0 4px; }
.restock-item-expiry { color: var(--danger-soft-text); font-size: var(--text-xs); font-weight: 600; }

/* Offer Progress: "Add to poster" menu, sized like the small buttons next to it. */
.exp-poster-select { width: auto; max-width: 220px; padding: 5px 28px 5px 10px; font-size: var(--text-sm); }

/* --- Missing best-before dates (employees, phone first) ---------------------------------------------------------------- */
.mbd-summary { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-4); color: var(--text-secondary); font-size: var(--text-sm); }
.mbd-num { display: block; font-size: var(--text-xl); font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.mbd-done .mbd-num { color: var(--success-soft-text); }
.mbd-filters { display: grid; gap: var(--space-2); margin: var(--space-3) 0 var(--space-4); }
.mbd-selects { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mbd-selects select { width: auto; min-width: 0; max-width: 100%; min-height: 40px; }
.mbd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: var(--space-3); }
.mbd-card { background: var(--bg-surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius-lg);
    padding: var(--space-4); display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.mbd-card > *, .mbd-form .cnt-date-row input { min-width: 0; }
.mbd-card.risk-high { border-left-color: var(--danger); }
.mbd-card.risk-mid { border-left-color: var(--warning); }
.mbd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.mbd-qty { display: grid; justify-items: end; text-align: right; white-space: nowrap; }
.mbd-qty strong { font-size: var(--text-xl); font-variant-numeric: tabular-nums; line-height: 1.1; }
.mbd-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--space-3); }
.mbd-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mbd-actions .btn { min-height: 44px; }
.mbd-form { display: grid; gap: var(--space-2); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.mbd-form input[type=date], .mbd-form input[type=number], .mbd-form input[data-num] { min-height: 44px; font-size: 16px; }
.mbd-more { display: flex; justify-content: center; margin-top: var(--space-4); }
.mbd-nodate-list { display: grid; gap: var(--space-2); }
.mbd-nodate-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
@media (max-width: 480px) {
    .mbd-list { grid-template-columns: minmax(0, 1fr); }
    .mbd-actions .btn { flex: 1; justify-content: center; }
    .mbd-nodate-row { flex-direction: column; align-items: stretch; }
}

/* ===== Count differences (best-before check: more / fewer than OneWorld) ================================================== */
.mbd-recount { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
    background: var(--warning-soft-bg); color: var(--warning-soft-text); font-size: var(--text-sm); }
.mbd-diff { display: grid; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--border);
    background: var(--bg-elevated); font-size: var(--text-sm); }
.mbd-diff.less { border-color: var(--warning); }
.mbd-diff.more { border-color: var(--info, var(--accent)); }
.mbd-diff > span { color: var(--text-secondary); }
.mbd-diff input[type=text] { min-height: 44px; font-size: 16px; min-width: 0; }
.mbd-check { display: flex; gap: var(--space-2); align-items: center; font-weight: 600; cursor: pointer; min-height: 44px; }
.mbd-check input { width: 22px; height: 22px; flex: none; }
.mbd-note-label { font-weight: 600; margin-top: var(--space-2); }
.mbd-note { width: 100%; min-height: 4.5em; resize: vertical; font: inherit; }
.mbd-plus { color: var(--success-soft-text); }
.mbd-minus { color: var(--danger); }
.cdf-card.cdf-more { border-left-color: var(--success, var(--accent)); }
.cdf-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: var(--space-2); }
.cdf-numbers > div { display: grid; gap: 2px; padding: var(--space-2); border-radius: var(--radius-md); background: var(--bg-elevated); }
.cdf-numbers strong { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.cdf-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.cdf-date { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.cdf-note { font-style: italic; color: var(--text-secondary); font-size: var(--text-sm); }
.cdf-decision { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
/* Search + Scan + Found on shelf: on a phone the search box gets its own row. */
.mbd-filters .ra-search { flex-wrap: wrap; }
@media (max-width: 560px) {
    .mbd-filters .ra-search .search-input { flex: 1 1 100%; max-width: none; }
    .mbd-filters .ra-search > button, .mbd-filters .ra-search > .btn { flex: 1 1 0; justify-content: center; }
}

/* "done today" opens the list of what was done that day */
.mbd-done-btn { display: block; text-align: left; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.mbd-done-btn:hover .mbd-done-link, .mbd-done-btn:focus-visible .mbd-done-link { text-decoration: underline; }
.mbd-done-link { color: var(--accent); font-weight: 600; margin-left: 4px; }
.mbd-done-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.mbd-done-head input[type=date] { width: auto; min-height: 40px; }
.mbd-done-list { display: grid; gap: var(--space-2); }
.mbd-done-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-3); align-items: start;
    padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.mbd-done-time { font-variant-numeric: tabular-nums; color: var(--text-secondary); padding-top: 2px; }
.mbd-done-main { display: grid; gap: 4px; min-width: 0; }
@media (max-width: 560px) {
    .mbd-done-row { grid-template-columns: auto minmax(0, 1fr); }
    .mbd-done-row > :last-child { grid-column: 2; justify-self: start; }
}

/* Expired tab: checked the shelf -> write off / stock adjustment */
.exp-table tr.exp-clear-row td { border-top: none; padding-top: 0; }
.exp-clear { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md); background: var(--bg-subtle, rgba(127,127,127,.08)); }
.exp-clear-label { font-size: var(--text-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.exp-clear input.exp-clear-qty { width: 84px; flex: 0 0 84px; }
.exp-clear input.exp-clear-note { width: 220px; flex: 0 1 220px; max-width: 100%; }
@media (max-width: 700px) { .exp-clear input.exp-clear-note { width: 100%; flex-basis: 100%; } }
