:root {
  --bg: #f7f8fa;      --surface: #ffffff;  --border: #e3e6ec;
  --text: #16181d;    --muted: #6b7280;    --accent: #1f6feb;
  --accent-soft: rgba(31,111,235,.10);
  --danger: #c02a2a;  --ok: #15803d;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;    --surface: #171a21;  --border: #272b35;
    --text: #e7e9ee;  --muted: #9aa1ad;    --accent: #6ea8fe;
    --accent-soft: rgba(110,168,254,.14);
    --danger: #f87171; --ok: #4ade80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
        "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  word-break: keep-all;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.search-form { display: flex; gap: 6px; flex: 1 1 220px; min-width: 0; }
.search-form input {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.header-nav { margin-left: auto; }

/* layout */
main.wrap { padding-top: 28px; padding-bottom: 56px; }
section { margin-bottom: 36px; }
h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.hero { padding: 8px 0 4px; }
.hero p { margin: 4px 0; color: var(--muted); }
.hero-stats { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.empty {
  color: var(--muted); background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 24px; text-align: center;
}
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* region grid */
.region-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.region-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; color: var(--text);
  box-shadow: var(--shadow); transition: border-color .12s, transform .12s;
}
.region-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.region-sido { font-size: 12px; color: var(--muted); }
.region-card strong { font-size: 16px; }
.region-card .muted { font-size: 12px; }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
tr.is-error td { color: var(--danger); }
tr.is-off td { opacity: .55; }

/* tags */
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.tag-cancel { background: rgba(192,42,42,.12); color: var(--danger); }

/* tabs */
.tabs { display: flex; gap: 4px; margin: 12px 0 20px; }
.tab {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); background: var(--surface); font-size: 14px;
}
.tab:hover { text-decoration: none; border-color: var(--accent); }
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* chart */
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; overflow-x: auto; }
.chart { width: 100%; min-width: 480px; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .dot { fill: var(--accent); }

/* cards & forms */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card-narrow { max-width: 380px; margin: 40px auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, button { font: inherit; }
input, select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); min-width: 0;
}
.btn {
  padding: 9px 18px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.inline { display: inline; }

/* admin */
.admin-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head h1 { margin: 0; }
.admin-nav { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.stat-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px;
}
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.card + .card { margin-top: 20px; }

/* flashes */
.flashes { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.flash-error { border-color: var(--danger); color: var(--danger); }
.flash-ok { border-color: var(--ok); color: var(--ok); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 24px 0; }
.site-footer p { margin: 4px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 620px) {
  .header-inner { height: auto; padding: 10px 0; }
  .search-form { order: 3; flex-basis: 100%; }
  h1 { font-size: 22px; }
}

/* 단지 배정 체크리스트 */
.checklist {
  display: grid; gap: 2px; margin: 12px 0;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  max-height: 460px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px;
}
.check {
  flex-direction: row; align-items: baseline; gap: 8px;
  padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: 14px;
}
.check:hover { background: var(--accent-soft); }
.check input { min-width: auto; width: auto; }
.check.is-other { opacity: .7; }
tr.is-selected td { background: var(--accent-soft); }

/* 면적 필터 (거래유형 탭 아래 보조 줄) */
.tabs-sub { margin: -8px 0 20px; align-items: center; flex-wrap: wrap; gap: 4px; }
.tabs-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.tab-sm { padding: 4px 12px; font-size: 13px; }
