:root {
  --bg: #f8fafc;
  --rail: #ffffff;
  --stage: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --pine: #15803d;
  --pine-hover: #166534;
  --pine-soft: #f0fdf4;
  --heal: #c2410c;
  --heal-soft: #fff7ed;
  --edu: #15803d;
  --edu-soft: #f0fdf4;
  --kids: #b45309;
  --kids-soft: #fffbeb;
  --center: #0369a1;
  --center-soft: #f0f9ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --sans: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100%;
  min-height: 100%;
}

/* Sidebar */
.rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 20px 16px 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--pine-soft);
  color: var(--pine);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #bbf7d0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.nav-btn:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search input::placeholder {
  color: #94a3b8;
}

.search input:focus {
  background: #ffffff;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.1);
}

.regions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
  overflow: auto;
  min-height: 0;
  padding-right: 2px;
}

.region {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: #334155;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.region:hover {
  background: #f1f5f9;
  color: var(--ink);
}

.region[aria-selected="true"] {
  background: var(--pine);
  color: #ffffff;
}

.region .name {
  font-weight: 600;
  font-size: 14px;
}

.counts {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
}

.region[aria-selected="true"] .counts {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: #94a3b8;
  font-size: 12px;
}

.sources p { margin: 0; }

/* Main Stage */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--stage);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px 16px;
}

.stage-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.chip {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: #cbd5e1;
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 28px 24px;
  min-height: 0;
  flex: 1;
}

.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.col-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.badge-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: #f1f5f9;
  padding: 2px 9px;
  border-radius: 999px;
}

.col-list {
  overflow: auto;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.card:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.card h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tag {
  flex: none;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.tag.program { background: var(--edu-soft); color: var(--edu); }
.tag.center { background: var(--center-soft); color: var(--center); }
.tag.kids { background: var(--kids-soft); color: var(--kids); }
.tag.healing { background: var(--heal-soft); color: var(--heal); }

.card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card .addr {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  margin: 24px 8px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.more-note {
  margin: 8px 4px 0;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* Modal */
dialog {
  width: min(500px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.detail { padding: 24px; }

.detail-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.detail h3 {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: var(--ink);
}

.close {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

.close:hover {
  background: #f1f5f9;
  color: var(--ink);
}

.facts {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.facts li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  font-size: 14px;
}

.facts span {
  color: var(--muted);
  font-weight: 500;
}

.facts a {
  color: var(--pine);
  text-decoration: none;
  font-weight: 600;
}

.facts a:hover { text-decoration: underline; }

.visits {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.visits th, .visits td {
  text-align: right;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.visits th { color: var(--muted); font-weight: 600; }
.visits th:first-child, .visits td:first-child { text-align: left; }

.note {
  margin: 14px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .app { display: block; height: auto; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .regions {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    max-width: 100%;
    padding-bottom: 4px;
    gap: 6px;
  }
  .region {
    flex: none;
    width: auto;
    gap: 8px;
    background: #f1f5f9;
  }
  .stage { min-height: 100vh; }
  .stage-head, .board { padding-left: 16px; padding-right: 16px; }
  .stage-head { flex-direction: column; align-items: stretch; }
  .filters { justify-content: flex-start; }
  .board { grid-template-columns: 1fr; }
  .col { min-height: 400px; }
}
