:root {
  font-family: Inter, "Noto Sans JP", "Yu Gothic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #10233f;
  background: #eef2f6;
  font-synthesis: none;
  --blue: #1467d8;
  --navy: #10233f;
  --border: #d8e0e9;
  --muted: #64748b;
  --green: #16a34a;
  --yellow: #f4c430;
  --panel: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { display: grid; grid-template-rows: 76px 40px 1fr 44px; min-width: 1120px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-header { display: grid; grid-template-columns: 330px minmax(420px, 1fr) auto; align-items: center; gap: 20px; padding: 12px 20px; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--border); z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #e7f0fd; color: var(--blue); font-size: 26px; font-weight: 800; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.search-wrap { position: relative; }
.search-wrap input { width: 100%; height: 46px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 0 16px; background: #f8fafc; color: var(--navy); outline: none; }
.search-wrap input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20,103,216,.12); }
.search-results { position: absolute; left: 0; right: 0; top: 52px; max-height: 360px; overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 36px rgba(15,23,42,.16); z-index: 50; }
.search-result { width: 100%; display: flex; align-items: baseline; gap: 14px; padding: 12px 14px; text-align: left; border: 0; border-bottom: 1px solid #edf1f5; background: #fff; color: var(--navy); }
.search-result:hover { background: #f4f8ff; }
.search-result strong { min-width: 110px; font-size: 15px; }
.search-result span, .search-empty { color: var(--muted); font-size: 13px; }
.search-empty { padding: 16px; }
.search-result-exception { cursor: default; background: #fbfcfe; }
.search-result-exception:hover { background: #fbfcfe; }
.search-result-exception span { font-style: italic; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.call-window-field { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; flex-shrink: 0; }
.call-window-field label { font-size: 12px; font-weight: 700; color: #29425f; white-space: nowrap; }
.call-window-field select { border: 0; background: transparent; color: var(--navy); font-weight: 700; outline: none; }
.call-window-field input[type="number"] { width: 48px; border: 0; background: transparent; color: var(--navy); font-weight: 700; outline: none; text-align: right; }
.call-window-field span { color: var(--muted); font-size: 12px; font-weight: 700; }
.mini-toggle-button { min-height: 26px; padding: 0 10px; border: 1px solid #cbd5e1; border-radius: 999px; background: #eef2f6; color: #64748b; font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.mini-toggle-button[aria-pressed="true"] { background: #dcfce7; border-color: #16a34a; color: #15803d; }

.settings-bar { display: flex; align-items: center; gap: 10px; padding: 0 20px; background: #f5f8fb; border-bottom: 1px solid var(--border); overflow-x: auto; }
.settings-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
/* Priority 3: can shrink and ellipsize, but never wraps character-by-character. */
.forecast-source-status { color: var(--muted); font-size: 12px; white-space: nowrap; flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.forecast-source-status.error { color: #b42318; font-weight: 700; }
/* Priority 4 (lowest): the first to shrink/ellipsize, never pushes buttons around. */
.forecast-format-hint { color: #94a3b8; font-size: 11px; white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.boundary-mode-field { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.boundary-mode-label { font-size: 12px; font-weight: 700; color: #29425f; white-space: nowrap; }
.boundary-mode-toggle { display: flex; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; overflow: hidden; flex-shrink: 0; }
.mode-button { min-height: 40px; border: 0; border-right: 1px solid #cbd5e1; background: #fff; color: #475569; font-weight: 700; font-size: 13px; padding: 0 14px; white-space: nowrap; }
.mode-button:last-child { border-right: 0; }
.mode-button:hover { background: #f8fafc; }
.mode-button.active { background: var(--blue); color: #fff; }
.primary-button, .secondary-button { min-height: 42px; border-radius: 9px; border: 1px solid transparent; padding: 0 16px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.primary-button { background: var(--blue); color: #fff; box-shadow: 0 3px 8px rgba(20,103,216,.18); }
.primary-button:hover:not(:disabled) { background: #0f58bc; }
.secondary-button { background: #fff; color: #29425f; border-color: #cbd5e1; }
.secondary-button:hover { background: #f8fafc; }
.compact { min-height: 42px; }
#forecast-merged-button { min-width: 200px; }

.app-main { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 0; }
.map-shell { position: relative; min-width: 0; background: #dfe6ec; border-right: 1px solid var(--border); }
.map { position: absolute; inset: 0; }
.map-legend { position: absolute; left: 18px; bottom: 18px; width: 245px; display: grid; gap: 9px; padding: 14px 16px; border: 1px solid rgba(203,213,225,.85); border-radius: 12px; background: rgba(255,255,255,.95); box-shadow: 0 8px 20px rgba(15,23,42,.12); z-index: 5; }
.map-legend strong { font-size: 13px; }
.map-legend span { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #334155; }
.map-legend small { color: var(--muted); line-height: 1.45; }
.legend-dot { width: 16px; height: 16px; border-radius: 4px; border: 1px solid #667085; }
.legend-dot.selected { background: rgba(22,163,74,.55); border-color: #15803d; }
.legend-dot.nearby { background: rgba(244,196,48,.5); border-color: #d4a60b; }
.legend-dot.called { background: rgba(37,99,235,.4); border-color: #1d4ed8; }
.legend-line { width: 16px; height: 0; border-top: 2px solid #0f172a; }
.legend-line.postal { border-top: 1px solid #64748b; }
.legend-line.municipality { border-top: 2.5px solid #334155; opacity: .8; }
.legend-line.prefecture { border-top: 3.5px solid #4b5563; opacity: .65; }
.privacy-chip { position: absolute; top: 16px; right: 16px; z-index: 5; background: rgba(15,35,63,.9); color: #fff; border-radius: 999px; padding: 8px 12px; font-size: 12px; box-shadow: 0 4px 12px rgba(15,23,42,.18); transition: opacity .5s ease; }
.privacy-chip.is-hidden { opacity: 0; pointer-events: none; }
.municipality-hover-tooltip { position: absolute; z-index: 6; pointer-events: none; background: rgba(15,23,42,.92); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 6px; box-shadow: 0 4px 10px rgba(15,23,42,.25); white-space: nowrap; }

.detail-panel { overflow: auto; background: var(--panel); padding: 20px 18px 24px; box-shadow: -2px 0 6px rgba(15,23,42,.05); }
.empty-state { margin: 80px auto 0; max-width: 300px; text-align: center; color: #334155; }
.empty-icon { margin: 0 auto 16px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: #edf4ff; color: var(--blue); font-size: 30px; }
.empty-state h2 { margin: 0 0 10px; font-size: 19px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.empty-state ol { display: inline-grid; gap: 7px; margin: 0; padding-left: 22px; text-align: left; color: #475569; font-size: 13px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid #e7edf3; }
.eyebrow { margin: 0 0 4px; color: var(--blue) !important; font-size: 11px !important; font-weight: 800; letter-spacing: .08em; }
.detail-header h2 { margin: 0; font-size: 30px; letter-spacing: .01em; }
.detail-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.region-breadcrumb { margin-top: 4px !important; font-size: 11px !important; color: #94a3b8 !important; letter-spacing: .01em; }
.region-badge { white-space: nowrap; border-radius: 999px; background: #eaf7ee; color: #167238; padding: 7px 10px; font-size: 12px; font-weight: 800; }
.call-panel { display: grid; gap: 10px; margin: 16px 0; }
.call-status { display: grid; gap: 6px; border-radius: 10px; padding: 12px 14px; border: 1px solid #dfe6ee; background: #fbfcfe; }
.call-status.called { border-left: 4px solid #1d4ed8; background: #eef3ff; }
.call-status.not-called { border-left: 4px solid #94a3b8; }
.call-status-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.call-status-line span { color: #475569; font-size: 12px; font-weight: 700; }
.call-status-line strong { font-size: 15px; color: var(--navy); }
.call-status-line small { color: #7c899a; font-size: 11px; }
.call-toggle { width: 100%; min-height: 44px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 16px 0 20px; }
.metric { display: grid; gap: 5px; border: 1px solid #dfe6ee; border-radius: 10px; padding: 13px 14px; background: #fbfcfe; }
.metric span { color: #475569; font-size: 12px; font-weight: 700; }
.metric strong { font-size: 21px; color: var(--navy); }
.metric small { color: #7c899a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-muted strong { color: #94a3b8; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 18px 0 8px; }
.section-title h3 { margin: 0; font-size: 16px; }
.section-title span { color: var(--muted); font-size: 11px; }
.nearby-list { border: 1px solid #dfe6ee; border-radius: 10px; overflow: hidden; }
.nearby-row { width: 100%; min-height: 58px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-bottom: 1px solid #e8edf2; background: #fff; text-align: left; color: var(--navy); }
.nearby-row:last-child { border-bottom: 0; }
.nearby-row:hover { background: #f8fbff; }
.nearby-rank { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: #f2f4f7; color: #64748b; font-size: 11px; font-weight: 800; }
.nearby-row strong { display: block; font-size: 14px; }
.nearby-row small { display: block; margin-top: 2px; color: #7c899a; font-size: 10px; }
.distance { white-space: nowrap; color: #334155; font-size: 12px; font-weight: 700; }
.notice-box { display: grid; gap: 4px; margin: 14px 0; padding: 12px 13px; border-left: 4px solid #eab308; border-radius: 8px; background: #fff9db; color: #5f4a05; }
.notice-box strong { font-size: 12px; }
.notice-box span { font-size: 11px; line-height: 1.45; }
.detail-panel > .primary-button { width: 100%; min-height: 48px; margin-top: 2px; }
.empty { margin: 0; padding: 16px; color: var(--muted); font-size: 13px; }

.link-button { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 700; text-decoration: underline; }
.link-button:disabled { color: var(--muted); text-decoration: none; }

.source-csv-download { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid #dfe6ee; border-radius: 10px; padding: 11px 13px; background: #fbfcfe; }
.source-csv-download-info { display: grid; gap: 2px; overflow: hidden; }
.source-csv-download-info strong { font-size: 13px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-csv-download-info span { font-size: 11px; color: #7c899a; }
.source-csv-download a.primary-button { min-height: 38px; padding: 0 16px; text-decoration: none; display: inline-flex; align-items: center; flex-shrink: 0; }

.perf-card, .forecast-card { border: 1px solid #dfe6ee; border-radius: 10px; padding: 13px 14px; background: #fbfcfe; display: grid; gap: 10px; }
.slot-tabs { display: flex; gap: 6px; }
.slot-tab { flex: 1; min-height: 40px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: var(--navy); font-weight: 700; padding: 0 6px; display: grid; line-height: 1.25; }
.slot-tab strong { display: block; font-size: 11px; color: var(--muted); }
.slot-tab .slot-denom { font-size: 14px; }
.slot-tab.active { background: #eaf2ff; border-color: var(--blue); color: var(--blue); }
.slot-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot-field { display: grid; gap: 4px; }
.slot-field label { font-size: 12px; font-weight: 700; color: #475569; }
.slot-field .field-with-unit { display: flex; align-items: center; gap: 6px; }
.slot-field input[type="number"] { width: 100%; height: 38px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0 10px; background: #fff; }
.slot-field .unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
.slot-updated { grid-column: 1 / -1; color: #7c899a; font-size: 11px; }
.forecast-highlight strong { font-size: 26px; color: var(--blue); }
.rounds-panel { display: flex; gap: 18px; margin: 4px 0 16px; }
.rounds-panel label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--navy); }
.rounds-panel input[type="checkbox"] { width: 18px; height: 18px; }

.invalid-dialog { width: 520px; max-width: 90vw; border: 0; border-radius: 14px; padding: 22px; color: var(--navy); box-shadow: 0 24px 80px rgba(15,23,42,.32); }
.invalid-dialog::backdrop { background: rgba(15,23,42,.45); }
.invalid-dialog h2 { margin: 0 0 8px; font-size: 19px; }
.invalid-dialog p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.invalid-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.invalid-row { display: grid; grid-template-columns: 56px 1fr 90px; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #edf1f5; font-size: 13px; }
.invalid-row:last-child { border-bottom: 0; }
.invalid-row span:first-child { color: var(--muted); }
.invalid-row .reason { text-align: right; font-weight: 700; color: #b45309; }

.app-footer { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr; align-items: center; gap: 18px; padding: 0 20px; background: #fff; border-top: 1px solid var(--border); color: #59697d; font-size: 11px; z-index: 20; }
.app-footer span + span { border-left: 1px solid #e2e8f0; padding-left: 18px; }
.status-bar { position: fixed; left: 50%; top: 88px; z-index: 100; transform: translateX(-50%); max-width: 640px; padding: 11px 16px; border-radius: 9px; background: #1e293b; color: #fff; box-shadow: 0 12px 30px rgba(15,23,42,.24); font-size: 13px; }
.status-bar[data-mode="error"] { background: #b42318; }
.status-bar[data-mode="success"] { background: #167238; }
.column-dialog { width: 440px; border: 0; border-radius: 14px; padding: 22px; color: var(--navy); box-shadow: 0 24px 80px rgba(15,23,42,.32); }
.column-dialog::backdrop { background: rgba(15,23,42,.45); }
.column-dialog h2 { margin: 0 0 8px; font-size: 19px; }
.column-dialog p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.column-dialog label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; }
.column-dialog select { width: 100%; height: 42px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0 10px; background: #fff; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.maplibregl-ctrl-attrib { font-size: 10px !important; }
@media (max-width: 1260px) {
  .app-header { grid-template-columns: 270px minmax(360px, 1fr) auto; }
  .brand h1 { font-size: 19px; }
  .app-main { grid-template-columns: minmax(0, 1fr) 360px; }
}
