/* Operational panel kit: Dashboard (index.php), Scan Station (scan.php) and Goods In
   (goods-in.php). Every rule is scoped under .dp (or the .dp-popup dialog) so nothing
   reaches other pages. Tokens come from style.css :root; this block names roles. */

.dp {
    --dp-ink: var(--black-2);
    --dp-ink-2: var(--black-3);
    --dp-panel: var(--surface);
    --dp-line: #e4e6eb;
    --dp-line-2: var(--line-soft);
    --dp-head: var(--black-2);
    --dp-head-text: var(--white);
    --dp-head-meta: var(--on-dark);
    --dp-cell-0: #eceef2;
    --dp-cell-1: #c9ccd4;
    --dp-cell-2: #8d919b;
    --dp-cell-3: #464a54;
    --dp-cell-4: var(--black);
    --dp-amber: #8a4f00;   /* warn hue darkened: 5.5:1 on --warn-bg, where --warn is 3.7:1 */
    --dp-amber-bg: var(--warn-bg);
    --dp-green: var(--ok);
    --dp-shadow: 0 1px 2px rgba(16, 16, 20, .05), 0 8px 24px -12px rgba(16, 16, 20, .18);
    --dp-radius: 12px;
    --dp-gap: 16px;
    color: var(--text);
}
.dp ::selection { background: var(--red-tint-2); color: var(--black); }

/* ---- grid ------------------------------------------------------------- */
.dp-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--dp-gap);
    align-items: stretch;
}
.dp-scan     { grid-column: span 5; }
.dp-status   { grid-column: span 7; }
.dp-trend    { grid-column: span 7; }
.dp-map      { grid-column: span 5; }
.dp-accounts { grid-column: span 4; }
.dp-age      { grid-column: span 4; }
.dp-dispatch { grid-column: span 4; }
.dp-recent   { grid-column: span 8; }
.dp-people   { grid-column: span 4; }

/* Chart panels: the body is a column and the chart takes whatever height the row
   gives it, so a panel never shows a block of white under its chart. */
.dp-trend-body, .dp-age .dp-body, .dp-dispatch .dp-body, .dp-people-body { display: flex; flex-direction: column; }
.dp-trend-chart { flex: 1; min-height: 260px; position: relative; }
.dp-trend-chart > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.dp-trend-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-25); margin-top: var(--sp-35); }
.dp-trend-stats > div { display: flex; flex-direction: column; gap: 1px; padding: var(--sp-25) var(--sp-35); background: var(--surface-inset); border-radius: var(--radius-md); }
.dp-trend-stats span { font-size: var(--fs-200); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--text-3); }
.dp-trend-stats strong { font-size: 22px; line-height: 1.15; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; color: var(--dp-ink); }
.dp-trend-stats em { font-style: normal; font-size: var(--fs-300); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- panel ------------------------------------------------------------ */
.dp-panel {
    background: var(--dp-panel);
    border: 1px solid var(--dp-line);
    border-radius: var(--dp-radius);
    box-shadow: var(--dp-shadow);
    overflow: hidden;
    display: flex; flex-direction: column;
    min-width: 0;
}
.dp-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    min-height: 42px; padding: 0 var(--sp-4);
    background: var(--dp-head); color: var(--dp-head-text);
}
.dp-head h2 {
    margin: 0; display: flex; align-items: center; gap: var(--sp-25);
    font-size: var(--fs-500); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); color: var(--dp-head-text);
}
.dp-head h2::before {
    content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--red); flex-shrink: 0;
}
.dp-head-meta { font-size: var(--fs-300); color: var(--dp-head-meta); white-space: nowrap; }
.dp-head-meta a { color: var(--white); font-weight: var(--fw-semi); text-decoration: none; }
.dp-head-meta a:hover { text-decoration: underline; text-underline-offset: 3px; }
.dp-body { padding: var(--sp-4); flex: 1; min-width: 0; }
.dp-body-flush { padding: 0; }

