/* 殯葬客戶管理系統 · RWD 樣式 */
:root {
    --primary: #37474f;
    --primary-dark: #263238;
    --accent: #00897b;
    --danger: #c62828;
    --bg: #f4f6f8;
    --card: #ffffff;
    --border: #d9dee3;
    --text: #263238;
    --muted: #78909c;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }

/* ---------- 頂部導覽 ---------- */
.topbar { background: var(--primary); color: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
/* 公司名稱可長可短：長名字自己截斷加省略號，不把右邊的帳號擠掉 */
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; margin-right: auto;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip { background: rgba(255,255,255,.15); padding: 4px 12px; border-radius: 999px;
    font-size: .85rem; flex: none; white-space: nowrap; }
.hamburger { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }
.nav { display: flex; gap: 4px; padding: 0 12px 8px; flex-wrap: wrap; }
.nav a { color: #eceff1; padding: 8px 14px; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a.logout { color: #ffcdd2; margin-left: auto; }

/* ---------- 容器 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 60px; }
.page-title { font-size: 1.5rem; margin: 0 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.muted { color: var(--muted); }
.readonly-tag { font-size: .75rem; background: #eceff1; color: var(--muted); padding: 2px 10px; border-radius: 999px; vertical-align: middle; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: .95rem; }
.flash-success { background: #e0f2f1; color: #00695c; border: 1px solid #b2dfdb; }
.flash-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: #eceff1; color: var(--text); border: 1px solid var(--border);
    padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: .95rem;
    min-height: 42px; transition: background .15s, opacity .15s; }
.btn:hover { background: #dfe4e8; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #00796b; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: .9; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .85rem; }

/* ---------- 功能選單卡片 ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.menu-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; color: var(--text); }
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.menu-card h2 { margin: 8px 0 6px; font-size: 1.15rem; }
.menu-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.menu-icon { font-size: 2rem; }
.menu-card.highlight { border-color: var(--accent); }

/* ---------- 搜尋列 ---------- */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.search-bar input[type=text] { flex: 1 1 200px; padding: 6px 12px; border: 1px solid var(--border);
    border-radius: 8px; min-height: 36px; height: 36px; font-size: .92rem; }
.search-bar .btn { min-height: 36px; height: 36px; padding: 4px 14px; }

/* ---------- 卡片 / 面板 ---------- */
.card, .panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-title { margin: 0 0 14px; font-size: 1.1rem; }
.panel h2 { margin: 0 0 14px; font-size: 1.15rem; border-bottom: 2px solid #eceff1; padding-bottom: 8px; }

/* ---------- 表單 ---------- */
.record-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; background: var(--card); }
.record-form legend { font-weight: 700; color: var(--primary); padding: 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.field span { color: var(--muted); font-size: .85rem; }
.field.required span::after { content: " *"; color: var(--danger); }
.field input, .field select, .search-bar select, select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    min-height: 42px; font-size: .95rem; width: 100%; background: #fff; }
/* 上面那條是給文字欄位用的；套到勾選框上會變成巨大的方塊／圓圈，
   在手機上直接壓過旁邊的文字，所以一律還原成原生尺寸。 */
.field input[type=radio], .field input[type=checkbox] {
    width: 20px; height: 20px; min-width: 20px; min-height: 20px;
    padding: 0; margin: 0; flex: 0 0 20px; accent-color: var(--primary); }
.field.grow { flex: 1 1 220px; }
.field.small { max-width: 120px; }
.inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-actions { display: flex; gap: 12px; margin-top: 10px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 10px; }
/* 農曆對照：自成一行，且整串不從中間斷開 */
.lunar-hint { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- 表格（桌機） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.data-table th { background: #eceff1; color: var(--primary); font-weight: 600; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 身分管理欄位多，桌機把列壓扁且一律不換行；真的太窄就由 .table-wrap 水平捲動 */
@media (min-width: 641px) {
    .users-table th, .users-table td { padding: 6px 10px; white-space: nowrap; }
    .users-table .actions { flex-wrap: nowrap; }
    .users-table td[colspan] { white-space: normal; }   /* 展開的編輯表單照常換行 */
    .users-table .btn-sm { padding: 2px 9px; min-height: 27px; font-size: .8rem; }
    .users-table .sign-tag, .users-table .badge { padding: 1px 8px; font-size: .78rem; }
}
.badge { background: #e0f2f1; color: #00695c; padding: 3px 10px; border-radius: 999px;
    font-size: .8rem; display: inline-block; white-space: nowrap; }
/* 導覽列未讀徽章（聯繫紀錄） */
/* 儀表板未讀提示條 */
/* 聯繫紀錄：卡片式（諮詢內容獨立成一區塊，長訊息不撐爆版面） */
.inq-list { display: grid; gap: 12px; margin-top: 4px; }
.inq-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.inq-card.is-unread { border-left: 4px solid #e53935; background: #fffdf5; }
.inq-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 10px; }
.inq-head .who { font-weight: 700; font-size: 1.02rem; }
.inq-head .phone { color: #00695c; text-decoration: none; font-weight: 600; }
.inq-head .time { color: var(--muted); font-size: .82rem; margin-left: auto; }
.inq-msg { background: #f6f8f9; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.inq-meta { margin-top: 8px; font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 18px; }
.inq-foot { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inq-act { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.inq-note { width: 120px; min-height: 30px; padding: 2px 8px; font-size: .82rem; border: 1px solid var(--border); border-radius: 6px; }
.sign-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; white-space: nowrap; }
.sign-done { background: #e0f2f1; color: #00695c; border: 1px solid #80cbc4; }
.sign-prog { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.sign-draft { background: #eceff1; color: #607d8b; border: 1px solid #cfd8dc; }
.sign-none { background: transparent; color: #b0bec5; border: 1px dashed #cfd8dc; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center; }

/* ---------- 總覽詳情 ---------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 20px; }
.info-row { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #eceff1; }
.info-label { color: var(--muted); min-width: 90px; font-size: .88rem; }
.info-value { font-weight: 500; }

/* ---------- 手寫簽名 ---------- */
.sig-wrap { border: 2px dashed var(--border); border-radius: var(--radius); background: #fafcff; padding: 6px; margin: 6px 0 12px; }
.sig-canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; border-radius: 6px; background: #fff; }
.clause-list { margin: 4px 0; padding-left: 20px; }
.clause-list li { padding: 2px 0; }
.consent { display: flex; gap: 10px; align-items: flex-start; background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px; padding: 12px 14px; margin: 10px 0; font-size: .92rem; }
.consent input { margin-top: 3px; width: 18px; height: 18px; flex-shrink: 0; }
.hash { font-family: ui-monospace, "Courier New", monospace; font-size: .8rem; color: var(--muted); }
.hash-block { display: block; font-family: ui-monospace, "Courier New", monospace; font-size: .82rem; word-break: break-all; background: #263238; color: #b2dfdb; padding: 12px 14px; border-radius: 8px; }
.verify-banner { padding: 18px; border-radius: var(--radius); font-size: 1.1rem; text-align: center; }
.verify-ok { background: #e0f2f1; color: #00695c; border: 1px solid #b2dfdb; }
.verify-bad { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.verify-warn { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }

/* ---------- 簽約流程 ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.steps .step { flex: 1 1 auto; text-align: center; padding: 10px 8px; background: var(--card);
    border: 1px solid var(--border); border-radius: 8px; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.steps .step.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* 方案選擇：一列一個，由上到下排 */
.plan-picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.plan-row { display: flex; align-items: stretch; gap: 8px; }
.plan-row .plan-option { flex: 1; }
.plan-preview { align-self: center; white-space: nowrap; }
.plan-option { cursor: pointer; display: flex; }
.plan-option input { position: absolute; opacity: 0; }
.plan-card { flex: 1; display: flex; align-items: baseline; gap: 12px; border: 2px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px; transition: border-color .15s, box-shadow .15s; }
.plan-option input:checked + .plan-card { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,137,123,.15); }
.plan-card h3 { margin: 0; font-size: 1rem; flex: 1 1 auto; }
.plan-price { font-size: 1.1rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.plan-sub { color: var(--muted); font-size: .85rem; white-space: nowrap; }
@media (max-width: 560px) { .plan-card { flex-wrap: wrap; gap: 4px 12px; } .plan-card h3 { flex: 1 1 100%; } }
.plan-total { font-size: 1.1rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.plan-section { margin: 10px 0 14px; padding-bottom: 10px; border-bottom: 1px dashed #eceff1; }
.plan-section h3 { font-size: 1rem; margin: 0 0 6px; color: var(--primary); }
.mini-table { width: 100%; border-collapse: collapse; margin: 4px 0; }
.mini-table th, .mini-table td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; font-size: .9rem; }
.mini-table th { background: #eceff1; }

.tag-manual { background: #fff3e0; color: #e65100; padding: 1px 6px; border-radius: 5px; font-size: .72rem; white-space: nowrap; }

/* Excel 式緊湊加購表 */
.addon-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px) { .addon-cols { grid-template-columns: 1fr; } }
.xls-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.xls-table th, .xls-table td { border: 1px solid var(--border); padding: 2px 5px; text-align: left; }
.xls-table thead th { background: #37474f; color: #fff; font-size: .76rem; padding: 4px 5px; font-weight: 600; }
.xls-table td.nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xls-table td.nm .unit { color: var(--muted); font-size: .72rem; margin-left: 3px; }
.xls-table .c-sel { width: 26px; text-align: center; }
.xls-table .c-qty { width: 52px; }
.xls-table .c-up { width: 60px; text-align: right; }
.xls-table .c-amt { width: 66px; }
.xls-table input[type=number] { width: 100%; min-height: 26px; padding: 1px 4px; font-size: .8rem; border: 1px solid var(--border); border-radius: 4px; }
.xls-table input[type=checkbox] { width: 17px; height: 17px; }
.xls-table th.c-item { width: 190px; }
/* 花籃置辦欄位較多，窄畫面（手機）給最小寬度→由 .table-wrap 水平捲動，避免欄位擠壓／裁切 */
#flower-table { min-width: 720px; }
.xls-table .c-chk { text-align: center; }
.xls-table th.c-chk { width: 42px; white-space: nowrap; }
.xls-table th.c-chk.wide { width: 72px; }
.xls-table td.c-chk input[type=checkbox] { margin: 0; vertical-align: middle; }
.xls-table tr.on { background: #e0f2f1; }
.xls-table tr.on td.nm { font-weight: 600; }
.xls-table .auto { color: var(--muted); font-size: .72rem; }
.xls-table td.c-up { white-space: nowrap; }

.dual-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .dual-sign { grid-template-columns: 1fr; } }

/* Excel 式費用明細統計表（緊湊，手機可一次瀏覽） */
.stmt-table { width: 100%; border-collapse: collapse; font-size: .84rem; table-layout: fixed; }
.stmt-table col.c1 { width: 48%; }
.stmt-table col.c2 { width: 28%; }
.stmt-table col.c3 { width: 24%; }
.stmt-table td { border: 1px solid #b0bec5; padding: 3px 7px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }
.stmt-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-table tr.cat td { background: #c8e6c9; color: #1b5e20; text-align: center; font-weight: 700; letter-spacing: 1px; padding: 4px; }
.stmt-table tr.hd td { background: #eceff1; color: #607d8b; font-weight: 600; font-size: .74rem; padding: 2px 7px; }
.stmt-table tr.sub td { background: #bbdefb; color: #0d47a1; font-weight: 700; }
.stmt-table td.muted { text-align: center; color: var(--muted); }
.stmt-table tr.grand td { background: #37474f; color: #fff; font-size: .98rem; font-weight: 700; }
.stmt-table tr.grand td.num { color: #ffd54f; }
@media (max-width: 480px) {
    .stmt-table { font-size: .76rem; }
    .stmt-table td { padding: 2px 5px; }
    .stmt-table tr.hd td { font-size: .68rem; }
    .stmt-table tr.grand td { font-size: .9rem; }
}

/* ---------- 登入頁 ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
    background: linear-gradient(160deg, #f1f8f6 0%, #eef2f6 48%, #faf6ef 100%); }
.login-box { background: #fff; padding: 40px 30px 34px; border-radius: 18px;
    box-shadow: 0 12px 44px rgba(55,71,79,.12); width: 100%; max-width: 380px;
    border: 1px solid #eef1f3; text-align: center; }
.login-logo { width: 220px; max-width: 78%; height: auto; object-fit: contain;
    margin: 0 auto 14px; display: block; }
.login-box h1 { font-size: 1.3rem; margin: 0 0 4px; text-align: center; color: var(--primary); }
.login-box .subtitle { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: .9rem; }
.login-box form { text-align: left; }
.login-box label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
.login-box input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    margin-top: 6px; min-height: 46px; font-size: 1rem; transition: border-color .15s, box-shadow .15s; }
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,137,123,.12); }
.login-box .btn-block { margin-top: 4px; }

/* =========================================================
   RWD 響應式
   ========================================================= */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .nav { display: none; flex-direction: column; padding: 0 12px 12px; }
    .nav.open { display: flex; }
    .nav a.logout { margin-left: 0; }
    .user-chip { display: none; }

    /* 表格 → 卡片式 */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
        margin-bottom: 12px; padding: 8px 4px; box-shadow: var(--shadow); }
    .data-table td { border: none; border-bottom: 1px dashed #eceff1; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .data-table td:last-child { border-bottom: none; }
    .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; font-weight: 600; text-align: left; }
    .data-table td[data-label=""]::before { content: ""; }
    .actions { justify-content: flex-end; }

    .inline-form { flex-direction: column; align-items: stretch; }
    .search-bar { gap: 6px; align-items: center; }
    .search-bar input[type=text] { min-height: 34px; height: 34px; padding: 4px 10px; font-size: .88rem; }
    .search-bar .btn { min-height: 34px; height: 34px; padding: 2px 12px; font-size: .85rem; }
    .field.small { max-width: none; }
    .info-row { flex-direction: column; gap: 2px; }
}

@media (max-width: 420px) {
    .page-title { font-size: 1.25rem; }
    .container { padding: 16px 12px 50px; }
}

/* ---------- 成本統計 / 利潤報表 ---------- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.sum-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; background: var(--card); }
.sum-card.accent { border-color: var(--accent); background: rgba(0,137,123,.06); }
.sum-label { color: var(--muted); font-size: .82rem; }
.sum-value { font-size: 1.35rem; font-weight: 700; }
.profit-pos { color: #1b5e20; font-weight: 600; }
.profit-neg { color: #c62828; font-weight: 600; }
tfoot .grand-row td { background: #37474f; color: #fff; font-weight: 700; }

/* Excel 式成本工作表 */
.cost-xls td.ci { white-space: normal; word-break: break-all; }
.cost-xls td.ci input[type=text] { width: 100%; min-height: 26px; padding: 1px 4px; font-size: .8rem; border: 1px solid var(--border); border-radius: 4px; }
.cost-xls .c-qty { width: 46px; }
.cost-xls .c-amt { width: 78px; text-align: right; font-variant-numeric: tabular-nums; }
.cost-xls tr.cost-custom td.ci { background: #fffef7; }
.cost-xls tfoot .cost-foot td { background: #37474f; color: #fff; font-weight: 700; text-align: right; }
.cost-xls tfoot .cost-foot td:first-child { text-align: left; }
.cost-xls thead th.c-up, .cost-xls thead th.c-qty, .cost-xls thead th.c-amt { text-align: center; }

/* 個案進度：總覽清單的小圓標與詳細頁的逐項清單 */
.prog { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.prog-dot { background: #eceff1; color: #90a4ae; border: 1px solid var(--border); border-radius: 999px;
    padding: 2px 8px; font-size: .74rem; white-space: nowrap; }
.prog-dot.is-done { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; font-weight: 600; }
.prog-list { display: grid; gap: 6px; }
.prog-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border);
    border-radius: var(--radius); background: #fafafa; color: #78909c; }
.prog-row.is-done { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.prog-mark { width: 1.2em; text-align: center; font-weight: 700; }
.prog-name { flex: 1; font-weight: 600; }
.prog-when { font-size: .82rem; font-variant-numeric: tabular-nums; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 塔位資訊：紙本表單上的打勾欄，畫面上做成一排可點的選項 */
.pick-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 6px 0; }
.pick { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400;
        white-space: nowrap; cursor: pointer; }
/* 勾選圓圈要壓回實際大小：.field input 那條規則給了 width:100% 與 min-height:42px，
   套到 radio／checkbox 上會變成巨大的圓圈，在手機上直接壓過旁邊的文字。 */
.pick input[type=radio], .pick input[type=checkbox] {
    width: 20px; height: 20px; min-width: 20px; min-height: 20px;
    flex: 0 0 20px; margin: 0; padding: 0; accent-color: var(--primary);
}

/* 試算表式輸入表格（下單清單、塔位明細）。
   .xls-wrap 負責水平捲動：欄位多的表格寧可捲，也不要擠壓或撐破版面。 */
.xls-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
.xls { width: 100%; border-collapse: collapse; font-size: .82rem; }
.xls th, .xls td { border: 1px solid var(--border); padding: 2px 4px; text-align: left; vertical-align: middle; }
.xls thead th { background: #37474f; color: #fff; font-size: .76rem; padding: 5px 4px; font-weight: 600; white-space: nowrap; }
.xls td input { width: 100%; min-width: 0; min-height: 28px; padding: 2px 5px; font-size: .82rem;
                border: 1px solid transparent; border-radius: 4px; background: transparent; }
.xls td input:focus { border-color: var(--primary); background: #fff; outline: none; }
.xls tbody tr:nth-child(even) { background: #fafafa; }
.xls .rownum { width: 34px; text-align: center; color: var(--muted); font-size: .74rem; }
.xls .cell-qty { width: 84px; }
.xls .cell-del { width: 40px; text-align: center; }
.xls-del { border: 0; background: none; color: #c62828; cursor: pointer; font-size: .95rem; line-height: 1; padding: 4px 6px; }
.xls-del:hover { background: #ffebee; border-radius: 4px; }
.xls-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.xls-hint { color: var(--muted); font-size: .82rem; }

/* 塔位明細有 11 個欄位，窄畫面一定放不下：給最小寬度讓外框去捲，
   欄位各自給合理寬度，塔位名稱最寬（現場的名稱很長）。 */
.xls.unit-table { min-width: 940px; }
.unit-table th:nth-child(1), .unit-table td:nth-child(1) { width: 92px; }
.unit-table th:nth-child(2), .unit-table td:nth-child(2) { width: 100px; }
.unit-table th:nth-child(3), .unit-table td:nth-child(3) { width: 210px; }
.unit-table th:nth-child(4), .unit-table td:nth-child(4) { width: 76px; }
.unit-table th:nth-child(n+5):nth-child(-n+10),
.unit-table td:nth-child(n+5):nth-child(-n+10) { width: 58px; }
.unit-table th:nth-child(11), .unit-table td:nth-child(11) { width: 100px; }
/* 說明文字裡的範例字串很長，窄畫面要能折行，不然會把版面撐開 */
.record-form code { white-space: normal; word-break: break-word; background: #f5f5f5; padding: 1px 4px; border-radius: 3px; }

/* 塔位案件的處理進度標籤：未完成灰底、完成綠底，一眼掃得出來 */
.prog-cell { white-space: nowrap; }
.prog-tag { display: inline-block; padding: 2px 8px; margin: 1px 2px 1px 0; border-radius: 999px;
            font-size: .78rem; background: #eceff1; color: var(--muted); }
.prog-tag.on { background: #c8e6c9; color: #1b5e20; font-weight: 600; }

/* 塔位資料的備註列：細項在左、內容在右，尺寸與其他備註欄一致 */
.note-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.note-row .note-item { flex: 0 1 190px; padding: 10px 12px; border: 1px solid var(--border);
                       border-radius: 8px; min-height: 42px; font-size: .95rem; background: #fff; }
.note-row .note-content { flex: 1 1 auto; padding: 10px 12px; border: 1px solid var(--border);
                          border-radius: 8px; font-size: .95rem; background: #fff; resize: vertical; }
.note-row .note-del { align-self: center; }
@media (max-width: 640px) { .note-row { flex-wrap: wrap; } .note-row .note-item { flex: 1 1 100%; } }
