/* ============================================================
   bidalytics admin - 궁전건설 디자인 톤(navy/red) 일관 적용
   ============================================================ */
:root {
  --navy: #1f3a68;
  --navy-2: #2d4a7a;
  --red: #c9302c;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e7ed;
  --muted: #6b7280;
  --text: #1f2937;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }      /* 모바일 가로 스크롤 차단 — 테이블만 자체 스크롤 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
               "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 로그인 ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 12px;
  padding: 40px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { color: var(--navy); margin: 0 0 4px; font-size: 24px; }
.login-sub { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-card input {
  font-size: 15px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
.login-card input:focus { border-color: var(--navy); }
.login-card button {
  margin-top: 8px; padding: 12px; background: var(--navy); color: #fff;
  border: 0; border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 600;
}
.login-card button:hover { background: var(--navy-2); }
.msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.msg-err { background: #fdecea; color: var(--red); }
.msg-warn { background: #fff5e6; color: #b06000; }

/* ===== 상단바 ===== */
.admin-topbar {
  background: var(--navy); color: #fff;
  padding: 0 24px; display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}
.admin-brand { display: flex; align-items: baseline; gap: 12px; }
.admin-brand a { color: #fff; font-weight: 700; font-size: 18px; }
.admin-tag { color: rgba(255,255,255,.7); font-size: 12px; }
.admin-nav { display: flex; gap: 4px; align-items: center; }
.admin-nav a {
  color: rgba(255,255,255,.85); padding: 6px 14px; border-radius: 6px; font-size: 14px;
}
.admin-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.admin-nav a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.admin-nav .logout { color: rgba(255,255,255,.6); margin-left: 12px; font-size: 13px; }

/* ===== 메인 ===== */
.admin-main { max-width: 1400px; margin: 0 auto; padding: 24px; width: 100%; overflow-x: hidden; }
.admin-main > section, .admin-main > div { max-width: 100%; }
.page-title { font-size: 22px; margin: 4px 0 18px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; color: var(--navy); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 대시보드 헤더 ===== */
.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}
.dash-head .page-title { margin: 0; }
.dash-context { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ctx-item { font-size: 13px; }
.ctx-item strong { color: var(--navy); }

/* ===== 카드 ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card {
  background: var(--card); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .12s, box-shadow .12s;
  border-top: 3px solid transparent;
  position: relative;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.08); text-decoration: none; }
.card-icon { font-size: 18px; opacity: .7; }
.card-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.card-value { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.1; margin: 2px 0; }
.card-sub { color: var(--muted); font-size: 11px; }
.card-urgent { border-top-color: var(--red); background: linear-gradient(180deg, #fff8f8 0%, #fff 60%); }
.card-urgent .card-value { color: var(--red); }
.card-mine { border-top-color: var(--navy); background: linear-gradient(180deg, #fff6e8 0%, #fff 60%); }
.card-mine .card-value { color: #b06000; }
.card-empty .card-value { color: var(--muted); font-size: 24px; }

/* ===== 대시보드 그리드 ===== */
.dashboard-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 18px;
}
.dashboard-grid .block { margin-bottom: 0; }
@media (max-width: 1100px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* 컴팩트 테이블 */
.data-table.compact thead th { padding: 8px 10px; font-size: 11px; }
.data-table.compact tbody td { padding: 8px 10px; font-size: 12.5px; }

/* 통계 패널 */
.stat-panel h3 { font-size: 13px; color: var(--navy); margin: 16px 0 8px; }
.stat-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row strong { color: var(--navy); font-size: 14px; }
.stat-row strong.big { font-size: 18px; }
.stat-row.hl { background: #fff8e8; padding: 8px 10px; border-radius: 6px; border-bottom: 0; margin: 4px -8px; }
.stat-row.hl strong { color: var(--red); }
.stat-divider { height: 1px; background: var(--line); margin: 10px 0; }

/* 랭크 리스트 */
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
  display: grid; grid-template-columns: 80px 1fr 36px;
  gap: 8px; align-items: center; padding: 4px 0; font-size: 12px;
}
.rank-label {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  background: #eef1f6; color: var(--text); white-space: nowrap;
  text-overflow: ellipsis; overflow: hidden;
}
.rank-label.mine { background: var(--red); color: #fff; font-weight: 600; }
.rank-bar {
  height: 8px; background: #f0f3f8; border-radius: 4px;
  overflow: hidden; position: relative;
}
.bar-fill {
  display: block; height: 100%; background: var(--navy); border-radius: 4px;
  transition: width .2s;
}
.bar-fill.mine { background: var(--red); }
.rank-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ===== 블록 ===== */
.block {
  background: var(--card); border-radius: 12px; padding: 20px 22px;
  margin-bottom: 18px; box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.block h2 { margin: 0 0 12px; font-size: 16px; color: var(--navy); }

/* ===== 차트 컨테이너 — height 고정 (canvas 폭주 방지) ===== */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  max-height: 280px;
}
.chart-wrap.tall { height: 360px; max-height: 360px; }
.chart-wrap.short { height: 200px; max-height: 200px; }
.chart-wrap canvas {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}

/* ===== 필터 ===== */
.filters {
  display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap;
}
.filters input[type="text"] {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; min-width: 240px;
}
.filters button {
  padding: 8px 16px; background: var(--navy); color: #fff;
  border: 0; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.filters .chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

/* ===== 테이블 ===== */
.data-table {
  width: 100%; background: var(--card); border-collapse: collapse;
  border-radius: 8px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.data-table thead th {
  background: #f0f3f8; color: var(--navy); padding: 10px 12px; text-align: left;
  font-size: 12px; font-weight: 700; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top;
  font-size: 13px;
}
.data-table tbody tr:hover { background: #fafbfc; }
.meta { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* 추천 표시 */
.rec-rate { color: var(--red); font-size: 15px; font-weight: 700; }
.rec-range { color: var(--muted); font-size: 11px; }
.rec-conf { color: var(--muted); font-size: 11px; }

/* D-day */
.dday { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #eef1f6; color: var(--navy); }
.dday.today { background: var(--red); color: #fff; }
.dday.near { background: #ff9800; color: #fff; }
.dday.past { background: #d0d4dc; color: #6b7280; }

/* 푸터 */
.admin-footer {
  text-align: center; color: var(--muted); padding: 16px; font-size: 11px;
}

/* ===== 지역/공종 배지 ===== */
.region-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: #e9ecf2; color: var(--navy); font-size: 11px; font-weight: 600;
}
.region-badge.mine { background: var(--red); color: #fff; }
.cnstty-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: #eef3fa; color: var(--navy); font-size: 11px; font-weight: 500;
}
.cnstty-badge.mine { background: var(--navy); color: #fff; font-weight: 700; }
.badge-kyojung {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  background: #ffeac0; color: #b06000; font-size: 10px; font-weight: 700;
  margin-left: 2px; vertical-align: middle;
}

/* 입찰가능 배지 */
.eli-badge {
  display: inline-block; padding: 3px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
}
.eli-solo    { background: #d4edda; color: #155724; }
.eli-partner { background: #fff3cd; color: #856404; }
.eli-no      { background: #f8d7da; color: #721c24; }
.eli-unknown { background: #e9ecef; color: #6c757d; }

/* 발주처/경쟁업체 expand */
.org-row { cursor: pointer; }
.org-row:hover { background: #f0f3f8 !important; }
.expand-arrow { display: inline-block; width: 14px; color: var(--muted); font-size: 10px; }
.org-detail td { background: #f9fafc; padding: 14px 18px; }
.org-chart-wrap {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: stretch;
  max-width: 100%;
  width: 100%;
}
@media (max-width: 1000px) { .org-chart-wrap { grid-template-columns: 1fr; } }
.org-chart-canvas {
  position: relative;
  height: 200px;        /* 차트 높이 고정 — 화면 벗어남 방지 */
  max-height: 220px;
  min-width: 0;
  width: 100%;
}
.org-chart-canvas canvas {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}
.org-chart-meta {
  font-size: 13px;
  line-height: 1.6;
  min-width: 0;
}
.org-chart-meta ul.reason-list { margin: 4px 0 8px; padding-left: 18px; }
.org-chart-meta strong { color: var(--navy); }
tr.my-region { background: #fff8f8; }
tr.my-region:hover { background: #ffe8e8; }
tr.my-target { background: #fff2e0; }
tr.my-target:hover { background: #ffe6c2; }

.filter-hint {
  margin: -10px 0 14px; padding: 8px 12px; background: #f0f3f8; border-radius: 6px;
}

.th-sub { display: block; font-weight: 400; color: var(--muted); font-size: 10px; }

/* 서브 헤더 (2단 헤더) */
.data-table thead tr.sub-th th {
  background: #f7f9fc; padding: 6px 10px; font-weight: 500;
  font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line);
}

/* sno 전략 페이지 */
.strategy-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }
@media (max-width: 900px) { .strategy-grid { grid-template-columns: 1fr; } }
.sno-cold td { background: #f0f8ff; }
.simulator {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: #fff8e8; padding: 12px 16px; border-radius: 8px; margin-top: 8px;
}
.simulator label { font-weight: 600; }
.simulator select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); font-size: 14px; }
.sim-result { font-size: 15px; font-weight: 700; color: var(--navy); }
.sim-result.good { color: #155724; }
.sim-result.warn { color: var(--red); }

/* MFG 결과 카드 */
.mfg-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 16px; }
@media (max-width: 720px) { .mfg-result { grid-template-columns: 1fr; } }
.mfg-card {
  background: linear-gradient(135deg, #fff8e8 0%, #fff 100%);
  border-radius: 8px; padding: 14px 16px;
  border-left: 4px solid var(--red);
}
.mfg-label { color: var(--muted); font-size: 11px; }
.mfg-value { font-size: 22px; font-weight: 700; color: var(--red); margin: 4px 0; }
.mfg-sub { color: var(--muted); font-size: 11px; }

/* 종합 시뮬레이터 */
.combo-sim {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  background: #f0f3f8; padding: 14px 18px; border-radius: 8px;
}
.combo-sim label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.combo-sim input, .combo-sim select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.combo-sim input { width: 120px; }
.combo-sim .unit { color: var(--muted); }

/* 시뮬레이터 입력 그리드 */
.sim-input-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (max-width: 600px) { .sim-input-grid { grid-template-columns: 1fr; } }
.sim-input-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.sim-input-grid input {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.sim-input-grid .unit { font-size: 11px; color: var(--muted); font-weight: 400; }

/* 피드백 폼 */
.feedback-form { display: flex; flex-direction: column; gap: 10px; }
.feedback-form .ff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .feedback-form .ff-row { grid-template-columns: 1fr; } }
.feedback-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.feedback-form input, .feedback-form select, .feedback-form textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.feedback-form button {
  padding: 12px; background: var(--navy); color: #fff; border: 0; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 10px;
}
.feedback-form button:hover { background: var(--navy-2); }

.msg-success { background: #d4edda; color: #155724; padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }

/* 자동 추천 컬럼 */
.auto-rate { color: var(--red); font-size: 13px; font-weight: 700; }
.auto-sno { color: var(--navy); font-size: 11px; }
.auto-score { color: var(--muted); font-size: 10px; font-weight: 600; }

/* 신뢰도 배지 */
.conf-badge {
  display: inline-block; padding: 4px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 700; min-width: 36px; text-align: center;
}
.conf-high { background: #d4edda; color: #155724; }
.conf-mid  { background: #fff3cd; color: #856404; }
.conf-low  { background: #f8d7da; color: #721c24; }
.feedback-mark { font-size: 11px; cursor: help; margin-top: 2px; }

select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: #fff; cursor: pointer;
}

.bid-link {
  color: var(--navy); font-weight: 500; text-decoration: none;
}
.bid-link:hover { color: var(--red); text-decoration: underline; }

.est-bid { color: var(--navy); font-weight: 600; font-size: 12px; }

/* ===== 공고 상세 ===== */
.detail-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.detail-title h1 { margin: 0 0 6px; font-size: 20px; color: var(--navy); }
.detail-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.detail-meta .ext-link { color: var(--red); font-weight: 600; }
.btn-back {
  padding: 8px 16px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; color: var(--navy); font-size: 13px; white-space: nowrap;
}
.btn-back:hover { background: #f0f3f8; text-decoration: none; }

.info-table .data-table { width: 100%; }
.info-table .data-table th {
  background: #f0f3f8; color: var(--navy); padding: 8px 12px;
  width: 100px; text-align: left; font-size: 12px;
}
.info-table .data-table td { padding: 8px 12px; font-size: 13px; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* 계산기 */
.calc-box { background: #fbfcfe; }
.calc-row {
  display: grid; grid-template-columns: 180px 1fr 40px;
  gap: 8px; align-items: center; margin-bottom: 10px;
}
.calc-row label { font-size: 13px; color: var(--text); }
.calc-row input[type="text"], .calc-row input[type="number"] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-variant-numeric: tabular-nums; text-align: right;
}
.calc-row input[readonly] { background: #f0f3f8; color: var(--navy); font-weight: 600; }
.calc-row.final input { background: #fff8e8; color: var(--red); font-weight: 700; font-size: 16px; }
.calc-row .unit { color: var(--muted); font-size: 12px; }
.calc-row.slider-row { grid-template-columns: 180px 1fr; }
.calc-row.slider-row input[type="range"] { width: 100%; }
.calc-arrow { text-align: center; color: var(--muted); font-size: 20px; margin: 4px 0; }
.calc-hint {
  background: #fff8e8; padding: 8px 12px; border-radius: 6px;
  font-size: 12px; margin-bottom: 10px;
}

/* 추천 근거 */
.reason-list { padding-left: 20px; line-height: 1.8; font-size: 13px; }
.reason-box h3 { color: var(--navy); font-size: 14px; margin: 16px 0 8px; }
.scenario-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.scenario-table th { background: #f0f3f8; padding: 8px; text-align: left; }
.scenario-table th.num { text-align: right; }
.scenario-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.scenario-table tr.highlight { background: #fff8e8; }

/* ============================================================
   반응형 — 모바일 (≤900px / ≤720px / ≤480px 단계)
   ============================================================ */

/* 태블릿 / 작은 데스크톱 */
@media (max-width: 900px) {
  .admin-main { padding: 14px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .org-chart-wrap { grid-template-columns: 1fr; }
  .calc-row { grid-template-columns: 140px 1fr 36px; }
}

/* 모바일 일반 */
@media (max-width: 720px) {
  /* 가로 스크롤 강제 차단 (개별 테이블만 자체 스크롤) */
  html, body { overflow-x: hidden !important; max-width: 100vw !important; }
  .admin-main { max-width: 100vw; padding: 12px 10px; overflow-x: hidden; }
  .block, .cards, .dashboard-grid, .filters, .filter-hint, .dash-head, .dash-context {
    max-width: 100%;
  }

  /* stat-row 가 화면 안에서 정렬되도록 */
  .stat-row { width: 100%; gap: 12px; }
  .stat-row span:first-child { flex: 1 1 auto; min-width: 0; }
  .stat-row strong { flex: 0 0 auto; white-space: nowrap; }
  .stat-row.hl { margin: 4px 0; padding: 8px 10px; }

  /* 상단바 */
  .admin-topbar {
    flex-direction: column; height: auto; padding: 6px 10px; gap: 4px;
  }
  .admin-brand { width: 100%; justify-content: space-between; }
  .admin-brand a { font-size: 16px; }
  .admin-tag { display: none; }
  .admin-nav {
    width: 100%; gap: 0; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; padding-bottom: 4px;
  }
  .admin-nav::-webkit-scrollbar { height: 2px; }
  .admin-nav a {
    white-space: nowrap; padding: 6px 10px; font-size: 12px;
    flex-shrink: 0;
  }
  .admin-nav .logout { margin-left: 4px; }

  /* 메인 영역 */
  .admin-main { padding: 12px 10px; }
  .page-title { font-size: 18px; margin-bottom: 12px; }

  /* 대시보드 헤더 */
  .dash-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .dash-context { flex-direction: column; gap: 2px; align-items: flex-start; }
  .ctx-item { font-size: 12px; }

  /* 카드 — 모바일 2x N 그리드 */
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  .card { padding: 12px 12px; gap: 2px; }
  .card-icon { font-size: 14px; }
  .card-label { font-size: 11px; }
  .card-value { font-size: 22px; }
  .card-sub { font-size: 10px; }

  /* 필터 바 */
  .filters { gap: 6px; }
  .filters select, .filters input[type="text"], .filters button {
    flex: 1 1 calc(50% - 4px); min-width: 0;
    padding: 8px 10px; font-size: 12px;
  }
  .filters .chk { font-size: 12px; flex: 1 1 100%; }
  .filters > span.muted { flex: 1 1 100%; font-size: 11px; }
  .filter-hint { font-size: 11px; padding: 6px 10px; }

  /* 블록 */
  .block { padding: 14px 14px; margin-bottom: 14px; border-radius: 10px; }
  .block h2 { font-size: 14px; margin-bottom: 10px; }

  /* 테이블 — 부모(.block)가 가로 스크롤 컨테이너, 테이블은 자체 너비 유지 */
  .block { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table {
    display: table;       /* table 그대로 (display: block 금지 — 컬럼 넓이 깨짐) */
    width: max-content;
    min-width: 100%;
    white-space: nowrap;
    font-size: 11px;
  }
  .data-table thead th { padding: 6px 8px; font-size: 10.5px; }
  .data-table tbody td { padding: 6px 8px; font-size: 11px; vertical-align: top; }
  .data-table .meta { font-size: 9.5px; white-space: nowrap; }
  .data-table.compact thead th { padding: 5px 6px; font-size: 10px; }
  .data-table.compact tbody td { padding: 5px 6px; font-size: 10.5px; }
  /* expand row 의 내용은 줄바꿈 허용 */
  .org-detail td, .org-detail td * { white-space: normal; }

  /* 배지 — 모바일에서 한 줄 짧게 */
  .region-badge, .cnstty-badge, .badge-kyojung {
    font-size: 10px; padding: 1px 6px;
  }
  .eli-badge { font-size: 10px; padding: 2px 6px; }

  /* 통계 패널 */
  .stat-row { font-size: 12px; padding: 4px 0; }
  .stat-row strong { font-size: 13px; }
  .stat-row strong.big { font-size: 15px; }
  .stat-panel h3 { font-size: 12px; margin: 12px 0 6px; }
  .rank-list li {
    grid-template-columns: 60px 1fr 30px;
    font-size: 11px; gap: 6px;
  }
  .rank-label { font-size: 10px; padding: 1px 6px; }

  /* 차트 컨테이너 — 모바일에서 더 짧게 */
  .chart-wrap { height: 220px; max-height: 220px; }
  .chart-wrap.tall { height: 260px; max-height: 260px; }
  .chart-wrap.short { height: 160px; max-height: 160px; }

  /* 차트 expand — 테이블 가로 스크롤에 갇히지 않도록 sticky + viewport 너비 */
  .org-detail {
    position: relative;
  }
  .org-detail > td {
    position: sticky;
    left: 0;
    width: calc(100vw - 22px);
    max-width: calc(100vw - 22px);
    min-width: 0;
    box-sizing: border-box;
    padding: 10px 12px;
    background: #f9fafc;
    z-index: 2;
  }
  .org-chart-wrap {
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }
  .org-chart-canvas {
    height: 180px;
    max-height: 180px;
    width: 100%;
  }
  .org-chart-meta { font-size: 12px; line-height: 1.5; }
  .org-chart-meta ul.reason-list { padding-left: 16px; }

  /* 상세 페이지 */
  .detail-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .detail-title h1 { font-size: 16px; }
  .detail-meta { gap: 6px; font-size: 11px; }
  .btn-back { padding: 6px 12px; font-size: 12px; }
  .info-table .data-table th { width: 80px; padding: 6px 8px; font-size: 11px; }
  .info-table .data-table td { padding: 6px 8px; font-size: 11px; white-space: normal; }

  /* 계산기 — 한 줄로 stack */
  .calc-row {
    grid-template-columns: 1fr;
    gap: 3px;
    margin-bottom: 8px;
  }
  .calc-row label { font-size: 12px; }
  .calc-row input[type="text"], .calc-row input[type="number"] {
    padding: 8px 10px; font-size: 14px;
  }
  .calc-row.final input { font-size: 14px; }
  .calc-row .unit {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    pointer-events: none; opacity: .5;
  }
  .calc-row { position: relative; }
  .calc-arrow { font-size: 16px; }

  /* 시나리오 표 */
  .scenario-table { font-size: 11px; }
  .scenario-table th, .scenario-table td { padding: 6px 6px; }

  /* 추천 근거 */
  .rec-rate { font-size: 13px; }
  .rec-range, .rec-conf { font-size: 9.5px; }

  /* 로그인 화면 */
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 20px; }

  /* 푸터 */
  .admin-footer { padding: 12px; font-size: 10px; }
}

/* 매우 작은 모바일 (≤480px) */
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card-value { font-size: 20px; }
  .filters select, .filters input[type="text"], .filters button {
    flex: 1 1 100%;
  }
  .data-table { font-size: 10.5px; }
  .data-table thead th { font-size: 10px; }
  .org-chart-canvas { height: 160px; max-height: 160px; }
}
