/* ===== 基本設定 ===== */
:root {
  /* 日寅能源企業色（取自 riin-energy.com.tw） */
  --brand: #34b8b1;        /* Logo 青綠 */
  --brand-light: #69cbcd;  /* 漸層淺端 */
  --brand-blue: #4faabf;   /* 輔助藍綠 */
  --brand-dark: #187a75;   /* 深青綠：文字、主要按鈕（白字對比 5:1 以上） */
  --brand-deeper: #11605c;
  --brand-grad: linear-gradient(100deg, #2fb7b1 0%, #69cbcd 100%);
  --focus: #2b86a8;
  --bg: #f3f7f7;
  --surface: #ffffff;
  --ink: #292929;
  --ink-soft: #4f625f;
  --muted: #5f706d;
  --line: #dce9e7;
  --field-line: #c9d6d4;
  --hover: #edf8f7;
  --accent: var(--brand-dark);
  --accent-soft: #edf8f7;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --st-none: #187a75;     /* 未裝板：目標客戶 */
  --st-has: #2d64a3;      /* 已裝板 */
  --st-unsure: #c08a12;   /* 看不清 */
  --st-notfound: #a8433a; /* 定位錯誤 */
  --st-todo: #c5d3d1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 74, 70, .06), 0 4px 16px rgba(24, 74, 70, .06);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6;
  color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.3; margin: 0; }
h2 { font-size: 1.12rem; margin-bottom: 12px; }
h3 { font-size: 1rem; }
p { margin: 0 0 6px; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 5px; margin-right: 6px;
  font: 600 .78rem/1.5 ui-monospace, Consolas, monospace; text-align: center;
  border: 1px solid currentColor; border-radius: 4px; opacity: .85;
}

/* ===== 頁首 ===== */
.site-header { position: sticky; top: 0; z-index: 20; background: #fff; color: var(--ink); box-shadow: 0 1px 0 var(--line); }
.site-header::after { content: ""; display: block; height: 3px; background: var(--brand-grad); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand { gap: 14px; }
.brand-logo { display: block; flex-shrink: 0; line-height: 0; border-radius: 4px; }
.brand-logo img { display: block; width: 150px; height: 30px; }
.brand-text { padding-left: 14px; border-left: 1px solid var(--line); }
.brand h1 { font-size: 1.1rem; color: var(--ink); }
.brand-sub { font-size: .8rem; color: var(--muted); margin: 0; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .92rem; }
.site-nav a:hover { background: var(--hover); color: var(--brand-dark); }

.source-banner { background: #edf8f7; border-bottom: 1px solid #cde9e6; color: #1f4e4b; font-size: .88rem; padding: 9px 0; }
.source-banner strong { display: inline-block; background: var(--brand-dark); color: #fff; padding: 0 8px; border-radius: 6px; margin-right: 6px; font-size: .78rem; }

/* ===== 進度 ===== */
.progress-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin: 16px 0; }
.progress-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .92rem; }
.progress-bar { display: flex; height: 10px; border-radius: 99px; background: var(--st-todo); overflow: hidden; margin: 8px 0; }
.seg { display: block; height: 100%; width: 0; transition: width .3s; }
.seg-none { background: var(--st-none); }
.seg-has { background: var(--st-has); }
.seg-unsure { background: var(--st-unsure); }
.seg-notfound { background: var(--st-notfound); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .84rem; color: var(--ink-soft); }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot-none { background: var(--st-none); } .dot-has { background: var(--st-has); }
.dot-unsure { background: var(--st-unsure); } .dot-notfound { background: var(--st-notfound); }
.dot-todo { background: var(--st-todo); }

/* ===== 版面 ===== */
.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }

/* ===== 判讀區 ===== */
.factory-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.factory-head h3 { font-size: 1.25rem; }
.factory-meta { font-size: .82rem; color: var(--muted); margin-bottom: 2px; }
.factory-addr { color: var(--ink-soft); margin: 2px 0 0; }
.warn-line { color: #8a5a00; background: #fff4dc; font-size: .82rem; padding: 3px 8px; border-radius: 6px; margin-top: 6px; display: inline-block; }
.nav-btns { display: flex; gap: 6px; flex-shrink: 0; }

.status { font-weight: 700; }
.status.s-none { color: var(--st-none); } .status.s-has { color: var(--st-has); }
.status.s-unsure { color: var(--st-unsure); } .status.s-notfound { color: var(--st-notfound); }

.map-frame { position: relative; border-radius: 10px; overflow: hidden; background: #22302f; height: min(62vh, 620px); min-height: 320px; }
.map-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.map-tools {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .94); padding: 5px 8px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  font-size: .85rem; font-variant-numeric: tabular-nums;
}
.map-frame.flash::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 5px var(--flash, var(--accent)); animation: flash .5s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.query-row { margin-top: 10px; }
.query-row label { font-size: .84rem; font-weight: 600; color: var(--ink-soft); }
.query-input { display: flex; gap: 6px; }
.query-input input { flex: 1; min-width: 0; }

.judge { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.judge-btn {
  min-height: 56px; padding: 8px; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: .95rem; color: #fff; border: 2px solid transparent;
  transition: transform .08s, filter .15s;
}
.judge-btn:hover { filter: brightness(1.08); }
.judge-btn:active { transform: scale(.97); }
.judge-btn.current { border-color: #fff; box-shadow: 0 0 0 3px var(--brand-blue); }
.j-none { background: var(--st-none); }
.j-has { background: var(--st-has); }
.j-unsure { background: var(--st-unsure); }
.j-notfound { background: var(--st-notfound); }
.judge-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ===== 表單 ===== */
.field { margin: 0 0 12px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="text"], input[type="search"], input[type="password"], select {
  width: 100%; min-height: 40px; padding: 7px 10px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--field-line); border-radius: 8px;
}
select:disabled { background: #eef3f2; color: var(--muted); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.field-error { color: var(--danger); font-size: .82rem; margin: 4px 0 0; }
.field-error:empty { display: none; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .92rem; margin-bottom: 8px; cursor: pointer; font-weight: 400 !important; color: var(--ink) !important; }
.check.compact { margin: 0; font-size: .86rem; align-items: center; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.check.compact input { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; margin: 0 !important; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: 4px 11px; border-radius: 99px; border: 1px solid var(--field-line); background: #fff; font-size: .85rem; color: var(--ink-soft); font-weight: 500; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ===== 按鈕 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 40px; padding: 7px 14px; font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none;
  color: var(--ink); background: #fff; border: 1px solid var(--field-line); border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--brand-deeper); border-color: var(--brand-deeper); }
.btn-danger { color: var(--danger); border-color: #e6b8b3; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 3px 10px; font-size: .84rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== 檢視切換 ===== */
.main-col { min-width: 0; }
.view-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.view-tab {
  flex: 1; min-height: 42px; font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer;
  border: 1px solid var(--field-line); background: #fff; color: var(--ink-soft); border-radius: 10px;
}
.view-tab.active { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.coord-line { font-size: .78rem; color: var(--muted); margin: 2px 0 0; }

/* ===== 快速牆 ===== */
.wall-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.wall-head h2 { margin: 0; }
.wall-controls { display: flex; gap: 12px; flex-wrap: wrap; }
.inline-field { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.inline-field select { width: auto; min-height: 34px; padding: 4px 8px; }
.wall-hint { margin: 8px 0 10px; }
.hint-touch { display: none; }
.wall-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wall-grid.size-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wcell { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.wcell.st-has { border-color: var(--st-has); box-shadow: 0 0 0 2px rgba(45, 100, 163, .25); }
.wcell.st-none { border-color: var(--st-none); }
.wcell.st-unsure { border-color: var(--st-unsure); }
.wcell.st-notfound { border-color: var(--st-notfound); }
.wcell-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px; font-size: .84rem; background: #f2f8f7; border-bottom: 1px solid var(--line); min-width: 0; }
.wnum { display: grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px; background: var(--brand-dark); color: #fff; font-weight: 700; font-size: .8rem; }
.wname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.wstatus { font-size: .74rem; font-weight: 700; white-space: nowrap; }
.st-has .wstatus { color: var(--st-has); } .st-none .wstatus { color: var(--st-none); }
.st-unsure .wstatus { color: var(--st-unsure); } .st-notfound .wstatus { color: var(--st-notfound); }
.wmap { position: relative; aspect-ratio: 1 / 1; background: #22302f; }
.wmap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.wall-grid.size-9 .wmap { aspect-ratio: 4 / 3; }
.wcell-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; }
.wbtn {
  min-height: 34px; padding: 2px 4px; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  border-radius: 7px; border: 1.5px solid var(--field-line); background: #fff; color: var(--ink-soft);
}
.wbtn:hover { background: var(--hover); }
.wbtn.w-has { border-color: var(--st-has); color: var(--st-has); }
.wbtn.on.w-has { background: var(--st-has); color: #fff; }
.wbtn.on.w-none { background: var(--st-none); border-color: var(--st-none); color: #fff; }
.wbtn.on.w-unsure { background: var(--st-unsure); border-color: var(--st-unsure); color: #fff; }
.wbtn.on.w-notfound { background: var(--st-notfound); border-color: var(--st-notfound); color: #fff; }
.wcell-addr { font-size: .75rem; color: var(--muted); padding: 0 8px 7px; margin: 0; line-height: 1.45; }
.wcell-addr .badge { margin-left: 4px; }
.wcell-addr .link-btn { font-size: .75rem; }
.wall-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.wall-foot .wall-commit { margin-left: auto; min-height: 46px; }

/* ===== 名單 ===== */
.list-panel { position: sticky; top: 72px; }
.list-summary { font-size: .86rem; color: var(--ink-soft); margin: 12px 0 6px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.list-panel .table-wrap { max-height: calc(100vh - 470px); min-height: 220px; }
.ftable { width: 100%; border-collapse: collapse; font-size: .86rem; }
.ftable th { position: sticky; top: 0; background: #f2f8f7; text-align: left; font-weight: 600; color: var(--ink-soft); padding: 7px 10px; border-bottom: 1px solid var(--line); z-index: 1; }
.ftable td { padding: 7px 10px; border-bottom: 1px solid #e8f0ef; vertical-align: top; }
.ftable tbody tr:last-child td { border-bottom: 0; }
#listBody tr { cursor: pointer; }
#listBody tr:hover { background: var(--hover); }
#listBody tr.active { background: #d8f0ee; box-shadow: inset 3px 0 0 var(--brand); }
.t-id { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-name { font-weight: 600; }
.t-addr { color: var(--muted); font-size: .8rem; }
.badge { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: .74rem; font-weight: 700; line-height: 1.75; white-space: nowrap; color: #fff; }
.b-none { background: var(--st-none); } .b-has { background: var(--st-has); }
.b-unsure { background: var(--st-unsure); } .b-notfound { background: var(--st-notfound); }
.b-todo { background: #e6eeed; color: var(--muted); }
.b-land { background: #fff1d6; color: #8a5a00; }
/* 特登申辦情形 */
.td-s { background: #dff3f1; color: #13615c; font-family: ui-monospace, Consolas, monospace; }
.td-r { background: #e6edf8; color: #24497f; font-family: ui-monospace, Consolas, monospace; }
.td-a { background: #fff1d6; color: #8a5a00; }
.td-x { background: #f3e4e4; color: #8c2f2f; }
.tedeng-line { margin: 4px 0 0; font-size: .86rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }

.pager { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; font-size: .86rem; }

.empty { text-align: center; padding: 24px 16px; color: var(--ink-soft); border: 2px dashed var(--line); border-radius: 10px; margin-top: 8px; }
.empty-title { font-weight: 700; color: var(--ink); }
.empty .btn { margin-top: 6px; }

/* ===== 匯出 ===== */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.export-box { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.export-box h3 { margin-bottom: 10px; }
.export-box .btn-danger { margin-top: 10px; }
.sub-title { margin: 18px 0 8px; }
.county-table td:not(:first-child), .county-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.settings-form { max-width: 720px; }

/* ===== 自動偵測 ===== */
.auto-key { font-size: .88rem; font-weight: 600; padding: 6px 10px; border-radius: 8px; display: inline-block; margin: 6px 0 12px; }
.auto-key.ok { background: var(--accent-soft); color: var(--accent); }
.auto-key.bad { background: var(--danger-soft); color: var(--danger); }
.auto-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.auto-test { margin-top: 10px; }
.auto-bar { margin: 12px 0 4px; }
#autoMax { max-width: 140px; }
.warn-text { color: var(--danger); font-weight: 600; }
@media (max-width: 800px) { .auto-steps { grid-template-columns: 1fr; } }
.help ol { padding-left: 20px; margin: 0 0 8px; }
.help li { margin-bottom: 6px; }
.site-footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 8px 0 40px; }

/* ===== 提示訊息 ===== */
.toast-area { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); font-size: .9rem; border-left: 5px solid var(--brand); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: #ef6b62; }
.toast.info { border-left-color: var(--brand-blue); }
.toast.leaving { opacity: 0; transition: opacity .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== 平板 ===== */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .wall-grid.size-9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .list-panel { position: static; }
  .list-panel .table-wrap { max-height: 480px; }
}

/* ===== 手機 ===== */
@media (max-width: 640px) {
  html { scroll-padding-top: 104px; }
  .brand-sub { display: none; }
  .brand { gap: 10px; }
  .brand-logo img { width: 120px; height: 24px; }
  .brand-text { padding-left: 10px; }
  .brand h1 { font-size: 1rem; }
  .header-inner { padding-top: 8px; padding-bottom: 6px; }
  .site-nav { width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .site-nav a { white-space: nowrap; padding: 5px 8px; font-size: .88rem; }
  .panel { padding: 12px; }
  .factory-head { flex-direction: column; }
  .factory-head h3 { font-size: 1.1rem; }
  .nav-btns { width: 100%; }
  .nav-btns .btn { flex: 1; }
  .map-frame { height: 52vh; min-height: 280px; }
  .judge { grid-template-columns: 1fr 1fr; }
  .wall-grid, .wall-grid.size-4, .wall-grid.size-9 { grid-template-columns: 1fr 1fr; gap: 6px; }
  .wcell-actions { grid-template-columns: 1fr 1fr; }
  .wcell-addr { display: none; }
  .hint-desk { display: none; }
  .hint-touch { display: block; }
  .wall-foot .wall-commit { width: 100%; margin-left: 0; }
  .judge-btn kbd { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .export-grid { grid-template-columns: 1fr; }
  .toast-area { left: 12px; right: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast, .map-frame.flash::after { animation: none; }
}

/* 台電饋線 */
.fd-ok { background: #dff3f1; color: #13615c; }
.fd-zero { background: #fde7e5; color: #a3261c; }
.fd-nodata, .fd-nocoord { background: #e9efee; color: #5f706d; }

/* 今日路線 */
.route-main { margin-top: 6px; }
.route-btn.on { color: var(--accent); font-weight: 700; }
.route-start, .route-fill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; font-size: .9rem; }
#routeN { width: 56px; min-height: 34px; padding: 4px 8px; text-align: center; }
.route-fill .field-error { width: 100%; }
.plan-list { list-style: none; margin: 0; padding: 0; counter-reset: plan; }
.route-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.route-item::before { counter-increment: plan; content: counter(plan); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: .9rem; }
.route-item .p-name { font-weight: 700; }
.route-item .p-sub { font-size: .84rem; color: var(--ink-soft); }
.route-item .p-actions { display: flex; gap: 6px; }
.route-actions { margin-top: 10px; }
.route-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.nav-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 99px; background: var(--brand-dark); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
@media (max-width: 640px) {
  .route-item { grid-template-columns: 30px 1fr; }
  .route-item .p-actions { grid-column: 1 / -1; }
}

/* 屋頂坪數 */
.rf-s { background: #e9efee; color: #4f625f; }
.rf-m { background: #fff1d6; color: #8a5a00; }
.rf-l { background: #ffe0cc; color: #a3400d; }
.rf-none, .rf-nocoord { background: #e9efee; color: #5f706d; }

/* 自動偵測：台灣不適用提示 */
.notice-box { background: #fff7e6; border: 1px solid #f1d9a8; border-left: 5px solid #c08a12; border-radius: 10px; padding: 10px 14px; margin: 8px 0 12px; color: #5e4300; font-size: .9rem; }
.notice-box strong { display: block; margin-bottom: 4px; color: #8a5a00; }
.notice-box p { margin: 0 0 4px; }
.notice-box p:last-child { margin-bottom: 0; }
#autoGate { display: block; margin: 0 0 8px; }

/* ===== 手機版／電腦版切換鈕 ===== */
.ui-toggle {
  order: 3; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 4px 12px;
  font: inherit; font-size: .86rem; font-weight: 700; color: var(--brand-dark); background: var(--accent-soft);
  border: 1px solid #cde9e6; border-radius: 99px; cursor: pointer; white-space: nowrap;
}
.ui-toggle:hover { background: #dff3f1; }
.ui-toggle .ic-desk { display: none; }
html.ui-mobile .ui-toggle .ic-desk { display: inline; }
html.ui-mobile .ui-toggle .ic-phone { display: none; }
html.ui-mobile .site-nav .nav-long, html.ui-mobile .site-nav .nav-auto { display: none; }
.site-nav { order: 2; }

/* ===== 手機版（html.ui-mobile；手機預設，也可在電腦上手動切換） ===== */
html.ui-mobile body { font-size: 16px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
html.ui-mobile .wrap { max-width: 560px; padding: 0 12px; }
html.ui-mobile .header-inner { flex-wrap: nowrap; padding-top: 8px; padding-bottom: 8px; }
html.ui-mobile .brand { gap: 8px; min-width: 0; }
html.ui-mobile .brand-logo img { width: 110px; height: 22px; }
html.ui-mobile .brand-text { padding-left: 8px; min-width: 0; }
html.ui-mobile .brand h1 { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.ui-mobile .brand-sub { display: none; }
html.ui-mobile .ui-toggle { margin-left: auto; padding: 4px 10px; }
/* 底部導覽列 */
html.ui-mobile .site-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 0;
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(24, 74, 70, .08);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
html.ui-mobile .site-nav::-webkit-scrollbar { display: none; }
html.ui-mobile .site-nav a {
  flex: 1 0 auto; min-width: 64px; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 3px;
  padding: 4px 8px; font-size: .86rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; border-radius: 10px;
}
html.ui-mobile .site-nav a:active, html.ui-mobile .site-nav a:hover { background: var(--hover); color: var(--brand-dark); }
html.ui-mobile { scroll-padding-top: 64px; }
/* 資料來源說明收合成兩行，點一下展開 */
html.ui-mobile .source-banner { font-size: .82rem; cursor: pointer; }
html.ui-mobile .source-banner .wrap { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
html.ui-mobile .source-banner.open .wrap { display: block; }
/* 版面一欄 */
html.ui-mobile .layout { grid-template-columns: 1fr; gap: 12px; }
html.ui-mobile .panel { padding: 12px; border-radius: 12px; }
html.ui-mobile .list-panel { position: static; }
html.ui-mobile .list-panel .table-wrap { max-height: 60vh; }
html.ui-mobile .field-row { grid-template-columns: 1fr; gap: 0; }
html.ui-mobile .export-grid, html.ui-mobile .auto-steps { grid-template-columns: 1fr; }
html.ui-mobile input[type="text"], html.ui-mobile input[type="search"], html.ui-mobile input[type="password"], html.ui-mobile select { font-size: 16px; min-height: 44px; }
html.ui-mobile .btn { min-height: 44px; }
html.ui-mobile .btn-sm { min-height: 36px; }
/* 快速牆：一次一欄、衛星圖放大、按鈕好按 */
html.ui-mobile .wall-grid, html.ui-mobile .wall-grid.size-4, html.ui-mobile .wall-grid.size-9 { grid-template-columns: 1fr; gap: 12px; }
html.ui-mobile .wmap, html.ui-mobile .wall-grid.size-9 .wmap { aspect-ratio: 1 / 1; }
html.ui-mobile .wcell-actions { grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px; }
html.ui-mobile .wbtn { min-height: 48px; font-size: .95rem; }
html.ui-mobile .wcell-head { font-size: .95rem; padding: 8px 10px; }
html.ui-mobile .wcell-addr { display: block; font-size: .82rem; padding: 0 10px 10px; }
html.ui-mobile .wall-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
html.ui-mobile .wall-foot #wallInfo { grid-column: 1 / -1; order: -1; text-align: center; }
html.ui-mobile .wall-foot .wall-commit { grid-column: 1 / -1; width: 100%; margin-left: 0; min-height: 52px; font-size: 1rem; }
html.ui-mobile .hint-desk, html.ui-mobile .judge-btn kbd { display: none; }
html.ui-mobile .hint-touch { display: block; }
/* 單筆檢視 */
html.ui-mobile .factory-head { flex-direction: column; }
html.ui-mobile .factory-head h3 { font-size: 1.1rem; }
html.ui-mobile .nav-btns { width: 100%; }
html.ui-mobile .nav-btns .btn { flex: 1; }
html.ui-mobile .map-frame { height: 56vh; min-height: 300px; }
html.ui-mobile .judge { grid-template-columns: 1fr 1fr; }
html.ui-mobile .judge-btn { min-height: 56px; }
/* 路線、提示訊息 */
html.ui-mobile .route-item { grid-template-columns: 30px 1fr; }
html.ui-mobile .route-item .p-actions { grid-column: 1 / -1; }
html.ui-mobile .route-links .btn { flex: 1 1 100%; }
html.ui-mobile .toast-area { left: 12px; right: 12px; max-width: none; bottom: calc(76px + env(safe-area-inset-bottom)); }
html.ui-mobile .site-footer { padding-bottom: 16px; }
/* 從主畫面開啟（全螢幕 App 模式） */
@media (display-mode: standalone) {
  .site-header { padding-top: env(safe-area-inset-top); }
}

[hidden] { display: none !important; }
