/* 생약표준품 분양 현황 — 색은 실제 보관 모습에서 가져옴
   호박색 = 갈색 유리 바이알, 은회색 = 알루미늄 캡, 밝은 회색 = 해머톤 금속 트레이, 짙은 강철색 = 보관장
   (차트 계열색·상태색은 charts.js의 검증된 팔레트를 그대로 씀) */
:root {
  --bg: #f3f2ef;            /* 트레이 회색을 살짝 데운 배경 */
  --surface: #ffffff;
  --surface-2: #f2efea;
  --text: #1e2125;
  --muted: #61656c;
  --line: #e1ded8;
  --primary: #8a4a14;       /* 바이알 호박색 (흰 글자 대비 7:1) */
  --primary-2: #6b380e;
  --primary-soft: #f7ece0;
  --amber: #c27424;         /* 빛 받은 바이알 */
  --steel: #22262c;         /* 보관장·상단바 */
  --steel-2: #2e333a;
  --silver: #c5c9ce;        /* 알루미늄 캡 */
  --accent: #b5671c;
  --danger: #b4382f;
  --danger-soft: #fbeae8;
  --warn-soft: #fdf3e1;
  --info-soft: #e7edf5;
  --info: #2f5786;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 24, 18, .06), 0 3px 10px rgba(30, 24, 18, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Pretendard, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 25px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sci { font-style: italic; }

/* 상단바: 보관장 강철색 + 호박색 띠 */
.topbar { background: var(--steel); color: #fff; position: sticky; top: 0; z-index: 1000; border-bottom: 3px solid var(--amber); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; min-height: 58px; }
.brand { color: #fff; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; display: block; }
nav { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
nav a { color: #cfd3d8; padding: 8px 12px; border-radius: 8px; font-size: 14.5px; }
nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
nav a.active { background: rgba(194,116,36,.22); color: #ffd9ad; font-weight: 600; }
.nav-sep { flex: 1; }
nav .ro-badge { margin-left: 6px; background: rgba(255,255,255,.14); color: #ffd9ad; align-self: center; }
.menu-btn { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
@media (max-width: 900px) {
  .menu-btn { display: block; }
  nav { display: none; position: absolute; top: 61px; left: 0; right: 0; background: var(--steel); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; border-bottom: 3px solid var(--amber); }
  nav.open { display: flex; }
  .nav-sep { display: none; }
  nav .ro-badge { align-self: flex-start; margin: 6px 12px; }
}

main { max-width: 1240px; width: 100%; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
.footer { color: #b9bdc3; font-size: 12.5px; padding: 22px 16px; background: var(--steel); border-top: 3px solid var(--amber); }
.footer-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.footer-src { word-break: keep-all; }

/* 카드·그리드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; } /* 나란히 놓인 카드는 윗선·높이를 맞춤 */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; color: var(--muted); }

/* 첫 화면 사진 */
.hero { position: relative; overflow: hidden; color: #fff; border-radius: 16px; padding: 44px 32px 36px; margin-bottom: 18px; min-height: 300px;
  background: var(--steel) url('/img/vials-shelf-1400.jpg') 70% 37% / cover no-repeat; }
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(20,22,26,.92) 0%, rgba(20,22,26,.78) 45%, rgba(60,30,8,.25) 100%); }
.hero > * { position: relative; }
.hero .eyebrow { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; color: #ffcf96; background: rgba(194,116,36,.25); border: 1px solid rgba(255,207,150,.35); border-radius: 999px; padding: 3px 10px; margin-bottom: 12px; }
.hero h1 { font-size: 32px; margin-bottom: 10px; }
.hero p { margin: 0; color: #e6e1da; max-width: 620px; }
.hero .search-big { margin-top: 20px; display: flex; gap: 8px; max-width: 620px; }
.hero .search-big input { flex: 1; border: 0; padding: 13px 15px; border-radius: 10px; font-size: 15px; }
.hero .hero-sub { margin-top: 12px; font-size: 13px; color: #cfc8bf; }
.hero .hero-sub a { color: #ffcf96; font-weight: 600; }
.mfds-link { font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid #dcc7b0; border-radius: 6px; padding: 2px 7px; background: #fff; }
.mfds-link:hover { background: var(--primary-soft); text-decoration: none; }
@media (max-width: 640px) { .hero { padding: 28px 18px; min-height: 0; } .hero h1 { font-size: 25px; } }

/* 사진 띠 (목록 화면 머리) */
.photo-band { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 18px; padding: 26px 24px; color: #fff; background: var(--steel) center / cover no-repeat; }
.photo-band::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,22,26,.9) 0%, rgba(20,22,26,.7) 55%, rgba(20,22,26,.35) 100%); }
.photo-band > * { position: relative; }
.photo-band h1 { margin-bottom: 4px; }
.photo-band p { margin: 0; color: #e2ddd6; }
.band-caps { background-image: url('/img/vials-grid-1600.jpg'); }
.band-tray { background-image: url('/img/vials-tray-1400.jpg'); background-position: center 40%; }

/* 보관 안내 카드 */
.storage { display: grid; grid-template-columns: 300px 1fr; gap: 0; padding: 0; overflow: hidden; }
.storage img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 240px; }
.storage .body { padding: 20px 22px; }
.storage ul { margin: 10px 0 0; padding-left: 18px; }
.storage li { margin-bottom: 5px; }
@media (max-width: 760px) { .storage { grid-template-columns: 1fr; } .storage img { max-height: 220px; min-height: 0; } }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* 새 온라인 수요조사 알림 */
.new-badge { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.5; vertical-align: 1px; white-space: nowrap; }
/* 현황: 구분별 숫자 묶음 */
.cat-stats { margin-bottom: 18px; }
.cat-stat h2 { font-size: 16px; margin: 0 0 8px; }
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
/* 현황 숫자 상자: 설명을 두 줄 자리로 고정해 두 구분의 상자 크기·위치를 맞춤 */
.cat-stats .stat .sub { line-height: 1.5; min-height: 3em; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--silver); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat.warn::before { background: var(--amber); }
.stat.warn .value { color: var(--primary); }
.stat .sub { font-size: 12.5px; color: var(--muted); }
.stat .sub .up { color: #006300; font-weight: 600; }
.stat .sub .down { color: var(--danger); font-weight: 600; }

/* 폼 */
label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; color: #3a3d42; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #cfccc6; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #e8bf8f; border-color: var(--primary); }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }
.checkline { display: flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; padding-bottom: 9px; }
.checkline input { width: auto; accent-color: var(--primary); }

/* 버튼 */
.btn { font: inherit; font-size: 14px; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; cursor: pointer; background: var(--primary); color: #fff; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--primary-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary-2); border-color: #dcc7b0; }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: #e6b9b4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.light { background: var(--amber); color: #fff; }
.btn.light:hover { background: var(--primary); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f0eee9; font-size: 13px; color: #45484d; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcf8f3; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
tr.clickable { cursor: pointer; }

/* 배지 */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eeece8; color: #45484d; white-space: nowrap; }
.badge.green { background: #e6f2e6; color: #1d5e1d; }
.badge.gray { background: #ecedee; color: #5c6066; }
.badge.warn { background: var(--warn-soft); color: #8a5a12; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
/* 제조 수요조사 신청 */
.request-cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin: 4px 0 18px; padding: 18px 22px; border-radius: 14px;
  background: linear-gradient(100deg, #fff7ec 0%, #fdf1e0 100%); border: 1px solid #f0d6b2; }
.request-cta h2 { font-size: 18px; margin: 0 0 6px; }
.request-cta p { margin: 0 0 4px; color: #5b4a36; max-width: 760px; }
.request-cta .btn { flex-shrink: 0; }
.review-note { font-size: 14.5px; line-height: 1.6; }
.request-grid { align-items: start; }
.request-grid > * { min-width: 0; }
.request-grid h3 { font-size: 15px; margin: 0 0 10px; }
.req { color: var(--danger); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.checkline.wrap { white-space: normal; align-items: flex-start; font-size: 14px; }
.checkline.wrap input { margin-top: 4px; flex-shrink: 0; }
.checkline.strong { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); }
.badge.research { background: #ece6f3; color: #5b3d84; cursor: help; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tab.active { color: var(--primary-2); border-bottom-color: var(--amber); }
a.tab:hover { text-decoration: none; color: var(--primary-2); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.list li:last-child { border-bottom: 0; }

/* 모달·알림 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 22, 26, .5); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.notice.info { background: var(--info-soft); color: #234a73; }
.notice.warn { background: var(--warn-soft); color: #7a4f10; }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.dropzone { display: block; border: 2px dashed #d6c2ab; border-radius: var(--radius); padding: 28px 16px; text-align: center; cursor: pointer; background: #faf6f1; font-weight: 400; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
details summary { cursor: pointer; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--steel); color: #fff; padding: 11px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 3000; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* 관리자 로그인: 사진 + 양식 */
.login-wrap { max-width: 820px; margin: 30px auto; display: grid; grid-template-columns: 1fr 1fr; padding: 0; overflow: hidden; }
.login-wrap .photo { background: var(--steel) url('/img/vials-tray-700.jpg') center 45% / cover no-repeat; min-height: 360px; position: relative; }
.login-wrap .photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,22,26,0) 50%, rgba(20,22,26,.6)); }
.login-wrap .form { padding: 32px 28px; }
@media (max-width: 700px) { .login-wrap { grid-template-columns: 1fr; } .login-wrap .photo { min-height: 160px; } }

/* ===== 분석 화면 공통 ===== */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
/* ztd-charts 자리 (charts-ztd.js). 범례: 강조 계열 = 호박색, 나머지 = 회색 */
.ztd-slot { width: 100%; }
/* 범례만 쓰려고 붙인 ztd 카드: 이 앱의 카드 안에 있으므로 테두리·바탕·여백·리플레이 버튼을 지움 */
.ztd-slot .ztd-card { border: 0 !important; background: none !important; box-shadow: none !important; padding: 0 !important; border-radius: 0 !important; }
.ztd-slot .ztd-card > header > div:first-child { display: none !important; } /* 카드 제목('막대 차트')·다시 재생 버튼 — 제목은 앱 카드에 있음 */
/* 월별 / 연도별 전환 */
.period-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; flex-shrink: 0; }
.period-toggle button { font: inherit; font-size: 13px; padding: 4px 11px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.period-toggle button + button { border-left: 1px solid var(--line); }
.period-toggle button.on { background: var(--primary-soft); color: var(--primary-2); font-weight: 700; }
@media print { .period-toggle { display: none; } }
.card .desc { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }

/* 차트 */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .tick { font-size: 11px; fill: #898781; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: #52514e; margin: 4px 0 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 4000; display: none; pointer-events: none; background: #fff; border: 1px solid rgba(11,11,11,.12); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 8px 10px; font-size: 12.5px; min-width: 150px; color: #0b0b0b; }
.chart-tip b { display: block; margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 6px; }
.chart-tip div span { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-tip .tot { border-top: 1px solid #e1e0d9; margin-top: 4px; padding-top: 4px; color: #52514e; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 64px; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: #f0efec; border-radius: 4px; height: 12px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; }
.hbar-n { text-align: right; font-variant-numeric: tabular-nums; color: #52514e; }
.stack100 { display: flex; height: 18px; border-radius: 5px; overflow: hidden; gap: 2px; background: #fff; margin: 6px 0 4px; }
.stack100 div { min-width: 2px; }
.spark { vertical-align: middle; }
.scorebar { display: flex; height: 10px; width: 120px; background: #f0efec; border-radius: 4px; overflow: hidden; gap: 1px; }
.scorebar i { display: block; height: 100%; }
.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .multiples { grid-template-columns: 1fr; } }
.multiples h3 { font-size: 14px; margin: 0 0 4px; }

/* 상태 배지 (아이콘 + 글자) */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.st::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st.ok { background: #e6f4e6; color: #006300; }
.st.low { background: #fff4d9; color: #8a5a00; }
.st.low::before { border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
.st.out { background: #fbe9e9; color: #b42f2f; }
.st.out::before { border-radius: 0; width: 8px; height: 2px; }
.st.closed, .st.missing { background: #eeeeec; color: #5f5e59; }
.st.closed::before, .st.missing::before { background: none; border: 1.5px solid currentColor; width: 6px; height: 6px; }
.tier { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tier.t긴급 { background: #d03b3b; color: #fff; }
.tier.t높음 { background: #ec835a; color: #fff; }
.tier.t보통 { background: #fff4d9; color: #8a5a00; }
.tier.t낮음 { background: #eeeeec; color: #5f5e59; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: #fff; white-space: nowrap; }
a.chip:hover { text-decoration: none; background: var(--primary-soft); }
.chip .k { color: var(--muted); font-size: 11.5px; }
.dot-st { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.reasons { margin: 0; padding-left: 16px; font-size: 13px; color: #45484d; min-width: 210px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.window-select { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.window-select a { padding: 6px 12px; font-size: 13.5px; color: var(--muted); border-right: 1px solid var(--line); }
.window-select a:last-child { border-right: 0; }
.window-select a.on { background: var(--primary-soft); color: var(--primary-2); font-weight: 700; }
.window-select a:hover { text-decoration: none; background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.findings { margin: 0; padding-left: 20px; }
.findings li { margin-bottom: 6px; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }

/* 공정서 시험법 원문 */
.test-book + .test-book { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.test-book h3 { margin-bottom: 8px; }
details.test { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: #fff; }
details.test > summary { padding: 9px 12px; font-weight: 700; background: #f6f4f0; border-radius: 10px; }
details.test[open] > summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.test-text { padding: 10px 14px; font-size: 14px; line-height: 1.7; color: #2c2f33; }
.test-text p { margin: 0 0 6px; }
mark.std-hl { background: #fdf0de; color: inherit; border-radius: 4px; padding: 0 2px; }
mark.std-hl a { color: var(--primary-2); font-weight: 700; }
mark.std-hl.focus { background: #f6c98d; box-shadow: 0 0 0 2px #f6c98d; }

/* 분석 질문 창 */
.ask-fab { position: fixed; right: 20px; bottom: 20px; z-index: 2500; border: 0; border-radius: 999px; padding: 12px 18px; font: inherit; font-weight: 700; font-size: 14px;
  background: var(--primary); color: #fff; box-shadow: 0 6px 20px rgba(30,24,18,.25); cursor: pointer; }
.ask-fab:hover { background: var(--primary-2); }
.ask-panel { position: fixed; right: 20px; bottom: 76px; z-index: 2500; width: min(440px, calc(100vw - 32px)); height: min(620px, calc(100vh - 120px));
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.2); display: flex; flex-direction: column; overflow: hidden; }
.ask-panel[hidden] { display: none; }
.ask-panel header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--steel); color: #fff; border-bottom: 3px solid var(--amber); }
.ask-panel header .muted { color: #b9bdc3; }
.ask-panel header .close-x { margin-left: auto; color: #fff; }
.ask-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.ask-msg { padding: 9px 12px; border-radius: 10px; max-width: 92%; line-height: 1.55; }
.ask-msg p { margin: 0 0 6px; } .ask-msg p:last-child { margin: 0; }
.ask-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.ask-msg.user { align-self: flex-end; background: var(--primary-soft); white-space: pre-wrap; }
.ask-msg.assistant { align-self: flex-start; background: #f3f2ef; }
.ask-panel form { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.ask-panel textarea { min-height: 0; resize: none; }
.ask-ex { cursor: pointer; text-align: left; white-space: normal; }
.ask-ex:hover { background: var(--primary-soft); }
@media (max-width: 560px) { .ask-panel { right: 8px; left: 8px; width: auto; bottom: 70px; } .ask-fab { right: 12px; bottom: 12px; } }

/* 보고서 결론·참고 자료 구분 */
.report .conclusion { font-size: 15px; background: var(--primary-soft); border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; padding: 12px 14px 12px 32px; }
.report .ai-opinion { border: 1px solid #e8d3bb; background: #fffaf3; border-radius: 10px; padding: 12px 16px; margin: 12px 0; font-size: 14px; }
.report .ai-opinion p { margin: 0 0 8px; }
.ref-divider { margin: 40px 0 10px; text-align: center; border-top: 2px dashed var(--line); }
.ref-divider span { position: relative; top: -13px; background: #fff; padding: 0 14px; color: var(--muted); font-weight: 700; letter-spacing: .1em; }

/* 보고서 (인쇄용) */
.report { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 36px 32px; max-width: 980px; margin: 0 auto; overflow: hidden; }
.report-cover { margin: 0 -36px 22px; padding: 30px 36px 24px; color: #fff; position: relative; background: var(--steel) url('/img/vials-grid-1600.jpg') center / cover no-repeat; border-bottom: 3px solid var(--amber); }
.report-cover::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,22,26,.93) 0%, rgba(20,22,26,.8) 60%, rgba(20,22,26,.5) 100%); }
.report-cover > * { position: relative; }
.report-cover .meta { color: #ddd8d1; margin: 0; }
.report h1 { font-size: 26px; margin-bottom: 6px; }
.report h2 { font-size: 19px; border-bottom: 2px solid var(--amber); padding-bottom: 6px; margin: 30px 0 12px; }
.report h3 { font-size: 15px; margin: 18px 0 8px; }
.report .meta { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.report table { font-size: 12.5px; }
.report th, .report td { padding: 6px 8px; }
.report .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.report .note { font-size: 12.5px; color: var(--muted); }
.report-actions { max-width: 980px; margin: 0 auto 12px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) { .report { padding: 0 14px 18px; } .report-cover { margin: 0 -14px 18px; padding: 22px 14px; } .report .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .footer, .report-actions, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; max-width: none; }
  .report-cover { margin: 0 0 18px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report h2 { break-after: avoid; }
  .report .block, .report tr, .report .chart, .stat { break-inside: avoid; }
  .page-break { break-before: page; }
  .table-wrap { overflow: visible; border: 0; max-height: none; }
  th { position: static; }
}
