/* =========================================================
 * 鐵道邊坡監測系統 — 樣式（示範版）
 * 版面參照 PPT「基隆市道路邊坡維護管理資訊平臺」畫面：深藍側欄、淺藍頂部細條、全版地圖
 * ========================================================= */
:root {
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --side: #2c5282;
  --side-2: #264a77;
  --side-hi: #3b6bb0;
  --top: #bfd3ea;
  --bg: #eef2f8;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #66758a;
  --border: #dbe3ee;
  --head: #e4ecf6;
  --zebra: #f6f9fc;
  --primary: #2c5282;
  --primary-2: #1f4176;
  --ok: #2e9e5b;
  --warn: #f2c230;
  --alert: #f08a24;
  --act: #d83b3b;
  /* 邊坡分級 A–D（A 最危險 → D 最不危險）：地圖 canvas、圖表、徽章皆讀取此組變數 */
  --grade-a: #d0312d;
  --grade-b: #f08a24;
  --grade-c: #e8c21a;
  --grade-d: #2e9e5b;
  --shadow: 0 2px 10px rgba(22, 46, 84, .10);
  --shadow-lg: 0 10px 30px rgba(15, 34, 66, .22);
  --radius: 10px;
}
body.dark {
  --top: #24364f;
  --bg: #121b28;
  --card: #1b2737;
  --text: #e3eaf3;
  --muted: #9fb0c5;
  --border: #2c3b50;
  --head: #23324a;
  --zebra: #1f2c3e;
  --side: #17283f;
  --side-2: #132236;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
body.is-sys { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.mono { font-family: var(--mono); font-size: 13px; }
.sub { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.c { text-align: center; }
.center { text-align: center; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--muted); padding: 32px 0 !important; }

/* ---------- 狀態燈號 ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.st-ok { background: #e3f4ea; color: #1f7a45; }
.badge.st-warn { background: #fdf4d3; color: #8a6a00; }
.badge.st-warn i { background: var(--warn); }
.badge.st-alert { background: #fde8d4; color: #b35a0c; }
.badge.st-alert i { background: var(--alert); }
.badge.st-act { background: #fbe0e0; color: #b02525; }
.badge.st-act i { background: var(--act); }
.badge.st-off { background: #e9edf2; color: #6b7686; }
body.dark .badge.st-ok { background: #1d3a2b; color: #7fd6a2; }
body.dark .badge.st-warn { background: #3b3417; color: #f2d36b; }
body.dark .badge.st-alert { background: #3e2a17; color: #f5ae6a; }
body.dark .badge.st-act { background: #402020; color: #f28b8b; }
body.dark .badge.st-off { background: #2a3442; color: #a6b2c2; }
/* 邊坡分級徽章：實心圓角方塊＋白字（黃/橘底加細微文字陰影提高可讀性） */
.gtag { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 5px; font-size: 12.5px; font-weight: 800; line-height: 1; color: #fff; letter-spacing: .02em; vertical-align: middle; flex: none; font-family: var(--font); }
.gtag.g-A { background: var(--grade-a); }
.gtag.g-B { background: var(--grade-b); text-shadow: 0 0 2px rgba(80, 35, 0, .55); }
.gtag.g-C { background: var(--grade-c); text-shadow: 0 0 2px rgba(70, 55, 0, .7); }
.gtag.g-D { background: var(--grade-d); }
.gtag.wl { padding: 0 8px; }
.gtag.lg { min-width: 38px; height: 38px; font-size: 21px; border-radius: 8px; }
body.dark .gtag { box-shadow: 0 0 0 1px rgba(255, 255, 255, .28); }
/* 歷年評定 */
.ghist { display: inline-flex; align-items: flex-end; gap: 3px; flex-wrap: wrap; }
.gh-y { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.gh-y small { font-size: 11px; color: var(--muted); line-height: 1.1; font-weight: 400; }
.gh-arr { font-style: normal; font-size: 10px; color: #a3aebd; padding-bottom: 4px; }
.gh-arr.up { color: var(--grade-a); } .gh-arr.dn { color: var(--grade-d); }
/* 分級判定區塊（抽屜／檢視） */
.gblock { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.gb-top { display: flex; align-items: center; gap: 10px; }
.gb-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gb-t > b { font-size: 14px; }
.gb-t small { font-size: 12px; color: var(--muted); }
.gb-t small b { color: var(--text); }
.gc { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.gc-row { display: grid; grid-template-columns: 56px 1fr 40px; align-items: center; gap: 6px; font-size: 12px; }
.gc-row > span { color: var(--muted); white-space: nowrap; }
.gc-row b { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.gc-row b small { color: var(--muted); font-weight: 400; }
.gc-bar { height: 6px; border-radius: 3px; background: var(--zebra); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.gc-bar i { display: block; height: 100%; border-radius: 3px; }
.gb-crit { font-size: 12px; line-height: 1.6; }
.gnote { font-style: normal; display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; background: #fff6d6; color: #8a6a00; border: 1px solid #f0dc94; font-size: 11.5px; white-space: nowrap; }
body.dark .gnote { background: #3a3317; border-color: #5a4d1d; color: #f2d36b; }
.gb-hist { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }

/* ---------- 按鈕 / 表單 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid #c9d4e3; background: var(--card); color: var(--primary); font-weight: 600; white-space: nowrap; transition: background .15s, box-shadow .15s, border-color .15s; }
.btn:hover { background: #edf3fb; border-color: #9fb4d3; box-shadow: 0 1px 4px rgba(44, 82, 130, .15); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-danger { background: var(--act); border-color: var(--act); color: #fff; }
.btn-danger:hover { background: #b92c2c; border-color: #b92c2c; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; margin-top: 12px; }
body.dark .btn { border-color: #3a4c66; color: #cfe0f7; }
body.dark .btn:hover { background: #22324a; }
body.dark .btn-primary { background: #3b6bb0; border-color: #3b6bb0; color: #fff; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: rgba(44, 82, 130, .1); color: var(--primary); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.sm .ico { width: 14px; height: 14px; }
.lnk { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.lnk:hover { background: #e7eef8; }
.lnk.danger { color: var(--act); } .lnk.danger:hover { background: #fbe6e6; }
.lnk.ok { color: var(--ok); } .lnk.ok:hover { background: #e3f4ea; }
body.dark .lnk { color: #8fb7ef; }
.inp { height: 34px; padding: 0 10px; border: 1px solid #cdd7e4; border-radius: 7px; background: var(--card); outline: none; min-width: 0; }
.inp:focus { border-color: #5a86c5; box-shadow: 0 0 0 3px rgba(59, 107, 176, .15); }
textarea.inp { height: auto; padding: 8px 10px; resize: vertical; width: 100%; font-family: var(--mono); font-size: 13px; }
.inp-sm { height: 28px; font-size: 13px; padding: 0 6px; }
.num-in { width: 90px; }
body.dark .inp { border-color: #3a4c66; background: #142030; }
.inp-ico { position: relative; display: inline-flex; align-items: center; }
.inp-ico .ico { position: absolute; left: 9px; width: 16px; height: 16px; color: var(--muted); }
.inp-ico .inp { padding-left: 32px; width: 240px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 4px; background: #eef2f8; color: #4b5d75; font-size: 12px; white-space: nowrap; }
body.dark .chip { background: #23324a; color: #b8c6d8; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #c4cdd9; transition: .2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }
.seg { display: inline-flex; border: 1px solid #c9d4e3; border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 0 12px; height: 32px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.seg button + button { border-left: 1px solid #dbe3ee; }
.seg button:hover { background: #f0f4fa; }
.seg button.on { background: var(--primary); color: #fff; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 13px; }
.seg-full { display: flex; margin-bottom: 10px; }
.seg-full button { flex: 1; justify-content: center; }
body.dark .seg { border-color: #3a4c66; }
body.dark .seg button:hover { background: #22324a; }
.chk { display: flex; align-items: center; gap: 8px; padding: 6px 2px; cursor: pointer; font-size: 14px; }
.chk input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.chk.inline { display: inline-flex; margin-right: 14px; padding: 4px 0; }
.chk-row { display: flex; flex-wrap: wrap; align-items: center; }
.req { color: var(--act); font-style: normal; }
.lbl { display: block; font-weight: 700; font-size: 13px; margin: 12px 0 6px; }
.lbl-in { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- 卡片 / 頁面 ---------- */
.page { padding: 20px 24px 28px; max-width: 1680px; margin: 0 auto; }
.page-hd { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-hd h2 { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.page-hd p { margin: 4px 0 0; }
.hd-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.demo-note, .readonly { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #8a6a00; background: #fdf6dc; border: 1px solid #f1e2a6; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.demo-note .ico, .readonly .ico { width: 14px; height: 14px; }
.readonly { color: #9b2c2c; background: #fde9e9; border-color: #f4c4c4; font-size: 13px; font-weight: 700; }
body.dark .demo-note { background: #3a3317; border-color: #5a4d1d; color: #f2d36b; }
body.dark .readonly { background: #3d2020; border-color: #5c2a2a; color: #f5a3a3; }
.upd { font-size: 13px; color: var(--muted); white-space: nowrap; }
.upd b { font-family: var(--mono); color: var(--text); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-hd h3 { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.card-hd h3 .ico { color: var(--primary); }
.kpis { display: grid; gap: 14px; margin-bottom: 16px; }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; border-top: 4px solid var(--primary); display: grid; grid-template-columns: 1fr auto; align-items: end; row-gap: 2px; }
.kpi small { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.kpi b { font-size: 32px; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .sub { text-align: right; }
.kpi-ok { border-top-color: var(--ok); } .kpi-ok b { color: var(--ok); }
.kpi-warn { border-top-color: var(--warn); } .kpi-warn b { color: #b58d00; }
.kpi-alert { border-top-color: var(--alert); } .kpi-alert b { color: #d06f10; }
.kpi-act { border-top-color: var(--act); } .kpi-act b { color: var(--act); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar.wrap { flex-wrap: wrap; }
.tb-r { margin-left: auto; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 0; }
.tab { border: 1px solid transparent; border-bottom: 0; background: none; padding: 10px 18px; font-weight: 700; color: var(--muted); border-radius: 9px 9px 0 0; display: inline-flex; align-items: center; gap: 8px; margin-bottom: -2px; }
.tab:hover { color: var(--primary); background: rgba(44, 82, 130, .06); }
.tab.on { background: var(--card); color: var(--primary); border-color: var(--border); border-bottom: 2px solid var(--card); }
.tab em { font-style: normal; font-size: 12px; background: #e4ecf6; color: var(--primary); padding: 0 7px; border-radius: 99px; }
body.dark .tab.on { color: #8fb7ef; }
.tab-card { border-top-left-radius: 0; border-top: 0; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.tbl-scroll { max-height: 420px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { background: var(--head); color: #2b4366; font-weight: 700; text-align: left; padding: 9px 12px; white-space: nowrap; font-size: 13px; position: sticky; top: 0; z-index: 1; }
body.dark .tbl th { color: #c6d6ec; }
.tbl td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:nth-child(even) td { background: var(--zebra); }
.tbl tbody tr:hover td { background: #e8f0fb; }
body.dark .tbl tbody tr:hover td { background: #24344c; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl th.c, .tbl td.c { text-align: center; }
.tbl .ops { white-space: nowrap; text-align: right; }
.tbl-click tbody tr { cursor: pointer; }
.tbl td .sub { font-size: 12px; }
.tbl tfoot td { background: var(--head); font-weight: 800; padding: 9px 12px; position: sticky; bottom: 0; }
.tbl-cross td.heat-0 { color: #b02525; font-weight: 700; }
.tbl-cross td.heat-1 { color: #b35a0c; font-weight: 700; }
.tbl-cross td.heat-2 { color: #1f7a45; font-weight: 700; }
.tbl-cross td.zero { color: #b6c0cc; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pager-info { font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 4px; align-items: center; }
.pg { min-width: 32px; height: 30px; padding: 0 9px; border: 1px solid #cdd7e4; background: var(--card); border-radius: 6px; font-size: 13px; color: var(--text); }
.pg:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pg:disabled { opacity: .45; cursor: default; }
.pg-ell { padding: 0 4px; color: var(--muted); }
body.dark .pg { border-color: #3a4c66; }

/* ---------- Toast / Modal / Tooltip ---------- */
#toasts { position: fixed; right: 20px; top: 56px; z-index: 5000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; max-width: 420px; background: #1e3a64; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateX(20px); transition: .25s; }
.toast.show { opacity: 1; transform: none; }
.toast.warn { background: #a8461a; }
.toast .ico { width: 16px; height: 16px; }
.modal-mask { position: fixed; inset: 0; background: rgba(12, 24, 44, .45); z-index: 4000; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s; padding: 20px; }
.modal-mask.show { opacity: 1; }
.modal { background: var(--card); border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 96vw; max-height: 92vh; display: flex; flex-direction: column; transform: translateY(10px); transition: transform .2s; }
.modal-mask.show .modal { transform: none; }
.modal-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-hd h3 { font-size: 17px; font-weight: 800; }
.modal-bd { padding: 16px 18px; overflow: auto; flex: 1; min-height: 0; }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.confirm-msg { margin: 4px 0; line-height: 1.7; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg label { font-size: 13px; font-weight: 700; color: #3b4d66; }
body.dark .fg label { color: #c2d0e3; }
.fg .inp { width: 100%; }
.fg .inp[readonly] { background: #f0f3f7; color: var(--muted); }
.span-2 { grid-column: span 2; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--border); }
.form-row:first-of-type { border-top: 0; }
.form-row.top { align-items: start; }
.form-row > label { font-weight: 700; font-size: 14px; }
.row-c { display: flex; align-items: center; gap: 10px; }
.chart-tip { position: fixed; z-index: 6000; pointer-events: none; display: none; background: rgba(20, 34, 56, .94); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 13px; line-height: 1.5; box-shadow: var(--shadow-lg); max-width: 280px; }

/* ---------- 圖表 ---------- */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: #e3e9f1; stroke-width: 1; }
.chart-svg .axis { stroke: #8494a9; stroke-width: 1.2; }
.chart-svg .ax { font-size: 12px; fill: #66758a; }
.chart-svg .val { font-size: 12px; fill: #2b3a4f; font-weight: 700; }
body.dark .chart-svg .grid { stroke: #2c3b50; }
body.dark .chart-svg .val { fill: #e3eaf3; }
body.dark .chart-svg .ax { fill: #9fb0c5; }
.chart-svg .bar:hover, .chart-svg .pt:hover { filter: brightness(1.12); }
.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 36px; padding: 4px 8px; }
.donut-svg { width: 300px; height: 300px; flex: none; }
.donut-svg .slice { transition: transform .15s; transform-origin: 160px 160px; }
.donut-svg .slice:hover { transform: scale(1.03); }
.donut-pct { fill: #fff; font-size: 13px; font-weight: 600; pointer-events: none; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.donut-legend li { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.donut-legend i { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.spark { display: block; }

/* =========================================================
 * 首頁
 * ========================================================= */
.home { position: relative; min-height: 100vh; display: flex; flex-direction: column; align-items: center; color: #fff; overflow-x: hidden; }
.home-bg { position: fixed; inset: 0; z-index: -1; background: radial-gradient(1200px 600px at 20% 10%, rgba(80, 140, 220, .35), transparent 60%), linear-gradient(140deg, #0d2445 0%, #1a4479 50%, #10294b 100%); }
.home-bg::after { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(115deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 46px); }
.home-bg.has-img { background: linear-gradient(140deg, rgba(10, 30, 60, .78), rgba(24, 64, 116, .70)), url("img/hero-bg.jpg") center / cover no-repeat, #10294b; }
.home-hd { width: 100%; max-width: 1280px; display: flex; align-items: center; gap: 16px; padding: 48px 32px 10px; position: relative; }
.home-logo { width: 54px; height: 54px; border-radius: 14px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); display: flex; align-items: center; justify-content: center; }
.home-logo .ico { width: 30px; height: 30px; }
.home-hd h1 { font-size: 34px; font-weight: 800; letter-spacing: 3px; }
.home-hd p { margin: 4px 0 0; font-size: 17px; color: #c6d8f0; letter-spacing: 2px; }
.home-demo { position: absolute; right: 32px; top: 22px; font-size: 13px; color: #ffe8a3; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 232, 163, .35); padding: 3px 12px; border-radius: 99px; }
.sys-cards { flex: 1; width: 100%; max-width: 1280px; display: grid; grid-template-columns: repeat(3, minmax(320px, 1fr)); gap: 28px; padding: 30px 32px; align-content: center; }
.sys-card { position: relative; display: flex; flex-direction: column; background: #fff; color: var(--text); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .28); transition: transform .25s, box-shadow .25s; min-height: 470px; }
.sys-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 22px 46px rgba(0, 0, 0, .38); }
.sys-media { position: relative; height: 230px; background: linear-gradient(135deg, var(--c), #10294b); overflow: hidden; }
.sys-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.sys-card:hover .sys-media img { transform: scale(1.05); }
.sys-media-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(6, 18, 36, .85) 100%); }
.sys-media-t { position: absolute; left: 20px; right: 20px; bottom: 16px; color: #fff; }
.sys-media-t h2 { font-size: 26px; font-weight: 800; letter-spacing: 1px; text-shadow: 0 2px 8px rgba(0, 0, 0, .4); margin-top: 6px; }
.sys-tag { display: inline-flex; align-items: center; gap: 5px; background: var(--c); padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.sys-tag .ico { width: 15px; height: 15px; }
.sys-body { flex: 1; display: flex; flex-direction: column; padding: 16px 20px 18px; gap: 14px; }
.sys-desc { margin: 0; color: #4a5a70; line-height: 1.65; font-size: 14px; min-height: 46px; }
.sys-stats { display: grid; grid-template-columns: .85fr 1fr 1.3fr; gap: 0; border: 1px solid #e3e9f1; border-radius: 10px; overflow: hidden; }
.sys-stats > div { padding: 10px 10px; display: flex; flex-direction: column; gap: 3px; position: relative; min-width: 0; }
.sys-stats > div + div { border-left: 1px solid #e3e9f1; }
.sys-stats b { font-size: 26px; font-weight: 800; color: var(--c); line-height: 1.15; }
.sys-stats b.sm { font-size: 15px; white-space: nowrap; color: #2b3a4f; line-height: 1.4; padding-top: 4px; }
.sys-stats small { font-size: 12px; color: #6b7a8f; }
.sys-go { margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; background: var(--c); color: #fff; font-weight: 700; padding: 9px 20px; border-radius: 8px; transition: gap .2s, filter .2s; }
.sys-card:hover .sys-go { gap: 14px; filter: brightness(1.08); }
/* 首頁卡：邊坡分級數量列 */
.sys-grades { display: flex; align-items: center; gap: 12px; margin-top: -4px; font-size: 13px; color: #4a5a70; white-space: nowrap; }
.sys-grades .sg-l { font-size: 12px; color: #6b7a8f; font-weight: 700; margin-right: -2px; }
.sys-grades .sg-it { display: inline-flex; align-items: center; gap: 5px; }
.sys-grades .gtag { min-width: 18px; height: 18px; font-size: 11.5px; border-radius: 4px; padding: 0 4px; }
.sys-grades b { font-weight: 800; color: #2b3a4f; font-variant-numeric: tabular-nums; }
.sys-legend { display: flex; gap: 12px; font-size: 12px; color: #6b7a8f; margin-top: -6px; }
.sys-legend span { display: inline-flex; align-items: center; gap: 4px; }
.sys-legend em { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.home-ft { padding: 14px 0 22px; font-size: 13px; color: #b5c7df; letter-spacing: 1px; }

/* =========================================================
 * 系統頁共通框架
 * ========================================================= */
.shell { display: flex; height: 100vh; width: 100vw; overflow: hidden; }
.side { width: 220px; flex: none; background: var(--side); color: #e8f0fb; display: flex; flex-direction: column; z-index: 20; box-shadow: 2px 0 8px rgba(0, 0, 0, .12); }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid rgba(255, 255, 255, .1); min-height: 64px; }
.brand-ico { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.brand-t { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-t b { font-size: 15px; font-weight: 800; letter-spacing: .5px; }
.brand-t small { font-size: 12px; color: #a9c0e0; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 0 22px; height: 50px; border: 0; background: none; color: #e8f0fb; font-weight: 700; font-size: 14.5px; letter-spacing: .5px; text-align: left; position: relative; transition: background .15s; }
.nav-item:hover { background: rgba(255, 255, 255, .08); }
.nav-item.active { background: rgba(255, 255, 255, .16); }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: #8cc3ff; }
.nav-item .ico { width: 20px; height: 20px; }
.caret { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid currentColor; margin-left: auto; transition: transform .2s; opacity: .85; }
.caret.dark { margin-left: 4px; }
.nav-group.open .caret { transform: rotate(180deg); }
.nav-group.has-active > .nav-toggle { color: #fff; }
.nav-sub { display: none; background: var(--side-2); padding: 4px 0; }
.nav-group.open .nav-sub { display: block; }
.nav-subitem { display: block; padding: 0 22px 0 56px; height: 40px; line-height: 40px; font-size: 14px; color: #c9daf1; position: relative; }
.nav-subitem:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-subitem.active { color: #fff; font-weight: 700; background: rgba(255, 255, 255, .14); }
.nav-subitem.active::before { content: ""; position: absolute; left: 40px; top: 17px; width: 6px; height: 6px; border-radius: 50%; background: #8cc3ff; }
.side-foot { padding: 12px 14px 14px; border-top: 1px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; gap: 6px; }
.sys-switch-l { font-size: 12px; color: #a9c0e0; }
.sys-switch { height: 34px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: #fff; padding: 0 8px; outline: none; }
.sys-switch option { color: #1f2d3d; }
.back-home { display: flex; align-items: center; gap: 6px; margin-top: 6px; height: 34px; padding: 0 10px; border-radius: 7px; color: #dbe8f8; font-size: 14px; font-weight: 600; }
.back-home:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.back-home .ico { width: 16px; height: 16px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 44px; flex: none; background: var(--top); display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 20px; border-bottom: 1px solid rgba(44, 82, 130, .15); z-index: 15; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #3b5578; white-space: nowrap; overflow: hidden; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumbs b { color: #1c3557; }
.crumbs .sep { font-style: normal; color: #7d93b2; }
body.dark .crumbs { color: #a9bdd8; } body.dark .crumbs b { color: #e3eaf3; }
.top-r { display: flex; align-items: center; gap: 14px; }
.demo-pill { font-size: 12px; color: #8a6a00; background: #fff6d6; border: 1px solid #f1e2a6; padding: 1px 9px; border-radius: 99px; }
.daynight { width: 54px; height: 28px; border-radius: 99px; border: 0; background: #f6c443; position: relative; padding: 0; transition: background .25s; }
.daynight .knob { position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; color: #e3a008; transition: transform .25s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.daynight .knob .ico { width: 15px; height: 15px; }
.daynight.night { background: #3c4e6e; }
.daynight.night .knob { transform: translateX(26px); color: #3c4e6e; }
.top-btn { border: 0; background: none; height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #3c5a82; border-radius: 8px; position: relative; padding: 0 6px; }
.top-btn:hover { background: rgba(255, 255, 255, .5); }
.top-btn.circ { border: 1.5px solid #3c5a82; border-radius: 50%; width: 30px; height: 30px; min-width: 30px; padding: 0; background: #fff; }
.top-btn.circ .ico { width: 16px; height: 16px; }
.top-btn.user span { font-weight: 700; font-size: 14px; }
body.dark .top-btn { color: #c6d6ec; } body.dark .top-btn.circ { background: #1b2737; border-color: #8fa6c4; }
.reddot { position: absolute; top: 4px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--act); box-shadow: 0 0 0 2px var(--top); }
.dd { position: relative; }
.dd-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 3000; min-width: 200px; overflow: hidden; }
.dd-menu.show { display: block; }
.dd-h { padding: 10px 14px; font-weight: 800; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dd-h small { font-weight: 400; color: var(--muted); font-size: 12px; }
.dd-notif { width: 340px; }
.notif { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif:hover { background: #f2f6fc; }
body.dark .notif:hover { background: #23324a; }
.notif > .gtag { margin-top: 2px; flex: none; }
.notif > div { min-width: 0; }
.notif p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.notif b { font-size: 13px; }
.notif p { margin: 2px 0; font-size: 13px; color: var(--text); }
.notif small { font-size: 12px; color: var(--muted); }
.dd-more { display: block; text-align: center; padding: 9px; font-size: 13px; font-weight: 700; color: var(--primary); }
.dd-more:hover { background: #f2f6fc; }
.dd-user .dd-h { flex-direction: column; align-items: flex-start; gap: 2px; }
.dd-it { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 14px; font-size: 14px; }
.dd-it:hover { background: #f2f6fc; }
body.dark .dd-it:hover { background: #23324a; }
.content { flex: 1; min-height: 0; overflow: auto; position: relative; }
.content.page-map { overflow: hidden; }

/* =========================================================
 * 地圖頁
 * ========================================================= */
.map-wrap { position: absolute; inset: 0; overflow: hidden; }
.map { position: absolute; inset: 0; background: #bcd9ea; font-family: var(--font); }
.fl { position: absolute; z-index: 1000; display: flex; flex-direction: column; gap: 12px; }
.fl-tl { left: 24px; top: 22px; align-items: flex-start; }
.fl-tr { right: 24px; top: 22px; align-items: flex-end; transition: right .25s; }
.fl-bl { left: 24px; bottom: 10px; align-items: flex-start; gap: 10px; }
.fl-br { right: 24px; bottom: 10px; align-items: flex-end; gap: 10px; transition: right .25s; }
.drawer-open .fl-tr, .drawer-open .fl-br { right: 384px; }
.fbtn { display: inline-flex; align-items: center; gap: 9px; height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: #fff; color: #1f2d3d; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); font-size: 14px; font-weight: 600; white-space: nowrap; transition: box-shadow .15s, background .15s; }
.fbtn:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .25); background: #f7faff; }
.fbtn.on { background: #e9f1fc; color: var(--primary); }
.fbtn .ico { width: 19px; height: 19px; }
.fbtn .cnt { font-style: normal; color: #7a879a; font-size: 13px; font-weight: 400; }
.fbtn-accent { background: var(--primary); color: #fff; }
.fbtn-accent:hover { background: var(--primary-2); }
.fpanel { display: none; background: #fff; color: #1f2d3d; border-radius: 10px; box-shadow: 0 6px 22px rgba(0, 0, 0, .22); padding: 12px 16px; width: 270px; position: absolute; left: 0; top: 52px; }
.fpanel.show { display: block; }
.fpanel.right { left: auto; right: 0; top: 104px; }
.fpanel.up { position: static; order: -1; }
.fl-br .fpanel.up.right { position: static; }
.fp-h { font-weight: 800; font-size: 14px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid #e3e9f1; }
.fp-note { margin: 8px 0 0; font-size: 12px; color: #6b7a8f; line-height: 1.55; }
.zoom-ctl { display: flex; flex-direction: column; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); overflow: hidden; }
.zoom-ctl button { width: 40px; height: 36px; border: 0; background: #fff; font-size: 18px; font-weight: 700; color: #3c5a82; }
.zoom-ctl button + button { border-top: 1px solid #e3e9f1; }
.zoom-ctl button:hover { background: #eef4fc; }
.coord { background: rgba(255, 255, 255, .92); border: 1px solid #ccd5e0; padding: 4px 8px; font-size: 12px; line-height: 1.5; color: #1f2d3d; border-radius: 2px; white-space: nowrap; }
.ztag { background: rgba(255, 255, 255, .92); border: 1px solid #ccd5e0; padding: 2px 8px; font-size: 12px; color: #1f2d3d; border-radius: 2px; }
.map-search { position: absolute; left: 50%; top: 22px; transform: translateX(-50%); z-index: 1000; width: 380px; display: flex; align-items: center; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); padding-left: 12px; transition: left .25s; }
.drawer-open .map-search { left: calc(50% - 180px); }
.map-search > .ico { color: #66758a; }
.map-search input { flex: 1; border: 0; outline: none; height: 40px; padding: 0 12px 0 8px; background: transparent; color: #1f2d3d; min-width: 0; }
.ms-res { display: none; position: absolute; left: 0; right: 0; top: 46px; background: #fff; border-radius: 8px; box-shadow: 0 6px 22px rgba(0, 0, 0, .22); overflow: hidden; max-height: 360px; overflow-y: auto; }
.ms-res.show { display: block; }
.ms-res button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: #fff; padding: 8px 12px; text-align: left; border-bottom: 1px solid #eef2f7; color: #1f2d3d; }
.ms-res button:hover { background: #eef4fc; }
.ms-res button b { font-family: var(--mono); font-size: 13px; flex: none; }
.ms-res button span { font-size: 13px; color: #4a5a70; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-none { padding: 12px; color: #66758a; font-size: 13px; }
.ppt-tag { display: none; position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 900; background: rgba(31, 45, 61, .78); color: #fff; font-size: 12px; padding: 3px 12px; border-radius: 99px; letter-spacing: 1px; }
.ppt-tag.show { display: block; }
.map-demo { position: absolute; right: 24px; top: 4px; z-index: 900; font-size: 12px; color: #6b5300; background: rgba(255, 246, 214, .9); padding: 0 8px; border-radius: 0 0 6px 6px; transition: right .25s; }
.drawer-open .map-demo { right: 384px; }
.lg { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.lg small { color: #6b7a8f; font-size: 12px; }
.lg-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: none; }
.lg-dot.st-ok { background: var(--ok); } .lg-dot.st-warn { background: var(--warn); } .lg-dot.st-alert { background: var(--alert); } .lg-dot.st-act { background: var(--act); }
.lg-line { width: 26px; height: 5px; border-radius: 3px; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, .15); flex: none; }
.lg-st { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #263445; flex: none; margin: 0 7px; }
.lg-zone { width: 26px; height: 16px; border-radius: 40% 60% 50% 45%; background: linear-gradient(90deg, rgba(240, 138, 36, .65) 50%, rgba(70, 179, 94, .65) 50%); border: 1px solid #c4581a; flex: none; }

/* Leaflet 圖徵 */
.leaflet-container { font-family: var(--font); }
.leaflet-tooltip { font-size: 13px; font-family: var(--font); }
.county-lb { color: #5f6b52; font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; text-shadow: 0 0 3px #fff, 0 0 3px #fff; letter-spacing: 1px; }
.base-ppt .county-lb.in-ppt { display: none; }
.st-lb span { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 700; color: #1f2d3d; background: rgba(255, 255, 255, .88); border: 1px solid rgba(38, 52, 69, .35); padding: 0 5px; border-radius: 3px; line-height: 17px; }
.rain-lb span { display: inline-block; white-space: nowrap; font-size: 12px; color: #12558f; background: rgba(255, 255, 255, .85); padding: 0 4px; border-radius: 3px; }
.rain-ic span { display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 3px; background: #1677c9; color: #fff; font-size: 11px; font-weight: 700; border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); line-height: 1; }

/* 邊坡詳情抽屜 */
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: 360px; z-index: 1100; background: var(--card); box-shadow: -6px 0 24px rgba(0, 0, 0, .18); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .28s ease; }
.drawer.show { transform: none; }
.dr-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 14px 16px 12px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #eef4fc, var(--card)); }
body.dark .dr-hd { background: var(--head); }
.dr-id { font-family: var(--mono); font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; font-size: 14px; }
body.dark .dr-id { color: #8fb7ef; }
.dr-hd h3 { font-size: 16px; font-weight: 800; margin-top: 6px; line-height: 1.4; }
.dr-bd { flex: 1; overflow-y: auto; padding: 12px 16px; }
.dr-ft { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.dr-ft .btn { flex: 1; justify-content: center; padding: 0 8px; }
.dt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.dt-grid > div { background: var(--card); padding: 7px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dt-grid label { font-size: 12px; color: var(--muted); }
.dt-grid span { font-size: 14px; font-weight: 600; }
.dt-grid .mono { font-size: 12.5px; }
.dt-h { font-size: 14px; font-weight: 800; margin: 14px 0 8px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.dt-h small { font-size: 12px; color: var(--muted); font-weight: 400; }
.dt-upd { margin-top: 10px; font-size: 12px; }
.view-hd { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* =========================================================
 * 統計分析
 * ========================================================= */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats-grid .span-2 { grid-column: span 2; }

#chLine { max-width: 1100px; margin: 0 auto; }

/* =========================================================
 * 報表管理（S02 詳細仿 image10.png）
 * ========================================================= */
.rp-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.rp-hd h2 { font-size: 22px; font-weight: 800; }
.rp-hd p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.rp-hd p b { color: var(--primary); font-family: var(--mono); font-size: 13.5px; }
body.dark .rp-hd p b { color: #8fb7ef; }
.rp-btns { display: flex; align-items: center; gap: 10px; }
.vsep { width: 1px; height: 26px; background: #ccd5e0; margin: 0 4px; }
.rp-sec { padding: 0; overflow: hidden; margin-bottom: 16px; }
.rp-sec-h { background: #dbe6f2; padding: 13px 18px; font-weight: 800; font-size: 15px; color: #1f2d3d; }
body.dark .rp-sec-h { background: var(--head); color: var(--text); }
.rp-sec-h small { font-weight: 400; }
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th { width: 150px; background: #f3f6fa; color: #3b4d66; font-weight: 500; text-align: left; padding: 12px 14px; border-top: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: middle; }
.kv td { padding: 12px 14px; border-top: 1px solid var(--border); border-right: 1px solid var(--border); }
.kv td:last-child { border-right: 0; }
body.dark .kv th { background: #1f2c3e; color: #c2d0e3; }
.rp-check { border: 0; }
.rp-check th { position: static; }
.tri { display: inline-flex; border: 1px solid #cdd7e4; border-radius: 6px; overflow: hidden; }
.tri span { padding: 2px 12px; font-size: 13px; color: #9aa6b6; }
.tri span + span { border-left: 1px solid #cdd7e4; }
.tri span.on { font-weight: 800; }
.tri span.on.st-ok { background: #e3f4ea; color: #1f7a45; }
.tri span.on.st-warn { background: #fdf4d3; color: #8a6a00; }
.tri span.on.st-act { background: #fbe0e0; color: #b02525; }
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 16px 18px; }
.photos figure { margin: 0; }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, #d5dce5, #bcc6d2); border: 1px solid var(--border); }
.ph-ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #6b7686; font-size: 14px; font-weight: 700; background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .18) 0 10px, transparent 10px 20px); }
.ph-ph .ico { width: 34px; height: 34px; }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photos figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }
.rp-sum { display: grid; grid-template-columns: 180px 260px 1fr; gap: 16px; padding: 14px 18px; }
.rp-sum > div { display: flex; flex-direction: column; gap: 6px; }
.rp-sum label { font-size: 12px; color: var(--muted); font-weight: 700; }

/* =========================================================
 * 帳號管理 / 資安
 * ========================================================= */
.acc-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.tbl.nowrap td { white-space: nowrap; }
.tbl-acc { font-size: 13px; }
.tbl-acc th, .tbl-acc td { padding-left: 8px; padding-right: 8px; }
.tbl-acc .inp-sm { padding: 0 2px; }
.tbl-acc td.ops .lnk { padding: 2px 4px; }
.perm td:first-child { font-weight: 600; white-space: nowrap; }
.perm input { width: 16px; height: 16px; accent-color: var(--primary); }
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.enc-list { display: flex; flex-direction: column; gap: 10px; }
.enc-list > div { display: grid; grid-template-columns: 76px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--zebra); }
.enc-list .badge { grid-row: span 2; justify-self: start; }
.enc-list b { font-size: 14px; }

/* ---------- 響應式 ---------- */
@media (max-width: 1280px) {
  .kpis-5 { grid-template-columns: repeat(3, 1fr); }
  .live-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .acc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .sys-cards { grid-template-columns: 1fr; max-width: 520px; }
  .stats-grid, .sec-grid { grid-template-columns: 1fr; }
  .stats-grid .span-2 { grid-column: auto; }
  .live-grid { grid-template-columns: 1fr; }
}

/* =========================================================
 * 地圖：底圖選擇／疊圖（增補規格 B）與地圖工具（增補規格 A）
 * ========================================================= */
/* 右上浮動欄：面板改為直接展開在按鈕下方（不覆蓋其他按鈕），下方按鈕自動往下移；高度不足時面板內捲動 */
.fl-tr { max-height: calc(100% - 120px); }
.prof-open .fl-tr { max-height: calc(100% - 350px); }
.fl-tr > * { flex: none; }
.fl-tr > .fpanel, .fl-tr > .fpanel.right { position: static; min-height: 0; flex: 0 1 auto; overflow-y: auto; }
.fpanel.tools { width: 300px; }
.fl-tl .fpanel { max-height: calc(100vh - 190px); overflow-y: auto; }
.prof-open .fl-tl .fpanel { max-height: calc(100vh - 420px); }
#pBase { width: 330px; }

/* 圖層清單小標籤：線上圖資／示意 */
.ltag { margin-left: auto; flex: none; font-style: normal; font-size: 11px; line-height: 16px; padding: 0 5px; border-radius: 3px; }
.ltag.on { background: #e3eefc; color: #1f5fa8; }
.ltag.demo { background: #f1f3f6; color: #7a879a; }
.op-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-top: 8px; border-top: 1px dashed #e3e9f1; font-size: 12.5px; color: #4a5a70; }
.op-row input { flex: 1; min-width: 0; accent-color: var(--primary); }
.op-row b { width: 34px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 底圖選擇：radio + 來源小字 + 失敗標註 */
.base-it { align-items: flex-start; padding: 5px 2px; }
.base-it input { margin-top: 2px; flex: none; }
.base-it > span { display: flex; flex-direction: column; line-height: 1.35; font-size: 13.5px; }
.b-src { font-size: 11.5px; color: #7a879a; }
.b-bad { display: none; margin-left: auto; flex: none; font-style: normal; font-size: 11px; color: #8a5a00; background: #fff1c2; border-radius: 3px; padding: 0 5px; line-height: 16px; }
.base-it.bad .b-bad { display: inline-block; }
.fp-attr { margin-top: 8px; padding: 6px 8px; background: #f4f7fb; border-radius: 6px; font-size: 11.5px; color: #4a5a70; line-height: 1.5; }

/* 線上底圖載入失敗提示（右上、黃色小提示） */
.base-warn { display: none; position: absolute; right: 200px; top: 4px; z-index: 950; font-size: 12px; color: #6b4a00; background: #ffe58f; border: 1px solid #f0c94a; padding: 1px 10px; border-radius: 0 0 6px 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); transition: right .25s; }
.base-warn.show { display: block; }
.drawer-open .base-warn { right: 560px; }

/* 向量底圖：線上圖磚載入成功時由程式 removeLayer（.vec-off 僅保留為狀態 class） */
.leaflet-vec-pane { transition: opacity .5s; }
.vec-off .leaflet-vec-pane { opacity: 0; }
.vec-off .county-lb { display: none; }
.map .leaflet-tile-pane { opacity: 1; }

/* 授權標示（Leaflet attribution，放在左下座標列右側，不與 Z／圖例重疊） */
.map-wrap .leaflet-bottom.leaflet-left { left: 236px; bottom: 10px; transition: bottom .2s; }
.map-wrap .leaflet-control-attribution { margin: 0; background: rgba(255, 255, 255, .85); color: #3b4d66; font-size: 11px; line-height: 16px; padding: 1px 6px; border-radius: 3px; max-width: 560px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prof-open .leaflet-bottom.leaflet-left { bottom: 240px; }

/* 圖例新增項目 */
.lg-hatch { width: 26px; height: 16px; flex: none; border: 1px solid #d4559a; background: repeating-linear-gradient(45deg, rgba(232, 92, 160, .75) 0 2px, rgba(255, 220, 238, .5) 2px 6px); }
.lg-hatch.all { border-color: #9a6ad8; background: repeating-linear-gradient(-45deg, rgba(150, 100, 220, .7) 0 2px, rgba(236, 226, 252, .5) 2px 6px); }
.lg-bnd { width: 26px; height: 0; flex: none; border-top: 2px dashed #8a5cc0; }

/* 「地圖工具」按鈕：作用中高亮 */
.fbtn.act { background: var(--primary); color: #fff; }
.fbtn.act:hover { background: var(--primary-2); }
.fp-hs { display: block; font-size: 11.5px; font-weight: 400; color: #7a879a; margin-top: 2px; }
.tl-it { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: #1f2d3d; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.tl-it:hover { background: #f2f6fc; }
.tl-it.on { background: #e3edfb; color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.tl-it .ico { width: 18px; height: 18px; flex: none; color: #4a6180; }
.tl-it.on .ico { color: var(--primary); }
.tl-it span { flex: 1; }
.tl-chk input { width: 16px; height: 16px; margin: 0 1px; accent-color: var(--primary); flex: none; }
.src { flex: none; font-style: normal; font-size: 11px; font-weight: 600; line-height: 16px; padding: 0 6px; border-radius: 3px; }
.src.ppt { background: #eceff3; color: #66758a; }
.src.sug { background: #dcebff; color: #1f63c0; }
.tl-sub { display: none; margin: 2px 0 6px 34px; }
.tl-sub.show { display: block; }
.tl-row { display: flex; gap: 6px; margin-bottom: 6px; }
.tl-in { flex: 1; min-width: 0; height: 30px; border: 1px solid #ccd5e0; border-radius: 6px; padding: 0 8px; font-size: 13px; color: #1f2d3d; background: #fff; }
.tl-in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(44, 82, 130, .15); }
.tl-go { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.tl-go:hover { background: var(--primary-2); }
.tl-go.ghost { background: #eef2f7; color: #3b4d66; }
.tl-go.ghost:hover { background: #e1e8f1; }
.tl-go.wide { width: 100%; }
.tl-go .ico { width: 15px; height: 15px; }
.tl-err { font-size: 12px; color: #c0392b; min-height: 0; }
.tl-err:empty { display: none; }
.tl-hint { margin-top: 8px; padding: 8px 10px; background: #f4f7fb; border-radius: 7px; font-size: 12.5px; line-height: 1.6; color: #3b4d66; }
.tl-hint small { color: #7a879a; font-size: 11.5px; }
.tl-btns { display: flex; gap: 6px; margin-top: 6px; }
.map.tool-cross, .map.tool-cross .leaflet-interactive, .map.tool-cross .slope-ic { cursor: crosshair !important; }

/* 標高標註（棕色 ▲ + 山名 xxx m） */
.elev-lb { white-space: nowrap; color: #7a4b1c; font-size: 11.5px; font-weight: 700; text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.elev-lb i { font-style: normal; color: #8b5a2b; font-size: 12px; margin-right: 2px; }

/* 量測標籤 */
.ms-lb span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: #fff; background: rgba(217, 72, 15, .9); padding: 1px 6px; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.ms-lb.live span { transform: translate(12px, -26px); background: rgba(31, 45, 61, .88); font-weight: 600; }
.ms-lb.live span b { color: #ffd479; }
.ms-lb.total span { transform: translate(10px, -50%); background: #1f2d3d; }
.ms-lb.area span { transform: translate(-50%, -50%); background: rgba(123, 44, 191, .92); text-align: center; line-height: 1.5; }
.coord-pin { color: #d9480f; }
.coord-pin .ico { width: 26px; height: 26px; fill: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); }

/* 標高／座標查詢資訊小卡 */
.tool-pop .leaflet-popup-content { margin: 10px 12px; font-size: 13px; color: #1f2d3d; }
.tc-h { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; padding-bottom: 6px; border-bottom: 1px solid #e3e9f1; }
.tc-h .ico { width: 16px; height: 16px; color: #7a4b1c; }
.tc-el { margin: 7px 0 6px; font-size: 13px; }
.tc-el b { font-size: 18px; color: #7a4b1c; }
.tc-el b.tc-wait { font-size: 13px; color: #7a879a; font-weight: 600; }
.tc-src { display: block; font-size: 11.5px; color: #7a879a; margin-top: 2px; }
.tc-src.om { color: #1f7a45; }
.tc-src.demo { color: #b0610e; }
.tc table { width: 100%; border-collapse: collapse; }
.tc th { width: 64px; text-align: left; font-weight: 500; color: #66758a; padding: 3px 6px 3px 0; vertical-align: top; white-space: nowrap; font-size: 12.5px; }
.tc td { padding: 3px 0; font-size: 12.5px; }
.tc td small { color: #7a879a; }
.tc-warn { color: #c4581a; font-weight: 700; }

/* 剖面分析面板（地圖下方，高約 220px；座標列／圖例同步抬高，不被遮住） */
.prof { display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 220px; z-index: 1050; background: #fff; color: #1f2d3d; box-shadow: 0 -4px 18px rgba(0, 0, 0, .18); flex-direction: column; transition: right .25s; }
.prof.show { display: flex; }
.drawer-open .prof { right: 360px; }
.prof-open .fl-bl, .prof-open .fl-br { bottom: 232px; }
.prof-h { display: flex; align-items: center; gap: 10px; padding: 7px 12px 5px 16px; border-bottom: 1px solid #e3e9f1; font-size: 13px; white-space: nowrap; }
.prof-h > b { font-size: 14px; }
.prof-t { color: #4a5a70; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.prof-st { color: #3b4d66; overflow: hidden; text-overflow: ellipsis; }
.prof-st b { color: #7a4b1c; }
.prof-note { margin-left: auto; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: #f1f3f6; color: #66758a; }
.prof-note.om { background: #e3f4ea; color: #1f7a45; }
.prof-note.demo { background: #fff1d6; color: #9a5200; }
.prof-h .icon-btn { flex: none; color: #4a5a70; }
.prof-b { flex: 1; min-height: 0; position: relative; }
.prof-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #66758a; font-size: 13px; }
.prof-svg { display: block; font-family: var(--font); }
.prof-svg text { font-size: 11px; fill: #66758a; }
.prof-svg text.ax { font-weight: 700; }
.prof-svg .pg { stroke: #e6ebf2; stroke-width: 1; }
.prof-svg .pa { fill: rgba(160, 90, 18, .22); }
.prof-svg .pl { fill: none; stroke: #a05a12; stroke-width: 2; }
.prof-svg .ph line { stroke: #1f2d3d; stroke-dasharray: 3 3; }
.prof-svg .ph circle { fill: #a05a12; stroke: #fff; stroke-width: 2; }
.prof-svg .ph rect { fill: rgba(31, 45, 61, .88); }
.prof-svg .ph text { fill: #fff; font-size: 12px; font-weight: 600; }
.prof-svg .hit { cursor: crosshair; }
.prof-tip { font-size: 12px; font-weight: 700; }

/* 作用中工具提示列（常駐於地圖上方中央；含完成／取消／沿鐵道剖面／結束工具） */
.tl-bar { display: none; position: absolute; left: 50%; top: 68px; transform: translateX(-50%); z-index: 1001; margin: 0; width: max-content; max-width: min(560px, calc(100% - 640px)); min-width: 300px; background: rgba(255, 255, 255, .97); box-shadow: 0 4px 16px rgba(0, 0, 0, .22); border: 1px solid #d6e0ec; }
.tl-bar.show { display: block; }
.base-ppt .tl-bar { top: 98px; }
.tl-bar .tl-btns { flex-wrap: wrap; }

/* =========================================================
 * 增補規格 C：邊坡分級 A–D（地圖圖層篩選、圖例、tooltip）
 * ========================================================= */
/* 圖層控制：邊坡點位下的等級篩選 */
.g-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: -2px 0 4px 24px; padding: 4px 0 6px 10px; border-left: 2px solid #e3e9f1; }
.gf-it { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; padding: 2px 0; white-space: nowrap; }
.gf-it input { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.gf-it .gtag { min-width: 18px; height: 18px; font-size: 11.5px; border-radius: 4px; }
.gf-it em { font-style: normal; color: #6b7a8f; font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }
/* 圖例：分組標題、等級色塊、狀態外圈 */
#pLegend { width: 290px; }
#pLegend .lg { padding: 3px 0; font-size: 13.5px; }
.lg-gh { font-size: 12.5px; font-weight: 800; color: #2c5282; margin: 8px 0 2px; display: flex; align-items: baseline; gap: 8px; }
.lg-gh:first-of-type { margin-top: 2px; }
.lg-gh small { font-weight: 400; color: #6b7a8f; font-size: 12px; }
.lg-g { gap: 8px !important; }
.lg-g small { margin-left: auto; }
.lg-gdot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: none; }
#pLegend .fp-note { margin: 6px 0 0; }
/* 邊坡點位 tooltip */
.stip { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; line-height: 1.45; }
.stip-h { display: flex; align-items: center; gap: 6px; }
.stip-h b { font-family: var(--mono); }
.stip small { color: #6b7a8f; font-size: 12px; }
/* 搜尋結果列的等級徽章 */
.ms-res button .gtag { min-width: 20px; height: 19px; font-size: 12px; }
.chart-svg .seg-v { font-size: 11.5px; font-weight: 700; pointer-events: none; }
.chart-svg .val.sm { font-size: 11.5px; }
/* 統計分析：分級 KPI、交叉表色階、升降級 */
.kpi-g small .gtag { margin-right: 2px; }
.kpi-gA { border-top-color: var(--grade-a); } .kpi-gA b { color: var(--grade-a); }
.kpi-gA { background: linear-gradient(180deg, rgba(208, 49, 45, .07), transparent 60%), var(--card); }
.kpi-gB { border-top-color: var(--grade-b); } .kpi-gB b { color: #c86a10; }
.kpi-gC { border-top-color: var(--grade-c); } .kpi-gC b { color: #9a7d00; }
.kpi-gD { border-top-color: var(--grade-d); } .kpi-gD b { color: var(--grade-d); }
body.dark .kpi-gB b { color: #f5ae6a; } body.dark .kpi-gC b { color: #f2d36b; } body.dark .kpi-gA b { color: #f07a76; }
.tbl-cross th .gtag { min-width: 20px; height: 19px; font-size: 12px; }
.tbl-cross td.gheat-A { color: #b02525; font-weight: 700; }
.tbl-cross td.gheat-B { color: #b35a0c; font-weight: 700; }
.tbl-cross td.gheat-C { color: #8a6f00; font-weight: 700; }
.tbl-cross td.gheat-D { color: #1f7a45; font-weight: 700; }
body.dark .tbl-cross td.gheat-A { color: #f28b8b; } body.dark .tbl-cross td.gheat-B { color: #f5ae6a; }
body.dark .tbl-cross td.gheat-C { color: #f2d36b; } body.dark .tbl-cross td.gheat-D { color: #7fd6a2; }
.t-up { color: var(--grade-a); font-weight: 700; white-space: nowrap; }
.t-dn { color: var(--grade-d); font-weight: 700; white-space: nowrap; }
body.dark .t-up { color: #f28b8b; } body.dark .t-dn { color: #7fd6a2; }
.chg-scroll { max-height: 300px; }
.tbl-chg td, .tbl-chg th { padding-top: 6px; padding-bottom: 6px; }
.tbl .c { text-align: center; }
/* 關注鐵道邊坡：等級欄與排序 */
td.nowrap, .tbl td.nowrap { white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.sortable:hover { color: var(--primary); }
.sort-ic { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 2px; }
/* 資料目錄：欄位說明（含邊坡分級 A–D 示意準則） */
.fld-card { margin-top: 16px; }
.fld-card .card-hd h3 { display: flex; align-items: center; gap: 6px; }
.fld-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; align-items: start; }
.fld-tbl td { font-size: 13px; vertical-align: middle; }
.fld-tbl td:first-child { white-space: nowrap; }
.fld-h { font-weight: 800; font-size: 14px; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fld-factors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
/* 等級徽章文字固定白色（避免被 .ms-res span 等通用規則覆寫） */
span.gtag { color: #fff !important; overflow: visible !important; white-space: nowrap !important; flex: none !important; }

/* 圖例：雨量站（示意資料） */
.lg-rain { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 3px; background: #1677c9; color: #fff; font-size: 11px; font-weight: 700; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); flex: none; line-height: 1; }

/* =========================================================
 * 增補規格 D：人工巡查＋分級（逾期標記、巡查概況、巡查紀錄頁）
 * ========================================================= */
:root { --od: #c81e1e; }
/* 逾期標記：紅底白字「逾期 N 天」；mini＝小紅點＋「逾期」 */
.odtag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--od); color: #fff !important; font-size: 12px; font-weight: 700; line-height: 19px; white-space: nowrap; flex: none; }
.odtag.mini { padding: 0 6px 0 5px; font-size: 11.5px; line-height: 17px; background: #fde4e4; color: var(--od) !important; border: 1px solid #f3b4b4; }
.odtag.mini::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--od); }
body.dark .odtag.mini { background: #402020; border-color: #7a3030; color: #f28b8b !important; }
.od-date { color: var(--od); font-weight: 700; }
body.dark .od-date { color: #f28b8b; }
.t-od { color: var(--od); }
/* 圖例／圖層控制中的逾期符號（紅色虛線外環） */
.lg-od { width: 18px; height: 18px; border-radius: 50%; border: 2px dashed var(--od); background: radial-gradient(circle, #8d99aa 0 5px, #fff 5px 7px, transparent 7px); flex: none; box-sizing: border-box; }
.gf-od { grid-column: 1 / -1; border-top: 1px dashed #e3e9f1; margin-top: 3px; padding-top: 5px !important; }
.gf-od .lg-od { width: 16px; height: 16px; }
/* 首頁方卡：逾期數 */
.sys-stats b.od-n { color: var(--od); }
/* KPI */
.kpis-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.kpis-7 .kpi { padding-left: 14px; padding-right: 12px; }
.kpis-7 .kpi small { white-space: nowrap; }
.kpi b .u, .kpi b i.u { font-style: normal; font-size: 18px; font-weight: 700; margin-left: 2px; }
.kpi-od { border-top-color: var(--od); } .kpi-od b { color: var(--od); }
.kpi-fix { border-top-color: var(--act); }
.kpi .sub .gtag { min-width: 17px; height: 17px; font-size: 11px; border-radius: 4px; }
.kpi small .ico { width: 15px; height: 15px; }
.tab em.em-od { background: #fde4e4; color: var(--od); }
/* 抽屜：巡查概況 */
.dt-h .ico { width: 16px; height: 16px; color: var(--primary); align-self: center; }
.gnote.sm { font-size: 11px; padding: 0 4px; margin-left: 2px; }
.ibox { border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.ibox.is-od { border-left-color: var(--od); background: linear-gradient(90deg, #fff4f4, var(--card) 55%); }
body.dark .ibox.is-od { background: var(--card); }
.ib-grid { display: grid; grid-template-columns: 70px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; }
.ib-grid > label { color: var(--muted); font-size: 12px; align-self: start; padding-top: 2px; }
.ib-desc { line-height: 1.55; }
.ib-next { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-none { color: var(--muted); }
.chip-local { background: #e6f0ff; color: #1f4f8a; font-size: 11px; }
.iphoto { margin: 0; }
.iphoto .ph { position: relative; aspect-ratio: 16 / 9; border-radius: 7px; overflow: hidden; background: #dfe5ec; }
.iphoto .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.iphoto .ph-ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #7b8798; font-size: 12px; }
.iphoto .ph-tag { position: absolute; left: 6px; top: 6px; font-style: normal; font-size: 11.5px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); padding: 1px 7px; border-radius: 4px; }
.iphoto figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.iphoto.none { font-size: 12px; color: var(--muted); background: var(--zebra); border: 1px dashed var(--border); border-radius: 7px; padding: 10px; text-align: center; }
.ins-dt .iphoto { margin-top: 12px; max-width: 420px; }
.dt-insp { font-size: 12.5px; table-layout: fixed; }
.dt-insp th, .dt-insp td { padding: 6px 6px; font-size: 12.5px; }
.dt-insp th:nth-child(1) { width: 82px; } .dt-insp th:nth-child(2) { width: 44px; } .dt-insp th:nth-child(3) { width: 74px; } .dt-insp th:nth-child(4) { width: 70px; } .dt-insp th:nth-child(6) { width: 34px; }
.dt-insp .badge { padding: 1px 6px; font-size: 11.5px; }
.dt-insp td.mono { font-size: 12px; }
.dt-insp tr.more { display: none; }
.dt-insp.show-all tr.more { display: table-row; }
.dt-insp .ph-ic { width: 14px; height: 14px; color: var(--muted); }
.dt-more { margin-top: 6px; }
/* 巡查紀錄頁 */
.ins-tb .inp { max-width: 170px; }
.ins-tb .inp-ico .inp { max-width: none; width: 220px; }
.ins-tb input[type=date] { width: 140px; }
.od-only { white-space: nowrap; }
.tbl-ins td { vertical-align: middle; }
.tbl-ins .ins-anom { max-width: 170px; }
.tbl-ins .ins-anom .chip { margin: 1px 0; }
.tbl-ins .ins-desc-c { max-width: 260px; }
.ph-yes .ico { width: 17px; height: 17px; color: var(--primary); }
.tbl-od td { vertical-align: middle; }
/* 新增巡查表單 */
.local-note { flex-direction: row !important; align-items: center; gap: 6px; font-size: 12.5px; color: #8a6a00; background: #fdf6dc; border: 1px solid #f1e2a6; padding: 7px 10px; border-radius: 7px; }
.local-note .ico { width: 15px; height: 15px; flex: none; }
.ins-sel { height: auto !important; margin-top: 6px; padding: 4px; }
.ins-desc { font-family: var(--font); }
.ins-file { font-size: 13px; }
#insSel { margin-top: 4px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
/* 資料集清單 */
.tbl-ds tr.on td { background: #e7effa; }
body.dark .tbl-ds tr.on td { background: #23324a; }
.tbl-ds td.sub { font-size: 13px; }
.tbl-ds .lnk .ico { width: 14px; height: 14px; vertical-align: -2px; }
.ds-prev { margin-top: 16px; }
.ds-scroll { overflow-x: auto; }
.tbl-dsv td.ds-long { max-width: 260px; }
/* 資安參數：逾期巡查提醒 */
.sec-grid .span-2 { grid-column: 1 / -1; }
.od-set { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 0 18px; }
.od-set .form-row { border-top: 0; }
/* 7 欄 KPI：數字與說明上下排列，避免窄欄換行 */
.kpis-7 .kpi { grid-template-columns: 1fr; }
.kpis-7 .kpi .sub { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 逾期清單：不換行 */
.tbl-od td, .tbl-od th { white-space: nowrap; padding-left: 9px; padding-right: 9px; }
.tbl-od td.ell { max-width: 200px; }
/* 內容區建立獨立疊放層，避免 Leaflet 圖層（z-index 400+）蓋住頂部通知下拉 */
.content { isolation: isolate; }
/* 報表綜合研判：徽章不撐滿 */
.rp-sum > div > .badge, .rp-sum > div > .odtag { align-self: flex-start; }
/* 資安參數：逾期巡查提醒 */
.od-set { grid-template-columns: 1fr 1fr !important; }
.od-set .form-row.top { grid-column: 1 / -1; }
/* 資料集清單 */
.tbl-ds td.mono { white-space: nowrap; }

/* =====================================================================
 * 增補規格 E：台鐵鐵路邊坡養護手冊（修訂二版）— 三類巡查、表 2.5／2.6／2.7
 * ===================================================================== */
/* 巡查類別徽章 */
.ptag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 12px; font-weight: 700; line-height: 19px; white-space: nowrap; border: 1px solid transparent; }
.pt-often { background: #e7eef9; color: #2c5282; border-color: #c6d5ec; }
.pt-periodic { background: #efe9fb; color: #5b3fa8; border-color: #d8ccf3; }
.pt-special { background: #fdf0e2; color: #a65a12; border-color: #f2d3ad; }
body.dark .pt-often { background: #1e3150; color: #a9c4ee; border-color: #2f4a73; }
body.dark .pt-periodic { background: #2c2348; color: #c6b5f2; border-color: #46386e; }
body.dark .pt-special { background: #3b2a17; color: #f0c08a; border-color: #5e4223; }
.od-ty { margin-left: 4px; color: var(--od); font-weight: 700; font-size: 11.5px; }
/* 依據來源標示 */
.src-tag { font-style: normal; display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 12px; line-height: 19px; white-space: nowrap; }
.src-hb { background: #e5f4ea; color: #1d6b3a; border: 1px solid #bfe2ca; }
.src-tbd { background: #fff6d6; color: #8a6a00; border: 1px solid #f0dc94; }
/* 巡查頻率對照表（可收合） */
.freq-card { padding: 0; margin-bottom: 14px; }
.freq-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; }
.freq-card > summary::-webkit-details-marker { display: none; }
.freq-card > summary b { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.freq-card > summary .caret { margin-left: auto; transition: transform .2s; }
.freq-card[open] > summary .caret { transform: rotate(180deg); }
.freq-card[open] > summary { border-bottom: 1px solid var(--border); }
.freq-card > .tbl-wrap, .freq-card > p { margin: 10px 16px; }
.freq-card > p { margin-top: 0; }
.freq-tbl th, .freq-tbl td { font-size: 13px; padding: 7px 10px; }
.freq-tbl td small { display: block; font-size: 11.5px; }
.freq-tbl tbody th { background: #f6f8fc; white-space: nowrap; }
body.dark .freq-tbl tbody th { background: #1f2c3e; }
.trig-cell ol { margin: 0; padding-left: 20px; line-height: 1.7; }
/* KPI 雙數值 */
.kpis-st .kpi { grid-template-columns: 1fr; align-items: start; align-content: start; row-gap: 4px; }
.kpis-st .kpi .sub { text-align: left; font-size: 12.5px; }
.kpi b.kpi-2 { display: flex; align-items: baseline; gap: 2px; flex-wrap: nowrap; white-space: nowrap; }
.kpi b.kpi-2 em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 700; margin: 0 10px 0 3px; }
/* 抽屜：巡查概況（依類別）與設施摘要 */
.ptbl { font-size: 12.5px; }
.ptbl th, .ptbl td { padding: 6px 8px !important; font-size: 12.5px; }
.ptbl thead th { background: var(--head) !important; color: #2b4366; font-weight: 700; width: auto !important; }
.ptbl { table-layout: fixed; }
.ptbl thead th:nth-child(1) { width: 104px; } .ptbl thead th:nth-child(2) { width: 86px; }
.ptbl td.mono { white-space: nowrap; font-size: 12px; }
.dt-grid .src-tag { white-space: normal; line-height: 1.4; padding: 1px 6px; }
.ptbl tbody th small { display: block; margin-top: 2px; font-weight: 400; font-size: 11.5px; }
.ptbl tr.is-od td { background: #fff4f4; }
body.dark .ptbl tr.is-od td { background: #3a2020; }
.trig { display: inline-block; padding: 0 6px; border-radius: 4px; background: #fdf0e2; color: #a65a12; font-size: 12px; }
.fac-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.tier-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.tier-list li { display: grid; grid-template-columns: 52px 1fr; gap: 6px; padding: 4px 6px; background: #f6f8fc; border-radius: 6px; }
body.dark .tier-list li { background: #1f2c3e; }
.fac-stab { display: grid; grid-template-columns: 92px 1fr; gap: 6px; font-size: 12.5px; align-items: start; }
.fac-stab label { color: var(--muted); font-size: 12px; }
.fac-stab .chip { margin: 1px 0; }
.chip-anc { background: #fde8d7; color: #9a4a10; font-weight: 700; }
/* 逾期清單：類別 × 等級彙整 */
.od-matrix { display: flex; align-items: center; gap: 16px; padding: 10px 14px 0; flex-wrap: wrap; }
.od-mx { width: auto; min-width: 420px; }
.od-mx th, .od-mx td { padding: 5px 12px; }
.od-pick { font-weight: 800; color: var(--od) !important; }
/* 表 2.5 缺失代號／危急性 */
.chip.dcode { min-width: 22px; text-align: center; font-weight: 700; padding: 1px 5px; }
.chip.d17 { background: #fde4e4; color: #b42318; }
.d17t { color: #b42318; font-weight: 700; }
.dg { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 14px; }
.dg-o { background: #e5f4ea; color: #1d6b3a; } .dg-t { background: #fff3d6; color: #8a5a00; } .dg-s { background: #fde4e4; color: #b42318; }
.tbl-route td { vertical-align: middle; }
.ins-who { max-width: 150px; }
.r25-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.r25-sum > div { background: #f6f8fc; border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; }
body.dark .r25-sum > div { background: #1f2c3e; }
.r25-sum small { color: var(--muted); font-size: 12px; } .r25-sum b { font-size: 17px; }

/* ---------- 表單：新增巡查（類別切換） ---------- */
.hb-wrap { font-size: 13px; }
.ins-top { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 10px 0; align-items: start; }
#insTrig { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
#insTrig > label { grid-column: 1 / -1; }
#insTrig > input { margin-top: 0 !important; }
.ins-top label { display: block; font-size: 13px; font-weight: 700; color: #3b4d66; margin-bottom: 4px; }
.ins-top .seg button small { font-weight: 400; opacity: .85; font-size: 11.5px; }
.ins-pick { display: grid; grid-template-columns: 240px 1fr; gap: 8px; }
.ins-pick .ins-sel { height: 76px; }
.often-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #f3f6fb; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; }
.often-note > span { display: inline-flex; align-items: center; gap: 6px; }
body.dark .often-note { background: #1f2c3e; }
.supp { margin-top: 12px; border-top: 2px solid var(--border); padding-top: 10px; }
.supp-h { font-weight: 800; margin-bottom: 8px; font-size: 14px; }
.supp .form-grid { gap: 8px 14px; }
.kv-sm th, .kv-sm td { padding: 7px 10px; font-size: 13px; }
.kv-sm th { width: 110px; }

/* ---------- 手冊表 2.6／2.7 版面 ---------- */
.hb-form { border: 1px solid #b9c5d6; border-radius: 6px; padding: 10px 12px; background: #fff; color: #1f2d3d; }
body.dark .hb-form { background: #16212f; color: #dbe5f2; border-color: #33465e; }
.hb-title { text-align: center; font-weight: 800; font-size: 15px; letter-spacing: .5px; margin: 2px 0 6px; }
.hb-note { text-align: center; color: #8a6a00; font-size: 12.5px; margin: 0 0 6px; }
.hb-head { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; margin-bottom: 6px; }
.hb-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.hb-tbl th, .hb-tbl td { border: 1px solid #8796ab; padding: 4px 7px; vertical-align: middle; font-size: 12.5px; text-align: left; }
body.dark .hb-tbl th, body.dark .hb-tbl td { border-color: #42566f; }
.hb-tbl > tbody > tr > th { background: #f3f6fa; font-weight: 700; text-align: center; line-height: 1.35; }
body.dark .hb-tbl > tbody > tr > th { background: #1f2c3e; }
.hb-tbl th.hb-sub { font-weight: 600; }
.hb-sub-l { color: var(--muted); }
.hb-split { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.hb-split > .hb-cks { border-left: 1px solid #8796ab; padding-left: 8px; }
.hb-cks { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; }
.hb-grid3 { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 12px; }
.hb-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 26px; }
.hb-tier .hb-line { min-height: 24px; }
.hb-c { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; white-space: nowrap; }
.hb-c input { margin: 0; width: 14px; height: 14px; }
.hb-ck { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; color: #6b7a8d; }
.hb-ck.on { color: inherit; font-weight: 700; }
.hb-ck.on > span { color: inherit; }
.hb-in { height: 26px; border: 1px solid #c9d4e3; border-radius: 4px; padding: 0 6px; font: inherit; font-size: 12.5px; background: var(--card); color: inherit; max-width: 100%; }
textarea.hb-in { height: auto; padding: 3px 6px; width: 100%; resize: vertical; }
select.hb-in { padding: 0 4px; }
.hb-in.num { width: 100%; padding: 0 3px; text-align: right; }
.hb-v { text-decoration: none; border-bottom: 1px solid #8796ab; display: inline-block; padding: 0 4px; text-align: center; line-height: 20px; }

/* ---------- 表 2.5 路線巡查（徒步）記事表 ---------- */
.r25 { border: 1px solid #b9c5d6; border-radius: 6px; padding: 10px 12px; background: #fff; color: #1f2d3d; }
body.dark .r25 { background: #16212f; color: #dbe5f2; border-color: #33465e; }
.r25-org { text-align: center; font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.r25-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.r25-date { margin-left: auto; }
.r25-tbl thead th { background: #f3f6fa; text-align: center; font-weight: 700; position: static; color: inherit; font-size: 12px; padding: 4px; }
body.dark .r25-tbl thead th { background: #1f2c3e; }
.r25-tbl th.r25-v { line-height: 1.2; }
.r25-tbl td { font-size: 12.5px; padding: 3px 4px; vertical-align: top; }
.r25-tbl td.num, .r25-tbl td.c { vertical-align: middle; }
.r25-dates > * { display: block; width: 100%; }
.r25-dates > * + * { margin-top: 3px; border-top: 1px dashed #c9d4e3; padding-top: 2px; }
.r25-tbl input.hb-in[type=date] { width: 100%; padding: 0 2px; font-size: 12px; }
.r25-tbl .r25-code { width: 100%; }
.r25-tbl select[name=danger] { width: 100%; padding: 0 2px; font-size: 14px; }
.r25-slope { margin-bottom: 3px; font-size: 12px; display: flex; gap: 4px; align-items: center; }
.r25-slope select { flex: 1; min-width: 0; }
.r25-del { font-size: 12px; margin-top: 3px; }
.r25-notes { margin-top: 8px; font-size: 12px; line-height: 1.65; }
.r25-notes p { margin: 2px 0; }
.r25-sign { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; }
#r25Add { margin-top: 6px; }

/* ---------- 列印（window.print；只印目前對話框內容） ---------- */
@media print {
  body.print-modal > *:not(.modal-mask) { display: none !important; }
  body.print-modal .modal-mask { position: static !important; background: none !important; display: block !important; }
  body.print-modal .modal-mask:not(:last-of-type) { display: none !important; }
  body.print-modal .modal { width: auto !important; max-width: none !important; max-height: none !important; box-shadow: none !important; transform: none !important; }
  body.print-modal .modal-bd { overflow: visible !important; }
  body.print-modal .modal-ft, body.print-modal .mclose { display: none !important; }
}

/* =====================================================================
 * 增補規格 E 第 2 階段：系統分工、人工量測、維護（修）紀錄、外部資料匯入
 * ===================================================================== */
/* 頂部分工型態標示 */
.mode-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; border: 1px solid; }
.mode-pill.m-import { background: #eef3fb; color: #2c5282; border-color: #c6d5ec; }
.mode-pill.m-entry { background: #e7f5ec; color: #1d6b3a; border-color: #bfe2ca; }
body.dark .mode-pill.m-import { background: #1e3150; color: #a9c4ee; border-color: #2f4a73; }
body.dark .mode-pill.m-entry { background: #1c3527; color: #9fd9b4; border-color: #2d5a3e; }
.src-note { color: #2c5282; background: #eef3fb; border-color: #c6d5ec; }
body.dark .src-note { background: #1e3150; border-color: #2f4a73; color: #a9c4ee; }
/* 來源／批次欄 */
.src-c { display: flex; flex-direction: column; line-height: 1.3; max-width: 190px; }
.src-c > span { font-size: 12.5px; }
.src-c small { font-size: 11px; }
.dr-ro { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.dr-ro .ico { width: 14px; height: 14px; }
fieldset.ro-set { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.ro-set[disabled] .inp, fieldset.ro-set[disabled] textarea { background: #f4f6f9; color: #4a5a6e; }
body.dark fieldset.ro-set[disabled] .inp, body.dark fieldset.ro-set[disabled] textarea { background: #1b2635; color: #b8c6d8; }
/* 管理值燈號 */
.ltag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ltag i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1.5px rgba(0,0,0,.12); }
.ltag.l-g i { background: #2e9e5b; } .ltag.l-g { color: #1d6b3a; }
.ltag.l-y i { background: #e0b000; } .ltag.l-y { color: #8a6a00; }
.ltag.l-o i { background: #f08a24; } .ltag.l-o { color: #b35a0c; }
.ltag.l-r i { background: #d0312d; } .ltag.l-r { color: #b02525; }
body.dark .ltag.l-g { color: #8fd6a8; } body.dark .ltag.l-y { color: #f2d36b; } body.dark .ltag.l-o { color: #f5b06c; } body.dark .ltag.l-r { color: #f28b8b; }
/* 抽屜：人工量測摘要、維護紀錄 */
.mbox { border-left-color: #5b7fb5; }
.mbox.na { padding: 8px 12px; }
.mi-list { display: flex; flex-direction: column; gap: 4px; border-top: 1px dashed var(--border); padding-top: 8px; }
.mi-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; font-size: 12.5px; }
.mi-row small { font-size: 11px; }
.mb-ft { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12.5px; }
.dt-maint th, .dt-maint td { font-size: 12.5px; padding: 6px 8px; }
/* 人工量測頁 */
.ms-ref { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 16px; }
.ms-ref .tbl-wrap { margin: 0; }
.kpi b.kpi-sm { font-size: 24px; }
.tbl-ms td, .tbl-mt td { font-size: 13px; }
.ms-who { max-width: 150px; } .ms-note { max-width: 170px; }
.ms-pick { max-width: 360px; }
.ms-trend { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; margin-bottom: 12px; }
.ms-chart { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.ms-side .dt-h { margin-top: 0; }
.ms-side .ibox { font-size: 13px; }
.ms-hist { max-height: 300px; }
.ref-l { font-size: 11.5px; font-weight: 700; }
.mf-auto { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: #f6f8fc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.mf-auto label { display: block; font-size: 11.5px; color: var(--muted); }
.mf-auto > span { grid-column: 1 / -1; }
body.dark .mf-auto { background: #1b2635; }
/* 維護（修）紀錄 */
.mt-content { max-width: 260px; } .mt-unit { max-width: 160px; }
.mt-sheet .hb-tbl th { background: #f3f6fa; }
body.dark .mt-sheet .hb-tbl th { background: #1f2c3e; }
.mt-att { display: flex; gap: 10px; margin-top: 10px; }
.mt-att .iphoto { flex: 1; }
/* 外部資料匯入 */
.imp-srcs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.imp-kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.imp-kv label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.imp-kv b { font-size: 14px; }
.imp-kv small { display: block; font-size: 11.5px; }
.imp-kv .chip { margin: 0 2px 2px 0; }
.tbl-imp td { font-size: 13px; }
.imp-src-c { max-width: 200px; }
.tbl-imp tr.has-det td:first-child .det-c { display: inline-block; margin-right: 6px; transition: transform .15s; transform: rotate(-90deg); }
.tbl-imp tr.has-det.open td:first-child .det-c { transform: none; }
.tbl-imp tr.imp-det td { background: #fbfcfe !important; padding: 8px 14px 12px 34px; cursor: default; }
body.dark .tbl-imp tr.imp-det td { background: #18222f !important; }
.imp-det-in { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.imp-det-in .ico { width: 15px; height: 15px; color: var(--od); }
.tbl-fd { max-width: 620px; }
.tbl-fd th, .tbl-fd td { font-size: 12.5px; padding: 5px 10px; }
.imp-bottom { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; margin-top: 16px; }
.imp-bottom .card-hd .readonly { font-size: 12px; }
.imp-form { margin: 10px 0; }
.imp-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.imp-prog .bar { flex: 1; height: 10px; border-radius: 99px; background: #e4ecf6; overflow: hidden; }
.imp-prog .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .07s linear; }
.tbl-ms th small { font-weight: 400; font-size: 11px; }
.tbl-ms td { padding: 7px 9px; } .tbl-ms th { padding: 9px 9px; }
.tbl-ms .ms-who { max-width: 118px; } .tbl-ms .ms-note { max-width: 130px; }
.tbl-mt td { padding: 7px 9px; } .tbl-mt th { padding: 9px 9px; }
.ms-side .mb-ft a { display: none; }
.tbl-mt .mt-content { max-width: 190px; } .tbl-mt .mt-unit { max-width: 110px; }
.tbl-mt th small { font-weight: 400; font-size: 11px; }
.src-c small { white-space: nowrap; }
.sys-legend .mode-pill { font-size: 11px; padding: 1px 7px; margin-right: 4px; }

/* =====================================================================
 * 增補規格 E 第 3 階段：地錨管理、監理資訊
 * ===================================================================== */
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpis-6 .kpi { grid-template-columns: 1fr; padding: 10px 12px; }
.kpis-6 .kpi .sub { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis-5 .kpi .sub { white-space: nowrap; }
.kpi-l { cursor: pointer; } .kpi-l:hover { box-shadow: 0 0 0 2px #c6d5ec; }
.kpi-na { border-top-color: #a3adbb; } .kpi-na b { color: #6b7686; }
.ltag.l-na i { background: #a3adbb; } .ltag.l-na { color: #6b7686; }
/* 地錨分級徽章（圓形 Ⅰ–Ⅳ） */
.agtag { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; vertical-align: middle; box-shadow: 0 0 0 1.5px rgba(255,255,255,.9), 0 0 0 2.5px rgba(0,0,0,.08); font-family: "Times New Roman", serif; }
.agtag.none { background: #e9edf2; color: #8a96a8; box-shadow: none; font-family: inherit; }
.ag-l { margin-left: 4px; font-size: 12px; font-weight: 700; color: #3b4d66; }
body.dark .ag-l { color: #c2d0e3; }
.agbar { display: inline-flex; width: 110px; height: 9px; border-radius: 99px; overflow: hidden; background: #e9edf2; vertical-align: middle; margin-right: 6px; }
.agbar i { display: block; height: 100%; } .agbar i.nt { background: #cfd6df; }
.ag-n { display: block; font-size: 11px; }
.lvtag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 19px; white-space: nowrap; }
.lvtag.lv0 { background: #e3f4ea; color: #1f7a45; } .lvtag.lv1 { background: #e6f0fb; color: #22609e; }
.lvtag.lv2 { background: #fde8d4; color: #b35a0c; } .lvtag.lv3 { background: #fbe0e0; color: #b02525; }
body.dark .lvtag.lv0 { background: #1d3a2b; color: #7fd6a2; } body.dark .lvtag.lv1 { background: #1e3150; color: #a9c4ee; }
body.dark .lvtag.lv2 { background: #3e2a17; color: #f5ae6a; } body.dark .lvtag.lv3 { background: #402020; color: #f28b8b; }
.at-trig { display: block; font-size: 11px; }
.pt-periodic { background: #efeafb; color: #5b3fb0; border-color: #d9cdf5; }
.pt-x { background: #eef3fb; color: #2c5282; border-color: #c6d5ec; }
.an-pick { max-width: 330px; }
.tbl-an td, .tbl-at td, .tbl-sv td, .tbl-pg td, .tbl-evr td, .tbl-nl td { font-size: 13px; padding: 7px 9px; }
.tbl-an th, .tbl-at th, .tbl-sv th, .tbl-pg th, .tbl-evr th, .tbl-nl th { padding: 9px 9px; }
.tbl-sv th small { font-weight: 400; font-size: 11px; }
tr.sel td { background: #eef4fc !important; } body.dark tr.sel td { background: #1e3150 !important; }
/* 建議辦理特別檢測 */
.anc-sug { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: #fff4e6; border: 1px solid #f5cf9f; color: #8a4a08; margin-top: 4px; }
.anc-sug > .ico { width: 18px; height: 18px; flex: none; color: #d0711a; }
.anc-sug > div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.anc-sug b { font-size: 13px; } .anc-sug small { font-size: 12px; color: #8a5a20; }
.anc-sug .btn { flex: none; }
body.dark .anc-sug { background: #3b2a17; border-color: #5e4223; color: #f0c08a; } body.dark .anc-sug small { color: #e0b080; }
.dr-bd .mbox .anc-sug, .modal .mbox .anc-sug { display: none; }
.abox { border-left-color: #7c5cc4; }
.sg-why > div + div { margin-top: 4px; }
/* 地錨展開圖 */
.amap-tb { padding: 10px 14px; margin-bottom: 14px; } .amap-tb .toolbar { margin: 0; }
.amap-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.amap-cvs { display: flex; gap: 12px; } .amap-cvs canvas { display: block; border: 1px solid var(--border); border-radius: 8px; }
.amap-side { font-size: 13px; } .amap-side .ib-grid { font-size: 13px; }
.am-h { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.am-h .ico { color: var(--primary); }
.am-score { font-size: 18px; }
.am-items { margin: 8px 0; } .am-items th, .am-items td { font-size: 12.5px; padding: 5px 8px; }
.am-hist { max-height: 220px; } .am-hist td, .am-hist th { font-size: 12.5px; padding: 5px 8px; }
.am-tip { margin: 10px 0; }
.amap-side .iphoto { margin-top: 6px; }
@media print {
  body.print-amap .side, body.print-amap .topbar, body.print-amap .page-hd, body.print-amap .amap-tb, body.print-amap .amap-side, body.print-amap #toasts { display: none !important; }
  body.print-amap .amap-wrap { display: block; } body.print-amap .content { overflow: visible !important; }
  body.print-amap .card { box-shadow: none; border: 0; }
}
/* 地錨檢測紀錄表／表單 */
.at-sheet .hb-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.at-sheet .hb-title b { font-size: 17px; }
.at-sheet .kv th { width: 110px; padding: 7px 10px; font-size: 13px; } .at-sheet .kv td { padding: 7px 10px; font-size: 13px; }
.at-sum, .af-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.at-sum > div, .af-sum > div { background: #f6f8fc; border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
body.dark .at-sum > div, body.dark .af-sum > div { background: #1b2635; }
.at-sum small, .af-sum small { font-size: 11.5px; color: var(--muted); } .at-sum b, .af-sum b { font-size: 16px; }
.at-gc { font-size: 13px !important; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.af-sum .af-warn { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; background: #fff4e6; color: #8a4a08; font-size: 13px; }
.af-warn .ico { width: 16px; height: 16px; color: #d0711a; }
.at-rows, .af-rows { max-height: 330px; }
.at-rows th, .at-rows td, .af-rows th, .af-rows td { font-size: 12px; padding: 5px 6px; white-space: nowrap; }
.at-rows th small, .af-rows th small { display: block; font-weight: 400; font-size: 10.5px; }
.at-rows tr.hl td { background: #fff7d6 !important; }
.inp-xs { height: 26px; font-size: 12px; padding: 0 4px; width: 64px; }
.af-rows .af-note { width: 120px; }
.fg-4 { grid-template-columns: repeat(4, 1fr); }
.af-tb { margin: 6px 0; }
/* 評分與分級標準 */
.std-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.std-tbl th, .std-tbl td { font-size: 13px; padding: 7px 10px; }
.std-tbl .inp { width: 100%; } .std-tbl .inp-sm[type=number] { width: 72px; text-align: right; }
.std-tbl.kv th { width: 100px; }
.inp-color { width: 44px; height: 28px; border: 1px solid #cdd7e4; border-radius: 6px; padding: 1px; background: var(--card); }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.std-eff .r25-sum { grid-template-columns: repeat(6, 1fr); }
/* 監理燈號 */
.sv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 450px; gap: 14px; align-items: start; }
.sv-map { display: block; border-radius: 8px; border: 1px solid var(--border); cursor: crosshair; }
.sv-leg { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 10px; }
.sv-sel-hd { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: 13px; min-width: 0; }
.sv-sel-hd .ell { max-width: 150px; }
.sv-side .seg { margin-bottom: 6px; }
/* 管理值 */
.th-tbl th, .th-tbl td { font-size: 13px; padding: 8px 10px; }
.th-tbl .inp-sm { width: 84px; } .th-tbl .inp-sm.num { text-align: right; } .th-tbl input[type=date] { width: 140px; }
.th-log { max-height: 300px; }
/* 通報 */
.tbl-nr td { font-size: 13px; padding: 8px 10px; } .tbl-nr tr.na td { color: var(--muted); }
.tbl-nr .chip { margin: 1px 2px 1px 0; }
.chip-ch { background: #e6f0ff; color: #1f4f8a; }
.sw { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; white-space: nowrap; }
.sw input { display: none; }
.sw i { width: 34px; height: 18px; border-radius: 99px; background: #c8d1dc; position: relative; transition: background .15s; }
.sw i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.sw input:checked + i { background: var(--ok); } .sw input:checked + i::after { left: 18px; }
.nl-to { max-width: 200px; font-size: 12px !important; }
/* 進度 */
.pg-basis { font-size: 12px !important; max-width: 220px; }
.pg-log { max-height: 260px; }
/* 監管分析 */
.tbl-sa td, .tbl-sa th { font-size: 13px; padding: 7px 9px; }
.drill { max-height: 420px; }
/* 事件後資料 */
.ev-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; margin-bottom: 16px; align-items: start; }
.tbl-ev td, .tbl-ev th { font-size: 12.5px; padding: 6px 8px; }
.ev-desc { max-width: 260px; }
.chip-cat.c-sp { background: #efeafb; color: #5b3fb0; } .chip-cat.c-ev { background: #e6f0ff; color: #1f4f8a; }
.chip-cat.c-fix { background: #e3f4ea; color: #1f7a45; } .chip-cat.c-em { background: #fbe0e0; color: #b02525; }
.ev-pick { border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.ev-pick .toolbar { margin-bottom: 6px; }
.ev-chks { max-height: 190px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ev-chks .chk { font-size: 12.5px; padding: 3px 2px; }
/* 通知鈴其他類別、首頁方卡監理列 */
.bell-ic { width: 26px; height: 26px; flex: none; border-radius: 6px; background: #eef3fb; color: #2c5282; display: inline-flex; align-items: center; justify-content: center; }
.bell-ic .ico { width: 16px; height: 16px; }
.sys-supv { min-height: 22px; margin-top: -6px; }
.sys-supv .ltag { font-size: 12px; }
.sys-supv .ss-anc { color: #4a5a70; font-size: 12.5px; }
.sys-supv .od-n { color: var(--od); }
.at-rows .hb-tbl, .af-rows .hb-tbl { table-layout: auto; } .at-sheet .hb-title { text-align: left; justify-content: flex-start; }
.nav-subitem { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-subitem.long { font-size: 12.5px; letter-spacing: -.6px; padding-right: 4px; }
.tbl-an .mono b { white-space: nowrap; }
td.mono > b, td > b.mono { white-space: nowrap; }
.dd-notif .dd-h small { display: block; margin-top: 2px; }
.ev-grid { grid-template-columns: 1.55fr 1fr; }
.tbl-ev th { line-height: 1.25; }
.dd-notif .dd-h { display: block; }
.std-tbl select.inp { width: auto; max-width: 100%; }
.dd-notif .dd-h small { white-space: normal; line-height: 1.4; }

/* =========================================================
 * 第 4 階段：圖台圖層分組、水系／氣象站圖例、輸出（PNG／列印）
 * ========================================================= */
.fp-gh { font-size: 12px; font-weight: 800; color: #2c5282; margin: 8px 0 0; padding-top: 6px; border-top: 1px dashed #e3e9f1; display: flex; align-items: baseline; gap: 6px; }
.fp-h + .fp-gh { margin-top: 2px; padding-top: 2px; border-top: 0; }
.fp-gh { white-space: nowrap; }
.fp-gh small { font-weight: 400; color: #8391a5; font-size: 11px; }
.lg-river { width: 26px; height: 12px; flex: none; display: inline-flex; }
.lg-wx { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; background: #7a4fc2; color: #fff; font-size: 10.5px; font-weight: 700; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); flex: none; line-height: 1; box-sizing: border-box; }
.ex-panel { width: 290px; }
.ex-panel .tl-go.wide { margin-top: 6px; }
.ex-panel .ex-opt { font-size: 13px; padding: 4px 2px 2px; }
.ex-panel .fp-note b { color: #b04a12; font-weight: 700; }
.map-print-h, .print-only { display: none !important; }
/* 列印準備（畫面上暫時固定地圖為 A4 橫向尺寸，讓 Leaflet 依列印尺寸載入圖磚） */
body.print-map .map-wrap { right: auto; bottom: auto; width: 1060px; height: 700px; background: #fff; }
body.print-map .map { top: 48px; }
body.print-map .map-print-h { display: flex !important; }
.map-print-h { position: absolute; left: 0; right: 0; top: 0; height: 46px; align-items: center; gap: 14px; flex-wrap: wrap; row-gap: 0; padding: 2px 4px; color: #1f2d3d; font-size: 12px; border-bottom: 2px solid #2c5282; box-sizing: border-box; align-content: center; }
.map-print-h b { font-size: 16px; font-weight: 800; }
.map-print-h .mph-demo { color: #6b5300; background: #fff6d6; padding: 0 6px; border-radius: 3px; }
.map-print-h small { flex-basis: 100%; color: #3b4d66; font-size: 11px; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body, body.is-sys { height: auto !important; overflow: visible !important; background: #fff !important; }
  body:has(.page-map) .side, body:has(.page-map) .topbar, body:has(.page-map) #toasts, .page-map .map-search, .page-map .fl-tl, .page-map .fl-tr, .page-map #bAux, .page-map #pAux, .page-map #bLegend,
  .page-map .ztag, .page-map .coord, .page-map .tl-hint, .page-map .prof, .page-map .drawer, .page-map .base-warn, .page-map .map-demo, .page-map .ppt-tag, .page-map .ms-res { display: none !important; }
  body:has(.page-map) .shell, body:has(.page-map) .main { display: block !important; height: auto !important; width: auto !important; overflow: visible !important; }
  .content.page-map { position: relative; overflow: hidden !important; width: 1060px; height: 700px; flex: none; isolation: auto; }
  .page-map .map-wrap { position: absolute; inset: 0; width: auto; height: auto; }
  .page-map .map { top: 48px; border: 1px solid #8796aa; }
  .page-map .map-print-h { display: flex !important; }
  .page-map .print-only { display: block !important; }
  .page-map .fl-br { right: 8px; bottom: 8px; }
  .page-map #pLegend { display: block !important; box-shadow: none; border: 1px solid #b8c4d4; padding: 8px 12px; width: 290px; }
  .page-map #pLegend .lg { font-size: 12px; padding: 1px 0; }
  .page-map #pLegend .lg-gh { margin: 4px 0 1px; font-size: 11.5px; }
  .page-map #pLegend .fp-note { font-size: 10.5px; }
  .page-map .leaflet-bottom.leaflet-left { left: 8px !important; bottom: 8px !important; }
  .page-map .leaflet-control-attribution { max-width: 700px; white-space: normal; }
}