.dp-muted { color: var(--text-3); }
.dp-small { font-size: var(--fs-300); margin: var(--sp-25) 0 0; }
.dp-small a, .dp-callout a { color: var(--red-dark); font-weight: var(--fw-semi); text-decoration: none; }
.dp-small a:hover, .dp-callout a:hover { text-decoration: underline; text-underline-offset: 3px; }
.dp-empty { margin: 0; padding: var(--sp-5); color: var(--text-3); text-align: center; }
.dp-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ---- scan station ----------------------------------------------------- */
.dp-ready {
    display: inline-flex; align-items: center; gap: var(--sp-15);
    font-size: var(--fs-300); font-weight: var(--fw-semi); color: var(--white);
}
.dp-ready-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #3ccf6e;
    box-shadow: 0 0 0 0 rgba(60, 207, 110, .55);
    animation: dp-breathe 2.4s var(--ease-in-out) infinite;
}
@keyframes dp-breathe {
    0%   { box-shadow: 0 0 0 0 rgba(60, 207, 110, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(60, 207, 110, 0); }
    100% { box-shadow: 0 0 0 0 rgba(60, 207, 110, 0); }
}

.dp-viewfinder {
    position: relative;
    height: 150px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 1px 1px, rgba(16, 16, 20, .07) 1px, transparent 0) 0 0 / 12px 12px,
        linear-gradient(180deg, var(--surface-inset), var(--surface));
    border: 1px solid var(--dp-line);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
    overflow: hidden;
}
.dp-corner { position: absolute; width: 22px; height: 22px; border-color: var(--dp-ink); border-style: solid; border-width: 0; }
.dp-corner.tl { top: 10px; left: 10px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 6px; }
.dp-corner.tr { top: 10px; right: 10px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 6px; }
.dp-corner.bl { bottom: 10px; left: 10px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 6px; }
.dp-corner.br { bottom: 10px; right: 10px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 6px; }

.dp-code { height: 76px; display: flex; align-items: center; justify-content: center; max-width: calc(100% - 64px); }
.dp-code svg { height: 76px; width: auto; max-width: 100%; display: block; transition: opacity var(--dur-3) var(--ease-out); }
.dp-viewfinder[data-state="idle"] .dp-code svg { opacity: .55; }
.dp-code-text {
    font-family: var(--font-mono); font-size: var(--fs-450); letter-spacing: 2px;
    color: var(--text-2); font-variant-numeric: tabular-nums;
}
.dp-viewfinder[data-state="typing"] .dp-code-text { color: var(--text); font-weight: var(--fw-bold); }

.dp-laser {
    position: absolute; top: 18px; bottom: 18px; left: 0; width: 3px;
    background: var(--red);
    box-shadow: 0 0 10px 2px var(--red-glow), 0 0 26px 6px rgba(200, 16, 46, .18);
    border-radius: 2px;
    animation: dp-sweep 2.6s var(--ease-in-out) infinite alternate;
}
@keyframes dp-sweep {
    from { transform: translateX(34px); }
    to   { transform: translateX(var(--dp-sweep-end, 400px)); }
}
.dp-viewfinder[data-state="typing"] .dp-laser { animation-duration: 1.1s; }
.dp-viewfinder[data-state="sent"] { border-color: var(--dp-green); box-shadow: 0 0 0 4px var(--ok-bg); }
.dp-viewfinder[data-state="sent"] .dp-laser { background: var(--dp-green); box-shadow: 0 0 14px 4px rgba(29, 122, 62, .4); animation-duration: .35s; }

