/* Visual language from design/dashboard.html (Claude Design export): white ground, #1E5199 glow. */
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-mono-400-latin.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-mono-500-latin.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap; src: url("/fonts/ibm-plex-mono-600-latin.woff2") format("woff2"); }

:root {
  --ink: #10151c; --ink-2: #3c4654; --ink-3: #6b7684; --ink-4: #97a1ad;
  --line: #e4e8ee; --line-2: #eef1f5; --bg: #ffffff; --bg-2: #f7f9fb; --bg-3: #f1f4f8;
  --brand: #1e5199; --brand-deep: #143a70; --brand-soft: #eff4fb; --brand-hover: #17407a;
  --blue: #3d6da6;
  --sans: "IBM Plex Sans TC", "IBM Plex Sans", "PingFang HK", "Microsoft JhengHei", "Helvetica Neue", Helvetica, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; font-size: 13px; }
button { font-family: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- LOGIN ---------- */
.login { position: fixed; inset: 0; background: #fff; display: grid; place-items: center; overflow: hidden; padding: 16px; }
.login .glow { position: absolute; border-radius: 50%; pointer-events: none; }
.login .g1 { width: 760px; height: 760px; left: -200px; bottom: -320px; background: radial-gradient(circle, rgba(30,81,153,.18), rgba(30,81,153,0) 65%); }
.login .g2 { width: 620px; height: 620px; right: -160px; top: -240px; background: radial-gradient(circle, rgba(30,81,153,.12), rgba(30,81,153,0) 65%); }
.login .grid { position: absolute; inset: 0; background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px); background-size: 56px 56px; -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 30%, transparent 78%); mask-image: radial-gradient(ellipse at 50% 45%, #000 30%, transparent 78%); }
.card { position: relative; width: 392px; max-width: 100%; padding: 40px 40px 32px; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 1px 2px rgba(16,21,28,.04), 0 24px 60px -24px rgba(16,21,28,.18); }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--brand), rgba(30,81,153,.15)); }
.card img.logo { height: 34px; display: block; }
.card h1 { font-size: 17px; font-weight: 600; letter-spacing: .01em; margin: 26px 0 4px; }
.card p.sub { margin: 0 0 26px; color: var(--ink-3); font-size: 12px; letter-spacing: .04em; }
label.f { display: block; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 7px; font-weight: 500; }
input.f { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--bg-2); font-family: var(--sans); font-size: 13px; color: var(--ink); outline: none; transition: .15s; }
input.f:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(30,81,153,.12); }
.field { margin-bottom: 18px; }
button.primary { width: 100%; height: 44px; border: 0; border-radius: 3px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; letter-spacing: .06em; cursor: pointer; box-shadow: 0 6px 22px -8px rgba(30,81,153,.55); transition: .15s; }
button.primary:hover { background: var(--brand-hover); box-shadow: 0 8px 28px -8px rgba(30,81,153,.7); }
button.primary:disabled { opacity: .6; cursor: progress; }
.form-error { min-height: 18px; margin: -6px 0 12px; font-size: 12px; color: #b3261e; }
.card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-2); color: var(--ink-4); font-size: 11px; letter-spacing: .04em; }

