:root {
  --ink: #15324a; --muted: #5a6f7e; --line: #dbe3e5; --soft: #f4f7f7; --bg: #eef3f4; --card: #fff;
  --accent: #0b796b; --accent-soft: #e3ecec; --warn: #a15c00; --bad: #a12e2e; --good: #06604f;
  font-family: "Noto Sans TC", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
header { position: sticky; top: 0; z-index: 5; background: var(--ink); color: #fff; padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top)); }
.brand { max-width: 64rem; margin: auto; font-size: 1.15rem; font-weight: 800; }
.brand span { font-size: .75rem; font-weight: 500; opacity: .7; margin-left: .4rem; }
main { max-width: 64rem; margin: auto; padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
h1 { margin: .2rem 0 .8rem; font-size: 1.5rem; }
h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
h3 { margin: .8rem 0 .4rem; font-size: 1rem; }
p { line-height: 1.55; margin: .4rem 0; }
.hint, .muted, .empty { color: var(--muted); }
.hint { font-size: .9rem; }
.empty { font-size: .9rem; margin: .3rem 0; }
.hidden { display: none !important; }
a { color: var(--accent); font-weight: 700; }

.card { background: var(--card); border-radius: 1rem; padding: 1rem; box-shadow: 0 6px 24px #15324a12; margin: 0 0 1rem; }
.card.narrow { max-width: 28rem; margin: 2rem auto; }

form.stack, .stack { display: grid; gap: .8rem; }
.form-grid { display: grid; gap: .8rem; }
label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 2.9rem; padding: .65rem .75rem; border: 1px solid #b8c5ca; border-radius: .6rem; font: inherit; font-size: 1rem; background: #fff; color: var(--ink); }
textarea { min-height: 5.5rem; resize: vertical; }
button { min-height: 2.9rem; border: 0; border-radius: .65rem; padding: .65rem 1rem; background: var(--accent); color: #fff; font: inherit; font-weight: 750; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button.secondary, .tabs button { background: var(--accent-soft); color: var(--ink); }
button.compact { min-height: 2.3rem; padding: .35rem .7rem; font-size: .88rem; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.inline-form > * { flex: 1 1 8rem; }
.inline-form > button { flex: 0 0 auto; }
.tabs { display: flex; gap: .4rem; margin: .4rem 0 .8rem; overflow-x: auto; }
.tabs button { flex: 1 0 auto; }
.tabs .active { background: var(--ink); color: #fff; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.title-row input { width: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
details { margin-top: .7rem; }
summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: .3rem 0; }

/* lists */
.list { display: grid; gap: .5rem; }
.row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .65rem .75rem; background: var(--soft); border-radius: .65rem; }
.row-main { flex: 1 1 12rem; min-width: 0; }
.row-main .muted { font-size: .88rem; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.row-button { width: 100%; text-align: left; color: var(--ink); background: var(--soft); font-weight: 400; }
.row-button.selected { outline: 2px solid var(--accent); }
.row.overdue { background: #fff4e5; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.check input { width: 1.3rem; min-height: 1.3rem; height: 1.3rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft); font-size: .78rem; font-weight: 800; }
.badge.ACCEPTED, .badge.DONE { background: #d5f0e6; color: var(--good); }
.badge.REJECTED, .badge.FAILED { background: #f7dede; color: var(--bad); }
.badge.IN_REVIEW { background: #fff0cc; color: #7a5200; }
.badge.CANCELLED { background: #eee; color: #777; }
.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* home */
.dashboard { display: grid; gap: 0; }

/* quotes */
.customer-box { display: grid; gap: .15rem; padding: .7rem .8rem; background: var(--soft); border-radius: .65rem; font-size: .92rem; }
.quote-item { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.quote-item:first-child { border-top: 0; }
.quote-item .seq-cell, .quote-item .amount-cell { font-weight: 700; align-self: center; }
.quote-item .amount-cell { text-align: right; }
.quote-item .f-description, .quote-item .f-note { grid-column: 1 / -1; }
.quote-item > button { grid-column: 1 / -1; justify-self: end; }
.preview { margin-top: 1rem; padding: .8rem; background: var(--soft); border-radius: .75rem; }
.table-scroll { overflow-x: auto; }
.preview table { width: 100%; border-collapse: collapse; min-width: 34rem; font-size: .9rem; }
.preview th, .preview td { padding: .45rem; text-align: left; border-bottom: 1px solid var(--line); }
.preview-totals { margin-left: auto; max-width: 18rem; }
.preview-totals p { display: flex; justify-content: space-between; margin: .3rem 0; }
.preview-totals .total { font-weight: 800; }
.statement { font-size: .85rem; color: var(--muted); white-space: pre-wrap; }

/* customers */
#customer-search { margin-bottom: .6rem; }
.link-row { margin: .8rem 0; }

/* costing & reports */
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-top: .8rem; }
.summary-grid .wide { grid-column: 1 / -1; }
.stat { display: grid; gap: .1rem; padding: .6rem .7rem; background: var(--soft); border-radius: .65rem; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat.strong strong { color: var(--good); }
.stat.negative strong { color: var(--bad); }

/* daily */
.usage-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1.3fr auto; gap: .35rem; margin: .35rem 0; }
.usage-row input { min-height: 2.6rem; padding: .5rem; font-size: .95rem; }
.daily-entry { padding: .75rem; background: var(--soft); border-radius: .65rem; }
.daily-entry h3 { margin: 0 0 .2rem; }
.issues { margin: .3rem 0; padding-left: 1.2rem; color: var(--bad); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin-top: .5rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .5rem; display: block; }

/* settings */
.business-card { padding: 1rem; border-radius: .9rem; background: linear-gradient(135deg, #15324a, #0b796b); color: #fff; margin-bottom: .8rem; }
.business-card p, .business-card .muted { color: #e6f0f0; }
.card-name { display: flex; align-items: center; gap: .6rem; font-size: 1.2rem; }
.card-name .badge { background: #ffffff30; color: #fff; }
.card-company { font-weight: 700; }
.card-intro { white-space: pre-wrap; border-top: 1px solid #ffffff40; padding-top: .5rem; }
.warning { color: #ffe2a8 !important; font-weight: 700; }
.partner-row { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .7rem; background: var(--soft); border-radius: .65rem; }
.partner-row .partner-name { grid-column: 1 / -1; }
.partner-row select, .partner-row input { min-height: 2.5rem; padding: .45rem; font-size: .92rem; }
.invite-grid { display: grid; gap: .6rem; margin-top: .8rem; }
.invite-code { font-size: 1.25rem; letter-spacing: .1em; }
.tier-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: .35rem; margin: .4rem 0; }

/* gongxin */
.integration-state { font-weight: 700; }
.integration-state.off { color: var(--warn); }
.participants { border: 1px solid var(--line); border-radius: .65rem; padding: .7rem; margin: 0; }
.participants legend { font-weight: 700; font-size: .9rem; }
.group-label { font-weight: 800; font-size: .85rem; color: var(--muted); margin: .5rem 0 .2rem; }
.participant-row { display: grid; grid-template-columns: auto 1fr; gap: .3rem .6rem; align-items: center; margin: .35rem 0; font-weight: 600; }
.participant-row input[type=checkbox] { width: 1.3rem; min-height: 1.3rem; height: 1.3rem; }
.participant-row input[type=text] { grid-column: 2; min-height: 2.5rem; }
.payload dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; margin: 0; }
.payload dt { font-weight: 700; }
.payload dd { margin: 0; }

/* bottom tab bar */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(7, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 20px #15324a14; }
#tabbar a { display: grid; justify-items: center; gap: .05rem; padding: .45rem 0 .5rem; font-size: .72rem; font-weight: 700; color: var(--muted); text-decoration: none; }
#tabbar a span { font-size: 1.25rem; line-height: 1.2; }
#tabbar a.active { color: var(--accent); }

#message { position: fixed; left: 1rem; right: 1rem; bottom: calc(4.8rem + env(safe-area-inset-bottom)); z-index: 20; margin: 0 auto; max-width: 30rem; padding: .75rem 1rem; border-radius: .8rem; background: var(--ink); color: #fff; text-align: center; opacity: 0; pointer-events: none; transform: translateY(.5rem); transition: opacity .2s, transform .2s; }
#message.show { opacity: .96; transform: none; }

@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .dashboard { grid-template-columns: 1fr 1fr; gap: 0 1rem; }
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quote-item { grid-template-columns: 4rem 2.2fr .8fr .8fr 1fr 1fr 1.6fr auto; align-items: end; }
  .quote-item .f-description, .quote-item .f-note, .quote-item > button { grid-column: auto; }
  .partner-row { grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1.4fr auto; align-items: center; }
  .partner-row .partner-name { grid-column: auto; }
  .invite-grid { grid-template-columns: 1fr 1fr; }
  #tabbar { left: 50%; right: auto; width: min(40rem, 100%); transform: translateX(-50%); border-radius: 1rem 1rem 0 0; }
}

/* ── v2 介面：卡片、分頁、浮動視窗（18–40 歲廠商：乾淨、一眼看懂、操作順） ── */
:root { --radius: 16px; --shadow: 0 2px 10px #15324a10, 0 8px 28px #15324a0d; }
.card { border-radius: var(--radius); box-shadow: var(--shadow); }
.view:not(.hidden) { animation: fade-in .22s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
button { transition: transform .08s, background-color .15s, opacity .15s; }
button:active:not(:disabled) { transform: scale(.97); }
button.ghost { background: transparent; color: var(--accent); min-height: 2.4rem; padding: .4rem .6rem; }
button.ghost.danger { color: var(--bad); }
button.icon { background: transparent; color: var(--muted); min-height: 2.2rem; width: 2.2rem; padding: 0; font-size: 1rem; }
.button-link { display: block; text-align: center; padding: .75rem 1rem; border-radius: .65rem; background: var(--accent); color: #fff; text-decoration: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

/* 首頁 */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: .8rem; margin-bottom: .8rem; }
.hello h1 { margin: 0; }
.hello p { margin: 0; font-size: .9rem; }
.hello input { width: auto; min-height: 2.4rem; padding: .35rem .6rem; font-size: .9rem; border-radius: 999px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.notice { background: #fff4e5; color: var(--warn); border-radius: .8rem; padding: .6rem .8rem; font-size: .9rem; font-weight: 600; cursor: pointer; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.tile { display: grid; gap: .3rem; align-content: start; min-height: 8.2rem; padding: .9rem; border-radius: var(--radius); background: #fff; color: var(--ink); text-align: left; font-weight: 400; box-shadow: var(--shadow); }
.tile-top { display: flex; justify-content: space-between; align-items: center; }
.tile-icon { font-size: 1.35rem; }
.tile-count { font-size: 1.7rem; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.tile-title { font-size: .98rem; }
.tile-preview { display: grid; gap: .1rem; }
.tile-preview span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.empty-tile .tile-count { color: #b7c3c9; }
.tile.warn { box-shadow: inset 0 0 0 2px #f0b35a, var(--shadow); }

/* 報價：步驟 */
.stepper { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 .9rem; counter-reset: step; }
.stepper li { flex: 1; display: flex; align-items: center; gap: .4rem; padding: .5rem .7rem; border-radius: 999px; background: #e2e9eb; color: var(--muted); font-size: .88rem; font-weight: 700; counter-increment: step; }
.stepper li::before { content: counter(step); display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #fff; font-size: .78rem; }
.stepper li.active { background: var(--ink); color: #fff; }
.stepper li.active::before { color: var(--ink); }
.stepper li.done::before { content: "✓"; color: var(--good); }
.case-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .8rem 1rem; }
.case-head > div { display: grid; gap: .1rem; min-width: 0; }
.case-head strong { font-size: 1.05rem; }
.case-head .muted { font-size: .85rem; }
.case-no { display: inline-block; font-size: .78rem; font-weight: 800; color: var(--accent); letter-spacing: .02em; margin-right: .35rem; }

/* 工種分頁 */
.chips-scroll { display: flex; gap: .45rem; overflow-x: auto; padding: .1rem .1rem .6rem; margin: 0 -.1rem; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: grid; justify-items: center; gap: 0; min-height: 2.6rem; padding: .35rem .95rem; border-radius: 999px; background: #fff; color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--line); }
.chip small { font-size: .7rem; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--ink); color: #fff; box-shadow: none; }
.chip.active small { color: #c9d6dc; }
.chip.add { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: transparent; }
.chip-grid { display: flex; flex-wrap: wrap; gap: .45rem; margin: .4rem 0 .8rem; }
.first-trade p { margin-top: 0; font-weight: 600; }

/* 工項卡片 */
.item-card { position: relative; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem; margin-bottom: .7rem; display: grid; gap: .55rem; }
.item-card.invalid { box-shadow: inset 0 0 0 2px #e38b8b, var(--shadow); }
.item-head { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; }
.item-no { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent-soft); font-size: .8rem; font-weight: 800; }
.item-title { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .4rem .1rem; font-weight: 700; min-height: 2.4rem; }
.item-title:focus { outline: none; border-bottom-color: var(--accent); }
.item-grid { display: grid; grid-template-columns: 1.6fr .8fr .8fr 1.1fr; gap: .4rem; }
.item-grid label { min-width: 0; }
.item-grid input { width: 100%; min-width: 0; }
.item-grid label { font-size: .75rem; color: var(--muted); font-weight: 600; gap: .15rem; }
.item-grid input { min-height: 2.5rem; padding: .45rem .55rem; }
.item-foot { display: flex; align-items: center; gap: .6rem; }
.item-note { flex: 1; min-height: 2.3rem; padding: .35rem .55rem; font-size: .88rem; background: var(--soft); border-color: transparent; }
.item-amount { font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.add-card { width: 100%; min-height: 3.2rem; border-radius: var(--radius); background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px #b9d8d3; border: 0; margin-bottom: .6rem; }

/* 歷史報價浮動視窗 */
.history-pop { position: absolute; left: .6rem; right: .6rem; top: 3.3rem; z-index: 15; background: #fff; border-radius: .9rem; box-shadow: 0 12px 36px #15324a33; padding: .4rem; display: grid; gap: .25rem; max-height: 17rem; overflow-y: auto; animation: fade-in .15s ease-out; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 0 .3rem; font-size: .8rem; font-weight: 800; color: var(--muted); }
.pop-row { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; text-align: left; background: var(--soft); color: var(--ink); font-weight: 400; padding: .5rem .65rem; min-height: auto; }
.pop-row .pop-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-row strong { color: var(--accent); }
.pop-row small { grid-column: 1 / -1; color: var(--muted); font-size: .75rem; }

/* 合計列 */
.quote-notes summary { color: var(--muted); font-size: .92rem; }
.total-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .8rem; margin-top: .6rem; padding: .7rem .8rem .7rem 1rem; border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: 0 8px 28px #15324a40; }
.total-bar > div { display: grid; }
.total-bar .muted { color: #b6c6cf; font-size: .75rem; }
.total-bar strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.total-bar button { background: #2fbfa8; color: #062b26; }
.total-bar .total-actions { display: flex; gap: .5rem; }
.total-bar button.save-only { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px #ffffff66; }
.quote-done { margin-top: .8rem; }
.quote-done .done-actions { display: grid; gap: .5rem; margin-top: .8rem; }

/* 底部浮動視窗 */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: #0b1a2680; opacity: 0; transition: opacity .2s; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; background: var(--bg); border-radius: 1.2rem 1.2rem 0 0; padding: .6rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .22s ease-out; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-panel::before { content: ""; display: block; width: 2.6rem; height: .3rem; border-radius: 999px; background: #c3ced3; margin: 0 auto .5rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.sheet-head h2 { margin: 0; }
#sheet-body { display: grid; gap: .8rem; }
.row-end { display: grid; justify-items: end; gap: .2rem; }
.done-box { display: grid; justify-items: center; gap: .2rem; padding: 1rem; background: #fff; border-radius: var(--radius); text-align: center; }
.done-box .big { font-size: 2rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .sheet-panel { left: 50%; right: auto; width: min(36rem, 100%); transform: translate(-50%, 100%); }
  .sheet.open .sheet-panel { transform: translate(-50%, 0); }
  #quote-customer-form { max-width: 36rem; }
}

.row > .check { flex: 1 1 auto; min-width: 0; }
.row > button.icon { flex: 0 0 auto; }
.tile { min-height: 7rem; }

/* ── 成本：分頁、工班表、派工浮窗、員工回報頁 ── */
.small { font-size: .8rem; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; padding: .25rem; margin-bottom: .9rem; background: #e2e9eb; border-radius: 999px; }
.segmented button { min-height: 2.4rem; border-radius: 999px; background: transparent; color: var(--muted); }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 6px #15324a1f; }
#costing-case { margin-bottom: .2rem; font-weight: 700; }

.week-nav { display: flex; align-items: center; gap: .3rem; margin-bottom: .4rem; }
.week-nav strong { flex: 1; text-align: center; font-size: 1.05rem; }
.week-nav button { font-size: 1.2rem; }
.week-nav #week-today { font-size: .9rem; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: center; font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: -.4rem; }
.dot.planned, .shift.planned { --tone: #7d93a3; }
.dot.onsite, .shift.onsite { --tone: #e6a21a; }
.dot.done, .shift.done { --tone: #0b796b; }
.dot.wait, .shift.wait { --tone: #c2410c; }
.dot { background: var(--tone); }

.crew-grid { overflow-x: auto; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.crew-row { display: grid; grid-template-columns: 6.2rem repeat(7, 7.4rem); border-bottom: 1px solid var(--line); width: max-content; min-width: 100%; }
.crew-row:last-child { border-bottom: 0; }
.crew-name { position: sticky; left: 0; z-index: 2; display: grid; align-content: start; gap: .1rem; padding: .55rem .5rem; background: #fff; border-right: 1px solid var(--line); font-size: .85rem; }
.crew-name .muted { font-size: .72rem; }
.crew-total { font-size: .75rem; font-weight: 800; color: var(--accent); }
.crew-head { background: var(--soft); }
.crew-head .crew-name { background: var(--soft); color: var(--muted); font-weight: 700; }
.crew-day { display: grid; justify-items: center; padding: .4rem 0; font-size: .78rem; color: var(--muted); }
.crew-day strong { color: var(--ink); font-size: .85rem; }
.crew-day.today { background: #e3f3f0; color: var(--accent); }
.crew-cell { display: grid; align-content: start; gap: .3rem; min-height: 4.6rem; padding: .3rem; border-left: 1px solid #eef2f3; cursor: pointer; }
.crew-cell.today { background: #f3fbf9; }
.crew-cell .plus { display: grid; place-items: center; height: 100%; min-height: 3.8rem; color: #c7d2d6; font-size: 1.2rem; }
.shift { display: grid; gap: .05rem; text-align: left; min-height: auto; padding: .35rem .45rem; border-radius: .55rem; background: color-mix(in srgb, var(--tone) 12%, #fff); color: var(--ink); font-weight: 400; border-left: 3px solid var(--tone); }
.shift strong { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift span { font-size: .72rem; color: var(--tone); font-weight: 700; }
.shift small { font-size: .66rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift.conflict { outline: 2px dashed #c2410c; outline-offset: -2px; }
.badge.wait { background: #fde7da; color: #9a3412; }
.shift-row { border-left: 4px solid var(--tone, #7d93a3); }
.shift-row.planned { --tone: #7d93a3; } .shift-row.onsite { --tone: #e6a21a; } .shift-row.done { --tone: #0b796b; } .shift-row.wait { --tone: #c2410c; }

/* 派工浮窗 */
.dispatch-head { display: grid; gap: .15rem; padding: .8rem; background: #fff; border-radius: var(--radius); }
.dispatch-head .badge { justify-self: start; margin-top: .2rem; }
.attendance { display: grid; gap: .5rem; padding: .8rem; background: #fff; border-radius: var(--radius); }
.attendance label { grid-template-columns: 5rem 1fr auto; align-items: center; }
.toggles { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.toggles label:not(.check) { display: flex; align-items: center; gap: .4rem; }
.toggles select { width: auto; min-height: 2.4rem; }
.line-button, .button-link.line { background: #06c755; color: #fff; }
.cost-box { padding: .7rem .9rem; background: #fff; border-radius: var(--radius); }
.cost-box p { display: flex; justify-content: space-between; margin: .25rem 0; font-size: .92rem; }
.cost-box p.total { border-top: 1px solid var(--line); padding-top: .4rem; font-size: 1rem; }
.cost-box p.total strong { color: var(--accent); }

/* 資料庫 */
.rate-row { display: grid; grid-template-columns: 1fr auto; gap: .45rem; align-items: end; padding: .7rem; background: var(--soft); border-radius: .75rem; }
.rate-row .row-main { grid-column: 1 / -1; }
.rate-row select { min-height: 2.5rem; }
.rate-fields { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.rate-fields label { font-size: .75rem; color: var(--muted); }
.rate-row > button { grid-column: 2; }

/* 員工回報頁（LINE 打開） */
.report { text-align: center; }
.report h1 { margin: .2rem 0; }
.report-when { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.report-status { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0; }
.report-status div { display: grid; gap: .2rem; padding: .8rem; border-radius: .9rem; background: var(--soft); }
.report-status div.ok { background: #d5f0e6; }
.report-status span { font-size: .85rem; color: var(--muted); }
.report-status strong { font-size: 1.5rem; }
.report-button { width: 100%; min-height: 4.2rem; font-size: 1.3rem; border-radius: 1rem; }
.report-done { font-size: 1.1rem; font-weight: 700; color: var(--good); }

@media (min-width: 720px) {
  .rate-row { grid-template-columns: 1.4fr .8fr 2fr auto; align-items: center; }
  .rate-row .row-main, .rate-fields { grid-column: auto; }
  .rate-row > button { grid-column: auto; }
}

/* ══ v5 介面美化：全面卡片化、毛玻璃頁首與功能表、財務、圖面 ══ */
:root { --bg: #f1f5f6; --accent: #0b7a6c; --accent-soft: #e2f1ee; --ink: #142f45; --muted: #66798a; --line: #e2e8eb; --radius: 18px; --shadow: 0 1px 2px #14304512, 0 6px 22px #1430450f; }
body { background: radial-gradient(1200px 500px at 100% -10%, #dff1ec 0%, transparent 60%), var(--bg); }
header { background: #ffffffcc; color: var(--ink); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid #ffffff; box-shadow: 0 1px 0 var(--line); padding-top: calc(.7rem + env(safe-area-inset-top)); padding-bottom: .7rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; letter-spacing: .02em; }
.brand::before { content: ""; width: 1.6rem; height: 1.6rem; border-radius: .5rem; background: url(/icon-192.png) center / cover; }
.brand span { color: var(--muted); opacity: 1; }
h1 { font-size: 1.55rem; letter-spacing: .01em; }
h2 { font-size: 1.05rem; }
.section-title { margin: 1.2rem 0 .6rem; }
.small { font-size: .8rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pill-button { min-height: 2.3rem; padding: .35rem .9rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .9rem; }
.card { border: 1px solid #ffffff; }
input, select, textarea { border-color: #d5dfe3; background: #fbfdfd; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #0b7a6c22; background: #fff; }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented.small button { min-height: 2.1rem; font-size: .88rem; }
.badge.wait { background: #fff1e0; color: #9a5a00; }

/* ── 底部功能表 ── */
#tabbar { background: #ffffffd9; backdrop-filter: saturate(1.8) blur(18px); -webkit-backdrop-filter: saturate(1.8) blur(18px); border-top: 1px solid #ffffff; box-shadow: 0 -1px 0 var(--line), 0 -8px 30px #14304514; padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); }
#tabbar a { gap: .15rem; padding: .35rem 0 .3rem; border-radius: .9rem; font-size: .68rem; letter-spacing: .02em; color: #7d8d99; transition: color .15s, background-color .2s; }
#tabbar a svg { width: 1.45rem; height: 1.45rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
#tabbar a.active { color: var(--accent); background: var(--accent-soft); }
#tabbar a.active svg { transform: translateY(-1px) scale(1.06); stroke-width: 2; }
#tabbar a:active svg { transform: scale(.9); }
@media (min-width: 720px) { #tabbar { border-radius: 1.3rem 1.3rem 0 0; } }

/* ── 客戶／案場 ── */
.search-bar { display: flex; align-items: center; gap: .5rem; padding: 0 .9rem; margin-bottom: .8rem; background: #fff; border-radius: 999px; box-shadow: var(--shadow); }
.search-bar input { border: 0; background: transparent; box-shadow: none; padding-left: 0; }
.card-grid { display: grid; gap: .6rem; }
.customer-card { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; padding: .8rem .9rem; text-align: left; background: #fff; color: var(--ink); font-weight: 400; border-radius: var(--radius); box-shadow: var(--shadow); }
.customer-card.selected { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow); }
.customer-main { display: grid; min-width: 0; }
.customer-main .muted { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-side { display: grid; justify-items: end; }
.customer-side strong { font-size: 1.2rem; color: var(--accent); }
.customer-side .muted { font-size: .72rem; }
.avatar { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: linear-gradient(135deg, #0b7a6c, #2fbfa8); color: #fff; font-weight: 800; font-size: 1.1rem; }
.avatar.big { width: 3.4rem; height: 3.4rem; font-size: 1.4rem; }
#customer-detail { margin-top: 1.2rem; }
.profile-hero { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; }
.hero-main { display: grid; gap: .1rem; min-width: 0; }
.hero-main h2 { margin: 0; font-size: 1.25rem; }
.hero-main .note { font-size: .85rem; color: var(--warn); }
.hero-actions { display: flex; gap: .4rem; }
.round-button { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; min-height: 0; padding: 0; border-radius: 50%; background: var(--accent-soft); text-decoration: none; font-size: 1.1rem; }
.case-cards { display: grid; gap: .7rem; margin-bottom: 1rem; }
.case-card { display: grid; gap: .3rem; padding: .9rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.case-card.archived { opacity: .65; }
.case-card-head { display: flex; justify-content: space-between; align-items: center; }
.case-title { font-size: 1.08rem; }
.case-stats { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.case-stats strong { color: var(--ink); }
.case-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .3rem; }
.case-actions .chip { min-height: 2.2rem; padding: .25rem .75rem; font-size: .85rem; }
.ghost-chip { color: var(--muted); }
.link-card { display: grid; gap: .3rem; font-weight: 700; }

/* ── 今日工事 ── */
.case-picker { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.case-picker select { font-weight: 700; }
#daily-form .case-picker { grid-template-columns: minmax(0, 1fr) auto auto; }
.photo-drop { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 4.2rem; padding: .8rem; border-radius: var(--radius); border: 2px dashed #b9d8d3; background: #f5fbfa; color: var(--accent); font-weight: 700; cursor: pointer; text-align: center; }
.photo-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-icon { font-size: 1.4rem; }
.timeline { display: grid; gap: .7rem; position: relative; padding-left: 1.1rem; }
.timeline::before { content: ""; position: absolute; left: .3rem; top: .4rem; bottom: .4rem; width: 2px; background: #cfe3df; border-radius: 2px; }
.timeline .daily-entry { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: var(--radius); padding: .8rem .9rem; }
.timeline .daily-entry::before { content: ""; position: absolute; left: -1.05rem; top: 1rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px #e2f1ee; }
.timeline-time { font-size: .75rem; color: var(--muted); font-weight: 700; }
.timeline .empty { margin-left: -.8rem; }
#dispatch-list .row { background: #fff; box-shadow: var(--shadow); border-radius: var(--radius); }

/* ── 設定 ── */
.business-card { border-radius: calc(var(--radius) + 4px); padding: 1.2rem; margin-bottom: .9rem; box-shadow: 0 12px 30px #0b7a6c40; background: linear-gradient(135deg, #142f45 0%, #0b7a6c 70%, #2fbfa8 130%); }
.menu { padding: .3rem; }
.menu-row { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; width: 100%; padding: .75rem .7rem; background: transparent; color: var(--ink); font-weight: 650; text-align: left; border-radius: .8rem; }
.menu-row + .menu-row { border-top: 1px solid var(--line); border-radius: 0; }
.menu-icon { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .7rem; background: var(--accent-soft); }
.chev { color: #a6b4bd; font-size: 1.3rem; }
.logout { width: 100%; margin: .4rem 0 1rem; background: #fff; color: var(--bad); box-shadow: var(--shadow); }
#lists-card .segmented { margin: .4rem 0 .8rem; }
.partner-row { background: #f7fafa; }

/* ── 工信 ── */
.status-pill { padding: .3rem .75rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 800; }
.status-pill.off { background: #fff1e0; color: #9a5a00; }
.gx-hero { display: grid; gap: .3rem; background: linear-gradient(135deg, #fff, #eef8f6); }
#gongxin-form h2 { margin-bottom: .4rem; }
#gongxin-submissions .row { background: #fff; box-shadow: var(--shadow); border-radius: var(--radius); }

/* ── 財務報表 ── */
.finance-head { display: grid; gap: .5rem; margin-bottom: .7rem; }
.finance-head .week-nav { margin: 0; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.kpi { display: grid; gap: .1rem; padding: .85rem .9rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone, #c9d6dc); }
.kpi span { font-size: .78rem; color: var(--muted); font-weight: 700; }
.kpi strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpi small { font-size: .72rem; color: var(--muted); }
.kpi.in { --tone: #0b7a6c; } .kpi.out { --tone: #e6a21a; } .kpi.positive { --tone: #2fbfa8; } .kpi.positive strong { color: var(--good); }
.kpi.negative { --tone: #c2410c; } .kpi.negative strong { color: var(--bad); } .kpi.warn { --tone: #f0b35a; } .kpi.warn strong { color: #9a5a00; }
.trend { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; align-items: end; height: 9.5rem; padding-top: .5rem; }
.trend-col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: .3rem; }
.trend-bars { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; border-bottom: 1px solid var(--line); }
.bar { width: 38%; min-height: 2px; border-radius: 5px 5px 0 0; transition: height .4s ease-out; }
.bar.in, .dot.in { background: #0b7a6c; } .bar.out, .dot.out { background: #f0b35a; }
.trend-label { text-align: center; font-size: .72rem; color: var(--muted); }
.legend .dot { width: .6rem; height: .6rem; margin: 0 .15rem 0 .5rem; }
.stack-bar { display: flex; height: .9rem; border-radius: 999px; overflow: hidden; background: var(--line); margin-bottom: .7rem; }
.stack-bar span { transition: width .4s ease-out; }
.c1 { background: #0b7a6c; } .c2 { background: #2fbfa8; } .c3 { background: #f0b35a; } .c4 { background: #8aa1b1; }
.dot.c1, .dot.c2, .dot.c3, .dot.c4 { width: .65rem; height: .65rem; margin: 0; }
.breakdown-rows { display: grid; gap: .35rem; }
.breakdown-row { display: grid; grid-template-columns: auto 1fr auto 3rem; gap: .5rem; align-items: center; font-size: .92rem; }
.breakdown-row .muted { text-align: right; font-size: .8rem; }
.money-card { display: grid; gap: .45rem; padding: .8rem; border-radius: .9rem; background: #fbfaf6; border: 1px solid #f3e7cf; }
.money-card-head { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.money-card-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.warn-text { color: #9a5a00; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { height: .45rem; border-radius: 999px; background: #efe6d2; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #2fbfa8, #0b7a6c); border-radius: inherit; }
.pl-row { display: grid; gap: .3rem; padding: .7rem .8rem; border-radius: .9rem; background: var(--soft); }
.pl-main { display: flex; flex-wrap: wrap; gap: .1rem .5rem; align-items: baseline; }
.pl-nums { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: .4rem; font-size: .82rem; color: var(--muted); }
.pl-nums b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pl-nums .positive b { color: var(--good); } .pl-nums .negative b { color: var(--bad); }

/* ── 設計圖面 ── */
.drawing-upload { display: grid; gap: .4rem; }
.drawing-group h3 { margin: .2rem 0 .5rem; font-size: .9rem; color: var(--muted); }
.drawing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.drawing-card { position: relative; display: grid; background: #fff; border-radius: 1rem; overflow: hidden; box-shadow: var(--shadow); }
.drawing-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: repeating-linear-gradient(45deg, #f3f7f8, #f3f7f8 8px, #eef3f5 8px, #eef3f5 16px); text-decoration: none; }
.drawing-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pdf-badge { padding: .45rem .8rem; border-radius: .6rem; background: #c2410c; color: #fff; font-weight: 900; letter-spacing: .06em; box-shadow: 0 6px 14px #c2410c40; }
.drawing-meta { display: grid; padding: .5rem .6rem .6rem; }
.drawing-meta strong { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawing-meta .muted { font-size: .72rem; }
.drawing-card > button.icon { position: absolute; top: .3rem; right: .3rem; background: #ffffffd9; border-radius: 50%; width: 1.9rem; min-height: 1.9rem; }

@media (min-width: 720px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
  .case-cards { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .drawing-grid { grid-template-columns: repeat(3, 1fr); }
  .finance-head { grid-template-columns: 1fr 1fr; align-items: center; }
}
#tabbar a span { font-size: .68rem; line-height: 1.25; font-weight: 700; }
.segmented.four button { padding: .3rem .15rem; font-size: .9rem; white-space: nowrap; }

/* 員工卡片 */
.employee-card { display: grid; grid-template-columns: auto 1fr; gap: .4rem .8rem; align-items: center; padding: .85rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.employee-main { display: grid; gap: .15rem; min-width: 0; }
.employee-main > div { display: flex; align-items: center; gap: .45rem; }
.employee-main .salary { font-size: .88rem; color: var(--accent); font-weight: 700; }
.employee-main a { text-decoration: none; }
.employee-actions { grid-column: 1 / -1; display: flex; gap: .4rem; flex-wrap: wrap; }
.employee-actions .chip { min-height: 2.1rem; padding: .2rem .8rem; font-size: .85rem; }
#partner-list .add-card { margin-bottom: .2rem; }
.participant-row.unlinked { opacity: .55; }

.switch-row { display: grid; grid-template-columns: 1fr auto; gap: .8rem; align-items: center; font-weight: 400; }
.switch-row > span { display: grid; gap: .2rem; }
.switch-row input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 3rem; height: 1.75rem; min-height: 0; padding: 0; border-radius: 999px; background: #cfd8dc; border: 0; position: relative; transition: background-color .2s; cursor: pointer; }
.switch-row input[type=checkbox]::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px #0003; transition: transform .2s; }
.switch-row input[type=checkbox]:checked { background: var(--accent); }
.switch-row input[type=checkbox]:checked::after { transform: translateX(1.25rem); }

/* ── 後台 ── */
body.admin main { padding-bottom: 2rem; max-width: 72rem; }
.admin-range { width: auto; grid-template-columns: repeat(3, auto); }
.admin-range button { padding: .3rem .9rem; }
.daily-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(2.2rem, 1fr); gap: .35rem; align-items: end; height: 13rem; overflow-x: auto; padding-top: 1rem; }
.daily-col { display: grid; grid-template-rows: auto 1fr auto auto; height: 100%; justify-items: center; gap: .15rem; }
.daily-value { font-size: .72rem; font-weight: 800; color: var(--ink); }
.daily-stack { display: flex; flex-direction: column-reverse; width: 62%; height: 100%; border-bottom: 1px solid var(--line); }
.daily-stack .seg { display: block; width: 100%; transition: height .4s ease-out; }
.seg.app, .dot.app { background: #0b7a6c; } .seg.web, .dot.web { background: #8fd3c7; } .dot.users { background: #f0b35a; }
.daily-stack .seg.web { border-radius: 5px 5px 0 0; }
.daily-users { font-size: .66rem; color: #9a5a00; font-weight: 700; min-height: .9rem; }
.daily-label { font-size: .66rem; color: var(--muted); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 32rem; }
.admin-table th, .admin-table td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.admin-table th:first-child, .admin-table td:first-child { text-align: left; }
.admin-table th { color: var(--muted); font-size: .8rem; }
.switch-server { display: block; text-align: center; padding: .75rem; border-radius: .65rem; color: var(--accent); text-decoration: none; font-weight: 700; }

/* ── iPhone：加入主畫面提示、主畫面模式 ── */
.ios-install { position: fixed; left: .8rem; right: .8rem; bottom: calc(5.2rem + env(safe-area-inset-bottom)); z-index: 25; display: flex; gap: .6rem; align-items: flex-start; padding: .9rem 1rem; border-radius: 1rem; background: #142f45; color: #fff; box-shadow: 0 12px 34px #14304566; animation: fade-in .25s ease-out; }
.ios-install > div { display: grid; gap: .25rem; font-size: .9rem; line-height: 1.5; }
.ios-install button.icon { color: #c9d6dc; flex: 0 0 auto; }
.share-icon { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: .35rem; background: #ffffff26; font-weight: 400; }
html.standalone header { padding-top: calc(.6rem + env(safe-area-inset-top)); }
html.standalone body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }

/* ── 電腦同步 ── */
.connect-pc { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .6rem; }
.connect-pc > p { margin: 0; }
.sync-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.sync-facts > div { display: grid; gap: .1rem; padding: .6rem .7rem; border-radius: .75rem; background: var(--soft); min-width: 0; }
.sync-facts strong { font-size: .88rem; line-height: 1.3; overflow-wrap: anywhere; }
.segmented.two { grid-template-columns: repeat(2, 1fr); margin: 0; }
.sync-conflicts summary { cursor: pointer; font-weight: 700; }
.sync-conflicts summary .badge { margin-left: .5rem; }
.conflict-row { display: grid; gap: .3rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.conflict-row > div { display: grid; gap: .1rem; }
.conflict-row pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--soft); padding: .5rem; border-radius: .5rem; margin: .3rem 0 0; }
.danger-text { color: var(--bad); }
.badge.wait { background: #fff0cc; color: #7a5200; }
.sync-error { margin: 0; padding: .6rem .75rem; border-radius: .65rem; background: #fbe9e9; color: var(--bad); font-size: .9rem; }
/* 手機離線版不收集使用統計，也沒有切換伺服器 */
html.local-app .card:has(#usage-toggle), html.local-app #switch-server { display: none; }
.register-fields { border: 0; padding: 0; margin: 0; display: grid; gap: .8rem; min-width: 0; }
.register-fields .check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 600; }
#profile-form input[readonly] { background: var(--soft); color: var(--muted); }
.inline-field { display: flex; gap: .5rem; align-items: stretch; }
.inline-field input { flex: 1 1 auto; min-width: 0; }
.inline-field button { flex: 0 0 auto; white-space: nowrap; }
.archived-box { margin: .8rem 0; }
.archived-box summary { cursor: pointer; color: var(--muted); font-weight: 700; padding: .4rem 0; }
.archived-box .list { display: grid; gap: .4rem; margin-top: .4rem; }
.choice-text { white-space: pre-line; line-height: 1.6; }
button.danger:not(.ghost) { background: var(--bad); color: #fff; }

/* 報價送出狀態 */
.sent-status { display: grid; gap: .25rem; margin-top: .8rem; padding: .75rem .9rem; border-radius: .75rem; background: #fff6e0; color: #7a5200; }
.sent-status.sent { background: #e3f4ee; color: var(--good); }
.sent-status span { font-size: .88rem; }
button.link-button { background: none; padding: 0; min-height: 0; color: inherit; text-decoration: underline; font-weight: 600; text-align: left; justify-self: start; }
.badge.wait { background: #fff0cc; color: #7a5200; }

/* 報價單預覽（Excel 風格） */
.quote-preview { margin-top: .8rem; display: grid; gap: .6rem; min-width: 0; }
.quote-preview > *, .preview-sheet { min-width: 0; max-width: 100%; }
.quote-preview .preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.quote-preview.stale .preview-sheet { opacity: .55; }
.quote-preview.stale #preview-state { color: var(--warn); font-weight: 700; }
.quote-preview .preview-actions { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.total-bar .total-actions { flex-wrap: wrap; }
#register-fields input.upper { text-transform: uppercase; }

.item-card .item-spec { font-size: .92rem; }

/* 忘記帳號或密碼 */
button.link-button.forgot { justify-self: center; color: var(--muted); font-weight: 500; font-size: .92rem; }
.recover-account { padding: .75rem .9rem; border-radius: .75rem; background: var(--accent-soft); word-break: break-all; }
.recover-account strong { display: block; font-size: 1.1rem; margin-top: .2rem; }

/* 今日工事：公司車、備料清單 */
.vehicle-chips { margin-top: .3rem; }
.prep-list { display: grid; gap: .3rem; margin: .35rem 0 .5rem; }
.prep-item { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .55rem; padding: .45rem .6rem; border-radius: .6rem; background: var(--accent-soft); font-weight: 500; }
.prep-item input[type=checkbox] { width: 1.25rem; height: 1.25rem; min-height: 0; margin: 0; }
.prep-item.done .prep-name { text-decoration: line-through; color: var(--muted); }
.prep-item .icon { min-height: 0; padding: .1rem .4rem; }
.prep-foot { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.prep-add { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 4rem auto; gap: .35rem; }
.prep-add input { min-width: 0; }

/* 報價：歷史報價 */
.history-box { display: grid; gap: .5rem; margin-bottom: .7rem; }
.history-box .two { display: grid; grid-template-columns: minmax(0, 10rem) minmax(0, 1fr); gap: .5rem; }
.badge.hist { background: #e0e7ff; color: #3730a3; }

/* 設定：報價單上的公司資料 */
.issuer-fields { border: 1px solid var(--line, #d5dee3); border-radius: .7rem; padding: .7rem .8rem; display: grid; gap: .5rem; }
.issuer-fields legend { font-weight: 700; padding: 0 .3rem; }

/* 案場卡片預覽（底部視窗） */
#sheet-body .preview-sheet { min-width: 0; max-width: 100%; }
#sheet-body .preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

/* 報價：匯入 Excel */
.case-head > .case-head-actions { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ghost-button { display: inline-flex; align-items: center; min-height: 2.4rem; padding: .4rem .6rem; border-radius: .6rem; color: var(--accent); font-weight: 700; cursor: pointer; }
.ghost-button:hover { background: var(--accent-soft); }
.import-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.import-table th, .import-table td { border: 1px solid #d5dee3; padding: .3rem .4rem; text-align: left; }
.import-table th { background: var(--accent-soft); }
.import-table td.blank { background: #fff6e0; }
.import-scroll { max-height: 45vh; overflow: auto; }

/* 站內傳送、收到的報價單 */
.hello-actions { display: flex; gap: .2rem; flex-wrap: wrap; justify-content: flex-end; }
.count-badge { display: inline-block; min-width: 1.3em; margin-left: .3rem; padding: 0 .35em; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; line-height: 1.4; text-align: center; }
.deliver-list { display: grid; gap: .35rem; max-height: 45vh; overflow: auto; }
.deliver-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: .6rem; background: var(--accent-soft); font-weight: 500; }
.deliver-row input[type=checkbox] { width: 1.25rem; height: 1.25rem; min-height: 0; margin: 0; }
.deliver-name { min-width: 0; }
.row-button.unread strong { color: var(--ink); }
.row-button.unread { box-shadow: inset 3px 0 0 var(--accent); }
.compact-link { padding: .4rem .7rem; }

/* 手機配對碼 */
.pair-code { display: grid; gap: .3rem; justify-items: center; text-align: center; padding: .9rem; border-radius: .8rem; background: var(--accent-soft); }
.pair-digits { font-size: 2.2rem; letter-spacing: .25em; font-variant-numeric: tabular-nums; }

/* 問題回報截圖 */
.issue-preview { width: 100%; max-height: 18rem; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); }

/* 接案狀態燈 */
.status-light { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 800; color: #fff; white-space: nowrap; vertical-align: middle; margin-right: .35rem; }
.status-light::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.status-light.available { background: #16a34a; }
.status-light.full { background: #dc2626; }
.provider-line { display: block; font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.provider-card .status-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.provider-card .status-buttons button { min-height: 3.2rem; font-size: 1.05rem; font-weight: 800; border: 2px solid transparent; }
.provider-card .status-buttons .available { background: #dcfce7; color: #166534; }
.provider-card .status-buttons .full { background: #fee2e2; color: #991b1b; }
.provider-card .status-buttons .available.on { background: #16a34a; color: #fff; }
.provider-card .status-buttons .full.on { background: #dc2626; color: #fff; }
.provider-card .chip.on { background: var(--ink); color: #fff; }

/* ── 流水帳 ── */
.segmented.five { grid-template-columns: repeat(5, 1fr); }
.segmented.five button { padding: .3rem .1rem; font-size: .86rem; white-space: nowrap; }
.ledger-entry #ledger-text { font-size: 1.05rem; min-height: 3rem; }
.ledger-preview:empty { display: none; }
.ledger-preview { display: grid; gap: .35rem; padding: .55rem .7rem; border-radius: .7rem; background: var(--soft); }
.ledger-preview-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.ledger-amount { font-size: 1.35rem; }
#cost-tab-ledger .week-nav select { margin-left: auto; max-width: 11rem; }
.ledger-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .6rem; }
.ledger-kpis > div { display: grid; gap: .1rem; }
.ledger-kpis strong { font-size: 1.15rem; }
.ledger-kpis .positive { color: var(--good); } .ledger-kpis .negative { color: var(--bad); }
.ledger-bar { display: flex; height: .7rem; border-radius: 999px; overflow: hidden; margin-bottom: .6rem; background: var(--line); }
.ledger-day { display: flex; justify-content: space-between; align-items: baseline; padding: .7rem .2rem .25rem; border-bottom: 1px solid var(--line); }
.ledger-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; width: 100%; text-align: left; }
.ledger-row .row-main { display: grid; gap: .1rem; min-width: 0; }
.ledger-row .row-main strong { overflow-wrap: anywhere; }
.ledger-row.pending { box-shadow: inset 3px 0 0 #dc2626; }
.ledger-row .money.positive { color: var(--good); }
.ledger-badge { display: inline-block; min-width: 2.6rem; padding: .15rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 800; text-align: center; color: #fff; }
.ledger-badge.pending, .chip.pending { background: #fee2e2; color: #b91c1c; box-shadow: none; }
.g1 { --g: #16a34a; } .g2 { --g: #2563eb; } .g3 { --g: #0891b2; } .g4 { --g: #ea580c; } .g5 { --g: #7c3aed; } .g6 { --g: #a16207; } .g7 { --g: #db2777; } .g8 { --g: #64748b; }
.ledger-badge[class*=" g"], .ledger-bar > span { background: var(--g); }
.chip[class*=" g"].active { background: var(--g); color: #fff; }
.check-line { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.check-line input[type=checkbox] { width: 1.2rem; height: 1.2rem; min-height: 0; }
.check-line input:not([type=checkbox]) { flex: 1 1 8rem; }

/* ── 報價 vs 實際、收款進度、師傅回報用料 ── */
.budget-list { display: grid; gap: .8rem; }
.budget-row { display: grid; gap: .3rem; }
.budget-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.budget-head .negative { color: var(--bad); font-weight: 700; }
.budget-bar { height: .6rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.budget-bar span { display: block; height: 100%; border-radius: 999px; background: #16a34a; }
.budget-bar span.over { background: #dc2626; }
.budget-bar.paid span { background: #2563eb; }
.budget-bar.paid { margin: .4rem 0 .6rem; }
.budget-total { margin: .3rem 0 0; font-weight: 700; }
.budget-total.negative { color: var(--bad); }
.chip.static { cursor: default; }
.report-row { display: grid; gap: .45rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.report-actions { display: flex; gap: .4rem; align-items: center; }
.report-actions input { flex: 1 1 6rem; min-width: 0; }
.report-materials h2 { margin: 0 0 .2rem; }
.report-material-list { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .3rem; }
.report-material-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; border-radius: .5rem; background: var(--soft); }
.report-material-list em { font-style: normal; font-size: .8rem; font-weight: 700; }
.report-material-list em.pending { color: #b45309; } .report-material-list em.approved { color: #15803d; } .report-material-list em.rejected { color: #b91c1c; }
.report-material-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .4rem; }
.report-material-form input[name=note], .report-material-form button { grid-column: 1 / -1; }

/* ── 拍單據 ── */
.receipt-photo { display: block; width: 100%; max-height: 45vh; object-fit: contain; border-radius: .6rem; background: #0b1b26; margin: .4rem 0; }
.receipt-items { display: grid; gap: .1rem; max-height: 45vh; overflow-y: auto; }
.receipt-item { display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.receipt-item .row-main { display: grid; gap: .1rem; min-width: 0; }
.receipt-item strong { overflow-wrap: anywhere; }
/* 財務「支出結構」用流水帳的分類顏色 */
.stack-bar span[class^="g"], .dot[class*=" g"] { background: var(--g); }
.stack-bar span.pending, .dot.pending { background: #f87171; }
.dot[class*=" g"], .dot.pending { width: .65rem; height: .65rem; margin: 0; }
.case-row { padding-left: .4rem; }

.archive-search { display: block; margin: .6rem auto 0; }