.dp-scan-form { position: relative; margin-top: var(--sp-35); }
.dp-scan-form input {
    width: 100%; height: 52px;
    padding: 0 60px 0 var(--sp-4);
    font-family: var(--font-mono); font-size: var(--fs-900); letter-spacing: 1px;
    color: var(--text); background: var(--surface);
    border: 2px solid var(--dp-ink); border-radius: var(--radius-lg);
    caret-color: var(--red);
    transition: border-color var(--t-base), box-shadow var(--t-base);
}
.dp-scan-form input::placeholder { color: var(--text-3); font-family: var(--font-sans); font-size: var(--fs-650); letter-spacing: 0; }
.dp-scan-form input:focus { outline: none; border-color: var(--red); box-shadow: var(--ring-strong), 0 0 0 7px var(--red-tint); }
.dp-go {
    position: absolute; top: 6px; right: 6px; width: 40px; height: 40px;
    display: grid; place-items: center;
    border: 0; border-radius: var(--radius-md); background: var(--red); color: var(--white); cursor: pointer;
    transition: background-color var(--t-base), transform var(--dur-1) var(--ease-out);
}
.dp-go:hover { background: var(--red-dark); }
.dp-go:active { transform: translateY(1px); }
.dp-go:focus-visible { outline: none; box-shadow: var(--ring-strong); }
.dp-ico { width: 18px; height: 18px; flex-shrink: 0; }

.dp-scan-note { margin: var(--sp-2) 0 0; font-size: var(--fs-300); color: var(--text-3); min-height: 1.4em; }

.dp-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); margin-top: var(--sp-35); }
.dp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    height: 42px; padding: 0 var(--sp-3);
    border-radius: var(--radius-md); border: 1.5px solid var(--dp-ink);
    background: var(--surface); color: var(--dp-ink);
    font-size: var(--fs-500); font-weight: var(--fw-bold); text-decoration: none; white-space: nowrap;
    transition: background-color var(--t-base), color var(--t-base), box-shadow var(--t-base), transform var(--dur-1) var(--ease-out);
}
.dp-btn:hover { background: var(--dp-ink); color: var(--white); }
.dp-btn:active { transform: translateY(1px); }
.dp-btn:focus-visible { outline: none; box-shadow: var(--ring-strong); }
.dp-btn-red { background: var(--red); border-color: var(--red); color: var(--white); box-shadow: 0 6px 16px -8px var(--red-glow); }
.dp-btn-red:hover { background: var(--red-dark); border-color: var(--red-dark); color: var(--white); }

/* ---- today / on hand -------------------------------------------------- */
.dp-status-body { display: flex; flex-direction: column; gap: var(--sp-35); }
.dp-kpis {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--dp-line); border-radius: var(--radius-lg); overflow: hidden;
}
.dp-kpi {
    position: relative;
    display: flex; flex-direction: column; gap: var(--sp-1);
    padding: var(--sp-35) var(--sp-4);
    text-decoration: none; color: var(--text);
    border-left: 1px solid var(--dp-line);
    transition: background-color var(--t-base);
}
.dp-kpi:first-child { border-left: 0; }
.dp-kpi:hover { background: var(--surface-2); }
.dp-kpi:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--red); }
.dp-kpi-label { font-size: var(--fs-250); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--text-2); }
.dp-kpi-num { font-size: 42px; line-height: 1; font-weight: var(--fw-bold); letter-spacing: -1px; font-variant-numeric: tabular-nums; color: var(--dp-ink); }
.dp-kpi.is-work::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--red); }
.dp-kpi.is-work .dp-kpi-num { color: var(--red); }
.dp-delta { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-300); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-delta svg { width: 9px; height: 9px; fill: currentColor; flex-shrink: 0; }
.dp-delta.is-up { color: var(--dp-green); }
.dp-delta.is-down { color: var(--text-2); }

.dp-onhand { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-25); }
.dp-stat {
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--sp-25) var(--sp-35);
    background: var(--surface-inset); border-radius: var(--radius-md);
    text-decoration: none; color: var(--text);
    transition: background-color var(--t-base), box-shadow var(--t-base);
}
.dp-stat:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--dp-line); }
.dp-stat:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--red); }
.dp-stat-num { font-size: 26px; line-height: 1.1; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; color: var(--dp-ink); }
.dp-stat-num small { font-size: var(--fs-500); font-weight: var(--fw-semi); color: var(--text-3); }
.dp-stat-label { font-size: var(--fs-300); color: var(--text-2); }
.dp-stat.is-warn { background: var(--dp-amber-bg); }
.dp-stat.is-warn .dp-stat-num, .dp-stat.is-warn .dp-stat-label { color: var(--dp-amber); }

