/* ───────────── 設計基準 ───────────── */
:root {
  --paper: #EEF1F3;
  --surface: #FFFFFF;
  --sunken: #F6F8F9;
  --ink: #17202A;
  --steel: #586472;
  --faint: #8A95A1;
  --line: #D5DBE0;
  --line-strong: #B9C2CA;
  --blue: #0A5BA8;
  --blue-dark: #084A89;
  --blue-wash: #E6EFF8;
  --yellow: #F6C343;
  --yellow-wash: #FEF6DD;
  --green: #1F9D55;
  --green-wash: #E5F5EC;
  --amber: #C27A00;
  --amber-lamp: #F2A900;
  --amber-wash: #FDF1DC;
  --red: #D33A2C;
  --red-wash: #FBE8E6;
  --lamp-off: #D9DEE3;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(23, 32, 42, .06), 0 2px 8px rgba(23, 32, 42, .05);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --font-code: "Barlow Condensed", "Noto Sans TC", sans-serif;
  --hazard: repeating-linear-gradient(-45deg, var(--yellow) 0 10px, var(--ink) 10px 20px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--steel); }
.small { font-size: 13px; }
.code { font-family: var(--font-code); font-weight: 600; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack > * + * { margin-top: 14px; }

/* ───────────── 安燈燈塔（招牌元素） ───────────── */
.andon { display: inline-flex; flex-direction: column; gap: 3px; padding: 4px; background: var(--ink); border-radius: 5px; flex: none; }
.andon i { display: block; width: 12px; height: 9px; border-radius: 2px; background: #3A4552; }
.andon.s-down i:nth-child(1) { background: var(--red); box-shadow: 0 0 8px var(--red); }
.andon.s-warning i:nth-child(2) { background: var(--amber-lamp); box-shadow: 0 0 8px var(--amber-lamp); }
.andon.s-normal i:nth-child(3) { background: var(--green); box-shadow: 0 0 6px var(--green); }
.andon.s-down i:nth-child(1) { animation: lamp 1.1s steps(2) infinite; }
@keyframes lamp { 50% { background: #5a2420; box-shadow: none; } }
.andon-lg { gap: 6px; padding: 8px; border-radius: 9px; }
.andon-lg i { width: 34px; height: 24px; border-radius: 4px; }
.andon.is-cycling i { animation: cycle 2.4s infinite; }
.andon.is-cycling i:nth-child(1) { animation-delay: 0s; --c: var(--red); }
.andon.is-cycling i:nth-child(2) { animation-delay: .8s; --c: var(--amber-lamp); }
.andon.is-cycling i:nth-child(3) { animation-delay: 1.6s; --c: var(--green); }
@keyframes cycle { 0%, 30% { background: var(--c); box-shadow: 0 0 14px var(--c); } 34%, 100% { background: #3A4552; box-shadow: none; } }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--steel); }

/* ───────────── 按鈕與表單 ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--sunken); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b52f23; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(23, 32, 42, .06); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 56px; font-size: 18px; padding: 0 26px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 700; cursor: pointer; }

.field { display: block; }
.field > span { display: block; font-size: 14px; font-weight: 700; color: var(--steel); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 7px; background: transparent; font-weight: 700; color: var(--steel); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* 標籤 */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 700; white-space: nowrap; line-height: 1.6; }
.tag-green { background: var(--green-wash); color: #17703e; }
.tag-amber { background: var(--amber-wash); color: #8a5600; }
.tag-red { background: var(--red-wash); color: #a8261b; }
.tag-blue { background: var(--blue-wash); color: var(--blue-dark); }
.tag-grey { background: #E8ECEF; color: var(--steel); }
.tag-law { background: var(--ink); color: var(--yellow); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot-normal { background: var(--green); } .dot-warning { background: var(--amber-lamp); } .dot-down { background: var(--red); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 16px; }
.empty { padding: 36px 18px; text-align: center; color: var(--steel); }

/* ───────────── 登入頁 ───────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.login-side {
  background: var(--ink); color: #E8ECEF; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 72px;
  position: relative; overflow: hidden;
}
.login-side::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--hazard); }
.login-brand { display: flex; gap: 22px; align-items: flex-start; }
.login-brand h1 { font-size: clamp(30px, 3.4vw, 44px); font-weight: 900; color: #fff; letter-spacing: .02em; }
.login-brand p { margin: 8px 0 0; color: #AAB4BE; font-size: 17px; max-width: 30em; }
.login-flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; max-width: 30em; }
.login-flow li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.login-flow b { font-family: var(--font-code); font-size: 28px; line-height: 1; color: var(--yellow); }
.login-flow strong { display: block; color: #fff; }
.login-flow span { color: #AAB4BE; font-size: 14px; }
.login-main { display: grid; place-items: center; padding: 40px 24px; }
.login-box { width: 100%; max-width: 400px; }
.login-box h2 { font-size: 24px; font-weight: 900; margin-bottom: 4px; }
.login-box .seg { margin: 22px 0; }
.login-error { background: var(--red-wash); color: #a8261b; padding: 10px 12px; border-radius: var(--r-sm); font-weight: 500; font-size: 14px; }
.demo-accounts { margin-top: 24px; border-top: 1px dashed var(--line-strong); padding-top: 16px; }
.demo-accounts p { margin: 0 0 8px; font-size: 13px; color: var(--steel); }
.demo-accounts .chip { font-family: var(--font-code); font-size: 15px; font-weight: 600; }
.mode-note { margin-top: 18px; font-size: 13px; color: var(--steel); background: var(--yellow-wash); padding: 8px 10px; border-radius: var(--r-sm); }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 28px 22px 34px; }
  .login-flow { display: none; }
  .login-brand .andon-lg { gap: 4px; padding: 6px; } .login-brand .andon-lg i { width: 22px; height: 15px; }
  .login-brand p { font-size: 15px; }
  .login-main { place-items: start center; padding-top: 28px; }
}

/* ───────────── 共用頂列 ───────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand strong { font-size: 17px; font-weight: 900; letter-spacing: .02em; }
.brand small { display: block; font-size: 12px; color: var(--steel); font-weight: 500; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--sunken); cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--yellow); display: grid; place-items: center; font-weight: 900; font-size: 14px; flex: none; }
.user-chip .who { font-size: 14px; font-weight: 700; line-height: 1.2; }
.user-chip .who small { display: block; font-weight: 500; color: var(--steel); font-size: 12px; }
.menu { position: absolute; right: 12px; top: 58px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(23,32,42,.14); padding: 6px; min-width: 200px; z-index: 50; }
.menu button, .menu a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; color: var(--ink); text-decoration: none; font-weight: 500; }
.menu button:hover, .menu a:hover { background: var(--sunken); }
.offline-pill { font-size: 12px; font-weight: 700; color: #8a5600; background: var(--yellow-wash); border: 1px solid #f0d58a; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }

/* ───────────── 現場前台 ───────────── */
.staff { max-width: 1180px; margin: 0 auto; padding: 18px 16px 120px; }
.staff-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.staff-head h1 { font-size: 24px; font-weight: 900; }
.progress-line { font-size: 14px; color: var(--steel); }
.progress-line b { font-family: var(--font-code); font-size: 22px; color: var(--ink); }
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar .input { padding-left: 40px; }
.searchbar::before { content: "⌕"; position: absolute; left: 13px; top: 8px; font-size: 22px; color: var(--faint); }

.machine-list { display: grid; gap: 10px; margin-top: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .machine-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1080px) { .machine-list { grid-template-columns: 1fr 1fr 1fr; } }
.mrow {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; text-align: left; width: 100%;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); cursor: pointer; color: inherit; text-decoration: none;
}
.mrow:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.mrow.st-down { border-left: 5px solid var(--red); }
.mrow.st-warning { border-left: 5px solid var(--amber-lamp); }
.mrow-code { font-family: var(--font-code); font-weight: 700; font-size: 24px; line-height: 1; letter-spacing: .02em; }
.mrow-name { font-weight: 700; font-size: 15px; margin-top: 3px; }
.mrow-meta { font-size: 13px; color: var(--steel); }
.mrow .row-wrap { margin-top: 8px; gap: 6px; }

/* 機台銘牌 */
.plate {
  position: relative; background: linear-gradient(180deg, #fff, #F3F5F7); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
}
.plate::before, .plate::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #9aa5b0); top: 10px; }
.plate::before { left: 10px; } .plate::after { right: 10px; }
.plate-code { font-family: var(--font-code); font-weight: 700; font-size: 44px; line-height: .95; letter-spacing: .02em; }
.plate-name { font-size: 19px; font-weight: 900; margin-top: 4px; }
.plate-meta { margin-top: 8px; }
.plate-status { text-align: center; display: grid; justify-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--steel); text-decoration: none; font-weight: 700; }
.back:hover { color: var(--ink); }

.detail-grid { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 980px) { .detail-grid { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); align-items: start; } }

.check-item { padding: 16px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.check-item:last-child { border-bottom: 0; }
.check-item.is-bad { background: var(--red-wash); }
.ci-title { font-weight: 700; font-size: 16px; }
.ci-std { font-size: 13px; color: var(--steel); }
.okng { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.okng button { min-height: 52px; border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); font-weight: 900; font-size: 17px; cursor: pointer; }
.okng button.on-ok { border-color: var(--green); background: var(--green-wash); color: #17703e; }
.okng button.on-ng { border-color: var(--red); background: var(--red); color: #fff; }
.num-in { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.num-in .input { font-family: var(--font-code); font-size: 26px; font-weight: 600; min-height: 54px; }
.num-in .input::placeholder { font-family: var(--font); font-size: 16px; font-weight: 400; }
.num-in .unit { font-weight: 700; color: var(--steel); min-width: 3em; }
.num-flag { font-size: 13px; font-weight: 700; }
.num-flag.ok { color: var(--green); } .num-flag.ng { color: var(--red); }

.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-pick label { cursor: pointer; }
.photo-thumb { width: 84px; height: 84px; border-radius: var(--r-md); object-fit: cover; border: 1px solid var(--line); }
.sev-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sev-pick button { text-align: left; padding: 12px 14px; border-radius: var(--r-md); border: 2px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.sev-pick button b { display: block; font-size: 16px; }
.sev-pick button span { font-size: 13px; color: var(--steel); }
.sev-pick button.on-warning { border-color: var(--amber-lamp); background: var(--amber-wash); }
.sev-pick button.on-critical { border-color: var(--red); background: var(--red-wash); }
.abn-box { padding: 16px 18px; background: var(--red-wash); border-top: 1px solid #f2c2bd; }
.abn-box h4 { color: #a8261b; margin-bottom: 10px; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.submit-bar .inner { max-width: 1180px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.submit-bar .hint { font-size: 14px; color: var(--steel); }

.done { text-align: center; padding: 40px 20px; }
.done .big { font-size: 64px; line-height: 1; }
.done h2 { font-size: 26px; font-weight: 900; margin: 12px 0 6px; }

/* 時間軸 */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 12px 18px 12px 46px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { position: absolute; left: 14px; top: 13px; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; }
.tl-ins { background: var(--green-wash); } .tl-ins.bad { background: var(--red-wash); }
.tl-mt { background: var(--blue-wash); } .tl-wo { background: var(--amber-wash); }
.tl-when { font-size: 12px; color: var(--faint); }
.tl-title { font-weight: 700; font-size: 15px; }
.tl-body { font-size: 14px; color: var(--steel); }
.tl-answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 14px; margin-top: 6px; font-size: 13px; }
.tl-answers .ng { color: var(--red); font-weight: 700; }

/* ───────────── 管理後台 ───────────── */
.admin { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.nav { padding: 10px; display: grid; gap: 2px; overflow-y: auto; }
.nav-group { font-size: 12px; color: var(--faint); font-weight: 700; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 15px; }
.nav a:hover { background: var(--sunken); }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.nav a .ico { width: 22px; text-align: center; }
.nav a .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; padding: 0 7px; border-radius: 999px; line-height: 20px; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.main { min-width: 0; }
.admin-top { position: sticky; top: 0; z-index: 30; background: rgba(238,241,243,.94); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.admin-top h1 { font-size: 20px; font-weight: 900; }
.page { padding: 20px 24px 60px; max-width: 1500px; }
.menu-toggle { display: none; }
.sound-btn[aria-pressed="false"] { border-color: var(--amber-lamp); background: var(--yellow-wash); }
@media (max-width: 980px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(23,32,42,.4); z-index: 55; }
  .menu-toggle { display: inline-flex; }
  .admin-top { padding: 10px 14px; }
  .admin-top h1 { font-size: 17px; }
  .page { padding: 14px 14px 60px; }
  .hide-m { display: none !important; }
}

/* 警報橫幅 */
.alarm {
  margin: 0 0 16px; border-radius: var(--r-lg); overflow: hidden; background: var(--surface);
  border: 2px solid var(--ink); box-shadow: 0 6px 20px rgba(211,58,44,.18);
}
.alarm-stripe { height: 10px; background: var(--hazard); animation: slide 1s linear infinite; background-size: 28px 28px; }
@keyframes slide { to { background-position: 28px 0; } }
.alarm-body { display: flex; gap: 14px; align-items: center; padding: 12px 16px; flex-wrap: wrap; }
.alarm-body .andon { transform: scale(1.1); }
.alarm-text { flex: 1; min-width: 220px; }
.alarm-text strong { font-size: 17px; display: block; }
.alarm-text span { font-size: 14px; color: var(--steel); }
.alarm-more { font-size: 13px; color: var(--steel); padding: 0 16px 12px; }

/* 總覽 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-num { font-family: var(--font-code); font-weight: 700; font-size: 40px; line-height: 1; }
.stat-num small { font-size: 22px; color: var(--faint); font-weight: 600; }
.stat-label { font-size: 14px; color: var(--steel); font-weight: 700; margin-top: 6px; }
.stat-sub { font-size: 13px; color: var(--faint); }
.stat.is-red .stat-num { color: var(--red); } .stat.is-amber .stat-num { color: var(--amber); }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } .stat:nth-child(2) { border-right: 0; } .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); } .stat-num { font-size: 32px; } }

.ov-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; }
@media (max-width: 1180px) { .ov-grid { grid-template-columns: 1fr; } }
.floor { padding: 6px 18px 18px; display: flex; flex-wrap: wrap; gap: 4px 22px; }
.floor-group { margin-top: 12px; }
.floor-group h4 { font-size: 13px; color: var(--steel); font-weight: 700; margin-bottom: 8px; }
.floor-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.floor-tiles .tile { width: 158px; }
@media (max-width: 560px) { .floor-group { width: 100%; } .floor-tiles .tile { width: calc(50% - 4px); } }
.tile { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--sunken); text-decoration: none; color: inherit; }
.tile:hover { border-color: var(--line-strong); background: var(--surface); }
.tile.st-down { background: var(--red-wash); border-color: #f2c2bd; }
.tile.st-warning { background: var(--amber-wash); border-color: #f1d9a8; }
.tile .andon i { width: 10px; height: 7px; }
.tile-code { font-family: var(--font-code); font-weight: 700; font-size: 19px; line-height: 1; }
.tile-name { font-size: 12px; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--steel); flex-wrap: wrap; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow strong { display: block; font-size: 15px; }
.feed-time { font-family: var(--font-code); font-size: 15px; color: var(--faint); min-width: 3.2em; }

.trend { padding: 14px 18px 10px; }
.trend svg { width: 100%; height: auto; display: block; }

/* 表格 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 150px; }
.toolbar .field > span { font-size: 12px; margin-bottom: 4px; }
.toolbar .input, .toolbar .select { min-height: 40px; padding: 6px 10px; font-size: 15px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 13px; color: var(--steel); font-weight: 700; padding: 10px 14px; background: var(--sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #FAFBFC; }
.tbl .code { font-size: 17px; }
.tbl td.num { text-align: right; font-family: var(--font-code); font-size: 17px; font-weight: 600; }
.tbl tr.expand td { background: var(--sunken); }
.count-note { font-size: 13px; color: var(--steel); margin: 10px 2px 0; }

/* 工單看板分頁 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 700; cursor: pointer; font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs button em { font-style: normal; font-family: var(--font-code); font-size: 16px; margin-left: 4px; }
.wo-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 16px; }
.wo-steps div { text-align: center; font-size: 13px; font-weight: 700; color: var(--faint); padding: 8px 4px; border-top: 4px solid var(--lamp-off); }
.wo-steps div.done { color: var(--ink); border-top-color: var(--blue); }
.wo-steps div.now { color: var(--blue); border-top-color: var(--blue); }

/* 機台管理 */
.mgr { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .mgr { grid-template-columns: 1fr; } }
.mgr-list { max-height: calc(100vh - 170px); overflow-y: auto; }
.mgr-list button { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 14px; cursor: pointer; }
.mgr-list button[aria-current="true"] { background: var(--blue-wash); }
.item-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.move { display: grid; gap: 2px; }
.move button { border: 1px solid var(--line); background: var(--surface); border-radius: 4px; width: 26px; height: 20px; font-size: 10px; cursor: pointer; line-height: 1; }

.qr-box { display: grid; justify-items: center; gap: 10px; text-align: center; }
.qr-box svg { width: 100%; max-width: 280px; height: auto; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); }
.qr-big svg { max-width: 520px; }
.url-text { font-family: var(--font-code); font-size: 16px; word-break: break-all; color: var(--steel); }
.tools-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

/* ───────────── 彈窗與提示 ───────────── */
.modal-scrim { position: fixed; inset: 0; background: rgba(23,32,42,.5); z-index: 80; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 18px; font-weight: 900; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.x-btn { border: 0; background: var(--sunken); width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.kv { display: grid; grid-template-columns: 7em 1fr; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--steel); font-weight: 700; }
.kv dd { margin: 0; }
.photo-full { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); }

#toast-root { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 15px; display: flex; gap: 10px; align-items: flex-start; animation: pop .2s ease-out; }
.toast.t-ok { border-left: 5px solid var(--green); }
.toast.t-warn { border-left: 5px solid var(--yellow); }
.toast.t-err { border-left: 5px solid var(--red); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 720px) { #toast-root { left: 16px; right: 16px; bottom: 90px; } }

@media print {
  .side, .admin-top, .no-print, #toast-root { display: none !important; }
  .admin { display: block; } body { background: #fff; }
  .print-qr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .print-qr .card { break-inside: avoid; }
}
