:root {
  --bg: #14181c; --panel: #1d2329; --panel2: #242c34; --line: #2f3a44; --text: #e8edf1; --muted: #9aa8b4;
  --accent: #f5c84c; --accent-ink: #2b2118; --good: #6fcf97; --warn: #f2a65a; --bad: #e5675c; --info: #7fb7e6;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.35; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: #4a5867; }
button.on, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.primary { width: 100%; padding: 10px; font-size: 15px; margin-top: 10px; }
button.small { padding: 4px 8px; font-size: 12px; }
button.icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-weight: 700; }
button:disabled { opacity: .45; cursor: default; }
select { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
b { font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

#app { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; }
#top { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; margin-right: 8px; }
.brand strong { font-size: 17px; letter-spacing: .3px; }
.brand span { font-size: 11px; color: var(--muted); }
.chip { display: flex; flex-direction: column; padding: 4px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; min-width: 80px; }
.chip b { font-size: 14px; }
.chip span { font-size: 11px; color: var(--muted); }
.chip.wx { flex-direction: row; gap: 12px; align-items: center; }
.chip.wx span { font-size: 13px; color: var(--text); }
#windArrow { display: inline-block; font-style: normal; color: var(--info); transition: transform .3s; }
.chip.danger b { color: var(--good); }
.chip.danger.d1 b { color: #c9e26f; } .chip.danger.d2 b { color: var(--warn); } .chip.danger.d3 b { color: #f08a4b; } .chip.danger.d4 b { color: var(--bad); }
.chip.danger.redflag { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.chip.speed { flex-direction: row; gap: 4px; padding: 3px; }
.chip.speed button { padding: 4px 8px; font-size: 12px; }
#btnHelp { margin-left: auto; }

main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
#mapwrap { position: relative; min-width: 0; min-height: 0; background: #0d1114; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#map { display: block; max-width: 100%; max-height: 100%; image-rendering: pixelated; cursor: crosshair; }
#overlayBar { position: absolute; left: 10px; top: 10px; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; }
#overlayBar label { pointer-events: auto; background: rgba(20, 24, 28, .8); padding: 4px 8px; border-radius: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
#legend { display: flex; flex-wrap: wrap; gap: 4px 10px; background: rgba(20, 24, 28, .8); padding: 6px 10px; border-radius: 8px; font-size: 11px; max-width: 520px; }
#legend span { display: inline-flex; align-items: center; gap: 5px; }
#legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
#forecast { position: absolute; right: 10px; bottom: 10px; background: rgba(20, 24, 28, .85); padding: 6px 10px; border-radius: 8px; font-size: 11px; color: var(--muted); display: flex; gap: 12px; pointer-events: none; }
#forecast b { color: var(--text); display: block; font-size: 12px; }
#forecast .ev { color: var(--bad); font-weight: 700; }
#tooltip { position: absolute; pointer-events: none; background: rgba(14, 18, 22, .94); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 280px; z-index: 5; }
#tooltip b { display: block; margin-bottom: 3px; }
#tooltip .muted { color: var(--muted); }

#side { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
#tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1 1 auto; border: 0; border-radius: 0; background: transparent; padding: 9px 6px; font-size: 12px; color: var(--muted); position: relative; }
#tabs button.on { color: var(--text); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
#tabs b { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 10px; margin-left: 4px; }
.tab { display: none; padding: 12px; overflow: auto; }
.tab.on { display: block; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.row.stat { justify-content: space-between; }
.row.stat span { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 10px; font-size: 12px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.tool { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 6px 8px; }
.tool b { font-size: 12px; }
.tool span { font-size: 10px; color: var(--muted); }
.tool.on span { color: var(--accent-ink); }
.box { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.box > b { display: block; margin-bottom: 6px; }
.units { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; font-size: 12px; }
.units div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.units div b { color: var(--text); }
.cluster { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.cluster .bar { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.fire { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 12px; }
.fire.active { border-color: var(--warn); }
.fire.rx { border-color: var(--info); }
.fire h4 { margin: 0 0 4px; font-size: 13px; display: flex; justify-content: space-between; }
.fire .meta { color: var(--muted); }
.fire .bar { display: flex; gap: 4px; margin-top: 6px; }
.fire .meter { height: 6px; background: #0e1216; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.fire .meter i { display: block; height: 100%; background: var(--good); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12px; margin: 6px 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }
.note { background: var(--panel2); border-left: 3px solid var(--accent); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 12px; }
.note h4 { margin: 0 0 4px; font-size: 13px; }
.note .src { color: var(--muted); font-size: 11px; margin-top: 4px; }
.note .yr { float: right; color: var(--muted); font-size: 11px; }
canvas.chart { width: 100%; height: 120px; background: #0e1216; border-radius: 8px; margin: 6px 0; display: block; }

#log { height: 110px; overflow: auto; background: #0e1216; border-top: 1px solid var(--line); padding: 6px 12px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#log div { padding: 1px 0; color: var(--muted); }
#log div b { color: var(--text); font-weight: 400; }
#log .good b { color: var(--good); } #log .warn b { color: var(--warn); } #log .bad b { color: var(--bad); }

.modal { position: fixed; inset: 0; background: rgba(5, 8, 10, .7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.card h2 { margin: 0 0 8px; font-size: 20px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; color: var(--accent); }
.card p { margin: 6px 0; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.card .actions button { flex: 1 1 auto; padding: 9px 12px; }
.card .rec { border-color: var(--accent); }
.card .muted { color: var(--muted); }
.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.score { background: var(--panel2); border-radius: 10px; padding: 8px; text-align: center; }
.score b { display: block; font-size: 22px; }
.score span { font-size: 11px; color: var(--muted); }
.grade { font-size: 40px; font-weight: 800; color: var(--accent); }
.setup label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.setup input[type=number] { width: 90px; font: inherit; background: var(--panel2); color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }

#app.phase-season #btnStart, #app.phase-season .tools, #app.phase-season #rxBox, #app.phase-season [data-hire] { opacity: .4; pointer-events: none; }
#app.phase-plan #btnDozer { opacity: .4; pointer-events: none; }

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 300px; }
  #side { border-left: 0; border-top: 1px solid var(--line); }
  #legend { max-width: 60vw; }
}
