/* 登入後的畫面：手機（主辦在工地）優先，電腦（品保）也好用。不用 flex gap（工地老平板 Chrome 79 不支援）。 */
:root {
  --bg: #F2F4F6; --panel: #fff; --ink: #15233F; --muted: #5A6577; --line: #D3DAE2; --soft: #E9EEF4;
  --blue: #1D5BB8; --blue-soft: #E3ECF8; --green: #2E7D4F; --green-soft: #E6F4EA; --red: #C0392B; --red-soft: #FBE9E7;
  --orange: #B35C00; --orange-soft: #FFF1DD; --gray-soft: #ECEFF3; --signal: #F3C318; --navy: #15233F;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1724; --panel: #172236; --ink: #E6ECF4; --muted: #9AA7BA; --line: #2A3850; --soft: #1D2A40;
    --blue: #6EA4F2; --blue-soft: #1B2D4A; --green: #6CC28E; --green-soft: #17301F; --red: #F08A7E; --red-soft: #3A1E1B;
    --orange: #F0B060; --orange-soft: #3A2A14; --gray-soft: #222E42; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1724; --panel: #172236; --ink: #E6ECF4; --muted: #9AA7BA; --line: #2A3850; --soft: #1D2A40;
  --blue: #6EA4F2; --blue-soft: #1B2D4A; --green: #6CC28E; --green-soft: #17301F; --red: #F08A7E; --red-soft: #3A1E1B;
  --orange: #F0B060; --orange-soft: #3A2A14; --gray-soft: #222E42; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
body.noscroll { overflow: hidden; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; }

/* 上方 */
.top { background: var(--navy); color: #fff; border-bottom: 4px solid var(--signal); position: sticky; top: 0; z-index: 20; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; max-width: 1080px; margin: 0 auto; }
.brand { color: #fff; font-weight: 900; font-size: 19px; text-decoration: none; letter-spacing: .04em; }
.who { color: #C9D6EA; font-size: 14px; margin-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 10px 8px; max-width: 1080px; margin: 0 auto; white-space: nowrap; }
.nav-item { flex: 0 0 auto; color: #DDE6F3; text-decoration: none; padding: 6px 12px; margin: 0 3px; border-radius: 999px; font-weight: 700; font-size: 15px; }
.nav-item.on { background: #fff; color: var(--navy); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 5px; border-radius: 10px; background: var(--signal); color: #15233F; font-size: 12px; line-height: 20px; text-align: center; }
.loading { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 100; background: linear-gradient(90deg, var(--signal) 30%, transparent 30%); background-size: 200% 100%; animation: load 1s linear infinite; }
@keyframes load { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.wrap { max-width: 1080px; margin: 0 auto; padding: 14px 16px 40px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 0 16px 30px; color: var(--muted); font-size: 13px; }
.banner { padding: 10px 16px; font-weight: 700; }
.banner.warn { background: var(--orange-soft); color: var(--orange); border-left: 6px solid var(--orange); }
.banner.red { background: var(--red-soft); color: var(--red); border-left: 6px solid var(--red); border-radius: 8px; margin: 10px 0; }
.banner ul { margin: 6px 0 0; padding-left: 20px; font-weight: 400; }
.msg { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-weight: 700; background: var(--red-soft); color: var(--red); border-left: 6px solid var(--red); white-space: pre-line; }
.msg.ok { background: var(--green-soft); color: var(--green); border-left-color: var(--green); }
.msg.warn { background: var(--orange-soft); color: var(--orange); border-left-color: var(--orange); }

.title { font-size: 22px; margin: 6px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; }
.card-title { font-size: 18px; margin: 0 0 10px; }
.link-card { display: block; color: inherit; text-decoration: none; }
.link-card:hover, .link-card:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.row-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-between > * { margin-right: 8px; }
.row-between > *:last-child { margin-right: 0; }
.line { margin: 4px 0; }
.big { font-size: 18px; }
.muted { color: var(--muted); }
p.muted { margin: 6px 0; font-size: 14px; }
.small { font-size: 13px; }
.block { display: block; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.red { color: var(--red); }
.green { color: var(--green); font-weight: 700; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.faded { opacity: .55; }
.crumbs { margin: 0 0 6px; }
.sub-title { font-size: 16px; margin: 14px 0 6px; color: var(--muted); }
.sub-item { display: inline-block; margin-right: 10px; }
.done-line { color: var(--green); font-weight: 700; margin: 4px 0; }
.todo { color: var(--orange); font-weight: 700; margin: 6px 0; }

/* 標籤 */
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--gray-soft); color: var(--muted); white-space: nowrap; vertical-align: 1px; margin-left: 4px; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.small-pill { font-size: 12px; }

/* 按鈕 */
.btn { display: inline-block; min-height: 44px; padding: 9px 16px; border-radius: 10px; border: 2px solid transparent; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none; line-height: 1.4; vertical-align: middle; background: none; }
.btn:disabled, .btn.busy { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.line { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn.line.danger { color: var(--red); }
.btn.link { min-height: 36px; padding: 4px 8px; color: var(--blue); border: none; background: none; font-weight: 700; }
.btn.link.danger { color: var(--red); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 14px; }
.btn.big { min-height: 56px; font-size: 18px; padding: 12px 22px; }
.btn.block { display: block; width: 100%; margin: 8px 0; }
.btn-row { margin: 6px -4px; }
.btn-row > .btn { margin: 4px; }
.card > .btn { margin: 4px 8px 4px 0; }
.file-btn { position: relative; overflow: hidden; margin: 8px 0 2px; }
.file-hidden { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* 表單 */
.input { display: block; width: 100%; min-height: 44px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 16px; }
.input:focus { outline: none; border-color: var(--blue); }
.input.inline { display: inline-block; width: auto; max-width: 100%; min-height: 40px; }
.small-input { font-size: 13px; min-height: 36px; margin-top: 8px; color: var(--muted); }
.field { display: block; margin-bottom: 12px; }
.lab { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.help { display: block; color: var(--muted); margin-top: 3px; }
.check { display: block; margin: 10px 0; font-weight: 700; }
.check input { width: 20px; height: 20px; vertical-align: -4px; margin-right: 4px; }
.filters { margin: 4px 0 12px; }
.filters > * { margin: 0 12px 8px 0; display: inline-block; vertical-align: middle; }
.filters .input.inline { min-width: 140px; }

/* 包商 */
.chips { margin: 0 0 8px; }
.chip { display: inline-block; padding: 4px 6px 4px 12px; margin: 0 6px 6px 0; border-radius: 999px; background: var(--blue-soft); color: var(--ink); font-weight: 700; font-size: 15px; }
.chip small { color: var(--muted); font-weight: 400; }
.chip-x { border: none; background: none; color: var(--red); font-size: 18px; line-height: 1; padding: 0 6px; cursor: pointer; }
.vresults { margin: 6px 0; max-height: 360px; overflow-y: auto; }
.vrow { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.vrow.on { border-color: var(--blue); background: var(--blue-soft); }
.vname { font-weight: 700; }
.vtax { color: var(--muted); font-size: 13px; margin-left: 8px; white-space: nowrap; }

/* 堂 */
.day-row { display: flex; align-items: center; flex-wrap: wrap; margin: 0 -4px 8px; }
.day-row > * { margin: 0 4px 6px; }
.day-row .input { flex: 1 1 140px; width: auto; }
.day-row .field { flex: 1 1 140px; }
.day-no { font-weight: 700; min-width: 56px; }
.day-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--soft); }
.day-line:last-child { border-bottom: none; }
.day-main { margin: 2px 8px 2px 0; }
.day-actions > * { margin: 2px 0 2px 6px; }
.pick-line { display: flex; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--soft); cursor: pointer; }
.pick-line input { width: 22px; height: 22px; margin: 2px 12px 0 0; flex: 0 0 auto; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { padding: 8px 8px; border-bottom: 1px solid var(--soft); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--bg); }
.table td.center, .table th.center { text-align: center; }
.table td.num, .table th.num { text-align: right; }
.table tr.faded td { opacity: .55; }
.table input[type=checkbox] { width: 20px; height: 20px; }

/* 照片、簽名 */
.thumbs { display: flex; flex-wrap: wrap; margin: 0 -5px; }
.thumb-box { margin: 0 5px 10px; width: 150px; }
.thumb { display: block; width: 150px; height: 112px; object-fit: cover; border-radius: 8px; background: var(--soft); cursor: zoom-in; }
.thumb-box figcaption { font-size: 12px; color: var(--muted); margin-top: 3px; }
.sig { display: block; max-width: 280px; max-height: 110px; background: #fff; border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; }
.small-sig { max-width: 140px; max-height: 56px; margin: 4px 8px; display: inline-block; vertical-align: middle; }

/* 簽到名單 */
.att { margin: 0; padding-left: 26px; }
.att li { padding: 7px 0; border-bottom: 1px solid var(--soft); }
.att li.removed .att-main b { text-decoration: line-through; color: var(--muted); }
.att-main { display: inline-block; vertical-align: middle; }

/* QR */
.qr-box { display: flex; align-items: center; flex-wrap: wrap; }
.qr-img { width: 220px; height: 220px; background: #fff; border-radius: 8px; margin: 0 16px 10px 0; cursor: zoom-in; }
.qr-side { flex: 1 1 200px; }
.qr-code { font-size: 34px; font-weight: 900; letter-spacing: .12em; margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.qr-full { text-align: center; color: #15233F; }
.qr-full img { width: 80vmin; height: 80vmin; max-width: 560px; max-height: 560px; }
.qr-full p { margin: 6px 0; font-size: 20px; font-weight: 700; }
.qr-full .qr-code { font-size: 40px; }

/* 對話框 */
.modal-bg { position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(10, 18, 32, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 12px; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 460px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal-card.wide { max-width: 640px; }
.modal-title { font-size: 19px; margin: 0 0 10px; }
.modal-text { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; margin: 14px -4px 0; }
.modal-actions .btn { margin: 4px; }
.padbox { position: relative; }
.pad { display: block; width: 100%; height: 240px; background: #fff; border: 3px solid #15233F; border-radius: 10px; touch-action: none; }
.padhint { position: absolute; left: 0; right: 0; top: 104px; text-align: center; color: #9AA3AF; pointer-events: none; font-size: 18px; }
.viewer { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 60; background: rgba(0, 0, 0, .9); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; color: #fff; }
.viewer.light { background: #fff; color: #15233F; }
.viewer img { max-width: 100%; max-height: 82vh; }
.viewer p { margin: 8px 0; }
.viewer-close { margin-top: 12px; }

/* 登入 */
.login { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; background: var(--navy); }
.login-card { background: var(--panel); border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 420px; border-top: 6px solid var(--signal); }
.login-card h1 { margin: 0 0 16px; font-size: 26px; }
.login-card h1 span { display: block; font-size: 15px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.forgot { margin-top: 16px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 10px; border-top: 1px solid var(--line); line-height: 0; }
.or span { background: var(--panel); padding: 0 10px; }
.ts { margin-top: 12px; }

@media (min-width: 760px) {
  .title { font-size: 26px; }
  .thumb-box, .thumb { width: 180px; }
  .thumb { height: 135px; }
}
