* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Meiryo", sans-serif; display: flex; flex-direction: column; height: 100vh; color: #333; }
header { background: #1e3a8a; color: #fff; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-input { background: rgba(255,255,255,0.12); color: #fff; border: 1px dashed rgba(255,255,255,0.5); border-radius: 4px; padding: 4px 8px; font-size: 15px; font-weight: bold; width: 420px; font-family: inherit; }
.title-input:focus { background: #fff; color: #1e3a8a; border: 1px solid #fff; outline: none; }
.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
select, button { padding: 5px 8px; border-radius: 4px; border: none; font-size: 12px; cursor: pointer; }
select { background: #fff; color: #333; }
.btn-csv { background: #10b981; color: #fff; font-weight: bold; }
.btn-print { background: #f59e0b; color: #fff; font-weight: bold; }
.btn-clear { background: #ef4444; color: #fff; }
.main { display: flex; flex: 1; overflow: hidden; }
#map { flex: 1; height: 100%; background: #e2e8f0; position: relative; }
.sidebar { width: 430px; background: #f8fafc; border-left: 1px solid #cbd5e1; display: flex; flex-direction: column; }

.summary { background: #fff; padding: 10px; border-bottom: 1px solid #cbd5e1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; text-align: center; }
.card { background: #f1f5f9; padding: 6px 2px; border-radius: 5px; border: 1px solid #cbd5e1; }
.card.total { background: #1e3a8a; border-color: #1e3a8a; color: #fff; }
.card.total small { color: #dbeafe; }
.card.total strong { color: #fff; font-size: 16px; }
.card small { font-size: 10px; display: block; color: #475569; font-weight: bold; }
.card strong { font-size: 15px; color: #1e293b; }

.list-head { padding: 7px 12px; font-size: 11px; font-weight: bold; background: #e2e8f0; display: flex; justify-content: space-between; }
.list-body { flex: 1; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 6px; border-bottom: 1px solid #e2e8f0; text-align: right; }
th { background: #f1f5f9; position: sticky; top: 0; z-index: 2; color: #475569; }
th:first-child, td:first-child { text-align: left; }
tbody tr { background: #fff; }
tbody tr:hover { background: #f8fafc; }
td.town-cell { cursor: pointer; }
td.num-cell { cursor: pointer; color: #64748b; }
td.num-cell:hover { background: #f1f5f9; color: #0f172a; }

tbody tr.mode-TOTAL td.town-cell { background: #fee2e2; color: #991b1b; font-weight: bold; border-left: 4px solid #dc2626; }
tbody tr.mode-KODATE td.town-cell { background: #dcfce7; color: #166534; font-weight: bold; border-left: 4px solid #15803d; }
tbody tr.mode-SHUGO td.town-cell { background: #f3e8ff; color: #6b21a8; font-weight: bold; border-left: 4px solid #7e22ce; }

td.active-TOTAL { background: #dc2626 !important; color: #ffffff !important; font-weight: bold; }
td.active-KODATE { background: #15803d !important; color: #ffffff !important; font-weight: bold; }
td.active-SHUGO { background: #7e22ce !important; color: #ffffff !important; font-weight: bold; }

@media print {
  header { background: #fff !important; color: #000 !important; border-bottom: 2px solid #1e3a8a; padding: 6px 0; }
  .controls { display: none !important; }
  .title-input { background: none !important; color: #000 !important; border: none !important; font-size: 18px; width: 100%; padding: 0; }
  .main { flex-direction: column; }
  #map { height: 52vh !important; width: 100% !important; }
  .sidebar { width: 100%; border: none; }
  tbody tr:not(.selected-row) { display: none !important; }
}