.dp-queue-clear {
    display: flex; align-items: center; gap: var(--sp-25);
    padding: var(--sp-25) var(--sp-35);
    border: 1px dashed var(--dp-line); border-radius: var(--radius-md);
    font-size: var(--fs-400); color: var(--text-2);
}
.dp-queue-clear svg { width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: var(--ok-bg); color: var(--dp-green); flex-shrink: 0; }
.dp-queue-clear strong { color: var(--text); }
.dp-queue-clear span { flex: 1; min-width: 0; }
.dp-queue-clear a {
    font-size: var(--fs-300); font-weight: var(--fw-semi); color: var(--dp-ink); text-decoration: none;
    padding: var(--sp-1) var(--sp-25); border: 1px solid var(--dp-line); border-radius: var(--radius-pill);
}
.dp-queue-clear a:hover { border-color: var(--dp-ink); }

/* ---- shared table ----------------------------------------------------- */
.dp-table-wrap { overflow-x: auto; }
.dp-table { width: 100%; border-collapse: collapse; font-size: var(--fs-450); font-variant-numeric: tabular-nums; }
.dp-table th {
    text-align: left; font-size: var(--fs-200); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--ls-caps);
    color: var(--text-3); padding: var(--sp-25) var(--sp-4); border-bottom: 1px solid var(--dp-line); background: var(--surface-2);
}
.dp-table td { padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--dp-line-2); vertical-align: middle; color: var(--text); }
.dp-table tbody tr:last-child td { border-bottom: 0; }
.dp-table tbody tr:hover td { background: var(--surface-2); }
.dp-table a { color: var(--text); text-decoration: none; }
.dp-table a:hover { color: var(--red-dark); text-decoration: underline; text-underline-offset: 3px; }
.dp-num { text-align: right; }
.dp-nowrap { white-space: nowrap; }
.dp-detail { color: var(--text-2); max-width: 0; width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-code-link { font-family: var(--font-mono); font-size: var(--fs-400); white-space: nowrap; }

.dp-tag {
    display: inline-block; padding: 2px var(--sp-2); border-radius: var(--radius-pill);
    font-size: var(--fs-200); font-weight: var(--fw-bold); white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.dp-tag.is-red { background: var(--red-light); color: var(--red-dark); }
.dp-tag-in { background: var(--ok-bg); color: var(--dp-green); }
.dp-tag-out { background: var(--dp-ink); color: var(--white); }
.dp-tag-adjust { background: var(--dp-amber-bg); color: var(--dp-amber); }

.dp-col-progress { display: flex; align-items: center; gap: var(--sp-2); }
.dp-progress { flex: 1; height: 8px; border-radius: var(--radius-pill); background: var(--track); overflow: hidden; min-width: 80px; }
.dp-progress span { display: block; height: 100%; width: var(--pct); background: var(--dp-green); border-radius: inherit; }

/* ---- trend chart ------------------------------------------------------ */
.dp-legend { display: flex; flex-wrap: wrap; gap: var(--sp-35); font-size: var(--fs-300); color: var(--dp-head-meta); }
.dp-legend span { display: inline-flex; align-items: center; gap: var(--sp-15); white-space: nowrap; }
.dp-legend strong { color: var(--white); font-variant-numeric: tabular-nums; }
.sw-in, .dp-b-in { background: var(--dp-ink); fill: var(--dp-ink); }
.dp-legend .sw-in { background: var(--white); }
.sw-out, .dp-b-out { background: var(--red); fill: var(--red); }
.sw-adj, .dp-b-adj { background: #e3a43a; fill: #e3a43a; }
.dp-b-none { fill: var(--dp-cell-0); }

.dp-chart { width: 100%; height: auto; display: block; overflow: visible; }
.dp-grid-line { stroke: var(--dp-line-2); stroke-width: 1; }
.dp-axis { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.dp-axis.is-now { fill: var(--red-dark); font-weight: var(--fw-bold); }
.dp-bar-total { font-size: 11px; font-weight: var(--fw-bold); fill: var(--text-2); }
.dp-bar-g rect { transform-box: fill-box; transform-origin: 50% 100%; animation: dp-grow .7s var(--ease-emphasis) both; animation-delay: calc(var(--i) * 40ms); }
.dp-bar-g text.dp-bar-total { animation: dp-fade .5s var(--ease-out) both; animation-delay: calc(300ms + var(--i) * 40ms); }
.dp-bar-g:hover rect { filter: brightness(1.15); }
@keyframes dp-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes dp-fade { from { opacity: 0; } to { opacity: 1; } }
.dp-chart .dp-axis { font-size: 12px; }
.dp-chart .dp-bar-total { font-size: 12px; }
.dp-trend-chart.is-static .dp-bar-g rect, .dp-trend-chart.is-static .dp-bar-g text { animation: none; }

/* ---- storage map ------------------------------------------------------ */
.dp-tabs { display: flex; gap: var(--sp-15); margin-bottom: var(--sp-3); }
.dp-tab {
    font: inherit; font-size: var(--fs-400); font-weight: var(--fw-bold); color: var(--text-2);
    padding: var(--sp-15) var(--sp-3); border-radius: var(--radius-pill);
    border: 1px solid var(--dp-line); background: var(--surface); cursor: pointer;
    transition: background-color var(--t-base), color var(--t-base), border-color var(--t-base);
}
.dp-tab span { font-weight: var(--fw-semi); color: var(--text-3); margin-left: var(--sp-1); font-variant-numeric: tabular-nums; }
.dp-tab[aria-selected="true"] { background: var(--dp-ink); border-color: var(--dp-ink); color: var(--white); }
.dp-tab[aria-selected="true"] span { color: var(--on-dark); }
.dp-tab:focus-visible { outline: none; box-shadow: var(--ring-strong); }
.dp-zone[hidden] { display: none; }

.dp-rack {
    display: grid;
    grid-template-columns: 16px repeat(var(--bays), minmax(0, 1fr));
    gap: 2px;
    font-size: 9px; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.dp-rack-corner, .dp-rack-bay, .dp-rack-aisle { line-height: 1; display: flex; align-items: center; justify-content: center; }
.dp-rack-bay { height: 12px; }
.dp-rack-aisle { font-weight: var(--fw-bold); color: var(--text-2); }
.dp-cell { height: 10px; border-radius: 2px; background: var(--dp-cell-0); transition: transform var(--dur-1) var(--ease-out); }
.dp-cell[data-l="x"] { background: transparent; }
.dp-cell[data-l="1"], .dp-scale i[data-l="1"] { background: var(--dp-cell-1); }
.dp-cell[data-l="2"], .dp-scale i[data-l="2"] { background: var(--dp-cell-2); }
.dp-cell[data-l="3"], .dp-scale i[data-l="3"] { background: var(--dp-cell-3); }
.dp-cell[data-l="4"], .dp-scale i[data-l="4"] { background: var(--dp-cell-4); }
.dp-scale i[data-l="0"] { background: var(--dp-cell-0); }
.dp-cell:not([data-l="x"]):hover { transform: scale(1.6); box-shadow: 0 0 0 1.5px var(--red); position: relative; z-index: 1; }

.dp-map-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-25); margin-top: var(--sp-35); }
.dp-scale { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-200); color: var(--text-3); }
.dp-scale i { width: 12px; height: 12px; border-radius: 2px; }
.dp-scale span:first-child { margin-right: var(--sp-1); }
.dp-scale span:last-child { margin-left: var(--sp-1); }
.dp-chips { display: flex; flex-wrap: wrap; gap: var(--sp-15); }
.dp-chip {
    font-size: var(--fs-300); color: var(--text-2); padding: 3px var(--sp-25);
    border: 1px solid var(--dp-line); border-radius: var(--radius-pill); white-space: nowrap;
}
.dp-chip strong { font-variant-numeric: tabular-nums; color: var(--text); margin-left: 2px; }
.dp-chip.is-used { border-color: var(--dp-ink); }

/* ---- accounts --------------------------------------------------------- */
.dp-split { display: grid; grid-template-columns: minmax(120px, 40%) minmax(0, 1fr); gap: var(--sp-5); align-items: center; }
.dp-donut { width: 100%; max-width: 220px; height: auto; aspect-ratio: 1; display: block; justify-self: center; }
.dp-donut-track { fill: none; stroke: var(--dp-cell-0); stroke-width: 16; }
.dp-donut-seg {
    fill: none; stroke-width: 16; transform: rotate(-90deg); transform-origin: 70px 70px;
    animation: dp-donut-in .9s var(--ease-emphasis) both; animation-delay: calc(var(--i) * 120ms);
}
@keyframes dp-donut-in { from { stroke-dasharray: 0 400; } }
.dp-donut-num { font-size: 30px; font-weight: var(--fw-bold); fill: var(--dp-ink); }
.dp-donut-sub { font-size: 10px; font-weight: var(--fw-semi); fill: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.dp-s1 { stroke: var(--dp-ink); background: var(--dp-ink); }
.dp-s2 { stroke: var(--red); background: var(--red); }
.dp-s3 { stroke: var(--dp-cell-2); background: var(--dp-cell-2); }
.dp-s4 { stroke: var(--dp-cell-1); background: var(--dp-cell-1); }
.dp-s5 { stroke: #e3a43a; background: #e3a43a; }

.dp-row {
    display: flex; align-items: center; gap: var(--sp-25);
    padding: var(--sp-15) var(--sp-2); margin: 0 calc(-1 * var(--sp-2));
    border-radius: var(--radius-sm); text-decoration: none; color: var(--text); font-size: var(--fs-500);
}
.dp-row:hover { background: var(--surface-2); }
.dp-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--red); }
.dp-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-row strong { font-variant-numeric: tabular-nums; font-size: var(--fs-650); }

.dp-typebar, .dp-carriers { display: flex; gap: 3px; height: 10px; margin-top: var(--sp-35); }
.dp-typeseg, .dp-carrier-seg { border-radius: 3px; min-width: 6px; animation: dp-widen .8s var(--ease-emphasis) both; transform-origin: 0 50%; }
@keyframes dp-widen { from { transform: scaleX(0); } }
.dp-t0, .dp-c0 { background: var(--dp-ink); }
.dp-t1, .dp-c1 { background: var(--red); }
.dp-t2, .dp-c2 { background: var(--dp-cell-2); }
.dp-typelegend { display: flex; flex-wrap: wrap; gap: var(--sp-15) var(--sp-35); margin-top: var(--sp-2); font-size: var(--fs-300); color: var(--text-2); }
.dp-typelegend > span { display: inline-flex; align-items: center; gap: var(--sp-15); white-space: nowrap; }
.dp-typelegend strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- horizontal bars (age, people) ------------------------------------ */
.dp-hbars { display: flex; flex-direction: column; justify-content: space-around; gap: var(--sp-3); flex: 1; }
.dp-hbar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 36px; align-items: center; gap: var(--sp-25); font-size: var(--fs-450); }
.dp-hbar-label { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: var(--sp-2); }
.dp-hbar-track { height: 16px; background: var(--dp-cell-0); border-radius: var(--radius-pill); overflow: hidden; }
.dp-hbar-fill {
    display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--dp-ink);
    transform-origin: 0 50%; animation: dp-widen .8s var(--ease-emphasis) both; animation-delay: calc(var(--i) * 70ms);
}
.dp-hbar.is-over .dp-hbar-fill { background: #e3a43a; }
.dp-hbar strong { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-550); }
.dp-people-list { display: flex; flex-direction: column; justify-content: center; gap: var(--sp-5); flex: 1; }
.dp-person-top { display: flex; align-items: center; gap: var(--sp-25); font-size: var(--fs-550); }
.dp-person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: var(--fw-semi); }
.dp-person-top strong { font-size: var(--fs-800); font-variant-numeric: tabular-nums; color: var(--dp-ink); }
.dp-person-bar {
    display: flex; gap: 2px; width: var(--w); height: 16px; margin-top: var(--sp-2); border-radius: var(--radius-pill); overflow: hidden;
    transform-origin: 0 50%; animation: dp-widen .8s var(--ease-emphasis) both; animation-delay: calc(var(--i) * 90ms);
}
.dp-person-bar > span { min-width: 4px; }
.dp-person-split { display: block; margin-top: var(--sp-15); font-size: var(--fs-300); color: var(--text-2); font-variant-numeric: tabular-nums; }
.dp-avatar {
    width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
    background: var(--dp-ink); color: var(--white); font-size: var(--fs-200); font-weight: var(--fw-bold);
}

