/* ═══════════════════════════════════════════════════════════
   AI 사용량 배지 / API 키 등록
═══════════════════════════════════════════════════════════ */
.ai-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #F8FBFF 0%, #EBF2FA 100%);
  border: 1px solid #BDD7EE;
  border-radius: 8px;
}
.usage-badge {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #1A5276;
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-badge strong { color: #C0392B; }
.usage-badge.user-key { color: #27AE60; }
.usage-badge.user-key strong { color: #1E8449; }
.usage-badge.expired { color: #C0392B; }
.usage-badge.expired strong { color: #A93226; }

.btn-apikey {
  padding: 7px 14px;
  background: #1E3A5F;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-apikey:hover {
  background: #2C3E7A;
  transform: translateY(-1px);
}

.badge-new {
  display: inline-block;
  background: #C0392B;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.badge-proxy {
  display: inline-block;
  background: #1A5276;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-proxy.off { background: #6c757d; }

.ai-notice {
  margin-top: 14px;
  padding: 10px 14px;
  background: #FFF8E1;
  border-left: 4px solid #F39C12;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: #6D4C00;
}
.ai-notice strong { color: #C0392B; }

/* ═══════════════════════════════════════════════════════════
   API 키 등록 모달
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,58,95,0.7);
  backdrop-filter: blur(4px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  background: #1E3A5F;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 4px;
}
.modal-close:hover { background: rgba(255,255,255,0.15); }

.modal-body {
  padding: 20px;
}
.modal-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #495057;
  margin-bottom: 14px;
}
.modal-desc strong { color: #1E3A5F; }

.modal-info {
  background: #F8FBFF;
  border: 1px solid #BDD7EE;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.6;
  color: #2c3e50;
}
.modal-info strong {
  display: block;
  color: #1E3A5F;
  margin-bottom: 6px;
  font-size: 13px;
}
.modal-info ol {
  margin-left: 18px;
  color: #495057;
}
.modal-info ol li { margin-bottom: 3px; }
.modal-info a {
  color: #1A5276;
  font-weight: 700;
  text-decoration: underline;
}
.modal-note {
  margin-top: 6px;
  color: #6c757d;
  font-size: 11px;
  font-style: italic;
}

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #1E3A5F;
  margin-bottom: 4px;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #DEE2E6;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  outline: none;
  transition: border-color 0.2s;
}
.modal-input:focus {
  border-color: #1E3A5F;
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}
.modal-security {
  margin-top: 8px;
  font-size: 11px;
  color: #27AE60;
  font-weight: 600;
}

.modal-footer {
  padding: 12px 20px;
  background: #F8F9FA;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #DEE2E6;
}
.modal-footer button {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-modal-clear {
  background: #fff;
  color: #C0392B;
  border: 1px solid #C0392B !important;
  margin-right: auto;
}
.btn-modal-clear:hover { background: #FFF5F5; }
.btn-modal-cancel {
  background: #ECEFF1;
  color: #495057;
}
.btn-modal-cancel:hover { background: #DDE2E5; }
.btn-modal-save {
  background: #1A5276;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,82,118,0.3);
}
.btn-modal-save:hover { background: #154360; }

/* ═══════════════════════════════════════════════════════════
   기본 리셋 & 글로벌
═══════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Malgun Gothic', '맑은 고딕', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #1a1a1a;
  background: #ECEFF1;
}

/* ═══════════════════════════════════════════════════════════
   랜딩 화면
═══════════════════════════════════════════════════════════ */
.landing-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #1E3A5F 0%, #2C3E7A 100%);
  padding: 20px 16px 40px;
}
.landing-container {
  max-width: 1100px;
  margin: 0 auto;
}

.landing-header {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 24px;
}
.logo-area {
  display: flex; align-items: center; gap: 18px;
}
.logo-icon {
  font-size: 48px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}
.landing-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.landing-header .subtitle {
  font-size: 12px;
  color: #BBD4F0;
  font-weight: 500;
}

.landing-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 안내 섹션 */
.intro-section {
  background: #fff;
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}
.intro-section h2 {
  font-size: 18px;
  color: #1E3A5F;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #EBF2FA;
}
.step-list {
  list-style: none;
  counter-reset: stepc;
}
.step-list li {
  counter-increment: stepc;
  position: relative;
  padding: 8px 0 8px 44px;
  font-size: 14px;
  line-height: 1.6;
  color: #2c3e50;
}
.step-list li::before {
  content: counter(stepc);
  position: absolute;
  left: 0; top: 8px;
  width: 30px; height: 30px;
  background: #1E3A5F;
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.step-list strong {
  color: #1E3A5F;
  margin-right: 4px;
}

/* 업로드 섹션 */
.upload-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}
.upload-zone-main {
  border: 3px dashed #BDD7EE;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  background: #F8FBFF;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone-main:hover {
  border-color: #1E3A5F;
  background: #EBF2FA;
}
.upload-zone-main.dragover {
  border-color: #C0392B;
  background: #FFF5F5;
}
.upload-icon {
  font-size: 56px;
  margin-bottom: 12px;
}
.upload-zone-main h3 {
  font-size: 18px;
  color: #1E3A5F;
  margin-bottom: 6px;
}
.upload-zone-main p {
  font-size: 13px;
  color: #6c757d;
  margin-bottom: 4px;
}
.upload-hint {
  font-size: 11px !important;
  color: #adb5bd !important;
  margin-bottom: 16px !important;
}
.btn-upload {
  margin-top: 12px;
  padding: 12px 28px;
  background: #1E3A5F;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30,58,95,0.3);
  transition: all 0.2s;
}
.btn-upload:hover {
  background: #2C3E7A;
  transform: translateY(-1px);
}

/* 미리보기 영역 */
.preview-area {
  background: #fff;
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  margin-top: 20px;
}
.preview-area h3 {
  font-size: 16px;
  color: #1E3A5F;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #EBF2FA;
}
#photoCount {
  color: #C0392B;
  font-weight: 800;
}
.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.preview-item {
  background: #F8F9FA;
  border: 1px solid #DEE2E6;
  border-radius: 8px;
  padding: 12px;
  position: relative;
}
.preview-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
}
.preview-item .preview-num {
  position: absolute;
  top: 16px; left: 16px;
  background: #C0392B;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}
.preview-item input[type="text"],
.preview-item textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #CED4DA;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  margin-bottom: 6px;
}
.preview-item label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #495057;
  margin-bottom: 3px;
}
.preview-item textarea { min-height: 50px; resize: vertical; }
.preview-item .remove-btn {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.preview-item .remove-btn:hover { background: #C0392B; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #DEE2E6;
}
.btn-primary, .btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-primary {
  background: #C0392B;
  color: #fff;
  box-shadow: 0 4px 12px rgba(192,57,43,0.3);
}
.btn-primary:hover {
  background: #A93226;
  transform: translateY(-1px);
}
.btn-secondary {
  background: #ECEFF1;
  color: #495057;
}
.btn-secondary:hover { background: #DDE2E5; }

/* 정보 카드 그리드 */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.info-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  color: #fff;
  backdrop-filter: blur(6px);
}
.info-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.info-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.info-card p {
  font-size: 11px;
  color: #BBD4F0;
  line-height: 1.5;
}

/* 푸터 */
.landing-footer {
  text-align: center;
  margin-top: 28px;
  padding: 18px;
  color: #BBD4F0;
}
.landing-footer p {
  font-size: 12px;
  margin-bottom: 4px;
}
.footer-sub {
  font-size: 10px !important;
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════
   보고서 화면
═══════════════════════════════════════════════════════════ */
.report-screen { background: #ECEFF1; }

.control-panel {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: #1E3A5F;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
.control-panel .logo {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: auto;
}
.btn {
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
  font-family: inherit;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-back { background: #6C757D; color: #fff; }
.btn-pdf  { background: #e74c3c; color: #fff; }
.btn-word { background: #2980b9; color: #fff; }

.reports-wrap {
  padding-top: 70px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

/* 보고서 페이지 (A4) */
.report-page {
  width: 210mm;
  min-height: 297mm;
  padding: 12mm 16mm;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  page-break-after: always;
  break-after: page;
  position: relative;
  overflow: hidden;
}

/* 헤더 */
.rpt-header {
  display: flex;
  margin-bottom: 10px;
  border-radius: 4px;
  overflow: hidden;
}
.rpt-header-main {
  flex: 1;
  background: #1E3A5F;
  padding: 12px 18px;
}
.rpt-header-main h1 {
  font-size: 19px;
  color: #fff;
  font-weight: 700;
  margin-bottom: 3px;
}
.rpt-header-main p {
  font-size: 10px;
  color: #AACCEE;
}
.rpt-header-badge {
  width: 64px;
  background: #C0392B;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.rpt-header-badge .pg-num {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.rpt-header-badge .pg-tot {
  font-size: 10px;
  color: #FFCCCC;
}

/* 섹션 타이틀 */
.section-title {
  background: #1E3A5F;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  margin-bottom: 0;
  border-radius: 3px 3px 0 0;
}
.section-title.red  { background: #A93226; }
.section-title.blue { background: #1A5276; }
.section-title.teal { background: #2C3E7A; }

/* 현장 개요 테이블 */
.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: 10px;
}
.overview-table td {
  border: 1px solid #BDD7EE;
  padding: 7px 10px;
  vertical-align: top;
  line-height: 1.5;
}
.overview-table .label {
  background: #EBF2FA;
  font-weight: 700;
  color: #1E3A5F;
  width: 18%;
  white-space: nowrap;
}

/* 사진 + 위험평가 분할 */
.split-zone {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.photo-box {
  width: 42%;
  background: #F8F9FA;
  border: 1px solid #DEE2E6;
  border-radius: 3px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 180px;
}
.photo-box .photo-label {
  font-size: 11px;
  font-weight: 700;
  color: #495057;
  margin-bottom: 6px;
}
.photo-box img {
  max-width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border-radius: 2px;
}
.photo-box .photo-caption {
  font-size: 9px;
  color: #6C757D;
  font-style: italic;
  margin-top: 5px;
  text-align: center;
}
.upload-zone {
  margin-top: 6px;
}
.upload-zone label {
  display: inline-block;
  padding: 4px 10px;
  background: #495057;
  color: #fff;
  font-size: 9px;
  border-radius: 3px;
  cursor: pointer;
}
.upload-zone input { display: none; }

.risk-box { flex: 1; }

/* 위험평가 테이블 */
.risk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}
.risk-table th {
  background: #F1F3F5;
  font-size: 10px;
  font-weight: 700;
  color: #1E3A5F;
  border: 1px solid #DEE2E6;
  padding: 6px 5px;
  text-align: center;
}
.risk-table td {
  border: 1px solid #DEE2E6;
  padding: 6px 5px;
  vertical-align: middle;
}
.risk-table tr:nth-child(even) td { background: #F8F9FA; }
.risk-table .factor { font-size: 10.5px; line-height: 1.4; }
.risk-table .num {
  text-align: center;
  font-weight: 700;
  color: #1A5276;
  font-size: 12px;
}
.risk-table .score {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
}

.grade-badge {
  display: block;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  padding: 3px 5px;
  border-radius: 3px;
}
.grade-critical { background: #C0392B; }
.grade-high     { background: #E67E22; }
.grade-med      { background: #F39C12; }
.grade-low      { background: #27AE60; }

/* 시나리오 박스 */
.scenario-box {
  background: #FFF5F5;
  border-left: 5px solid #C0392B;
  border-top: 1px solid #C0392B;
  border-bottom: 1px solid #C0392B;
  border-right: 1px solid #C0392B;
  padding: 8px 14px;
  font-size: 11px;
  line-height: 1.7;
  margin-bottom: 10px;
  border-radius: 0 3px 3px 0;
}
.scenario-box .warn {
  color: #C0392B;
  font-weight: 700;
}

/* Action Plan */
.action-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}
.action-table td {
  border: 1px solid #BDD7EE;
  padding: 6px 10px;
  vertical-align: middle;
  line-height: 1.5;
}
.action-table .num {
  width: 32px;
  text-align: center;
  font-weight: 700;
  color: #1A5276;
  font-size: 12px;
}
.action-table tr:nth-child(odd) td { background: #EBF2FA; }

/* 푸터 */
.rpt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid #1E3A5F;
  padding-top: 5px;
  margin-top: 8px;
  font-size: 9px;
  color: #6C757D;
}

/* ═══════════════════════════════════════════════════════════
   인쇄 미디어 쿼리
═══════════════════════════════════════════════════════════ */
@media print {
  body { background: #fff; }
  @page { size: A4; margin: 0; }

  #landing { display: none !important; }
  .control-panel,
  .upload-zone,
  .btn-back,
  .btn-pdf,
  .btn-word { display: none !important; }

  .reports-wrap {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    gap: 0 !important;
  }
  .report-page {
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: always;
    break-after: page;
  }
}

/* ═══════════════════════════════════════════════════════════
   반응형 (모바일)
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .landing-header h1 { font-size: 18px; }
  .landing-header .subtitle { font-size: 10px; }
  .logo-icon { font-size: 36px; }
  .upload-zone-main { padding: 32px 16px; }
  .upload-icon { font-size: 44px; }
  .upload-zone-main h3 { font-size: 16px; }
  .preview-list { grid-template-columns: 1fr 1fr; }
  .control-panel { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .control-panel .logo { font-size: 12px; flex-basis: 100%; }
  .btn { padding: 7px 12px; font-size: 11px; }
  .report-page {
    width: 100%;
    min-height: auto;
    padding: 14px 16px;
  }
}

/* 로딩 오버레이 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,58,95,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  flex-direction: column;
  color: #fff;
}
.loading-overlay .spinner {
  width: 60px; height: 60px;
  border: 5px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p {
  font-size: 14px;
  font-weight: 600;
}
