/* =============================================================================
 * 부동산 시세 대시보드 — 라이트 슬레이트 에디토리얼 핀테크 스타일
 * ========================================================================== */

:root {
  --bg: #f6f7fa;
  --bg-soft: #eef1f6;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --line: #e5e9f0;
  --line-soft: #eef1f6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #eef3ff;
  --up: #e11d48;
  --up-soft: #fff1f4;
  --down: #2563eb;
  --down-soft: #eff4ff;
  --jeonse: #0f9d8a;
  --jeonse-soft: #e8f8f4;
  --wolse: #c2740c;
  --wolse-soft: #fdf4e6;
  --ok: #0f9d8a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px -18px rgba(15, 23, 42, .28);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 380px at 50% -180px, #e9eefb 0%, rgba(246, 247, 250, 0) 70%),
    var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(28px + var(--safe-b));
}

.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;
}
.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--surface); padding: 10px 16px; border-radius: 0 0 12px 0;
}
.skip:focus { left: 0; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  background: rgba(246, 247, 250, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(229, 233, 240, .8);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #2563eb, #1e40af);
  color: #fff; box-shadow: 0 6px 14px -8px rgba(37, 99, 235, .9);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s, transform .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.96); }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 레이아웃 ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 14px 16px 0; }

/* ---------- 지역 칩 ---------- */
.region-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 2px -16px 12px; padding: 2px 16px 4px;
  overflow-x: auto; scrollbar-width: none;
}
.region-bar::-webkit-scrollbar { display: none; }
.chips { display: flex; gap: 8px; flex: none; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); border-radius: 999px; padding: 8px 14px;
  font: inherit; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  flex: none;
}
.chip .chip-sub { color: var(--faint); font-weight: 500; font-size: 12px; }
.chip:hover { border-color: #d6dce8; }
.chip.on {
  background: #0f172a; border-color: #0f172a; color: #fff;
  box-shadow: 0 8px 18px -12px rgba(15, 23, 42, .75);
}
.chip.on .chip-sub { color: rgba(255, 255, 255, .62); }
.chip-add { border-style: dashed; color: var(--accent); border-color: #c7d6f8; background: var(--accent-soft); }
.chip-add:hover { background: #e4ecff; }

/* ---------- 상태 ---------- */
.status[hidden] { display: none; }
.status {
  display: flex; align-items: center; gap: 8px;
  background: #fff8f8; border: 1px solid #f6d5d9; color: #9f1239;
  border-radius: 12px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status.ok { background: #f2fbf8; border-color: #cfeee6; color: #0b6b5e; }
.status .link-btn { margin-left: auto; }
.link-btn {
  appearance: none; background: none; border: 0; padding: 2px 4px; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 필터 ---------- */
.filters {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #ebeff6; border-radius: 12px; border: 1px solid #e4e9f1;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 11px;
  border-radius: 9px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-compact button { padding: 7px 12px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.card-head .sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.card-head > .pill { align-self: flex-start; flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-soft); color: var(--muted); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ---------- KPI ---------- */
.kpi-caption { margin: 0 2px 8px; font-size: 11.5px; color: var(--faint); font-weight: 600; letter-spacing: -.01em; }
.kpi-caption:empty { display: none; }
.kpi-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px 13px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 0 4px; display: flex; align-items: center; gap: 6px; }
.kpi-value {
  font-size: 24px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15;
  display: flex; align-items: baseline; gap: 3px;
}
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-meta { margin: 6px 0 0; font-size: 12px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.kpi-meta b { color: var(--text-2); font-weight: 650; }
.kpi-meta .delta { margin-left: auto; }
.delta {
  display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 12px;
  border-radius: 7px; padding: 2px 6px;
}
.delta.up { color: var(--up); background: var(--up-soft); }
.delta.down { color: var(--down); background: var(--down-soft); }
.delta.flat { color: var(--muted); background: var(--bg-soft); }
.sample-mark { color: var(--faint); font-size: 10px; font-weight: 700; margin-left: 1px; }
.kpi-bar { height: 5px; border-radius: 999px; background: var(--bg-soft); margin-top: 10px; overflow: hidden; }
.kpi-bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.kpi.accent { background: linear-gradient(180deg, #f8faff, #fff); }
.kpi.accent .kpi-value { color: #16307d; }

/* ---------- 차트 ---------- */
.chart-card { padding-bottom: 12px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: inherit; font-size: 10.5px; fill: var(--faint); }
.chart .grid-line { stroke: #eef1f6; stroke-width: 1; }
.chart .axis-line { stroke: #e2e7f0; stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-line.jeonse { stroke: var(--jeonse); stroke-dasharray: 0; }
.chart .series-line.rent { stroke: var(--wolse); stroke-dasharray: 4 4; stroke-width: 1.8; }
.chart .series-line.trade { stroke: #1d4ed8; }
.chart .dot { stroke: #fff; stroke-width: 1.5; }
.chart .hover-line { stroke: #cbd5e1; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .bar-trade { fill: #1d4ed8; opacity: .88; }
.chart .bar-rent { fill: #93c5fd; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(15, 23, 42, .94); color: #fff; border-radius: 10px;
  padding: 9px 11px; font-size: 11.5px; line-height: 1.5;
  box-shadow: 0 12px 24px -12px rgba(15, 23, 42, .7);
  transform: translate(-50%, -100%); transition: opacity .12s; white-space: nowrap;
  opacity: 0;
}
.chart-tip.on { opacity: 1; }
.chart-tip b { font-weight: 700; }
.chart-tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .row span:last-child { font-weight: 700; margin-left: 12px; }
.chart-tip .sw { width: 7px; height: 7px; border-radius: 3px; display: inline-block; margin-right: 4px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.legend button {
  appearance: none; background: none; border: 0; font: inherit; font-size: 11.5px;
  color: var(--muted); display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 2px 0; font-weight: 600;
}
.legend button.off { opacity: .38; text-decoration: line-through; }
.legend .sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-foot { margin-top: 6px; }
.chart-foot-title { font-size: 11.5px; color: var(--muted); font-weight: 600; display: block; margin: 6px 0 2px 2px; }
.chart-volume { height: auto; }

/* ---------- 자금 ---------- */
.budget-card .card-head { margin-bottom: 12px; }
.budget-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.money-field {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 8px 10px;
}
.money-field span { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.money-field input {
  width: 100%; min-width: 0; border: 0; background: transparent; font: inherit;
  font-size: 15px; font-weight: 700; color: var(--text); text-align: right;
  font-variant-numeric: tabular-nums; outline: none; padding: 0;
}
.money-field input::-webkit-outer-spin-button,
.money-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.money-field input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.money-field em { font-style: normal; font-size: 12px; color: var(--faint); font-weight: 600; }
.money-field:focus-within { border-color: #c3d3f7; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.budget-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.budget-summary .bs {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 10px; padding: 7px 10px; font-size: 12.5px; font-weight: 650;
  background: var(--bg-soft); color: var(--text-2);
  border: 0; font-family: inherit; line-height: 1.4; text-align: left;
}
.budget-summary .bs.hint { display: block; width: 100%; }
.budget-summary .bs b { font-weight: 750; }
.budget-summary .bs.buy { background: var(--jeonse-soft); color: #0a6f61; }
.budget-summary .bs.gap { background: var(--accent-soft); color: #1d4ed8; }
.budget-summary .bs.over { background: var(--bg-soft); color: var(--muted); }
.budget-summary .bs.total { background: #0f172a; color: #fff; }
.budget-summary .bs.total b { color: #fff; }
.budget-hint { font-size: 12px; color: var(--faint); margin: 8px 0 0; }

/* ---------- 표 ---------- */
.table-card { padding-bottom: 14px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.complex-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.complex-table thead th {
  position: sticky; top: 0; background: var(--surface);
  font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: right;
  padding: 0 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.complex-table thead th.th-apt { text-align: left; }
.complex-table thead th.th-star { width: 34px; cursor: default; }
.complex-table thead th .sort-mark { opacity: .5; font-size: 9px; margin-left: 2px; }
.complex-table tbody tr { cursor: pointer; transition: background .12s; }
.complex-table tbody tr:hover { background: var(--surface-2); }
.complex-table tbody td {
  padding: 11px 8px; border-bottom: 1px solid var(--line-soft);
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.complex-table tbody tr:last-child td { border-bottom: 0; }
.cell-apt { text-align: left; white-space: normal; min-width: 132px; }
.complex-table tbody td.cell-apt { text-align: left; }
.cell-apt .apt-name { font-weight: 650; color: var(--text); letter-spacing: -.01em; display: block; }
.cell-apt .apt-meta { font-size: 11.5px; color: var(--faint); display: block; margin-top: 1px; }
.cell-strong { font-weight: 700; }
.cell-muted { color: var(--faint); }
.ratio-badge {
  display: inline-block; padding: 2px 7px; border-radius: 7px;
  background: var(--jeonse-soft); color: #0a6f61; font-weight: 700; font-size: 12px;
  min-width: 46px; text-align: center;
}
.ratio-badge.high { background: var(--up-soft); color: #a81240; }
.budget-badge {
  display: inline-block; padding: 2px 7px; border-radius: 7px; font-size: 11.5px; font-weight: 700;
  background: var(--bg-soft); color: var(--muted);
}
.budget-badge.buy { background: var(--jeonse-soft); color: #0a6f61; }
.budget-badge.gap { background: var(--accent-soft); color: #1d4ed8; }
.star-btn {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 4px;
  color: #cbd5e1; display: grid; place-items: center; border-radius: 8px; line-height: 0;
}
.star-btn:hover { color: #f59e0b; background: #fffbeb; }
.star-btn.on { color: #f59e0b; }
.footnote { font-size: 11.5px; color: var(--faint); margin: 10px 0 0; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty p { margin: 0 0 4px; font-weight: 650; color: var(--text-2); }
.empty span { font-size: 12.5px; color: var(--faint); }

/* ---------- 관심 단지 ---------- */
.watch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.watch-item {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 11px 12px;
  background: var(--surface-2);
}
.watch-item .w-main { flex: 1; min-width: 0; }
.watch-item .w-apt { font-weight: 650; font-size: 13.5px; }
.watch-item .w-region { font-size: 11.5px; color: var(--faint); }
.watch-item .w-memo { font-size: 12.5px; color: var(--text-2); margin-top: 4px; white-space: pre-wrap; }
.watch-empty { font-size: 12.5px; color: var(--faint); padding: 6px 2px; }

/* ---------- 하단 ---------- */
.foot { padding: 18px 4px 10px; color: var(--faint); font-size: 11.5px; line-height: 1.6; }
.foot p { margin: 0 0 4px; }
.foot-meta { color: #b6c0cf; }

/* ---------- 모달 ---------- */
.modal, .drawer { position: fixed; inset: 0; z-index: 80; display: flex; }
.modal[hidden], .drawer[hidden] { display: none; }
.modal-backdrop, .drawer-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  position: relative; margin: auto; width: min(560px, calc(100vw - 24px));
  max-height: min(86vh, 760px); overflow: auto;
  background: var(--surface); border-radius: 20px; box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .5);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head, .drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 10px; position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-head h2, .drawer-head h2 { margin: 0; font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.modal-body { padding: 0 18px 20px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .cascade select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  font: inherit; font-size: 14px; background: var(--surface-2); color: var(--text); outline: none;
}
.field input:focus, .cascade select:focus { border-color: #c3d3f7; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.search-results {
  list-style: none; padding: 0; margin: 4px 0 6px; max-height: 260px; overflow: auto;
  border: 1px solid var(--line-soft); border-radius: 12px;
}
.search-results:empty { display: none; }
.search-results li { border-bottom: 1px solid var(--line-soft); }
.search-results li:last-child { border-bottom: 0; }
.search-btn {
  appearance: none; border: 0; background: none; width: 100%; text-align: left;
  font: inherit; padding: 10px 12px; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.search-btn:hover { background: var(--surface-2); }
.search-btn .sr-main { font-weight: 650; font-size: 13.5px; }
.search-btn .sr-sub { font-size: 11.5px; color: var(--faint); }
.search-btn .sr-add { font-size: 11.5px; color: var(--accent); font-weight: 700; white-space: nowrap; }
.search-btn[disabled] { opacity: .45; cursor: default; }
.search-empty { padding: 14px 12px; font-size: 12.5px; color: var(--faint); text-align: center; }
.cascade { border-top: 1px solid var(--line-soft); margin-top: 8px; padding-top: 10px; }
.cascade summary { font-size: 12.5px; color: var(--muted); font-weight: 650; cursor: pointer; padding: 4px 0; }
.cascade-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.cascade select { padding: 9px 8px; font-size: 13px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 650; padding: 9px 14px; border-radius: 11px; cursor: pointer; }
.btn-primary { background: #0f172a; color: #fff; border-color: #0f172a; width: 100%; }
.btn-primary:hover { background: #1e293b; }
.current-regions { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.current-regions h3 { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; font-weight: 650; }
.current-regions h3 span { color: var(--faint); font-weight: 500; }
.current-regions ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cur-region {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px;
  font-size: 13px;
}
.cur-region .cr-left { display: flex; flex-direction: column; }
.cur-region .cr-sub { font-size: 11.5px; color: var(--faint); }
.del-btn {
  appearance: none; border: 1px solid #f4d2d8; background: #fff6f7; color: #b91c44;
  font: inherit; font-size: 11.5px; font-weight: 650; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.del-btn:hover { background: #ffeef1; }

/* ---------- 드릴다운 ---------- */
.drawer { align-items: flex-end; justify-content: center; }
.drawer-panel {
  position: relative; width: min(680px, 100%); max-height: 88vh; overflow: hidden;
  background: var(--surface); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px -30px rgba(15, 23, 42, .5);
  display: flex; flex-direction: column;
  animation: slideUp .24s cubic-bezier(.2, .9, .3, 1);
  padding-bottom: var(--safe-b);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-dong { margin: 0 0 2px; font-size: 11.5px; color: var(--faint); font-weight: 600; }
.drawer-body { padding: 0 18px 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.drawer-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.dstat { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 9px 10px; }
.dstat .dl { font-size: 11px; color: var(--faint); font-weight: 600; display: block; }
.dstat .dv { font-size: 14.5px; font-weight: 750; letter-spacing: -.02em; }
.drawer-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.drawer-tabs button {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 650; padding: 6px 11px; border-radius: 999px; cursor: pointer;
}
.drawer-tabs button.on { background: #0f172a; border-color: #0f172a; color: #fff; }
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--line-soft);
}
.tx-item:last-child { border-bottom: 0; }
.tx-when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tx-amount { font-size: 14px; font-weight: 750; text-align: right; letter-spacing: -.02em; }
.tx-detail { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; }
.tx-tag { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--bg-soft); font-weight: 600; }
.tx-tag.jeonse { background: var(--jeonse-soft); color: #0a6f61; }
.tx-tag.wolse { background: var(--wolse-soft); color: var(--wolse); }
.tx-tag.trade { background: var(--accent-soft); color: #1d4ed8; }
.tx-tag.rr { background: #fff1f4; color: #b91c44; }
.drawer-memo { margin-top: 14px; }
.drawer-memo label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px; }
.drawer-memo textarea {
  width: 100%; min-height: 62px; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; font-size: 13px; resize: vertical; background: var(--surface-2); outline: none;
}
.drawer-memo textarea:focus { border-color: #c3d3f7; background: #fff; }
.drawer-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%) translateY(8px);
  background: rgba(15, 23, 42, .95); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; z-index: 120; opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: 0 16px 32px -16px rgba(15, 23, 42, .8); max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ---------- 스켈레톤 ---------- */
.sk { position: relative; overflow: hidden; background: #eef1f6; border-radius: 8px; color: transparent !important; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- 반응형 ---------- */
@media (min-width: 720px) {
  .app { padding: 20px 24px 0; }
  .region-bar { margin: 0 0 16px; padding: 0; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 16px 17px; }
  .kpi-value { font-size: 26px; }
  .card { padding: 22px; }
  .drawer { align-items: center; }
  .drawer-panel {
    border-radius: 22px; max-height: 82vh; width: min(680px, calc(100vw - 40px));
    animation: pop .2s cubic-bezier(.2, .9, .3, 1.1); padding-bottom: 0;
  }
}
@media (min-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi { padding: 15px 14px; }
  .kpi-value { font-size: 21px; }
  .kpi-label { font-size: 11.5px; }
  .budget-inputs { max-width: 560px; }
}

@media (max-width: 719px) {
  .card-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .card-head .link-btn { align-self: flex-start; }
  .legend { justify-content: flex-start; }
  .seg { overflow-x: auto; max-width: 100%; }
  .filters { gap: 8px; }
  .budget-inputs { gap: 6px; }
  .money-field {
    display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
    gap: 0 4px; padding: 7px 9px; align-items: center;
  }
  .money-field span { grid-column: 1 / -1; font-size: 10.5px; }
  .money-field input { grid-column: 1; text-align: right; font-size: 15px; }
  .money-field em { grid-column: 2; grid-row: 2; font-size: 11px; }
  .cascade-row { grid-template-columns: 1fr; }
  .drawer-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 표 → 카드형 */
  .complex-table thead { display: none; }
  .complex-table, .complex-table tbody, .complex-table tr, .complex-table td { display: block; width: 100%; }
  .complex-table tbody tr {
    border: 1px solid var(--line-soft); border-radius: 14px; padding: 12px 14px;
    margin-bottom: 8px; background: var(--surface-2);
    display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; position: relative;
  }
  .complex-table tbody tr:hover { background: var(--surface-2); }
  .complex-table tbody td {
    border: 0; padding: 0; text-align: left; white-space: normal;
    font-size: 14px; font-weight: 650; letter-spacing: -.01em; color: var(--text);
  }
  .complex-table tbody td::before {
    content: attr(data-label); display: block; color: var(--faint);
    font-size: 10.5px; font-weight: 600; letter-spacing: 0; margin-bottom: 1px;
  }
  .cell-apt { grid-column: 1 / -1; padding-right: 30px !important; margin-bottom: 2px; }
  .cell-apt::before { content: "" !important; margin: 0; }
  .cell-apt .apt-name { font-size: 15px; font-weight: 700; }
  .complex-table tbody td.td-star {
    position: absolute; top: 9px; right: 8px; width: auto !important; padding: 0 !important;
  }
  .complex-table tbody td.td-star::before { content: "" !important; }
  .cell-strong { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