.dp-callout { margin: var(--sp-4) 0 0; padding: var(--sp-25) var(--sp-35); border-radius: var(--radius-md); background: var(--surface-inset); font-size: var(--fs-400); color: var(--text-2); }
.dp-callout strong { color: var(--text); font-size: var(--fs-650); }
.dp-callout.is-warn { background: var(--dp-amber-bg); color: var(--dp-amber); }
.dp-callout.is-warn strong { color: var(--dp-amber); }

/* ---- dispatch mini bars ----------------------------------------------- */
.dp-minibars { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); align-items: end; gap: 5px; flex: 1; min-height: 120px; margin-top: var(--sp-4); padding-top: 14px; }
.dp-minibar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.dp-minibar span {
    display: block; height: max(2px, var(--h)); background: var(--dp-ink); border-radius: 3px 3px 1px 1px;
    transform-origin: 50% 100%; animation: dp-grow .7s var(--ease-emphasis) both; animation-delay: calc(var(--i) * 40ms);
}
.dp-minibar:last-child span { background: var(--red); }
.dp-minibar em { position: absolute; left: 0; right: 0; bottom: calc(var(--h) + 3px); text-align: center; font-style: normal; font-size: 10px; font-weight: var(--fw-bold); color: var(--text-3); }

/* ---- motion preference ------------------------------------------------ */
/* Lee's Windows reports reduced motion. The scanner laser and the Ready dot are
   the requested scan feedback, not decoration, so they keep running (the laser
   at a calmer pace). Chart entrance effects and hover transitions switch off. */
