/* ==========================================================================
   전략물자 전문판정(신청)서 AI 자동작성 시스템 - 스타일시트
   ========================================================================== */

/* 1. 디자인 토큰 & 변수 설정 */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --secondary: #475569;
  --secondary-hover: #334155;
  --secondary-light: #f1f5f9;
  
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  
  --bg-app: #f8fafc;
  --bg-panel: #ffffff;
  --bg-viewer: #e2e8f0;
  --bg-input: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-strong: #94a3b8;
  --border-official: #000000;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-serif: 'Noto Serif KR', 'Batang', ' 바탕', serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-doc: 0 12px 30px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* 기본 리셋 & 공통 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  transition: all 0.2s ease;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   2. 상단 헤더 네비게이션
   ========================================================================== */
.app-header {
  height: 64px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.logo-badge .icon-svg {
  width: 22px;
  height: 22px;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 상태 뱃지 */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chip-warning {
  background: #fef3c7;
  color: #92400e;
}
.chip-warning .status-dot {
  background: #d97706;
}

.chip-success {
  background: #dcfce7;
  color: #166534;
}
.chip-success .status-dot {
  background: #16a34a;
}

/* 버튼 공통 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary-light);
  color: var(--secondary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

/* ==========================================================================
   3. 메인 작업 레이아웃 (2열 분할)
   ========================================================================== */
.app-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   좌측 콘솔 패널 (입력 & 제어)
   -------------------------------------------------------------------------- */
.console-panel {
  width: 460px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 20;
  box-shadow: 2px 0 12px rgba(0,0,0,0.03);
}

.console-inner {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 퀵 모델 바 */
.model-quickbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.model-quick-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.model-quick-info .label {
  color: var(--text-muted);
}

.badge-model {
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.btn-link {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.model-desc-tag {
  font-size: 0.75rem;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* 입력 헤더 행 */
.input-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.console-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.section-icon {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

/* 샘플 메뉴 드롭다운 */
.sample-dropdown-container {
  position: relative;
}

.btn-sample-trigger {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.btn-sample-trigger:hover {
  background: #dbeafe;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  width: 250px;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dropdown-item {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  transition: background 0.15s;
}
.dropdown-item:hover {
  background: #f1f5f9;
  color: var(--primary);
}

/* 입력 상자 컨테이너 */
.input-box-wrapper {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.input-box-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 음성 컨트롤 바 */
.voice-control-bar {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-voice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--secondary);
}
.btn-voice:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: var(--primary-border);
}

/* 음성 녹음 중 활성화 스타일 */
.btn-voice.recording {
  background: #fee2e2;
  border-color: #ef4444;
  color: #dc2626;
}

.mic-icon {
  width: 15px;
  height: 15px;
}

.btn-voice.recording .mic-icon {
  color: #dc2626;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.voice-status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* 텍스트 입력창 */
.textarea-container {
  padding: 12px;
}

#rawInputText {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-main);
  background: transparent;
}
#rawInputText::placeholder {
  color: #94a3b8;
  font-size: 0.825rem;
}

.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-text-action {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.btn-text-action:hover {
  color: var(--danger);
}

/* 메인 AI 실행 버튼 (CTA) */
.action-btn-row {
  margin-top: -4px;
}

.btn-magic {
  width: 100%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.btn-magic:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}
.btn-magic:active {
  transform: translateY(1px);
}
.btn-magic:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.magic-icon-spin svg {
  width: 18px;
  height: 18px;
}

/* AI 로딩 진행 상태 */
.ai-progress-container {
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 9999px;
  animation: indeterminateProgress 1.4s infinite ease-in-out;
}

@keyframes indeterminateProgress {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(300%); width: 30%; }
}

.ai-progress-label {
  font-size: 0.78rem;
  color: var(--secondary);
  font-weight: 500;
  text-align: center;
}

/* 추출 요약 카드 */
.summary-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 14px;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.summary-title-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #166534;
  font-weight: 700;
  font-size: 0.9rem;
}

.summary-icon {
  width: 18px;
  height: 18px;
  color: #16a34a;
}

.badge-count {
  background: #16a34a;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
}

.summary-desc {
  font-size: 0.8rem;
  color: #166534;
  line-height: 1.5;
}

.missing-notice {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #bbf7d0;
  font-size: 0.75rem;
  color: #991b1b;
}

.notice-tag {
  font-weight: 700;
}

/* 서식 도구 박스 */
.form-tools-card {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tools-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.tools-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.btn-outline {
  border: 1px solid var(--border-medium);
  background: #ffffff;
  color: var(--secondary);
  font-size: 0.78rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: var(--text-main);
  color: var(--text-main);
}

.btn-outline-danger {
  border: 1px solid #fecaca;
  background: #ffffff;
  color: #b91c1c;
  font-size: 0.78rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-outline-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

/* --------------------------------------------------------------------------
   우측 패널 (실제 대한민국 공공 서식 A4 뷰어)
   -------------------------------------------------------------------------- */
.document-viewer-panel {
  flex: 1;
  background: var(--bg-viewer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 뷰어 상단 툴바 */
.viewer-toolbar {
  height: 48px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.viewer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-badge {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.725rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-title-preview {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.btn-icon-sm {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--secondary);
  border-radius: 4px;
}
.btn-icon-sm:hover {
  background: #ffffff;
  color: var(--text-main);
}

.zoom-text {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
}

/* A4 페이퍼 뷰포트 (중앙 정렬 스크롤) */
.paper-viewport {
  flex: 1;
  overflow: auto;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* --------------------------------------------------------------------------
   대한민국 공공서식 표준 [별지 제4호 서식] A4 디자인
   -------------------------------------------------------------------------- */
.a4-document {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  box-shadow: var(--shadow-doc);
  padding: 16mm 18mm;
  display: flex;
  flex-direction: column;
  position: relative;
  transform-origin: top center;
  transition: transform 0.15s ease-out;
  color: #000000;
  box-sizing: border-box;
}

/* 서식 상단 (별지 번호 및 처리기간) */
.doc-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.doc-num {
  font-size: 13px;
  font-weight: 500;
  color: #111;
  letter-spacing: -0.02em;
}

.doc-handling {
  text-align: right;
}

.handling-box {
  border: 1px solid #000000;
  padding: 4px 10px;
  display: inline-flex;
  flex-direction: column;
  text-align: center;
}

.handling-box .hl-ko {
  font-size: 11.5px;
  font-weight: 700;
}
.handling-box .hl-en {
  font-size: 9.5px;
  color: #333;
}

/* 서식 메인 타이틀 */
.doc-title-block {
  text-align: center;
  margin: 10px 0 16px 0;
}

.form-main-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin-bottom: 2px;
}

.form-sub-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #222;
}

/* 공식 서식 표 (테이블) */
.official-form-table {
  width: 100%;
  border-collapse: collapse;
  border: 1.5px solid #000000;
  margin-bottom: 12px;
}

.official-form-table th,
.official-form-table td {
  border: 0.75px solid #000000;
  padding: 6px 8px;
  font-size: 11px;
  vertical-align: middle;
}

.official-form-table .center {
  text-align: center;
}

.official-form-table .en {
  font-size: 9px;
  color: #333333;
  line-height: 1.2;
}

.official-form-table .note {
  font-size: 9.5px;
  font-weight: normal;
  color: #444;
}

.th-main {
  background: #fbfbfb;
  font-weight: 700;
  width: 15%;
}
.th-main .th-title {
  font-size: 12px;
  margin-bottom: 2px;
}

.th-sublabel {
  background: #fafafa;
  font-weight: 600;
}

.th-section-header {
  background: #f5f5f5;
  text-align: center;
  font-weight: 700;
}

/* 표 내부 인풋/텍스트에어리어 필드 (인쇄 시 자연스러운 텍스트처럼 보임) */
.form-field {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 5px;
  font-size: 11px;
  color: #000000;
  border-radius: 3px;
  outline: none;
  transition: all 0.2s;
}

.form-field:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.form-field:focus {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.field-textarea {
  resize: vertical;
  min-height: 48px;
  line-height: 1.4;
}

/* ⑤ 판정 결과 셀 */
.classification-item-cell {
  padding: 6px 10px !important;
}

.class-title {
  font-weight: 600;
  font-size: 11px;
  display: inline-block;
  min-width: 250px;
}

.choice-group {
  display: inline-flex;
  gap: 16px;
  vertical-align: middle;
}

.radio-label, .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 10.5px;
}

.radio-label input, .checkbox-label input {
  cursor: pointer;
}

.control-no-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 0.5px dashed #cccccc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
}

.inline-field {
  flex: 1;
  border: 0.75px solid #aaaaaa;
  padding: 3px 6px;
  background: #fff;
}

/* ⑨ 결과 공개 동의 여부 */
.consent-group {
  display: flex;
  gap: 20px;
}

/* 법령 선언문 & 신청인/기관장 블록 */
.declaration-block {
  margin-top: 12px;
  padding: 6px 4px;
}

.law-text-ko {
  font-size: 11px;
  text-align: justify;
  line-height: 1.5;
  color: #111;
  margin-bottom: 2px;
}

.law-text-en {
  font-size: 9.5px;
  text-align: justify;
  line-height: 1.35;
  color: #444;
  margin-bottom: 14px;
}

.sign-date-row {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.sign-date-row .date-input {
  width: 32px;
  text-align: center;
  border: none;
  border-bottom: 1px solid #000;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  background: transparent;
  padding: 0;
  margin: 0 4px;
}

.signature-line {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 20px;
}

.applicant-signature-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.sig-input {
  border: none;
  border-bottom: 1px solid #000;
  width: 150px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 6px;
  outline: none;
  text-align: center;
  background: transparent;
}

.sig-seal {
  font-size: 11px;
  font-weight: normal;
  color: #333;
}

.en-sub {
  font-size: 9px;
  color: #555;
  margin-top: 2px;
}

/* 기관장 확인란 */
.agency-declaration {
  border-top: 1px dashed #999;
  margin-top: 14px;
  padding-top: 12px;
}

.agency-date {
  margin-bottom: 8px;
}

.date-placeholder {
  font-weight: normal;
  letter-spacing: 0.2em;
}

.agency-head-seal {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-right: 30px;
}

.agency-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.4em;
}

.agency-seal-circle {
  font-size: 12px;
  font-weight: normal;
  color: #444;
}

.agency-en {
  text-align: right;
  margin-right: 26px;
  font-size: 9px;
  color: #666;
  margin-top: 2px;
}

/* 최하단 주의사항 문구 */
.doc-notice-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #000000;
}

.notice-text {
  font-size: 10px;
  color: #111;
  line-height: 1.4;
}

/* ==========================================================================
   4. AI 자동 입력 시 시각 효과 (Flash / Pulse Highlight)
   ========================================================================== */
.field-highlight {
  animation: flashHighlight 1.8s ease-out;
}

@keyframes flashHighlight {
  0% {
    background-color: #fef08a !important; /* 밝은 노랑 */
    box-shadow: 0 0 0 3px #facc15;
  }
  40% {
    background-color: #dbeafe !important; /* 부드러운 파랑 */
    box-shadow: 0 0 0 2px #3b82f6;
  }
  100% {
    background-color: transparent !important;
    box-shadow: none;
  }
}

/* ==========================================================================
   5. 모달 (설정 및 안내)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg {
  max-width: 720px;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.btn-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
}
.btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: 75vh;
}

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 폼 요소들 (모달 내) */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
}

.input-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all 0.2s;
}
.input-control:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-input-addon {
  position: absolute;
  right: 10px;
  font-size: 1rem;
  opacity: 0.6;
}
.btn-input-addon:hover {
  opacity: 1;
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}
.form-help a {
  color: var(--primary);
  text-decoration: underline;
}

.tip-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 14px;
}

.tip-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 4px;
}

.tip-content {
  font-size: 0.75rem;
  color: #1e3a8a;
  line-height: 1.45;
}

/* 안내 다이어그램 */
.arch-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0 20px 0;
  overflow-x: auto;
}

.arch-box {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  text-align: center;
}

.arch-box.highlight {
  border-color: #3b82f6;
  background: #eff6ff;
}

.arch-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.arch-arrow {
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: 700;
  padding: 0 6px;
}

.help-list {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--secondary);
  line-height: 1.7;
}

/* ==========================================================================
   6. 토스트 알림
   ========================================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 150;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  background: #15803d;
}
.toast-error {
  background: #b91c1c;
}
.toast-info {
  background: #1e293b;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   7. 인쇄 (Print) 및 PDF 출력 최적화 (@media print)
   ========================================================================== */
@media print {
  /* 인쇄 시 불필요한 UI 숨김 */
  .no-print,
  .app-header,
  .console-panel,
  .viewer-toolbar,
  .modal-backdrop,
  .toast-container {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-workspace {
    display: block !important;
    overflow: visible !important;
  }

  .document-viewer-panel {
    background: #ffffff !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .paper-viewport {
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .a4-document {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 12mm 15mm !important;
    width: 100% !important;
    min-height: auto !important;
    transform: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .official-form-table {
    border: 1.5pt solid #000000 !important;
  }

  .official-form-table th,
  .official-form-table td {
    border: 0.75pt solid #000000 !important;
  }

  /* 인쇄 시 인풋 필드 테두리 없애고 본문과 완전 일치 */
  .form-field {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 10mm;
  }
}
