:root {
  --bg: #f6f7f9; --card: #fff; --ink: #14202b; --muted: #5d6b79; --line: #dfe4ea; --accent: #0b5cff; --accent-ink: #fff;
  --ok: #1a9e55; --warn: #e0a800; --mid: #ee7a1a; --bad: #d3263a; --shadow: 0 1px 3px rgba(20,32,43,.08), 0 6px 20px rgba(20,32,43,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #10161c; --card: #19222b; --ink: #e8eef4; --muted: #93a3b3; --line: #2b3844; --accent: #5b8cff; --accent-ink: #08101c; --shadow: 0 1px 3px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; }
#topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#topbar .home { font-weight: 700; color: var(--ink); text-decoration: none; }
#topbar nav { display: flex; gap: 4px; flex: 1; }
#topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
#topbar nav a.on { background: var(--accent); color: var(--accent-ink); }
.lang { display: flex; gap: 2px; }
.lang button { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 4px 8px; border-radius: 6px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
header.page { padding: 14px 16px 6px; }
header.page h1 { margin: 0 0 2px; font-size: 22px; }
.muted { color: var(--muted); margin: 0; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px 1fr; gap: 0; }
.side { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tools { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.tools input[type=search], .calc input:not([type=checkbox]), .calc select, .claim-form input:not([type=checkbox]):not([type=file]), .claim-form textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 5px 10px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stats { font-size: 13px; color: var(--muted); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.list { overflow: auto; flex: 1; }
.row { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.row:hover { background: var(--bg); }
.row .a { font-weight: 600; }
.row .b { color: var(--muted); font-size: 13px; }
.badge { align-self: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.comp { grid-column: 1 / -1; font-size: 13px; color: var(--ok); font-weight: 600; }
#map { min-height: 420px; }
.state { padding: 16px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.pop h3 { margin: 0 0 4px; font-size: 15px; }
.pop p { margin: 2px 0; font-size: 13px; }
.pop .okc { color: var(--ok); font-weight: 700; }
.pop .btn { margin-top: 8px; width: 100%; }
.pop small { color: #6b7886; display: block; margin-top: 6px; }
.panel { padding: 16px; overflow: auto; }
.calc { display: grid; gap: 10px; }
.calc label, .claim-form label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.calc .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calc .inline { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
.calc .inline input { flex: none; width: auto; margin: 3px 0 0; }
.result { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.result.yes { border-color: var(--ok); }
.result strong { display: block; font-size: 16px; }
.note { font-size: 12px; color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(8,16,24,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 2000; }
.modal[hidden] { display: none; }
.modal-box { position: relative; background: var(--card); color: var(--ink); width: min(640px, 100%); max-height: 92vh; overflow: auto; border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.modal-box h2 { margin: 0 0 4px; }
.modal-box .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; }
.claim-form { display: grid; gap: 10px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.claim-form small { font-weight: 400; color: var(--muted); }
.check { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: 3px; }
.hp { position: absolute; left: -9999px; height: 0; opacity: 0; }
.msg { margin: 0; min-height: 1.2em; font-size: 14px; }
.msg.ok { color: var(--ok); font-weight: 600; }
.msg.err { color: var(--bad); font-weight: 600; }
.plane { color: var(--accent); font-size: 18px; line-height: 1; text-shadow: 0 0 2px #fff; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 46vh auto; }
  .layout .side { order: 2; border-right: 0; border-top: 1px solid var(--line); max-height: 60vh; }
  #map { min-height: 46vh; }
  .grid2 { grid-template-columns: 1fr; }
}
.scope { padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); }
.scope[hidden] { display: none; }
.scope.good { border-color: var(--ok); color: var(--ok); }
.scope.warn { border-color: var(--warn); color: #a77d00; }
.scope.bad { border-color: var(--bad); color: var(--bad); }
.scope-info { margin: 0 0 10px; }

.hist { width: 100%; max-width: 980px; margin: 0 auto; padding: 6px 16px 40px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.chk { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.chk label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.chk input, .chk select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.chk [hidden] { display: none; }
.result { margin-top: 12px; display: grid; gap: 6px; }
.result[hidden] { display: none; }
.result.no { border-color: var(--bad); }
.result .btn { justify-self: start; margin-top: 4px; }
.hist-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.hist-tools input[type=date], .hist-tools input[type=search] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.hist-tools input[type=search] { flex: 1; min-width: 180px; }
.hist-tools label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.hist-list { border-top: 1px solid var(--line); }
.hist-list .row { padding: 10px 4px; }
.claim-form a.note { justify-self: start; }
