/* Production Scanning, Scanning List and Scanning Dashboard */
.sc-page { --line: #dbe7ee; --line2: #edf3f6; --ink: var(--text-main); --mute: #55707f; --ok: #0b7a53; --warn: #a35a00; --bad: #b42318;
    display: flex; flex-direction: column; gap: 10px; min-height: 100%; font-variant-numeric: tabular-nums; }
.sc-page button, .sc-page input, .sc-page select { font-family: inherit; }
.sc-page :focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
.sc-page [hidden] { display: none !important; }
.sc-page .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.sc-head.header { flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: flex-start; margin-bottom: 0; padding-bottom: 10px; }
.sc-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.sc-acts .btn { min-height: 38px; padding: 0 13px; font-size: .86rem; white-space: nowrap; }
.sc-upd { font-size: .78rem; color: var(--mute); }
.sc-upd.bad { color: var(--bad); font-weight: 600; }
.sc-views { display: inline-flex; background: #e1edf3; border-radius: 10px; padding: 3px; }
.sc-views a { display: grid; place-items: center; border-radius: 8px; min-height: 32px; padding: 0 14px; font-size: .86rem; font-weight: 600; color: var(--mute); text-decoration: none; }
.sc-views a[aria-current] { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(8, 38, 58, .16); }

.sc-figs { display: flex; flex-wrap: wrap; gap: 4px 22px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 16px; font-size: .84rem; color: var(--mute); min-height: 40px; align-items: center; }
.sc-figs b { color: var(--ink); font-size: 1rem; font-weight: 700; }
.sc-figs .bad, .sc-figs .bad b { color: var(--bad); }
.sc-bridge { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; }
.sc-dot { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #a9bcc8; }
.sc-dot.on { background: #149468; }
.sc-dot.wait { background: #e09a1a; }
.sc-dot.bad { background: #d92d20; }
.sc-dot.blink { background: #e09a1a; }

.sc-bar1 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sc-bar1 > span { font-size: .82rem; font-weight: 600; color: var(--mute); }
.sc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-chip { border: 1px solid #c8dae4; background: #fff; border-radius: 999px; min-height: 32px; padding: 0 12px; font-size: .84rem; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap; }
.sc-chip small { font-weight: 600; color: var(--mute); margin-left: 3px; }
.sc-chip:hover { border-color: var(--primary); }
.sc-chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.sc-chip[aria-pressed="true"] small { color: #cfe6f2; }

.sc-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 56px 20px; color: var(--mute); text-align: center; }
.sc-empty i { font-size: 2rem; }
.sc-empty b { color: var(--ink); }
.sc-skel { height: 330px; border-radius: 14px; background: #e6f0f5; }

/* ---------- a station ---------- */
.sc-stations { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: stretch; }
.sc-card { position: relative; display: flex; flex-direction: column; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; overflow: hidden; transition: background-color 200ms ease-out; }
.sc-card.flash-ok { background: #e2f6ec; }
.sc-card.flash-bad { background: #fde7e4; }
.sc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sc-top h2 { margin: 0; font-size: 1.35rem; line-height: 1.15; font-weight: 700; color: var(--ink); }
.sc-top small { font-size: .76rem; color: var(--mute); }
.sc-pill { flex: none; border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600; background: #eef3f6; color: #48606f; }
.sc-pill.run { background: #dcf3e7; color: #075c3d; }
.sc-pill.slow { background: #fff1d9; color: #7c4400; }
.sc-pill.done { background: #dcebf6; color: #0b4670; }
.sc-job { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sc-none { margin: 0; color: var(--mute); }
.sc-pick { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--mute); margin-bottom: 3px; }
.sc-card select, .sc-card input { width: 100%; min-height: 38px; border: 1px solid #c8dae4; border-radius: 9px; background: #fff; padding: 0 10px; font-size: .88rem; color: var(--ink); min-width: 0; }
.sc-item { font-size: .98rem; font-weight: 600; color: var(--ink); line-height: 1.3; overflow-wrap: anywhere; }
.sc-sub { font-size: .8rem; color: var(--mute); overflow-wrap: anywhere; }
.sc-tables { display: flex; flex-wrap: wrap; gap: 4px; }
.sc-tables b { background: #e6f1f7; color: var(--primary); border-radius: 6px; padding: 1px 7px; font-size: .76rem; font-weight: 600; }
.sc-count { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; color: var(--mute); font-size: .86rem; }
.sc-count b { font-size: 2.1rem; line-height: 1; font-weight: 700; color: var(--ink); }
.sc-count em { margin-left: auto; font-style: normal; font-weight: 600; color: var(--ink); }
.sc-bar { height: 8px; border-radius: 4px; background: #e4eef3; overflow: hidden; }
.sc-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--ok); transition: width 300ms ease-out; }
.sc-job.full .sc-bar i { background: var(--primary); }
.sc-ean { font-size: .8rem; color: var(--mute); }
.sc-ean b { font-family: ui-monospace, Consolas, monospace; font-size: .92rem; color: var(--ink); letter-spacing: .02em; }
.sc-ean.bad { color: var(--bad); font-weight: 600; }
.sc-work { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sc-input { position: relative; display: block; }
.sc-input i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--mute); }
.sc-card .sc-input input { min-height: 44px; padding-left: 36px; font-size: .95rem; }
.sc-card .sc-input input:disabled { background: #f2f5f7; }
.sc-setup { border: 1px solid var(--line); border-radius: 10px; background: #f8fbfc; }
.sc-setup summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; cursor: pointer; font-size: .82rem; color: var(--ink); }
.sc-setup summary::-webkit-details-marker { display: none; }
.sc-setup summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sc-setup summary em { margin-left: auto; font-style: normal; font-weight: 600; color: var(--primary); }
.sc-setup summary em::after { content: "\F282"; font-family: "bootstrap-icons"; font-size: .7rem; margin-left: 5px; }
.sc-setup[open] summary em::after { content: "\F286"; }
.sc-setup > div { display: flex; flex-direction: column; gap: 9px; padding: 4px 12px 12px; }
.sc-setup label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--mute); min-width: 0; }
.sc-setup .btn { min-height: 38px; }
.sc-two { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.sc-seg { display: flex; background: #e1edf3; border-radius: 9px; padding: 3px; }
.sc-seg button { flex: 1; border: 0; background: none; border-radius: 7px; min-height: 30px; font-size: .82rem; font-weight: 600; color: var(--mute); cursor: pointer; }
.sc-seg button[aria-pressed="true"] { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(8, 38, 58, .16); }
.sc-hint { margin: 0; font-size: .8rem; color: var(--mute); }
.sc-hint.bad { color: var(--bad); }
.sc-link { align-self: flex-start; border: 0; background: none; padding: 0; min-height: 24px; font-size: .78rem; font-weight: 600; color: var(--primary); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sc-dev { display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: .78rem; color: var(--mute); }
.sc-dev span { display: inline-flex; align-items: center; gap: 6px; }
.sc-log { flex: 1; min-height: 84px; max-height: 148px; overflow-y: auto; border-top: 1px solid var(--line2); padding-top: 8px; font-size: .82rem; }
.sc-log p { display: flex; gap: 9px; margin: 0; padding: 2px 0; line-height: 1.4; color: var(--mute); }
.sc-log time { flex: none; color: var(--mute); }
.sc-log span { overflow-wrap: anywhere; min-width: 0; }
.sc-log .ok span { color: var(--ok); }
.sc-log .bad span { color: var(--bad); font-weight: 600; }
.sc-lock { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; text-align: center; background: #b42318; color: #fff; }
.sc-lock h3 { margin: 0; font-size: 1.7rem; font-weight: 700; color: #fff; }
.sc-lock strong { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.sc-lock p { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.sc-lock p b { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; }
.sc-lock label { display: flex; flex-direction: column; gap: 4px; font-size: .86rem; font-weight: 600; }
.sc-card .sc-lock input { width: 150px; text-align: center; font-size: 1.2rem; letter-spacing: .3em; }
.sc-lock em { font-style: normal; font-size: .86rem; min-height: 1.2em; }
.sc-lock .btn { background: #fff; color: #8f1a12; min-height: 44px; padding: 0 22px; font-weight: 700; gap: 8px; }

/* ---------- list ---------- */
.sc-stations.list { grid-template-columns: minmax(0, 1fr); }
.sc-stations.list .sc-skel { height: 170px; }
@media (min-width: 1000px) {
    .sc-stations.list .sc-card { display: grid; grid-template-columns: 132px minmax(230px, 1.2fr) minmax(250px, 1fr) minmax(220px, 1fr); gap: 4px 20px; align-items: start; }
    .sc-stations.list .sc-top { flex-direction: column; }
    .sc-stations.list .sc-log { max-height: 158px; min-height: 0; border-top: 0; border-left: 1px solid var(--line2); padding: 0 0 0 16px; align-self: stretch; }
    .sc-stations.list .sc-card.stopped { min-height: 230px; }
}
@media (max-width: 600px) {
    .sc-bridge, .sc-acts { margin-left: 0; }
    .sc-chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding: 3px; margin: -3px; }
}
@media (prefers-reduced-motion: reduce) { .sc-card, .sc-bar i { transition: none; } }

/* ---------- dashboard ---------- */
.sc-page.db { --panel: #fff; --track: #e4eef3; }
.db-clock { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.db-live { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--mute); }
.db-kpis { display: grid; grid-template-columns: minmax(250px, 2fr) repeat(5, minmax(112px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.db-kpis > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; min-width: 0; border-left: 1px solid var(--line2); }
.db-kpis > div:first-child { border-left: 0; }
.db-kpis span { font-size: .82rem; color: var(--mute); }
.db-kpis b { font-size: 1.7rem; line-height: 1.15; font-weight: 700; color: var(--ink); }
.db-kpis small { font-size: .78rem; color: var(--mute); }
.db-kpis .bad b { color: var(--bad); }
.db-kpis .warn b { color: var(--warn); }
.db-kpis .sc-bar { margin: 3px 0; background: var(--track); }
.db-filters { display: flex; flex-wrap: wrap; gap: 8px 26px; }
.db-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.db-card { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; overflow: hidden; color: var(--mute); font-size: .82rem; cursor: pointer; transition: border-color 180ms ease-out, background-color 250ms ease-out; }
.db-card:hover { border-color: var(--primary); }
.db-card[data-state="stopped"] { background: var(--stopbg, #fff4f2); border-color: var(--stopln, #f0bdb6); }
.db-card[data-state="slow"] { background: var(--slowbg, #fff9ed); border-color: var(--slowln, #ecd3a0); }
.db-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.db-st { font-size: 1.45rem; line-height: 1.15; font-weight: 700; color: var(--ink); }
.db-pill { flex: none; border-radius: 999px; padding: 3px 11px; font-size: .8rem; font-weight: 600; background: #eef3f6; color: #48606f; }
[data-state="running"] .db-pill { background: #dcf3e7; color: #075c3d; }
[data-state="slow"] .db-pill { background: #fde7bd; color: #7c4400; }
[data-state="stopped"] .db-pill { background: #b42318; color: #fff; }
[data-state="done"] .db-pill { background: #dcebf6; color: #0b4670; }
.db-item { font-size: .98rem; font-weight: 600; line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
.db-sub { overflow-wrap: anywhere; }
.db-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.db-tabs b { background: var(--tabbg, #e6f1f7); color: var(--tabink, var(--primary)); border-radius: 6px; padding: 1px 7px; font-size: .76rem; font-weight: 600; }
.db-qty { display: flex; align-items: baseline; gap: 9px; margin-top: auto; padding-top: 4px; font-size: .88rem; }
.db-qty b { font-size: 2.5rem; line-height: 1; font-weight: 700; color: var(--ink); }
.db-qty em { margin-left: auto; font-style: normal; font-weight: 700; font-size: 1rem; color: var(--ink); }
.db-card .sc-bar { display: block; background: var(--track); }
.db-card[data-state="done"] .sc-bar i { background: var(--primary); }
.db-row { display: flex; justify-content: space-between; gap: 10px; }
.db-pace { font-weight: 600; }
.db-pace.good { color: var(--ok); }
.db-pace.bad { color: var(--bad); }
.db-spark { display: block; height: 30px; }
.db-spark.big { height: 84px; }
.db-spark svg { width: 100%; height: 100%; display: block; }
.db-spark rect { fill: var(--sparkc, #0b76a8); }
.db-spark rect.z { fill: var(--track, #dbe7ee); }
.db-plus { position: absolute; left: 50%; top: 45%; font-size: 1.7rem; font-weight: 700; color: var(--ok); animation: dbPlus 1s ease-out forwards; pointer-events: none; }
.db-confetti { position: absolute; top: -10px; width: 8px; height: 12px; animation: dbFall 1.5s ease-in forwards; pointer-events: none; }
.db-card.hit { background: #e2f6ec; }
.db-card.shake { animation: dbShake .4s; background: #fde7e4; }
.db-skel { height: 270px; border-radius: 14px; background: var(--track); }
@keyframes dbPlus { 0% { opacity: 0; transform: translateY(8px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-42px); } }
@keyframes dbFall { to { transform: translateY(340px) rotate(340deg); opacity: 0; } }
@keyframes dbShake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.db-stale { display: flex; align-items: center; gap: 9px; background: #fff1d9; color: #6d3c00; border: 1px solid #ecd3a0; border-radius: 10px; padding: 9px 14px; font-size: .88rem; font-weight: 600; }
.db-alert { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: #b42318; color: #fff; }
.db-alert[hidden] { display: none; }
.db-alert i { font-size: clamp(4rem, 14vw, 9rem); }
.db-alert h1 { margin: 0; font-size: clamp(2.2rem, 8vw, 5rem); font-weight: 800; color: #fff; }
.db-alert h2 { margin: 0; font-size: clamp(1.4rem, 5vw, 3rem); font-weight: 700; color: #fff; }
.db-alert p { margin: 0; font-size: clamp(1rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
.db-alert b { font-family: ui-monospace, Consolas, monospace; }
.db-detail { border: 0; border-radius: 16px; padding: 20px 22px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow-y: auto; color: #16384d; box-shadow: 0 24px 60px rgba(8, 38, 58, .3); font-variant-numeric: tabular-nums; margin: auto; }
.db-detail::backdrop { background: rgba(8, 38, 58, .5); }
.db-detail h2 { margin: 0 44px 2px 0; font-size: 1.3rem; }
.db-detail p { margin: 0 0 14px; color: #55707f; }
.db-detail h3 { margin: 16px 0 8px; font-size: .9rem; }
.db-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; margin: 0; }
.db-detail dt { font-size: .78rem; color: #55707f; }
.db-detail dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.db-x { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: #eef4f7; color: #16384d; cursor: pointer; }

/* TV mode: the page alone, dark, for a wall screen */
body.db-tv > *:not(.main-content):not(.db-alert):not(dialog):not(script):not([class*="toast"]) { display: none !important; }
body.db-tv .main-content { margin: 0 !important; width: 100% !important; max-width: none !important; min-height: 100vh; padding: 18px 22px !important; background: #0b1c28; }
body.db-tv .sc-page.db { --panel: #122a3a; --line: #24435a; --line2: #1d3a4f; --ink: #f2f8fb; --mute: #a9c2d0; --ok: #4fd39c; --warn: #f5bd5c; --bad: #ff8a7d; --track: #24435a; --sparkc: #4ab4e0;
    --stopbg: #3a1a1a; --stopln: #8f3a33; --slowbg: #33290f; --slowln: #7a5d1d; --tabbg: #1f4258; --tabink: #cfe9f6; }
body.db-nologin .main-content { margin: 0; width: 100%; max-width: none; }
body.db-tv .page-title { color: #f2f8fb; }
body.db-tv .db-card { font-size: .95rem; }
body.db-tv .db-st { font-size: 2rem; }
body.db-tv .db-item { font-size: 1.15rem; }
body.db-tv .db-qty b { font-size: 3.2rem; }
body.db-tv .db-kpis b { font-size: 2.2rem; }
body.db-tv .db-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
body.db-tv .db-card.hit { background: #14493a; }
body.db-tv .sc-bar i { background: #2fb583; }
body.db-tv .sc-views, body.db-tv #dbRefresh, body.db-tv .sc-head > :not(.page-title):not(.db-clock):not(.db-live):not(.sc-acts) { display: none !important; }
body.db-tv .sc-acts > :not(#dbSound):not(#dbTv) { display: none !important; }
body.db-tv .sc-head.header { border-color: #24435a; }
body.db-tv .sc-chip { background: #122a3a; border-color: #2c516b; color: #f2f8fb; }
body.db-tv .sc-chip small { color: #a9c2d0; }
body.db-tv .sc-chip[aria-pressed="true"] { background: #cfe9f6; border-color: #cfe9f6; color: #0b1c28; }
body.db-tv .sc-chip[aria-pressed="true"] small { color: #24435a; }
body.db-tv .sc-acts .btn { background: #122a3a; border-color: #2c516b; color: #f2f8fb; }
@media (max-width: 1100px) {
    .db-kpis { grid-template-columns: repeat(5, 1fr); }
    .db-kpis > div:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--line2); }
    .db-kpis > div:nth-child(2) { border-left: 0; }
}
@media (max-width: 640px) {
    .db-kpis { grid-template-columns: 1fr 1fr; }
    .db-kpis > div { border-left: 0; padding: 8px 14px; }
}
@media (prefers-reduced-motion: reduce) { .db-card, .db-card.shake { animation: none; transition: none; } }