/* ---------- SHELL ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
header.top { height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 22px; padding: 0 20px; border-bottom: 1px solid var(--line); background: #fff; position: relative; z-index: 500; }
header.top img.logo { height: 26px; }
.divider { width: 1px; height: 26px; background: var(--line); }
.apptitle { font-size: 13.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.apptitle span { display: block; font-size: 10.5px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); margin-top: 2px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 2px; background: var(--bg-2); font-size: 11px; color: var(--ink-2); letter-spacing: .04em; white-space: nowrap; }
.pill.sync { color: var(--brand-deep); background: var(--brand-soft); border-color: rgba(30,81,153,.25); }
.pill.warn { color: #8a4b00; background: #fff6e8; border-color: #f3d9ae; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px rgba(30,81,153,.2); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
button.ghost { height: 28px; padding: 0 10px; white-space: nowrap; flex: none; border: 1px solid var(--line); border-radius: 2px; background: #fff; color: var(--ink-3); font-size: 11px; letter-spacing: .04em; cursor: pointer; }
button.ghost:hover { color: var(--brand); border-color: rgba(30,81,153,.35); }
main { flex: 1; display: grid; grid-template-columns: 266px minmax(0, 1fr) 322px; min-height: 0; }

/* ---------- PANELS ---------- */
aside { background: #fff; overflow-y: auto; min-height: 0; }
aside.left { border-right: 1px solid var(--line); }
aside.right { border-left: 1px solid var(--line); background: var(--bg-2); }
.sec { padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.sec.white { background: #fff; border-bottom: 1px solid var(--line); }
.sec h3 { margin: 0 0 12px; font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec h3 em { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--ink-4); letter-spacing: .02em; text-transform: none; }
.sec .note { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: var(--ink-4); }
.seg { display: grid; gap: 4px; }
.seg-item { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 10px; border: 1px solid rgba(30,81,153,.32); border-radius: 3px; background: var(--brand-soft); color: var(--brand-deep); font-size: 12.5px; font-weight: 500; }
.seg-item .k { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px rgba(30,81,153,.18); }
.seg-item .n { margin-left: auto; font-size: 11px; color: var(--brand-deep); opacity: .7; }
.chk { display: flex; align-items: center; gap: 9px; padding: 5px 2px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); position: relative; }
.chk:hover { color: var(--ink); }
.box { width: 13px; height: 13px; flex: 0 0 13px; border: 1px solid #c6cdd7; border-radius: 2px; background: #fff; position: relative; transition: .12s; }
.chk input { position: absolute; opacity: 0; pointer-events: none; }
.chk input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(30,81,153,.25); }
.chk input:checked + .box { background: var(--brand); border-color: var(--brand); }
.chk input:checked + .box::after { content: ""; position: absolute; left: 3.5px; top: 1px; width: 4px; height: 7px; border: solid #fff; border-width: 0 1.6px 1.6px 0; transform: rotate(42deg); }
.chk .lab { flex: 1; min-width: 0; }
.chk .lab small { color: var(--ink-4); font-size: 10.5px; }
.chk .n { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.chk.hot .n { color: var(--brand-deep); }
.districts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.minilink { font-size: 10.5px; letter-spacing: .06em; color: var(--blue); cursor: pointer; text-transform: uppercase; background: none; border: 0; padding: 0; }
.minilink:hover { color: var(--brand); }

.ramp { height: 8px; border-radius: 2px; background: linear-gradient(90deg, #7ea6da, #4f80c6, #2f66b3, #1e5199, #0b2a57); box-shadow: 0 0 18px -4px rgba(30,81,153,.5); }
.ramp-l { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 10px; color: var(--ink-4); }

/* ---------- MAP ---------- */
.mapwrap { position: relative; min-width: 0; background: var(--bg-3); }
#map { position: absolute; inset: 0; background: #f4f6f8; }
#map .leaflet-tile-pane { filter: saturate(.18) brightness(1.1) contrast(.92); }
#map .heat-coverage { opacity: .68; }
.maptop { position: absolute; left: 58px; top: 14px; right: 14px; flex-wrap: wrap; z-index: 450; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.maptop .chip { height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 2px; backdrop-filter: blur(6px); font-size: 11.5px; color: var(--ink-2); letter-spacing: .04em; box-shadow: 0 1px 3px rgba(16,21,28,.06); }
.maptop .chip b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.maptop .chip.progress { color: var(--brand-deep); border-color: rgba(30,81,153,.3); }
.maplegend { position: absolute; right: 14px; bottom: 26px; z-index: 450; width: 188px; padding: 12px 13px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 2px; box-shadow: 0 6px 24px -10px rgba(16,21,28,.3); }
.maplegend h4 { margin: 0 0 9px; font-size: 10px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); }
.maplegend .mk { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 10.5px; color: var(--ink-3); }
.maplegend .mk { align-items: flex-start; line-height: 1.45; }
.maplegend .mk i { flex: none; width: 10px; height: 10px; margin-top: 2px; border-radius: 50%; background: #4f84cb; opacity: .7; box-shadow: 0 0 6px #4f84cb; }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(255,255,255,.8) !important; }
.leaflet-bar a { border-radius: 0 !important; color: var(--ink-2) !important; }
.hint { position: absolute; left: 14px; bottom: 26px; z-index: 450; max-width: calc(100% - 226px); font-size: 10.5px; color: var(--ink-4); letter-spacing: .05em; background: rgba(255,255,255,.85); padding: 4px 8px; border: 1px solid var(--line-2); }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; z-index: 440; pointer-events: none; }
.map-empty div { background: rgba(255,255,255,.95); border: 1px solid var(--line); padding: 10px 14px; font-size: 12px; color: var(--ink-3); box-shadow: 0 6px 24px -10px rgba(16,21,28,.3); }

/* ---------- STATS ---------- */
.kpi { padding: 17px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.kpi .lbl { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; }
.kpi .lbl > span { letter-spacing: .04em; text-transform: none; color: var(--ink-4); font-size: 10.5px; }
.kpi .val { font-family: var(--mono); font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 7px; }
.kpi .val.hot { color: var(--brand-deep); text-shadow: 0 0 26px rgba(30,81,153,.35); }
.kpi .meta { margin-top: 6px; font-size: 11px; color: var(--ink-3); }
.kpi .meta b { color: var(--brand-deep); font-family: var(--mono); }
.kpirow { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.kpirow .kpi { border-bottom: 0; border-right: 1px solid var(--line); }
.kpirow .kpi:last-child { border-right: 0; }
.kpirow .val { font-size: 22px; }
.rank { display: grid; gap: 9px; }
.rowk { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 9px; font-size: 12.5px; }
.rowk .i { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.rowk .nm { color: var(--ink-2); }
.rowk .nm small { color: var(--ink-4); font-size: 10.5px; margin-left: 4px; }
.rowk .v { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.bar { grid-column: 2 / 4; height: 4px; background: var(--line-2); border-radius: 2px; overflow: hidden; margin-top: -4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #7ea6d8, var(--brand)); box-shadow: 0 0 10px rgba(30,81,153,.45); }
.empty { color: var(--ink-4); font-size: 12px; }
.nights { display: flex; align-items: flex-end; gap: 6px; height: 86px; }
.nights .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.nights .col .v { font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); }
.nights .col i { display: block; width: 100%; border-radius: 1px 1px 0 0; background: linear-gradient(180deg, var(--brand), #5e8fca); box-shadow: 0 0 8px rgba(30,81,153,.4); }
.nights-l { display: flex; gap: 6px; margin-top: 6px; font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); }
.nights-l span { flex: 1; text-align: center; }
.standards dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 11.5px; line-height: 1.55; }
.standards dt { color: var(--brand-deep); font-weight: 600; white-space: nowrap; }
.standards dd { margin: 0; color: var(--ink-2); }


/* ---------- RESPONSIVE ---------- */
@media (max-width: 1180px) {
  main { grid-template-columns: 240px minmax(0, 1fr); }
  aside.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  #app { height: auto; min-height: 100%; }
  main { grid-template-rows: minmax(560px, calc(100vh - 58px)) auto; }
}
@media (max-width: 760px) {
  header.top { gap: 12px; padding: 0 12px; }
  header.top .divider, .pill.hide-sm, .apptitle span { display: none; }
  .apptitle { font-size: 12.5px; white-space: normal; }
  main { grid-template-columns: 1fr; grid-template-rows: auto 62vh auto; }
  aside.left { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; }
  .maptop { left: 52px; }
  .hint { display: none; }
  .maplegend { width: 150px; }
}

/* ---------- 場地風險（右欄）+ 整體數字（左欄） ---------- */
.risk-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rcard { display: flex; flex-direction: column; gap: 8px; padding: 11px 12px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 3px; background: var(--bg-2); }
.rcard .num { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.rcard.critical { border-left-color: #d32f2f; }
.rcard.critical .num { color: #b3261e; }
.rcard.alert { border-left-color: #e08a1e; }
.rcard.alert .num { color: #9a5000; }
.rcard.watch { border-left-color: #dcc02c; }
.rcard.watch .num { color: #8a6d00; }
.rcard.normal { border-left-color: #56a65b; }
.rcard.normal .num { color: #2e7d32; }
.figures { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 9px 12px; align-items: baseline; }
.figures dt { font-size: 12.5px; color: var(--ink-2); }
.figures dd { margin: 0; font-family: var(--mono); font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); text-align: right; }

/* risk levels keep their own semantic colours; every other accent stays LBS blue */

@media (max-width: 760px) {
  .avatar { display: none; }
  .risk-summary { grid-template-columns: 1fr 1fr; }
}
