:root{--blue:#0b4fbf;--blue2:#073783;--ink:#14213d;--muted:#6d7890;--line:#dfe5ef;--bg:#f3f6fb;--ok:#128a52;--warn:#c47a00;--danger:#c83c44;--card:#fff;--shadow:0 12px 30px rgba(26,52,96,.09)}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans TC",sans-serif;min-height:100vh}.topbar{height:84px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 32px;position:sticky;top:0;z-index:10}.brand{display:flex;align-items:center;gap:14px}.brand img{width:48px;height:48px;object-fit:contain}.brand h1{margin:0;font-size:22px;letter-spacing:.04em}.brand p{margin:3px 0 0;color:var(--muted);font-size:13px}.top-actions{display:flex;align-items:center;gap:14px}.clock{font-variant-numeric:tabular-nums;font-weight:700;color:#33415c}.connection{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:8px 12px;font-size:13px;font-weight:800;background:#eef2f7;color:#566176}.connection i{width:9px;height:9px;border-radius:50%;background:#94a0b2}.connection.online{background:#e9f8f0;color:#0d7243}.connection.online i{background:#16a360;box-shadow:0 0 0 5px rgba(22,163,96,.12)}.connection.offline{background:#fff0f0;color:#a82d35}.connection.offline i{background:#d4454f}.nav-btn,.outline-btn{border:1px solid #cbd5e4;border-radius:10px;background:#fff;color:var(--blue);font-weight:800;text-decoration:none;padding:10px 14px;cursor:pointer}.nav-btn:hover,.outline-btn:hover{background:#eef4ff}main{max-width:1600px;margin:0 auto;padding:26px 30px 40px}.summary-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px;margin-bottom:20px}.summary-card{background:#fff;border:1px solid var(--line);border-radius:16px;padding:20px 22px;box-shadow:0 6px 18px rgba(26,52,96,.05);display:grid;grid-template-columns:1fr auto;grid-template-rows:auto auto;align-items:end}.summary-card span{color:var(--muted);font-weight:750}.summary-card strong{grid-row:1/3;grid-column:2;font-size:40px;line-height:1;color:var(--blue)}.summary-card small{margin-top:7px;color:#9aa4b4}.panel{background:#fff;border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);overflow:hidden}.live-panel{margin-bottom:20px}.panel-head{display:flex;align-items:center;justify-content:space-between;padding:22px 24px 16px;border-bottom:1px solid #edf0f5}.panel-head.compact{padding:19px 22px 14px}.panel-head h2{margin:2px 0 0;font-size:21px}.eyebrow{margin:0;color:var(--blue);font-size:11px;font-weight:900;letter-spacing:.13em}.head-meta,.muted{color:var(--muted);font-size:13px}.live-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(360px,1fr));gap:18px;padding:20px}.machine-card{border:1px solid #d9e1ed;border-radius:16px;padding:20px;background:linear-gradient(180deg,#fff,#fbfdff)}.machine-card-head{display:flex;justify-content:space-between;gap:20px;align-items:flex-start}.machine-card h3{font-size:26px;margin:2px 0 4px}.customer{color:var(--muted);font-weight:700}.status-pill{white-space:nowrap;border-radius:999px;background:#e8f8ef;color:#0c7544;padding:7px 11px;font-weight:900;font-size:12px}.progress-row{display:grid;grid-template-columns:110px 1fr;gap:20px;align-items:center;margin:22px 0}.progress-number{font-size:34px;font-weight:900;color:var(--blue);line-height:1}.progress-number small{font-size:16px;color:var(--muted);font-weight:700}.bar{height:13px;background:#e9edf4;border-radius:999px;overflow:hidden}.bar span{display:block;height:100%;background:linear-gradient(90deg,var(--blue),#2d7af0);border-radius:999px;transition:width .25s ease}.progress-label{display:flex;justify-content:space-between;margin-top:8px;color:var(--muted);font-size:12px}.metrics{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.metric{border:1px solid #e5eaf1;background:#fff;border-radius:12px;padding:12px}.metric span{display:block;color:var(--muted);font-size:11px}.metric b{display:block;font-size:20px;margin-top:5px}.last-action{margin-top:13px;padding-top:13px;border-top:1px solid #edf0f5;display:flex;justify-content:space-between;color:#4c5870;font-size:13px}.two-column{display:grid;grid-template-columns:minmax(340px,.75fr) minmax(600px,1.25fr);gap:20px}.queue-list{padding:8px 14px 18px}.queue-item{display:grid;grid-template-columns:36px 1fr auto;gap:12px;align-items:center;padding:14px 8px;border-bottom:1px solid #edf0f5}.queue-item:last-child{border-bottom:0}.queue-rank{width:30px;height:30px;display:grid;place-items:center;border-radius:8px;background:#eef4ff;color:var(--blue);font-weight:900}.queue-item b{display:block}.queue-item small{display:block;margin-top:4px;color:var(--muted)}.queue-status{font-size:11px;font-weight:900;padding:6px 9px;border-radius:999px;background:#f0f2f6;color:#68758b}.queue-status.in_progress{background:#e9f8f0;color:#0d7243}.queue-status.completed{background:#eaf1ff;color:#235db4}.event-table-wrap{overflow:auto;max-height:520px}table{width:100%;border-collapse:collapse;min-width:650px}th,td{text-align:left;padding:13px 15px;border-bottom:1px solid #edf0f5;font-size:13px}th{position:sticky;top:0;background:#f8fafc;color:#6b7589;font-size:11px;letter-spacing:.04em}td b{font-weight:850}.action-badge{display:inline-flex;border-radius:7px;background:#edf3ff;color:#245eb5;padding:5px 7px;font-weight:800}.empty-state{text-align:center;padding:52px 20px;color:var(--muted)}.empty-state h3{color:#35425a;margin-bottom:8px}.pulse-icon{margin:0 auto 16px;width:18px;height:18px;border-radius:50%;background:#9db7df;box-shadow:0 0 0 10px #edf3fb}.small-empty{text-align:center;padding:30px;color:var(--muted);display:none}footer{text-align:center;color:#8994a7;font-size:12px;padding:0 20px 28px}.hidden{display:none!important}
@media(max-width:1000px){.summary-grid{grid-template-columns:repeat(2,1fr)}.two-column{grid-template-columns:1fr}.topbar{padding:0 18px}.clock{display:none}main{padding:20px}.metrics{grid-template-columns:repeat(2,1fr)}}
@media(max-width:620px){.topbar{height:auto;min-height:78px;align-items:flex-start;padding:13px 14px}.brand img{width:40px;height:40px}.brand h1{font-size:17px}.brand p{font-size:11px}.top-actions{flex-wrap:wrap;justify-content:flex-end}.connection{font-size:11px;padding:7px 9px}.nav-btn{padding:8px 10px;font-size:12px}.summary-grid{grid-template-columns:1fr 1fr;gap:10px}.summary-card{padding:15px}.summary-card strong{font-size:30px}.live-cards{grid-template-columns:1fr;padding:12px}.machine-card{padding:16px}.machine-card h3{font-size:22px}.progress-row{grid-template-columns:1fr;gap:12px}.metrics{grid-template-columns:1fr 1fr}main{padding:13px}.head-meta{display:none}}
.production-dates{display:flex;gap:18px;flex-wrap:wrap;margin-top:14px;padding:10px 12px;border-radius:10px;background:#f4f7fb;color:#5f6d82;font-size:12px}.production-dates b{color:#2b3d58}
.factory-status-panel{margin-bottom:20px}.factory-status-body{display:grid;grid-template-columns:1.1fr repeat(4,minmax(140px,1fr));gap:14px;padding:20px 24px}.factory-main-status,.factory-stat{border:1px solid #e2e8f1;border-radius:14px;background:#fbfdff;padding:16px}.factory-main-status{display:flex;align-items:center;gap:14px}.factory-dot{width:18px;height:18px;border-radius:50%;background:#98a3b5;box-shadow:0 0 0 8px rgba(152,163,181,.12)}.factory-dot.work{background:#16a360;box-shadow:0 0 0 8px rgba(22,163,96,.13)}.factory-dot.break{background:#e49a17;box-shadow:0 0 0 8px rgba(228,154,23,.13)}.factory-dot.off{background:#7f8999}.factory-dot.overtime{background:#e56f1f;box-shadow:0 0 0 8px rgba(229,111,31,.13)}.factory-main-status strong{display:block;font-size:24px}.factory-main-status small,.factory-stat span{display:block;color:var(--muted);font-size:12px}.factory-stat b{display:block;margin-top:7px;font-size:20px}.factory-status-note{padding:0 24px 18px;color:var(--muted);font-size:12px}@media(max-width:1000px){.factory-status-body{grid-template-columns:repeat(2,1fr)}.factory-main-status{grid-column:1/-1}}@media(max-width:620px){.factory-status-body{grid-template-columns:1fr;padding:14px}.factory-main-status{grid-column:auto}}

/* V26：看板只顯示目前加工片數，不顯示百分比進度 */
.current-piece-row{display:flex;align-items:baseline;gap:14px;padding:18px 20px;border-radius:16px;background:#f5f8fc;margin:14px 0}
.current-piece-row span{font-size:14px;color:#667085;font-weight:700}
.current-piece-row strong{font-size:36px;line-height:1;color:#12365b}
.current-piece-row small{margin-left:auto;color:#667085;font-weight:700}

/* V28：看板聚焦公司、尺寸、目前片數與生產時間 */
.summary-grid-two{grid-template-columns:repeat(2,minmax(0,1fr));max-width:760px}
.factory-focus-grid{grid-template-columns:1.05fr 1.35fr 1.25fr 1fr 1.25fr}
.factory-company b{font-size:24px}
.factory-company small{display:block;margin-top:6px;color:var(--muted);font-weight:750}
.production-focus-card{padding:24px}
.production-focus-card .machine-card-head{align-items:center}
.production-focus-card h3{font-size:32px;margin:4px 0 6px;color:#12365b}
.field-label,.size-display span,.live-focus-item span{display:block;color:var(--muted);font-size:12px;font-weight:800}
.order-reference{color:var(--muted);font-size:14px;font-weight:750}
.size-display{margin-top:18px;padding:17px 18px;border:1px solid #e2e8f1;border-radius:14px;background:#f7f9fc}
.size-display b{display:block;margin-top:6px;font-size:25px;color:#253a5c}
.live-focus-metrics{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px}
.live-focus-item{border-radius:16px;background:#edf4ff;border:1px solid #dbe7f8;padding:19px 20px}
.live-focus-item strong{display:block;margin-top:7px;font-size:34px;line-height:1.15;color:var(--blue);font-variant-numeric:tabular-nums}
.live-focus-item small{display:block;margin-top:8px;color:var(--muted);font-weight:700}
.duration-item{background:#f3f7f4;border-color:#dfeae2}
.duration-item strong{color:#127247}
@media(max-width:1200px){.factory-focus-grid{grid-template-columns:repeat(2,1fr)}.factory-main-status{grid-column:1/-1}}
@media(max-width:700px){.summary-grid-two{grid-template-columns:1fr 1fr}.live-focus-metrics{grid-template-columns:1fr}.production-focus-card h3{font-size:27px}.size-display b{font-size:21px}.live-focus-item strong{font-size:29px}}

/* Combined live production status */
.live-panel-first{margin-top:0}
.live-panel-head{gap:20px}
.live-head-right{display:flex;align-items:center;gap:18px}
.live-shift-status{min-width:210px;padding:11px 15px;border-radius:12px}
.live-shift-status strong{font-size:20px}
@media(max-width:760px){.live-panel-head{align-items:flex-start}.live-head-right{align-items:flex-end;flex-direction:column}.live-shift-status{min-width:180px}}

.current-operation{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-top:14px;padding:13px 15px;border:1px solid #e1e8f2;border-radius:13px;background:#fff}.current-operation span{color:var(--muted);font-size:12px;font-weight:800}.current-operation b{color:#17345f;font-size:15px}


/* ===== v3.21：所有即時看板顯示完整件數、PLC、ADAM/KTC ===== */
.production-command-card{padding:0;overflow:hidden;border:0;background:#fff}
.command-order-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;padding:20px 22px;background:linear-gradient(135deg,#082f68,#0b57bd);color:#fff}
.command-eyebrow{font-size:10px;font-weight:900;letter-spacing:.15em;opacity:.7}
.command-order-head h3{margin:4px 0 5px;font-size:30px;color:#fff}
.command-order-head p{margin:0;color:rgba(255,255,255,.78);font-weight:700}
.command-status{min-width:180px;padding:11px 14px;border-radius:13px;background:rgba(255,255,255,.13);text-align:right}
.command-status span{display:block;font-size:19px;font-weight:950}
.command-status small{display:block;margin-top:5px;color:rgba(255,255,255,.72)}
.command-status.offline{background:rgba(205,55,55,.28)}
.command-main-grid{display:grid;grid-template-columns:minmax(440px,1.05fr) minmax(520px,.95fr);min-height:420px}
.command-progress,.command-machine{padding:18px 20px}
.command-progress{border-right:1px solid #e2e8f1}
.command-current{padding:16px;border-radius:14px;background:#eef5ff;border:1px solid #bfd7f6}
.command-current span,.command-total span{display:block;color:#627995;font-size:12px;font-weight:900}
.command-current strong{display:block;margin-top:6px;color:#123e77;font-size:28px}
.command-current b{display:block;margin-top:5px;color:#075dc5;font-size:37px}
.command-total{display:grid;grid-template-columns:1fr auto;align-items:end;gap:8px;margin:12px 0}
.command-total strong{font-size:30px;color:#173b68}
.command-total .bar{grid-column:1/-1}
.dash-bundles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;max-height:225px;overflow:auto}
.dash-bundle{display:grid;gap:3px;padding:10px;border-radius:11px;border:1px solid #d9e2ed;background:#f7f9fc}
.dash-bundle span{font-size:11px;color:#6d7f94;font-weight:900}
.dash-bundle b{font-size:14px;color:#173b68}
.dash-bundle small{font-size:11px;color:#7a899b}
.dash-bundle.completed{background:#eaf8ef;border-color:#a7d8b7}
.dash-bundle.completed small{color:#10703a;font-weight:900}
.dash-bundle.current{background:#eaf3ff;border:2px solid #4b91df}
.dash-bundle.current small{color:#075dc5;font-weight:900}
.command-section-title{margin:2px 0 8px;color:#173b68;font-size:13px;font-weight:950;letter-spacing:.04em}
.dash-machine-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.dash-machine-grid>div{padding:10px;border-radius:11px;border:1px solid #e0e7ef;background:#f8fafc}
.dash-machine-grid span{display:block;color:#718196;font-size:10px;font-weight:850}
.dash-machine-grid strong{display:block;margin-top:5px;color:#173b68;font-size:16px;overflow-wrap:anywhere}
.dash-alarm{margin:9px 0 12px;padding:9px 11px;border-radius:10px;background:#edf8f1;color:#13703a;font-weight:850;font-size:12px}
.dash-alarm.active{background:#ffe9e5;color:#9c2d25}
.dash-ktc-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.dash-ktc{padding:11px;border-radius:11px;background:#f5f8fc;border:1px solid #dfe7f0}
.dash-ktc span{display:block;color:#62758d;font-size:10px;font-weight:900}
.dash-ktc strong{display:block;margin-top:5px;color:#075dc5;font-size:22px}
.dash-ktc small{display:block;margin-top:4px;color:#74849a;font-size:10px}
.command-foot{display:flex;justify-content:space-between;gap:14px;padding:10px 20px;border-top:1px solid #e9edf3;background:#f9fbfd;color:#687990;font-size:11px}
.tv-dashboard{background:#07182f;color:#14213d;overflow:hidden}
.tv-dashboard .tv-topbar{height:72px;background:#071d3d;border-bottom-color:#173c6c;color:#fff}
.tv-dashboard .brand h1,.tv-dashboard .brand p,.tv-dashboard .clock{color:#fff}
.tv-dashboard .tv-main{max-width:none;height:calc(100vh - 72px);padding:12px 16px;display:grid;grid-template-rows:minmax(0,1fr) 132px;gap:10px}
.tv-dashboard .tv-live-panel{margin:0;min-height:0;display:flex;flex-direction:column}
.tv-dashboard .tv-live-panel .panel-head{padding:10px 16px 8px}
.tv-dashboard .tv-live-panel .live-cards{padding:10px;min-height:0;flex:1}
.tv-dashboard .production-command-card{height:100%;display:flex;flex-direction:column}
.tv-dashboard .command-order-head{padding:12px 16px}
.tv-dashboard .command-order-head h3{font-size:27px}
.tv-dashboard .command-main-grid{grid-template-columns:1.05fr .95fr;min-height:0;flex:1}
.tv-dashboard .command-progress,.tv-dashboard .command-machine{padding:11px 13px;overflow:hidden}
.tv-dashboard .command-current{padding:10px}
.tv-dashboard .command-current strong{font-size:22px}
.tv-dashboard .command-current b{font-size:30px}
.tv-dashboard .command-total{margin:7px 0}
.tv-dashboard .command-total strong{font-size:23px}
.tv-dashboard .dash-bundles{max-height:155px;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.tv-dashboard .dash-bundle{padding:7px}
.tv-dashboard .dash-machine-grid>div{padding:7px}
.tv-dashboard .dash-ktc{padding:7px}
.tv-dashboard .dash-ktc strong{font-size:18px}
.tv-bottom-strip{display:grid;grid-template-columns:160px 160px 1fr;gap:10px;min-height:0}
.tv-bottom-strip .summary-card{margin:0;padding:14px}
.tv-bottom-strip .summary-card strong{font-size:42px}
.tv-queue{min-height:0}
.tv-queue .panel-head{padding:8px 12px 5px}
.tv-queue .queue-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;padding:5px 10px 8px;overflow:hidden}
.tv-queue .queue-item{grid-template-columns:26px 1fr;padding:6px;border:1px solid #edf0f5;border-radius:8px}
.tv-queue .queue-item:nth-child(n+4){display:none}
.tv-queue .queue-status{display:none}
.tv-queue .queue-rank{width:24px;height:24px}
.tv-queue .queue-item small{font-size:9px;margin-top:2px}
@media(max-width:1100px){
  .command-main-grid{grid-template-columns:1fr}
  .command-progress{border-right:0;border-bottom:1px solid #e2e8f1}
  .dash-bundles{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dash-machine-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

.dash-head-cut{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 15px;border-bottom:1px solid #dbe6f2;background:#fff7df;color:#715300}
.dash-head-cut.done{background:#e9f8ef;color:#126e38}
.dash-head-cut b{font-size:12px}.dash-head-cut span{font-size:12px;font-weight:850}

/* v14: rough coil uses elapsed processing time instead of piece-count progress */
.rough-time-progress{display:block!important}
.rough-time-card{min-height:170px;display:flex;flex-direction:column;justify-content:center}
.rough-time-card strong{font-size:clamp(28px,3.2vw,46px)!important}
.rough-time-card b{font-size:clamp(34px,4vw,58px)!important;line-height:1.08}
