/* ===========================================================================
   報修管理系統 — 版面
   左側固定選單 + 頂列 + 內容區。寬度 < 992px 時選單收成抽屜，內容滿版。
   配色沿用舊系統（AdminLTE skin-blue）：主色 #3c8dbc，選單深灰藍 #222d32。
   =========================================================================== */
:root {
    --brand: #3c8dbc;
    --brand-dark: #357ca5;
    --sidebar-bg: #222d32;
    --sidebar-hover: #1e282c;
    --sidebar-text: #b8c7ce;
    --sidebar-w: 230px;
    --topbar-h: 50px;
    --page-bg: #ecf0f5;
    --bs-primary: #3c8dbc;
    --bs-primary-rgb: 60, 141, 188;
    --bs-link-color: #2f7fad;
    --bs-link-hover-color: #23608a;
}

html { font-size: 15px; }
body { font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif; background: var(--page-bg); color: #333; }
.icon { width: 18px; height: 18px; flex: none; }

.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand-dark); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: #2e6c8f; --bs-btn-active-bg: #2e6c8f; --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-dark); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(60, 141, 188, .2); }

/* ---------------------------------------------------------------- 頂列 */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 1030; background: var(--brand); color: #fff; display: flex; align-items: center; gap: .25rem; padding: 0 .5rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.1rem; padding: 0 .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.topbar-btn { background: none; border: 0; color: #fff; height: var(--topbar-h); min-width: 44px; padding: 0 .75rem; display: inline-flex; align-items: center; gap: .4rem; }
.topbar-btn:hover, .topbar-btn:focus-visible { background: var(--brand-dark); }
.notify-badge { position: absolute; top: 8px; right: 4px; font-size: .65rem; }
.notify-menu { width: min(360px, 94vw); padding: 0; max-height: 70vh; overflow-y: auto; }
.notify-item { display: block; padding: .6rem 1rem; border-bottom: 1px solid #f0f0f0; color: inherit; text-decoration: none; font-size: .9rem; white-space: normal; }
.notify-item.unread { background: #f3f9fd; }
.notify-item small { color: #888; display: block; }

/* ---------------------------------------------------------------- 左側選單
   預設收合成一列圖示（--rail-w）；展開是樹狀選單（--sidebar-w）。收合時每個群組的子選單會從右邊彈出，可以直接點。 */
:root { --rail-w: 54px; }
.sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); background: var(--sidebar-bg); overflow-y: auto; z-index: 1020; transition: transform .2s ease, width .2s ease; }
.nav-tree { list-style: none; margin: 0; padding: .35rem 0; }
.nav-node { position: relative; }
.nav-head { width: 100%; display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; background: none; border: 0; border-left: 3px solid transparent; color: var(--sidebar-text); text-align: left; text-decoration: none; white-space: nowrap; }
.nav-head:hover, .nav-head:focus-visible { background: var(--sidebar-hover); color: #fff; }
.nav-node.active > .nav-head { color: #fff; border-left-color: var(--brand); background: var(--sidebar-hover); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-head .caret { width: 14px; height: 14px; transition: transform .15s ease; opacity: .7; }
.nav-node.open > .nav-head .caret { transform: rotate(90deg); }
.nav-sub { display: none; background: #1a2226; padding: .25rem 0; }
.nav-node.open > .nav-sub { display: block; }
.nav-node.single > .nav-sub { display: none; }
.nav-sub-title { display: none; }
.nav-sub .nav-item { display: flex; align-items: center; gap: .5rem; padding: .42rem 1rem .42rem 2.95rem; color: var(--sidebar-text); text-decoration: none; font-size: .93rem; white-space: nowrap; }
.nav-sub .nav-item:hover, .nav-sub .nav-item:focus-visible { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-sub .nav-item.active { color: #fff; font-weight: 600; }
.nav-sub .nav-item.active::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); margin-left: -.85rem; margin-right: .2rem; }
.nav-sub .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-left: -.95rem; }
.nav-sub .nav-item.active .dot { display: none; }
.nav-divider { height: 1px; margin: .3rem 1rem .3rem 2.95rem; background: rgba(255, 255, 255, .08); }
.dot.tone-blue { background: #5aa7d6; } .dot.tone-red { background: #e0655f; } .dot.tone-amber { background: #e6a23c; } .dot.tone-gray { background: #8a99a3; } .dot.tone-green { background: #4cae7a; }
.sidebar-backdrop { display: none; }

.content { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 1rem) 1rem 0; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.content-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.content-header h1 { font-size: 1.45rem; font-weight: 500; margin: 0; }
.content-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.content-footer { margin-top: auto; padding: 1rem 0; color: #888; font-size: .85rem; text-align: center; }

/* 桌機收合：圖示列 + 彈出選單 */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { width: var(--rail-w); overflow: visible; }
    body.sidebar-collapsed .content { margin-left: var(--rail-w); }
    body.sidebar-collapsed .nav-head { justify-content: center; padding: .8rem 0; gap: 0; }
    body.sidebar-collapsed .nav-label, body.sidebar-collapsed .nav-head .caret { display: none; }
    body.sidebar-collapsed .nav-head .icon { width: 20px; height: 20px; }
    body.sidebar-collapsed .nav-sub, body.sidebar-collapsed .nav-node.open > .nav-sub { display: none; position: absolute; left: var(--rail-w); top: 0; min-width: 210px; padding: 0 0 .35rem; background: #1e282c; border-radius: 0 6px 6px 0; box-shadow: 4px 4px 14px rgba(0, 0, 0, .3); z-index: 1040; }
    body.sidebar-collapsed .nav-node:hover > .nav-sub, body.sidebar-collapsed .nav-node:focus-within > .nav-sub, body.sidebar-collapsed .nav-node.fly > .nav-sub { display: block; }
    body.sidebar-collapsed .nav-node:hover > .nav-head, body.sidebar-collapsed .nav-node.fly > .nav-head { background: var(--sidebar-hover); color: #fff; }
    body.sidebar-collapsed .nav-sub-title { display: block; padding: .72rem 1rem; color: #fff; font-weight: 600; background: var(--brand-dark); border-radius: 0 6px 0 0; white-space: nowrap; }
    body.sidebar-collapsed .nav-node.single > .nav-sub { padding: 0; min-width: 0; }
    body.sidebar-collapsed .nav-node.single .nav-sub-title { border-radius: 0 6px 6px 0; }
    body.sidebar-collapsed .nav-sub .nav-item { padding: .45rem 1.1rem .45rem 1.6rem; }
    body.sidebar-collapsed .nav-divider { margin: .3rem 1rem; }
    /* 靠近畫面底部的群組：選單往上長，不會跑出畫面 */
    /* 彈出選單的上下位置由 site.js 的 placeFlyout 計算：預設對齊圖示，超出畫面下緣才往上移，而且不會移到頁首後面 */
}

/* 手機、平板：選單變抽屜，裡面是展開的樹狀選單 */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: min(280px, 82vw); box-shadow: 2px 0 8px rgba(0, 0, 0, .3); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .45); z-index: 1015; }
    .content { margin-left: 0; padding-left: .75rem; padding-right: .75rem; }
    .content-header h1 { font-size: 1.25rem; }
}

/* ---------------------------------------------------------------- 卡片、表格 */
.box { background: #fff; border-radius: 4px; border-top: 3px solid var(--brand); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); margin-bottom: 1rem; }
.box-header { padding: .7rem 1rem; border-bottom: 1px solid #f0f0f0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.box-header h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.box-body { padding: 1rem; }
.box-body.flush { padding: 0; }

.table { margin: 0; }
.table > thead th { background: #f7f9fb; font-weight: 600; white-space: nowrap; border-bottom-width: 1px; }
.table td, .table th { vertical-align: middle; }
.table-hover tbody tr { cursor: default; }
.row-link { cursor: pointer; }

/* 窄螢幕：表格每一列改成一張卡片，欄名來自 data-label，不需要左右捲動 */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border-bottom: 8px solid var(--page-bg); padding: .5rem 0; }
    .table-stack td { border: 0; padding: .25rem 1rem; display: flex; gap: .75rem; }
    .table-stack td::before { content: attr(data-label); flex: 0 0 5.5em; color: #777; font-size: .85rem; }
    .table-stack td[data-label=""]::before { display: none; }
    .table-stack td.actions { justify-content: flex-end; }
}

.kpi { background: #fff; border-radius: 4px; padding: 1rem; display: flex; align-items: center; gap: .9rem; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); color: inherit; text-decoration: none; height: 100%; }
.kpi:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, .18); color: inherit; }
.kpi .num { font-size: 1.9rem; font-weight: 600; line-height: 1; }
.kpi .lbl { color: #666; font-size: .9rem; }
.kpi .bar { width: 6px; align-self: stretch; border-radius: 3px; }

.stat-row { display: grid; grid-template-columns: minmax(6em, 14em) 1fr 3.5em; gap: .6rem; align-items: center; padding: .3rem 0; font-size: .92rem; }
.stat-row .track { background: #eef2f5; border-radius: 3px; height: 14px; overflow: hidden; }
.stat-row .fill { background: var(--brand); height: 100%; }
.stat-row .val { text-align: right; font-variant-numeric: tabular-nums; }
.stat-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 右側面板 */
.side-panel { --bs-offcanvas-width: min(680px, 100vw); }
.side-panel.wide { --bs-offcanvas-width: min(920px, 100vw); }
.side-panel .offcanvas-header { background: var(--brand); color: #fff; padding: .75rem 1rem; }
.side-panel .offcanvas-header .btn-close { filter: invert(1) grayscale(1) brightness(2); opacity: .9; }
.side-panel .offcanvas-body { padding: 0; display: flex; flex-direction: column; }
.panel-scroll { flex: 1; overflow-y: auto; padding: 1rem; }
.panel-footer { border-top: 1px solid #e5e5e5; padding: .75rem 1rem; background: #fafafa; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.panel-section { font-weight: 600; color: var(--brand-dark); border-bottom: 1px solid #e3ebf0; padding-bottom: .3rem; margin: 1.25rem 0 .75rem; }
.panel-section:first-child { margin-top: 0; }
.form-label { font-size: .9rem; color: #555; margin-bottom: .2rem; }
.form-label.required::after { content: " *"; color: #d9534f; }
.field-error { color: #d9534f; font-size: .85rem; margin-top: .15rem; }
.dl { display: grid; grid-template-columns: 7em 1fr; gap: .35rem .75rem; margin: 0; }
.dl dt { color: #777; font-weight: 400; }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 480px) { .dl { grid-template-columns: 5.5em 1fr; } }

/* 處理歷程 */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid #d2dde4; padding: 0 0 1rem 1rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .3rem; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); }
.timeline .meta { color: #777; font-size: .85rem; }
.timeline .text { white-space: pre-wrap; word-break: break-word; }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; }

/* ---------------------------------------------------------------- 遮罩與小眼睛 */
.secret { display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; }
.secret-value { font-variant-numeric: tabular-nums; word-break: break-all; }
.secret-btn { border: 0; background: none; padding: .1rem .25rem; color: #6c8494; line-height: 1; border-radius: 3px; }
.secret-btn:hover, .secret-btn:focus-visible { color: var(--brand-dark); background: #eef4f8; }
.secret.revealed .secret-value { color: #1a1a1a; font-weight: 500; }

/* ---------------------------------------------------------------- 簽名板 */
.signature-pad { border: 1px dashed #9db3c1; border-radius: 4px; background: #fff; width: 100%; height: 180px; touch-action: none; display: block; }

/* ---------------------------------------------------------------- 登入前的頁面
   外觀沿用舊系統登入頁：漸層標題列、淺藍底、白色圓角卡片、三個頁籤。 */
body.auth { background: linear-gradient(135deg, #d6eaf8 0%, #ebf5fb 50%, #f0f7fd 100%) fixed; min-height: 100vh; color: #2c3e50; font-size: 1rem; }
.auth-header { padding: 1rem 2rem; color: #fff; text-align: center; background: linear-gradient(135deg, #3c8dbc 0%, #2980b9 100%); box-shadow: 0 2px 8px rgba(60, 141, 188, .3); }
.auth-header h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: 2px; line-height: 1.2; margin: 0; text-shadow: 1px 1px 4px rgba(0, 0, 0, .25); }
.auth-header p { font-size: .9rem; opacity: .85; letter-spacing: 1px; margin: .2rem 0 0; }
.auth-main { max-width: 960px; margin: 2rem auto; padding: 0 1rem 3rem; }
.auth-card { background: #fff; border: 1px solid #d1e8f5; border-radius: 16px; box-shadow: 0 8px 30px rgba(60, 141, 188, .15); overflow: hidden; }
.auth-card.narrow { max-width: 520px; margin: 0 auto; }

.auth-tabs { display: flex; list-style: none; margin: 0; padding: 0; background: #f0f7fd; border-bottom: 2px solid #d1e8f5; }
.auth-tabs li { flex: 1; display: flex; }
.auth-tab { flex: 1; padding: 1rem .5rem; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; background: transparent; font-size: 1rem; font-weight: 600; color: #6b8fa8; display: flex; align-items: center; justify-content: center; gap: .4rem; transition: color .25s ease, background-color .25s ease, border-color .25s ease; }
.auth-tab:hover { color: #3c8dbc; background: rgba(60, 141, 188, .06); }
.auth-tab.active { color: #2980b9; border-bottom-color: #2980b9; background: #fff; }
.auth-tab:focus-visible { outline: 2px solid #2980b9; outline-offset: -2px; }

.auth-pane { padding: 2rem; }
.auth-title { text-align: center; margin-bottom: 1.5rem; }
.auth-title h2 { font-size: 1.5rem; font-weight: 700; color: #2c3e50; margin: 0 0 .4rem; display: flex; align-items: center; justify-content: center; gap: .5rem; }
.auth-title h2 .icon { width: 1.4rem; height: 1.4rem; color: #3c8dbc; }
.auth-title p { color: #777; font-size: .95rem; margin: 0; }
.auth-form { max-width: 420px; margin: 0 auto; }
.auth-form.wide { max-width: 760px; }
.auth-card.narrow .auth-pane > * { max-width: 420px; margin-left: auto; margin-right: auto; }
.auth-card.narrow .auth-pane > a.btn { display: block; }

.auth-label, body.auth .form-label { display: block; color: #555; margin: 0 0 .4rem; font-weight: 500; font-size: .95rem; }
.auth-label.required::after { content: " *"; color: #e53e3e; }
.auth-input { position: relative; margin-bottom: 1.1rem; }
.auth-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: #999; pointer-events: none; }
.auth-input input { padding-left: 38px !important; }
.auth-input input, body.auth .form-control, body.auth .form-select { width: 100%; padding: 11px 12px; border: 1px solid #cfe0ea; border-radius: 8px; background-color: #fff; color: #333; font-size: 1rem; line-height: 1.4; transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
body.auth .form-select { padding-right: 2.25rem; }
.auth-input input:focus, body.auth .form-control:focus, body.auth .form-select:focus { outline: 0; border-color: #3c8dbc; background-color: #f0f7fd; box-shadow: 0 0 0 3px rgba(60, 141, 188, .18); }
.auth-input input::placeholder, body.auth .form-control::placeholder { color: #bbb; }

.auth-submit, body.auth .btn-primary { width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: 1.4rem; padding: 11px; border: 0; border-radius: 8px; background: linear-gradient(135deg, #3c8dbc 0%, #2980b9 100%); color: #fff; font-size: 1rem; font-weight: 600; text-decoration: none; transition: box-shadow .2s ease, transform .2s ease; }
.auth-submit:hover, body.auth .btn-primary:hover { background: linear-gradient(135deg, #2980b9 0%, #1a6fa0 100%); box-shadow: 0 6px 20px rgba(60, 141, 188, .4); transform: translateY(-1px); color: #fff; }
.auth-submit:disabled { opacity: .65; transform: none; box-shadow: none; }
.auth-links { text-align: center; margin-top: 1rem; }
.auth-links a, body.auth .btn-link { color: #3c8dbc; text-decoration: none; font-size: .9rem; }
.auth-links a:hover, body.auth .btn-link:hover { text-decoration: underline; }
.auth-errors, body.auth .validation-summary-errors { color: #e53e3e; font-size: .9rem; margin-bottom: .8rem; }
.auth-errors ul, body.auth .validation-summary-errors ul { list-style: none; padding: .7rem 1rem; margin: 0; background: #fdf0ef; border: 1px solid #f5c6c2; border-radius: 8px; }
.auth-errors.validation-summary-valid { display: none; }
body.auth .alert { border-radius: 8px; font-size: .95rem; }
body.auth .alert-info { background: #e8f4fd; border-color: #b8dcf2; color: #2c7cb0; }
.auth-dev { padding: .7rem 1rem; background: #fff8e1; border-top: 1px solid #f3e2a9; color: #7a5d00; font-size: .85rem; text-align: center; }
.otp-input { font-size: 1.8rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.pw-rules { font-size: .85rem; color: #666; padding-left: 1.1rem; margin: .4rem 0 0; }

@media (max-width: 480px) {
    .auth-header { padding: .85rem 1rem; }
    .auth-header h1 { font-size: 1.1rem; letter-spacing: 1px; }
    .auth-header p { font-size: .78rem; }
    .auth-main { margin: 1rem auto; padding: 0 .75rem 2rem; }
    .auth-pane { padding: 1.5rem 1.1rem; }
    .auth-tab { font-size: .9rem; padding: .85rem .25rem; gap: .25rem; }
    .auth-title h2 { font-size: 1.3rem; }
}

.badge-status { font-weight: 500; font-size: .82rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem .75rem; }
.duty-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.duty-cell { background: #fff; border: 1px solid #e3e8ec; border-radius: 4px; padding: .35rem; min-height: 78px; font-size: .88rem; }
.duty-cell.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.duty-cell.past { background: #f6f7f8; color: #999; }
.duty-cell .d { font-weight: 600; }
.duty-head { text-align: center; font-weight: 600; color: #666; padding: .25rem 0; }
@media (max-width: 767.98px) {
    .duty-grid { grid-template-columns: 1fr; }
    .duty-head, .duty-cell.blank { display: none; }
    .duty-cell { min-height: 0; display: flex; align-items: center; gap: .75rem; }
}

/* ---------------------------------------------------------------- 操作紀錄：舊值（劃掉）→ 新值 */
.audit-changes { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.audit-changes li { padding: .1rem 0; word-break: break-word; }
.audit-field { color: #666; margin-right: .4rem; }
.audit-field::after { content: "："; }
.audit-old { color: #b04a45; background: #fdf0ef; text-decoration: line-through; padding: 0 .25rem; border-radius: 3px; }
.audit-new { color: #1e7a45; background: #edf8f1; text-decoration: none; padding: 0 .25rem; border-radius: 3px; }
.audit-arrow { color: #999; margin: 0 .3rem; }
.history-item { border-bottom: 1px solid #f0f0f0; padding: .6rem 0; }
.history-item:last-child { border-bottom: 0; }
.history-item .meta { color: #777; font-size: .85rem; margin-bottom: .2rem; }

/* ---------------------------------------------------------------- 全站一致性
   把 Bootstrap 預設的亮藍色（連結、頁籤、勾選框、分頁）統一成系統主色。 */
:root { --bs-link-color-rgb: 47, 127, 173; --bs-link-hover-color-rgb: 35, 96, 138; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, .sidebar a:hover, .topbar a:hover, .dropdown-item:hover, .kpi:hover, .notify-item:hover { text-decoration: none; }
.btn { white-space: nowrap; }
.btn .icon { vertical-align: -3px; }
.btn-sm .icon { width: 15px; height: 15px; }
:focus-visible { outline: 2px solid rgba(60, 141, 188, .6); outline-offset: 1px; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); --bs-nav-link-color: #2f7fad; --bs-nav-link-hover-color: #23608a; gap: .25rem; }
.nav-pills .nav-link { padding: .4rem .95rem; }
.nav-pills .nav-link:not(.active):hover { background: #dfeaf1; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(60, 141, 188, .2); }
.pagination { --bs-pagination-color: #2f7fad; --bs-pagination-hover-color: #23608a; --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(60, 141, 188, .2); margin: 0; flex-wrap: wrap; }
.dropdown-item:active { background-color: var(--brand); }
.alert { border-radius: 4px; }
.badge { letter-spacing: .02em; }
.text-muted { color: #777 !important; }

/* 表格：桌機版不讓短欄位（單號、狀態、時間、人名、按鈕）斷行，長文字欄位才換行 */
.table { font-size: .95rem; }
.table > :not(caption) > * > * { padding: .55rem .75rem; }
.table > thead th { color: #555; font-size: .88rem; }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table td.actions { white-space: nowrap; text-align: right; width: 1%; }
.table td.actions .btn + .btn { margin-left: .25rem; }
@media (min-width: 768px) {
    .table > :not(caption) > * > :first-child { padding-left: 1rem; }
    .table > :not(caption) > * > :last-child { padding-right: 1rem; }
    .table td[data-label="單號"], .table td[data-label="狀態"], .table td[data-label="聯絡人"], .table td[data-label="工程師"],
    .table td[data-label$="時間"], .table td[data-label$="日期"], .table td[data-label="帳號"], .table td[data-label="最後登入"],
    .table td[data-label="時效"], .table td[data-label="建立"], .table td[data-label="區域"], .table td[data-label="部門"] { white-space: nowrap; }
}
.box-body.flush > .table-responsive, .box-body.flush > .table { border-radius: 0 0 4px 4px; }
.box-footer { padding: .6rem 1rem; border-top: 1px solid #f0f0f0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; color: #777; font-size: .9rem; }

/* 頂列在手機上：標題縮小，避免把右側按鈕擠掉 */
.topbar .brand { min-width: 0; flex: 0 1 auto; }
@media (max-width: 575.98px) {
    .topbar .brand { font-size: .95rem; padding: 0 .25rem; }
    .content-actions { width: 100%; }
    .content-actions .btn { flex: 1; }
    .panel-footer .btn { flex: 1; }
    .kpi { padding: .8rem; }
    .kpi .num { font-size: 1.6rem; }
}

/* ---------------------------------------------------------------- 值班表補充：週末、月份小計 */
.duty-cell { transition: box-shadow .15s ease; }
.duty-cell:not(.past):not(.blank):hover { box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.duty-cell.weekend { background: #fbf7f6; }
.duty-cell.weekend .d { color: #c0524c; }
.duty-cell.past.weekend { background: #f6f7f8; }
.duty-cell.blank { border-color: transparent; background: transparent; }
.duty-cell .duty-name { margin-top: .2rem; }
.duty-head:first-child, .duty-head:nth-child(7) { color: #c0524c; }
.duty-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid #f0f0f0; font-size: .9rem; }
.duty-summary .lbl { color: #777; margin-right: .25rem; }
.duty-summary .chip { background: #eef4f8; color: #2c5d7c; border-radius: 999px; padding: .15rem .7rem; white-space: nowrap; }
.duty-summary .chip b { margin-left: .4rem; font-variant-numeric: tabular-nums; }
.duty-summary .chip.warn { background: #fff4e0; color: #8a5a00; }
.duty-cell .d { white-space: nowrap; }
.record-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.settings-confirm { margin-top: 1.25rem; padding: .9rem 1rem; background: #fff8e1; border: 1px solid #f3e2a9; border-radius: 4px; max-width: 460px; }
.job-row { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.job-row:first-child { padding-top: 0; }
.job-row:last-child { border-bottom: 0; padding-bottom: 0; }
.job-head { margin-bottom: .5rem; }
.job-status { margin-top: .5rem; word-break: break-word; }
/* 系統設定頁：區塊填滿右側；寬螢幕時寄信與 AD 左右並排，排程在下方滿版 */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; align-items: start; }
@media (min-width: 1300px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.settings-confirm { max-width: none; }

/* ---------------------------------------------------------------- 可搜尋的下拉選單 */
.ss { position: relative; }
.ss-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; }
.ss-toggle { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ss-toggle.ss-placeholder { color: #8a949c; }
.ss-toggle:disabled { background-color: #e9ecef; cursor: default; }
.ss-toggle.is-invalid { border-color: #d9534f; }
.ss.open .ss-toggle { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(60, 141, 188, .2); }
.ss-menu { position: absolute; z-index: 1080; top: calc(100% + 3px); left: 0; right: 0; min-width: 200px; background: #fff; border: 1px solid #cfd8de; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .16); padding: .4rem; }
.ss.up .ss-menu { top: auto; bottom: calc(100% + 3px); }
.ss-input { margin-bottom: .35rem; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.ss-list li { padding: .4rem .6rem; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-list li.active { background: #e8f2f8; }
.ss-list li.selected { font-weight: 600; color: var(--brand-dark); }
.ss-list li.selected::after { content: " ✓"; }
.ss-empty { padding: .5rem .6rem; color: #888; font-size: .9rem; }
body.auth .ss-toggle { padding: 11px 2.25rem 11px 12px; border: 1px solid #cfe0ea; border-radius: 8px; font-size: 1rem; line-height: 1.4; }
@media (max-width: 575.98px) { .ss-list { max-height: 45vh; } .ss-list li { padding: .6rem .6rem; } }

/* ---------------------------------------------------------------- 疑似重複報修的提示 */
.dup-box { background: #fff8e1; border: 1px solid #f0d98a; border-left: 4px solid #e0a800; border-radius: 4px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .93rem; }
.dup-title { font-weight: 600; color: #6b5200; margin-bottom: .4rem; }
.dup-box ul { margin: 0 0 .6rem; padding-left: 1.2rem; }
.dup-box li { padding: .1rem 0; word-break: break-word; }
.dup-box li a { font-weight: 600; }
.dup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }

/* ---------------------------------------------------------------- 值班表：名單、假日、季年檢視、列印 */
.sort-list { list-style: decimal; padding-left: 2rem; margin: 0 0 .75rem; }
.sort-list:empty::before { content: "名單是空的，請從下方加入人員。"; color: #888; font-size: .9rem; margin-left: -2rem; }
.sort-list li { padding: .3rem 0; border-bottom: 1px solid #f0f0f0; }
.sort-list li > .sort-name { display: inline-block; min-width: 10em; }
.sort-actions { display: inline-flex; gap: .25rem; float: right; }
.special-list { list-style: none; padding: 0; margin: .75rem 0 0; }
.special-list li { display: flex; align-items: center; gap: .6rem; padding: .25rem 0; border-bottom: 1px solid #f0f0f0; }
.special-list li .btn { margin-left: auto; }
.month-checks { display: flex; flex-wrap: wrap; gap: 0 .25rem; }
.duty-month { font-size: 1rem; font-weight: 600; color: var(--brand-dark); margin: 1.25rem 0 .5rem; }
.duty-month:first-of-type { margin-top: 0; }
.duty-grid.compact .duty-cell { min-height: 52px; font-size: .82rem; padding: .25rem .3rem; }
.duty-cell.holiday { background: #fdf1ef; }
.duty-cell.holiday .d { color: #c0524c; }
.duty-cell.past.holiday { background: #f6f1f0; }
.duty-tag { margin-left: .35rem; font-size: .72rem; font-weight: 400; color: #c0524c; white-space: nowrap; }
.duty-tag.work { color: #1b7d8f; }
.duty-fri { margin-left: .3rem; font-size: .7rem; background: #e8f2f8; color: var(--brand-dark); border-radius: 3px; padding: 0 .25rem; }
@media print {
    .topbar, .sidebar, .sidebar-backdrop, .content-footer, .toast-container, .offcanvas, .offcanvas-backdrop, .d-print-none { display: none !important; }
    .content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
    .box { box-shadow: none; border: 0; }
    .duty-grid { gap: 2px; }
    .duty-cell { break-inside: avoid; border-color: #999; }
    .duty-month { break-after: avoid; }
}

/* ---------------------------------------------------------------- 報修儀表板
   面板高度固定、清單在面板內捲動：資料再多，整頁也不會被拉長。 */
.dash-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.dash-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
.dash-kpis .kpi { position: relative; padding: .8rem .9rem; gap: .75rem; }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi-icon.tone-blue { background: #e6f1f8; color: #2f7fad; } .kpi-icon.tone-amber { background: #fdf2dc; color: #b7791f; } .kpi-icon.tone-green { background: #e3f4ea; color: #2f855a; }
.kpi-icon.tone-gray { background: #eceff1; color: #5f6b73; } .kpi-icon.tone-red { background: #fde8e6; color: #c0524c; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-body .num { font-size: 1.75rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-body .lbl { color: #666; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-chip { position: absolute; top: .5rem; right: .6rem; font-size: .72rem; background: #eef4f8; color: #2c5d7c; border-radius: 999px; padding: .05rem .5rem; }
.kpi.alert-tile { box-shadow: inset 0 0 0 1px #f0c4c0, 0 1px 2px rgba(0, 0, 0, .1); }
.dash-summary { margin: .7rem 0 .8rem; color: #555; font-size: .93rem; }
.dash-summary b { color: #222; font-variant-numeric: tabular-nums; }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.dash-panel { background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); display: flex; flex-direction: column; height: 262px; min-width: 0; }
.dash-panel > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .9rem; border-bottom: 1px solid #f0f2f4; min-height: 44px; }
.dash-panel > header h2 { font-size: .98rem; font-weight: 600; margin: 0; white-space: nowrap; }
.dash-body { flex: 1; min-height: 0; padding: .7rem .9rem; overflow: hidden; }
.dash-body.scroll { overflow-y: auto; padding-top: .35rem; overscroll-behavior: contain; }
.dash-empty { color: #888; font-size: .9rem; margin: .5rem 0; }
.dash-sub { font-size: .82rem; font-weight: 600; color: #555; margin: .1rem 0 .3rem; }
.dash-sub small { font-weight: 400; color: #888; margin-left: .3rem; }
.dash-more { font-size: .82rem; color: #888; margin: .4rem 0 0; }

.legend { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: #555; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: .5rem; }
.chart { width: 100%; height: 100%; display: block; }
.chart .val { font-size: 10px; fill: #444; text-anchor: middle; font-variant-numeric: tabular-nums; }
.chart .axis { font-size: 11px; fill: #777; text-anchor: middle; }
.chart g:hover rect { fill: rgba(60, 141, 188, .07); }

.seg-bar { display: flex; gap: 2px; height: 26px; border-radius: 5px; overflow: hidden; margin: .2rem 0 .7rem; }
.seg-bar span { min-width: 3px; }
.seg-legend { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.seg-legend li { display: flex; align-items: center; gap: .5rem; padding: .22rem 0; border-bottom: 1px solid #f4f5f6; }
.seg-legend li:last-child { border-bottom: 0; }
.seg-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.seg-legend span { flex: 1; color: #444; }
.seg-legend b { font-variant-numeric: tabular-nums; }
.seg-legend small { color: #888; width: 3em; text-align: right; font-variant-numeric: tabular-nums; }

.hbar { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.hbar li { display: grid; grid-template-columns: minmax(0, 8.5em) 1fr 2.6em; align-items: center; gap: .5rem; padding: .28rem 0; }
.hbar .name { color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { background: #eef2f5; border-radius: 0 4px 4px 0; height: 12px; }
.hbar .fill { display: block; height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

.duty-now { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .7rem; }
.duty-now > div { background: #f5f8fa; border-radius: 6px; padding: .5rem .7rem; min-width: 0; }
.duty-now .lbl { display: block; font-size: .78rem; color: #777; }
.duty-now strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.mini-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .2rem 0; border-bottom: 1px solid #f4f5f6; }
.mini-list li:last-child { border-bottom: 0; }

.dash-tabs { border-bottom: 0; gap: .15rem; flex-wrap: nowrap; }
.dash-tabs .nav-link { border: 0; border-radius: 4px; padding: .2rem .6rem; font-size: .88rem; color: #666; white-space: nowrap; }
.dash-tabs .nav-link.active { background: #e6f1f8; color: #23608a; font-weight: 600; }
.dash-tabs .count { font-variant-numeric: tabular-nums; opacity: .8; margin-left: .15rem; }
.dash-search { max-width: 9.5em; }
.item-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.item-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: .6rem; align-items: center; padding: .34rem 0; border-bottom: 1px solid #f4f5f6; }
.item-list li:last-child { border-bottom: 0; }
.item-list a { font-weight: 600; font-variant-numeric: tabular-nums; }
.item-list .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-list .meta { grid-column: 2; color: #888; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-list .badge, .item-list .qty { grid-row: 1 / span 2; grid-column: 3; }
.item-list .qty { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-pair.active { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1199.98px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-panel { height: auto; max-height: 300px; }
    .dash-search { max-width: 7em; }
}
.dash-panel .hint { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e3e8ec; color: #5f6b73; font-size: .7rem; font-weight: 600; cursor: help; vertical-align: 1px; }
.dash-sub[title] { cursor: help; }
.rank { margin: 0; padding-left: 1.25rem; font-size: .84rem; line-height: 1.22; }
.rank li { padding: .06rem 0; }
.rank li span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank li b { font-variant-numeric: tabular-nums; }
.rank li small { color: #888; margin-left: .35rem; }
.dash-body.tab-content { overflow-y: auto; }
.rank-pair .dash-sub { margin: 0 0 .12rem; }

/* ---------------------------------------------------------------- 列表：排序與欄位顯示 */
.table [hidden] { display: none !important; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover, th.sortable:focus-visible { background: #f3f7fc; outline: 0; }
th.sortable .sort-icon { width: .95em; height: .95em; margin-left: .2rem; opacity: .35; vertical-align: -.12em; }
th.sortable.sorted { color: var(--bs-primary); }
th.sortable.sorted .sort-icon { opacity: 1; }
.table-tools { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; padding: .45rem 1rem; border-bottom: 1px solid #f0f0f0; }
.table-tools .btn .icon { width: 1em; height: 1em; vertical-align: -.12em; margin-right: .2rem; }
.col-menu { min-width: 13rem; max-height: 60vh; overflow-y: auto; font-size: .9rem; padding: .35rem 0; }
.col-menu label { display: flex; align-items: center; gap: .5rem; padding: .28rem .9rem; margin: 0; cursor: pointer; }
.col-menu label:hover { background: #f3f7fc; }
.col-menu label.locked { color: #999; cursor: default; }
.col-menu .col-menu-actions { display: flex; gap: .4rem; padding: .45rem .9rem .2rem; border-top: 1px solid #eee; margin-top: .3rem; }
.cell-clip { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767.98px) { .cell-clip { max-width: none; white-space: normal; } }
@media print { .table-tools, .sort-icon { display: none !important; } }
.cell-md { min-width: 8.5rem; }
.col-menu { max-height: 72vh; padding-bottom: 0; }
.col-menu .col-menu-actions { position: sticky; bottom: 0; background: #fff; padding-bottom: .5rem; }
@media (max-width: 767.98px) { .cell-md { min-width: 0; } }

/* 列表內容不換行（問題敘述這類長文字除外），放不下就左右捲；捲軸固定貼在視窗下緣；凍結欄留在左邊 */
.table-wrap { scrollbar-width: none; }
.table-wrap::-webkit-scrollbar { display: none; }
.table-xscroll { position: sticky; bottom: 0; z-index: 6; overflow-x: auto; overflow-y: hidden; height: 17px; background: #fff; border-top: 1px solid #e6eaee; }
.table-xscroll > div { height: 1px; }
@media (min-width: 768px) {
    table[data-table] th, table[data-table] td { white-space: nowrap; }
    table[data-table] td.cell-wrap { white-space: normal; }
    table[data-table] td.cell-wrap > .wrap-text { width: 22rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
    table[data-table] .col-frozen { position: sticky; z-index: 2; background-color: #fff; }
    table[data-table] thead .col-frozen { z-index: 3; background-color: #f7f9fb; }
    table[data-table] .col-frozen-last::after { content: ""; position: absolute; top: 0; bottom: 0; right: -6px; width: 6px; pointer-events: none; background: linear-gradient(to right, rgba(0, 0, 0, .09), transparent); }
    table[data-table].table-hover tbody tr:hover > .col-frozen { background-color: #f2f2f2; }
}
@media (max-width: 767.98px) { .table-xscroll { display: none; } }
@media print { .table-xscroll { display: none !important; } }

/* ---------------------------------------------------------------- 報修表單：ERP 訂單搜尋 */
.erp-pick { position: relative; }
.erp-results { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid #cfd8df; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); padding: .25rem; max-height: 320px; }
.erp-results li { white-space: normal; line-height: 1.35; }
.erp-results li strong { color: var(--brand-dark); margin-right: .4rem; }
.erp-results li small { display: block; color: #888; }
.erp-results li.empty { color: #888; cursor: default; }
.erp-results li .badge { font-weight: 500; margin-left: .35rem; }

/* ---------------------------------------------------------------- 系統訊息與二次確認（全系統共用這一組，不使用瀏覽器內建的 alert / confirm）
   提示訊息：右下角的 .toast（成功綠、失敗紅）；二次確認：.app-dialog（一般藍、危險操作紅） */
.toast-container .toast { border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-size: .95rem; min-width: 240px; }
.toast-container .toast.text-bg-success { background-color: #1e8e5a !important; }
.toast-container .toast.text-bg-danger { background-color: #c9302c !important; }
.toast-container .toast-body { padding: .7rem 1rem; white-space: pre-line; }
.app-dialog .modal-dialog { max-width: 430px; }
.app-dialog .modal-content { border: 0; border-top: 3px solid var(--brand); border-radius: 6px; box-shadow: 0 14px 44px rgba(0, 0, 0, .28); }
.app-dialog.danger .modal-content { border-top-color: #c9302c; }
.app-dialog .modal-header { border: 0; padding: 1.1rem 1.3rem .3rem; }
.app-dialog .modal-title { font-size: 1.08rem; font-weight: 600; color: #333; }
.app-dialog .modal-body { padding: .45rem 1.3rem 1.1rem; color: #555; white-space: pre-line; line-height: 1.6; }
.app-dialog .modal-footer { border: 0; padding: 0 1.3rem 1.1rem; gap: .5rem; }
.app-dialog .modal-footer .btn { min-width: 5.5rem; margin: 0; }

/* 欄位檢查的提示氣泡：取代瀏覽器內建的小氣泡，全系統同一個樣式 */
.field-bubble { position: fixed; z-index: 1095; max-width: min(300px, 90vw); background: #fff; color: #8a2522; border: 1px solid #e7bcba; border-left: 3px solid #c9302c; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); padding: .42rem .75rem; font-size: .9rem; line-height: 1.45; pointer-events: none; }
.field-bubble::before { content: ""; position: absolute; left: 14px; top: -6px; width: 10px; height: 10px; background: #fff; border-left: 1px solid #e7bcba; border-top: 1px solid #e7bcba; transform: rotate(45deg); }
.field-bubble.above::before { top: auto; bottom: -6px; transform: rotate(225deg); }
.ss:has(select.is-invalid) .ss-toggle { border-color: #dc3545; }
@media print { .field-bubble { display: none !important; } }

/* ---------------------------------------------------------------- 左上角公司標誌：原圖是藍字黑字，放在白底小牌子上才看得清楚 */
.topbar .brand { display: inline-flex; align-items: center; gap: .65rem; }
.topbar .brand-logo { height: 30px; width: auto; background: #fff; border-radius: 5px; padding: 3px 8px; box-sizing: content-box; flex: 0 0 auto; }
.topbar .brand-text { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) { .topbar .brand-text { display: none; } .topbar .brand-logo { height: 26px; } }

/* ---------------------------------------------------------------- 報修單的附檔：依種類分組，照片縮圖、影片與語音可以直接播放 */
.file-group { margin-top: .6rem; }
.file-group-title { font-size: .82rem; color: #777; margin-bottom: .25rem; }
.file-group-title b { color: #444; font-weight: 600; }
.media-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.media-item { max-width: 100%; }
.media-item video { display: block; width: 300px; max-width: 100%; max-height: 220px; background: #000; border-radius: 4px; }
.media-item audio { display: block; width: 300px; max-width: 100%; }
.media-item .media-name { font-size: .8rem; color: #666; margin-top: .15rem; word-break: break-all; }
.file-list { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.file-list li { padding: .1rem 0; }

/* ---------------------------------------------------------------- 報修單明細：每次服務一個頁籤 */
.reply-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; border-bottom: 1px solid #d5dee5; }
.reply-tabs .nav-link { white-space: nowrap; color: #555; padding: .45rem .85rem; line-height: 1.25; text-align: center; border-radius: 6px 6px 0 0; }
.reply-tabs .nav-link small { display: block; font-size: .78rem; color: #888; }
.reply-tabs .nav-link.active { color: var(--brand-dark); font-weight: 600; border-color: #d5dee5 #d5dee5 #fff; border-top: 2px solid var(--brand); }
.reply-tabs .nav-link.active small { color: var(--brand-dark); }
.tab-signed { display: inline-block; font-size: .7rem; font-weight: 500; color: #1e8e5a; border: 1px solid #a9d9c1; border-radius: 8px; padding: 0 .35rem; margin-left: .2rem; vertical-align: 1px; }
.reply-panes { border: 1px solid #d5dee5; border-top: 0; border-radius: 0 0 6px 6px; padding: 1rem; margin-bottom: 1rem; background: #fff; }
.reply-text { white-space: pre-wrap; word-break: break-word; }
.sign-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }
.sign-box { border: 1px solid #d5dee5; border-radius: 6px; padding: .6rem .75rem .75rem; display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.sign-title { font-weight: 600; color: #444; font-size: .92rem; }
.sign-image { max-width: 100%; max-height: 110px; background: #fff; border: 1px solid #e3e8ec; border-radius: 4px; }
.sign-empty { width: 100%; height: 72px; display: flex; align-items: center; justify-content: center; color: #aaa; border: 1px dashed #c9d4db; border-radius: 4px; background: #fafbfc; font-size: .9rem; }
.sign-meta { font-size: .8rem; color: #888; }
@media (max-width: 575.98px) { .sign-row { grid-template-columns: 1fr; } .reply-panes { padding: .75rem; } }
.thumbs img { width: 120px; height: 120px; cursor: zoom-in; }

/* ---------------------------------------------------------------- 蓋滿畫面的浮層：簽名板、圖片檢視 */
body.overlay-open { overflow: hidden; }
.sign-overlay { position: fixed; inset: 0; z-index: 1100; background: #f4f6f8; display: flex; flex-direction: column; touch-action: none; }
.sign-head { display: flex; align-items: center; gap: .75rem; background: var(--brand); color: #fff; padding: .55rem .5rem .55rem 1rem; }
.sign-head-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sign-close { background: none; border: 0; color: #fff; font-size: 1.9rem; line-height: 1; width: 44px; height: 40px; }
.sign-area { position: relative; flex: 1; min-height: 0; margin: .75rem; background: #fff; border: 2px dashed #9db3c1; border-radius: 8px; overflow: hidden; }
.sign-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sign-guide { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #c5ced5; font-size: clamp(1.4rem, 6vw, 2.6rem); letter-spacing: .2em; pointer-events: none; user-select: none; }
.sign-foot { display: flex; align-items: center; gap: .5rem; padding: 0 .75rem calc(.75rem + env(safe-area-inset-bottom, 0px)); }
.sign-foot .btn { min-height: 46px; min-width: 6rem; }
.sign-foot .btn-primary { min-width: 8rem; }
.sign-msg { flex: 1; color: #c9302c; font-size: .95rem; }
@media (max-width: 575.98px) { .sign-foot { flex-wrap: wrap; } .sign-msg { flex: 0 0 100%; min-height: 1.3rem; } .sign-foot .btn { flex: 1; min-width: 0; } }
.viewer { position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, .9); display: flex; align-items: center; justify-content: center; }
.viewer-img { max-width: 94vw; max-height: calc(100vh - 90px); object-fit: contain; background: #111; border-radius: 4px; }
.viewer-nav, .viewer-close { position: absolute; background: rgba(255, 255, 255, .14); border: 0; color: #fff; border-radius: 50%; width: 48px; height: 48px; font-size: 2rem; line-height: 1; display: flex; align-items: center; justify-content: center; padding-bottom: 4px; }
.viewer-nav:hover, .viewer-close:hover { background: rgba(255, 255, 255, .3); }
.viewer-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.viewer-next { right: 12px; top: 50%; transform: translateY(-50%); }
.viewer-close { right: 12px; top: 12px; }
.viewer-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom, 0px)); display: flex; gap: 1rem; justify-content: center; align-items: center; color: #ddd; font-size: .9rem; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.viewer-caption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }
.viewer-link { color: #9fd0ee; white-space: nowrap; }
@media print { .sign-overlay, .viewer { display: none !important; } }

/* 值班表：改過班的日子顯示「原本 → 現在」 */
.duty-change { margin-top: .25rem; font-size: .8rem; line-height: 1.3; color: #b4560a; background: #fff4e5; border: 1px solid #f3d3a8; border-radius: 4px; padding: .1rem .35rem; word-break: break-word; }
.duty-cell.past .duty-change { color: #a0764f; background: #f7f1e8; border-color: #e8dcc8; }
@media print { .duty-change { background: none; border: 0; padding: 0; color: #000; font-size: .85rem; } }

/* ---------------------------------------------------------------- 儀表板：績效排行
   每個人一列：名次徽章、姓名、數值，下面一條長條（速度王是處理時間，越短越好；回覆王是比例，越長越好）與張數。
   前三名的徽章是金、銀、銅；長條只用一個顏色表示大小，文字一律用一般的字色。 */
.rank { list-style: none; margin: 0; padding: 0; font-size: .86rem; line-height: 1.25; }
.rank li { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; column-gap: .5rem; row-gap: .16rem; align-items: center; padding: .24rem .4rem; border-radius: 6px; }
.rank li + li { margin-top: .08rem; }
.rank li.top1 { background: #fff8e6; }
.rank li:hover { background: #f3f7fb; }
.rank li span { display: inline; white-space: normal; overflow: visible; }
.rank .rk { grid-row: 1 / span 2; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 700; color: #5b6770; background: #e9eef2; font-variant-numeric: tabular-nums; }
.rank .top1 .rk { background: #f2b01e; color: #fff; box-shadow: 0 0 0 2px #fde9b3; }
.rank .top2 .rk { background: #9aa7b2; color: #fff; }
.rank .top3 .rk { background: #c58b5f; color: #fff; }
.rank .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #333; }
.rank .top1 .who { font-weight: 600; }
.rank .val { white-space: nowrap; color: #666; font-size: .8rem; text-align: right; }
.rank .val b { color: #222; font-size: .95rem; font-variant-numeric: tabular-nums; }
.rank .bar { grid-column: 2; height: 5px; border-radius: 3px; background: #eef2f5; overflow: hidden; display: block; }
.rank .bar i { display: block; height: 100%; border-radius: 3px; background: #2a78d6; }
.rank-reply .bar i { background: #1baf7a; }
.rank .cnt { grid-column: 3; color: #888; font-size: .76rem; text-align: right; white-space: nowrap; }
.rank li small { margin: 0; }
/* 績效排行要放進固定高度的格子：張數和數值排在同一行，長條獨立一行 */
.rank li { grid-template-columns: 1.35rem minmax(0, 1fr) auto auto; row-gap: .12rem; padding: .16rem .4rem; }
.rank li + li { margin-top: 0; }
.rank .rk { width: 1.35rem; height: 1.35rem; font-size: .74rem; }
.rank .bar { grid-column: 2 / 5; height: 4px; }
.rank .cnt { grid-column: 4; grid-row: 1; min-width: 2.6em; }

/* 回覆表單：檢測工程師選單底下「今天值班」的提示 */
.duty-hint { color: #b4560a; }
.duty-hint b { font-weight: 600; }
