* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif; font-size: 14px; color: #222; background: #f4f5f7; }

#header { display: flex; align-items: center; gap: 18px; height: 48px; padding: 0 14px; background: #1f4e79; color: #fff; }
#header h1 { font-size: 17px; margin: 0; white-space: nowrap; }
#header h1 small { font-size: 12px; font-weight: normal; opacity: .85; margin-left: 6px; }
.hgroup { display: flex; align-items: center; gap: 6px; }
.hlabel { font-size: 12px; opacity: .85; }
.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; overflow: hidden; }
.seg button { background: transparent; color: #fff; border: 0; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.seg button + button { border-left: 1px solid rgba(255,255,255,.4); }
.seg button.active { background: #fff; color: #1f4e79; font-weight: bold; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.linkbtn { margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; }

#main { display: flex; height: calc(100% - 48px); }
#map { flex: 1; min-width: 0; }
#panel { width: 380px; overflow-y: auto; background: #fff; border-left: 1px solid #ddd; padding: 10px; }
.box { border: 1px solid #e3e6ea; border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.box h2 { font-size: 13px; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid #1f4e79; color: #1f4e79; }
.row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.row label { width: 64px; color: #555; }
.row select, .row input[type=text] { flex: 1; padding: 4px 6px; border: 1px solid #bbb; border-radius: 4px; font-size: 13px; }
.row button, #infoClose { padding: 5px 12px; border: 0; border-radius: 4px; background: #1f4e79; color: #fff; cursor: pointer; }
.chk { display: block; margin: 3px 0; cursor: pointer; }
.chk.koji { color: #1a56c4; }
.chk.chosa { color: #1b8a3c; }
.muted { color: #777; font-size: 12px; }
.hidden { display: none !important; }

.list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.list li { padding: 5px 6px; border-bottom: 1px solid #eee; cursor: pointer; line-height: 1.35; }
.list li:hover, .list li.active { background: #eaf2fb; }
.list .lot { font-weight: bold; }
.list .lot.koji { color: #1a56c4; }
.list .lot.chosa { color: #1b8a3c; }
.list .price { float: right; font-weight: bold; }
.list .addr { display: block; font-size: 11px; color: #666; }

/* マーカー: □=地価公示地点 / △=地価調査地点（本家の凡例に合わせる）＋ラベル（番号 or 価格） */
.pmark { position: relative; cursor: pointer; }
.pmark .sym { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; box-sizing: border-box; }
.pmark.koji .sym { background: #fff; border: 2.5px solid #111; }
.pmark.chosa .sym { width: 0; height: 0; left: -9px; top: -9px; border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 16px solid #e0402a; }
.pmark.chosa .sym::after { content: ""; position: absolute; left: -5px; top: 4px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid #fff; }
.pmark .lbl { position: absolute; left: 11px; top: -9px; white-space: nowrap; padding: 0 4px; font-size: 12px; font-weight: bold; color: #111; background: rgba(255,255,255,.85); border-radius: 2px; text-shadow: 0 0 2px #fff; }
.pmark.chosa .lbl { color: #b3261e; }
.pmark.active .sym { box-shadow: 0 0 0 3px rgba(224,64,42,.6); }
.pmark.active .lbl { background: #e0402a; color: #fff; z-index: 10; }

.legend { display: flex; gap: 14px; font-size: 12px; margin: 6px 0 2px; color: #444; }
.legend .sq { display: inline-block; width: 12px; height: 12px; border: 2px solid #111; background: #fff; vertical-align: -2px; margin-right: 4px; }
.legend .tri { display: inline-block; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 12px solid #e0402a; vertical-align: -1px; margin-right: 4px; }
.seg.small { border-color: #bbb; }
.seg.small button { color: #1f4e79; background: #fff; padding: 2px 8px; }
.seg.small button.active { background: #1f4e79; color: #fff; }

.notice { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); z-index: 900; background: rgba(31,78,121,.92); color: #fff; padding: 6px 14px; border-radius: 4px; font-size: 13px; pointer-events: none; }

/* 詳細 */
#detail table { width: 100%; border-collapse: collapse; }
#detail th { text-align: left; width: 88px; color: #555; font-weight: normal; padding: 3px 4px; border-bottom: 1px solid #eee; vertical-align: top; }
#detail td { padding: 3px 4px; border-bottom: 1px solid #eee; }
#detail .big { font-size: 20px; font-weight: bold; color: #c0392b; }
#detail .kindtag { display: inline-block; padding: 1px 6px; border-radius: 3px; color: #fff; font-size: 11px; margin-right: 6px; }
#detail .kindtag.koji { background: #1a56c4; }
#detail .kindtag.chosa { background: #1b8a3c; }
#histTable { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
#histTable th, #histTable td { padding: 2px 4px; border-bottom: 1px solid #eee; text-align: right; }
#histTable th:first-child, #histTable td:first-child { text-align: left; }
.up { color: #c0392b; } .down { color: #1a56c4; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-body { background: #fff; max-width: 720px; max-height: 85vh; overflow-y: auto; padding: 20px 24px; border-radius: 8px; line-height: 1.6; }
.modal-body h2 { margin-top: 0; color: #1f4e79; font-size: 17px; }
.modal-body h3 { font-size: 14px; margin: 14px 0 4px; }
.modal-body code { background: #f1f3f5; padding: 1px 4px; border-radius: 3px; font-size: 12px; word-break: break-all; }

@media (max-width: 800px) {
  #main { flex-direction: column; }
  #panel { width: 100%; height: 45%; border-left: 0; border-top: 1px solid #ddd; }
  #header { flex-wrap: wrap; height: auto; padding: 6px 10px; gap: 8px; }
  #main { height: auto; min-height: calc(100% - 90px); }
  #map { height: 55vh; }
}

/* ===== 9/28 打ち合わせ対応 ===== */
.linkbtn { text-decoration: none; }
.linkbtn.contact { margin-left: 0; background: #fff; color: #1f4e79; font-weight: bold; }

/* ズームレベル表示（③） */
.zoominfo { background: rgba(255,255,255,.92); padding: 3px 8px; border-radius: 4px; font-size: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.zoominfo b { font-size: 14px; color: #1f4e79; }
.zoominfo span { color: #b3261e; margin-left: 4px; }

/* 吹き出し（⑤ 常時表示）＋ホバーで伸びる引き出し（④） */
.balloon { position: absolute; left: -14px; bottom: 16px; min-width: 96px; background: #fff; border: 1.5px solid #333; border-radius: 5px; padding: 2px 7px 3px; font-size: 11px; line-height: 1.4; color: #222; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,.25); text-align: center; }
.balloon::after { content: ""; position: absolute; left: 8px; bottom: -8px; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid #333; }
/* 常時表示は「価格 円/㎡」「（年）」の2行だけ */
.balloon .pv { font-size: 11px; }
.balloon .pv b { font-size: 12.5px; color: #c0392b; }
.balloon .py { font-size: 10.5px; color: #555; }
.balloon .bt { font-weight: bold; font-size: 12px; border-bottom: 1px solid #ddd; margin-bottom: 2px; text-align: left; }
.balloon .bl { text-align: left; }
.balloon .bl .k { display: inline-block; min-width: 48px; color: #777; margin-right: 4px; }
.balloon .bl b { color: #c0392b; }
.balloon .more { display: none; border-top: 1px dashed #bbb; margin-top: 3px; padding-top: 3px; white-space: normal; min-width: 260px; max-width: 300px; }
.balloon .hint { color: #1f4e79; font-size: 10px; margin-top: 2px; text-align: left; }
/* ホバー時の価格推移ミニグラフ */
.balloon .mini { margin-top: 4px; border-top: 1px solid #eee; padding-top: 3px; text-align: left; }
.balloon .mini .k { color: #777; font-size: 10px; }
.balloon .minibody { min-height: 20px; font-size: 10px; }
.balloon .minichart { display: block; }
.balloon .minisum { font-size: 10px; color: #555; }
.pmark.hover .balloon { text-align: left; }
.pmark.hover .balloon .pv, .pmark.hover .balloon .py { display: none; }
.pmark.hover .balloon .more { border-top: 0; margin-top: 0; padding-top: 0; }
.pmark.chosa .balloon { border-color: #e0402a; }
.pmark.chosa .balloon::after { border-top-color: #e0402a; }
.pmark.chosa .balloon .bt { color: #b3261e; }
/* 吹き出しモード: 番号ラベルは吹き出しに含むので隠す / 番号・価格モード: 吹き出しはホバー時だけ */
.pmark.mode-balloon .lbl, .cmark.mode-balloon .lbl { display: none; }
.pmark:not(.mode-balloon) .balloon, .cmark:not(.mode-balloon) .balloon { display: none; }
.pmark.hover .balloon, .cmark.hover .balloon { display: block; }
.pmark.hover .balloon .more, .cmark.hover .balloon .more { display: block; }
.pmark.hover .balloon, .cmark.hover .balloon { box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.pmark.active .balloon { border-width: 2.5px; }

/* CSV取り込み地点 ★ */
.cmark { position: relative; cursor: pointer; }
.cmark .sym { position: absolute; left: -10px; top: -13px; font-size: 20px; line-height: 1; color: var(--c); text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #000; }
.cmark .lbl { position: absolute; left: 12px; top: -10px; white-space: nowrap; padding: 0 4px; font-size: 12px; font-weight: bold; color: var(--c); background: rgba(255,255,255,.9); border-radius: 2px; }
.cmark .balloon { border-color: var(--c); }
.cmark .balloon::after { border-top-color: var(--c); }
.cmark .balloon .bt { color: var(--c); }
/* 取り込み地点の吹き出し: 常時は値だけ（項目名なし）、ホバー時は項目名ありの情報に切り替える */
.cmark .balloon .bv { text-align: center; }
.cmark.hover .balloon { text-align: left; }
.cmark.hover .balloon .sv { display: none; }
.cmark.hover .balloon .more { border-top: 0; margin-top: 0; padding-top: 0; }
.cmark.active .sym { font-size: 26px; left: -13px; top: -17px; }
.legend .star, .csvlayer .star { color: #e67e00; font-size: 14px; margin-right: 3px; }

/* レイヤー一覧の CSV 行 */
.csvlayer { display: flex; align-items: center; gap: 4px; }
.csvlayer .chk { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csvlayer .acts button { font-size: 11px; padding: 1px 6px; border: 1px solid #bbb; background: #fff; border-radius: 3px; cursor: pointer; color: #1f4e79; }

/* CSV 取り込み設定モーダル */
.modal-body.wide { max-width: 1100px; width: 94vw; max-height: 94vh; padding: 14px 24px 16px; }
.modal-body.wide h2 { margin-bottom: 4px; }
.csvgrid { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 6px 12px; margin: 2px 0 4px; max-width: 760px; }
.csvtools .inl { font-size: 12px; color: #555; white-space: nowrap; }
.csvtools .inl select { padding: 3px 4px; border: 1px solid #bbb; border-radius: 4px; font-size: 13px; max-width: 180px; }
.btns .step { margin: 0 auto 0 0 !important; align-self: center; }
#csvCheck { margin: 2px 0; }
.modal-body .step { margin: 6px 0 2px; font-size: 13px; font-weight: bold; color: #1f4e79; }
.csvgrid label { display: flex; flex-direction: column; font-size: 12px; color: #555; gap: 2px; }
.csvgrid input, .csvgrid select, .csvtools input { padding: 4px 6px; border: 1px solid #bbb; border-radius: 4px; font-size: 13px; }
.csvtools { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.csvtools input { flex: 1; }
.colwrap { max-height: 45vh; overflow: auto; border: 1px solid #ddd; border-radius: 4px; }
/* CSV を「列が横に並ぶ表」で見せる。指定した列は青系でハイライト（緯度・経度 > タイトル > 簡易 > 詳細） */
.csvtbl { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
.csvtbl th, .csvtbl td { border-right: 1px solid #e3e6ea; border-bottom: 1px solid #e3e6ea; padding: 3px 6px; white-space: nowrap; background: #fff; }
.csvtbl thead th, .csvtbl thead td { position: sticky; background: #f7f9fb; z-index: 2; }
.csvtbl thead tr.hdr th { top: 0; vertical-align: top; }
/* 見出し行の top は app.js（stickHeadRows）で実測して設定する */
.csvtbl .rowlbl { position: sticky; left: 0; z-index: 3; text-align: left; font-weight: bold; color: #1f4e79; background: #eef3f8; min-width: 330px; max-width: 330px; white-space: normal; }
.csvtbl thead .rowlbl { z-index: 4; }
.csvtbl .rowlbl small { display: block; font-weight: normal; color: #777; font-size: 10px; line-height: 1.3; }
.csvtbl .rowlbl.num { font-weight: normal; color: #555; }
.csvtbl .cn { font-weight: bold; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.csvtbl .pills { min-height: 16px; }
.csvtbl .v { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: #333; }
.csvtbl td.c { text-align: center; }
.csvtbl td.c label { display: block; cursor: pointer; }
.csvtbl select { font-size: 11px; padding: 1px 2px; border: 1px solid #bbb; border-radius: 3px; background: #fff; max-width: 92px; }
.csvtbl td.more { text-align: left; }
.pill { display: inline-block; font-size: 10px; line-height: 1.3; padding: 0 5px; margin: 1px 2px 0 0; border-radius: 8px; background: #1f4e79; color: #fff; font-weight: normal; vertical-align: middle; }
/* ハイライト色（濃い順に上書き） */
.csvtbl .c-detail, #detail tr.c-detail th, .csvlegend .sw.c-detail { background: #eef4fb !important; }
.csvtbl .c-hover, #detail tr.c-hover th, .csvlegend .sw.c-hover { background: #e4eef9 !important; }
.csvtbl .c-simple, #detail tr.c-simple th, .csvlegend .sw.c-simple { background: #d7e5f6 !important; }
.csvtbl .c-title, #detail tr.c-title th, .csvlegend .sw.c-title { background: #c5d9f1 !important; }
.csvtbl .c-lat, .csvtbl .c-lng, #detail tr.c-lat th, #detail tr.c-lng th, .csvlegend .sw.c-lat { background: #a9c7ea !important; }
.csvtbl thead th.c-lat, .csvtbl thead th.c-lng, .csvtbl thead th.c-title { color: #0f2f52; }
.csvlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 2px; font-size: 11px; color: #555; }
.csvlegend .sw { display: inline-block; width: 14px; height: 12px; border: 1px solid #ccd; vertical-align: -2px; margin-right: 4px; background: #fff; }
#detail .dhead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#detail .dhead b { flex: 1; }
.mini-btn { font-size: 11px; padding: 2px 8px; border: 1px solid #1f4e79; background: #fff; color: #1f4e79; border-radius: 3px; cursor: pointer; }
#detail th .pill { margin-left: 4px; }
.btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btns button, .csvtools button { padding: 5px 14px; border: 0; border-radius: 4px; background: #1f4e79; color: #fff; cursor: pointer; }
.btns button.sub, .csvtools button.sub { background: #e3e6ea; color: #333; }
.btns button:disabled { opacity: .45; cursor: not-allowed; }