@media (prefers-reduced-motion: reduce) {
    .dp *:not(.dp-laser):not(.dp-ready-dot), .dp *::before, .dp *::after { animation: none !important; transition: none !important; }
    /* style.css clamps every animation to .001ms x1 under reduced motion; undo it here only. */
    .dp .dp-laser { animation-duration: 3.4s !important; animation-iteration-count: infinite !important; }
    .dp .dp-ready-dot { animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
}

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 1599px) {
    .dp-recent, .dp-people { grid-column: span 12; }
    .dp-trend, .dp-map { grid-column: span 12; }
    .dp-trend-chart { min-height: 300px; }
    .dp-kpi-num { font-size: 36px; }
}
@media (max-width: 1280px) {
    .dp-scan, .dp-status, .dp-trend, .dp-map { grid-column: span 12; }
    .dp-accounts, .dp-age { grid-column: span 6; }
    .dp-dispatch { grid-column: span 12; }
    .dp-trend-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .dp { --dp-gap: 12px; }
    .dp-accounts, .dp-age, .dp-dispatch, .dp-people { grid-column: span 12; }
    .dp-kpis, .dp-onhand { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dp-kpi:nth-child(3) { border-left: 0; }
    .dp-kpi:nth-child(n+3) { border-top: 1px solid var(--dp-line); }
    .dp-head { flex-wrap: wrap; padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
}
@media (max-width: 600px) {
    .dp-body { padding: var(--sp-35); }
    .dp-kpi { padding: var(--sp-3); }
    .dp-kpi-num { font-size: 32px; }
    .dp-actions { grid-template-columns: 1fr; }
    .dp-scan-form input { font-size: var(--fs-700); }
    .dp-viewfinder { height: 132px; }
    .dp-code, .dp-code svg { height: 60px; }
    .dp-rack-wrap, .dp-zone { overflow-x: auto; }
    .dp-rack { min-width: 460px; }
    .dp-split { grid-template-columns: 1fr; justify-items: center; }
    .dp-split-list { width: 100%; }
    .dp-legend { gap: var(--sp-2); }
    .dp-queue-clear { flex-wrap: wrap; }
    .dp-recent .dp-table th:nth-child(5), .dp-recent .dp-table td:nth-child(5),
    .dp-recent .dp-table th:nth-child(6), .dp-recent .dp-table td:nth-child(6) { display: none; }
}

/* ---- Goods out / Stock move popup (dialog sits outside .dp) ------------ */
.dp-popup {
    position: fixed; inset: 0; margin: auto;   /* style.css zeroes margins, which un-centres <dialog> */
    width: min(1180px, 94vw); height: min(880px, 90vh); max-width: none; max-height: none;
    padding: 0; border: 0; border-radius: 14px; overflow: hidden;
    background: var(--surface); color: var(--text);
    box-shadow: 0 30px 80px -20px rgba(16, 16, 20, .55), 0 0 0 1px rgba(16, 16, 20, .08);
}
.dp-popup[open] { display: flex; flex-direction: column; animation: dp-popup-in 220ms var(--ease-out) both; }
.dp-popup::backdrop { background: rgba(16, 16, 20, .55); backdrop-filter: blur(3px); }
@keyframes dp-popup-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.dp-popup-head {
    display: flex; align-items: center; gap: var(--sp-3);
    min-height: 48px; padding: 0 var(--sp-2) 0 var(--sp-4);
    background: var(--black-2); color: var(--white); flex-shrink: 0;
}
.dp-popup-head h2 {
    margin: 0; display: flex; align-items: center; gap: var(--sp-25);
    font-size: var(--fs-650); font-weight: var(--fw-bold); color: var(--white);
}
.dp-popup-head h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--red); }
.dp-popup-env {
    font-size: var(--fs-200); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--white); background: var(--red); padding: 2px var(--sp-2); border-radius: var(--radius-pill);
}
.dp-popup-env:empty { display: none; }
.dp-popup-full {
    margin-left: auto; font-size: var(--fs-400); font-weight: var(--fw-semi); color: var(--on-dark); text-decoration: none;
    padding: var(--sp-15) var(--sp-25); border-radius: var(--radius-md);
}
.dp-popup-full:hover, .dp-popup-full:focus-visible { color: var(--white); background: var(--black-3); outline: none; }
.dp-popup-close {
    width: 36px; height: 36px; display: grid; place-items: center;
    border: 0; border-radius: var(--radius-md); background: transparent; color: var(--white); cursor: pointer;
}
.dp-popup-close svg { width: 18px; height: 18px; }
.dp-popup-close:hover, .dp-popup-close:focus-visible { background: var(--red); outline: none; }
.dp-popup-body { position: relative; flex: 1; min-height: 0; background: var(--surface); }
.dp-popup-frame { display: block; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity 160ms var(--ease-out); }
.dp-popup-frame.is-ready { opacity: 1; }
.dp-popup-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: var(--fs-500); }
.dp-popup-loading[hidden] { display: none; }
@media (max-width: 600px) {
    .dp-popup { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; }
    .dp-popup-full { display: none; }
}
