*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; background: #F0F4F8; }

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: #1A1A2E;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #F0F4F8;
  position: relative;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
  position: relative;
}
.home-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid #D1D9E6;
  background: #FFF;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #5A6B7F;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.home-btn:hover { color: #003366; border-color: #003366; }
.header-logo {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid #D1D9E6;
}
.header-text { display: flex; flex-direction: column; gap: 1px; }
.header-title { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; color: #003366; }
.header-sub { font-size: 11.5px; font-weight: 500; color: #5A6B7F; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.tab {
  flex: 1; height: 40px;
  border-radius: 999px;
  border: none; cursor: pointer;
  font-family: inherit;
  font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: #E4EAF2; color: #5A6B7F;
  transition: all 0.25s;
}
.tab.active { background: #003366; color: #FFF; }
.tab .badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: #FFF; color: #003366;
}
.tab.active .badge { background: rgba(255,255,255,0.2); color: #FFF; }

/* ── Views ── */
.views {
  flex: 1; overflow: hidden; position: relative;
}
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), opacity 0.3s;
}
.chat-view { transform: translateX(0); opacity: 1; }
.report-view { transform: translateX(100%); opacity: 0; overflow-y: auto; }
.chat-view.hidden { transform: translateX(-100%); opacity: 0; pointer-events: none; }
.report-view.active { transform: translateX(0); opacity: 1; pointer-events: all; }

/* ── Progress Badge ── */
.progress-badge {
  position: absolute; top: 8px; right: 14px; z-index: 5;
  border: 1px solid #D1D9E6;
  background: #FFF; color: #003366;
  font-family: inherit; font-size: 11.5px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,51,102,0.10);
  display: flex; align-items: center; gap: 6px;
}
.progress-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #003366; display: inline-block;
}

/* ── Messages ── */
.messages {
  flex: 1; overflow-y: auto;
  padding: 44px 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: #C0C8D4; border-radius: 2px; }

.msg-row {
  display: flex; gap: 8px;
  justify-content: flex-start;
  animation: msgIn 0.25s ease both;
}
.msg-row.user { justify-content: flex-end; }
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #FFF;
  border: 1px solid #D1D9E6;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-top: 2px;
}
.msg-avatar img { width: 24px; height: 24px; object-fit: contain; }
.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  background: #FFF;
  color: #1A1A2E;
  font-size: 14px; line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,51,102,0.08);
  white-space: pre-wrap;
}
.msg-row.user .msg-bubble {
  border-radius: 16px 16px 4px 16px;
  background: #003366;
  color: #FFF;
  box-shadow: 0 2px 6px rgba(0,51,102,0.22);
}

/* Typing */
.typing-row { display: flex; gap: 8px; align-items: center; }
.typing-dots {
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px;
  background: #FFF;
  box-shadow: 0 1px 3px rgba(0,51,102,0.08);
  display: flex; gap: 5px;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5A6B7F;
  animation: typingDot 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes msgIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes typingDot { 0%,60%,100% { transform:translateY(0); opacity:0.4; } 30% { transform:translateY(-4px); opacity:1; } }
@keyframes fieldFlash { 0% { background:#E3EDF7; } 100% { background:transparent; } }

/* ── Voice Panel ── */
.voice-panel {
  flex-shrink: 0; margin: 0 14px 8px;
  background: #FFF;
  border: 1px solid #D1D9E6;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,51,102,0.14);
  padding: 14px 16px 12px;
  animation: panelUp 0.25s ease both;
}
.voice-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rec-dot { width:8px;height:8px;border-radius:50%;background:#B3261E;animation:recBlink 1.1s infinite;flex-shrink:0; }
.voice-label { font-size:11.5px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;color:#1B3A5C; }
.wave-bars { display:flex;align-items:center;gap:2.5px;height:16px;margin-left:4px; }
.wave-bars span { width:3px;height:14px;border-radius:2px;background:#003366;animation:waveBar 0.9s ease-in-out infinite; }
.wave-bars span:nth-child(2){animation-delay:.12s;} .wave-bars span:nth-child(3){animation-delay:.24s;} .wave-bars span:nth-child(4){animation-delay:.36s;} .wave-bars span:nth-child(5){animation-delay:.48s;}
.voice-speaker { margin-left:auto; font-size:11px; font-weight:600; color:#5A6B7F; }
.voice-transcript { min-height:40px; font-size:14.5px; line-height:1.5; color:#1A1A2E; }
.voice-transcript.placeholder { color:#5A6B7F; font-style:normal; font-weight:500; }
.voice-actions { display:flex;gap:8px;justify-content:flex-end;margin-top:10px; }

@keyframes recBlink { 0%,100%{opacity:1;} 50%{opacity:0.3;} }
@keyframes waveBar { 0%,100%{transform:scaleY(0.3);} 50%{transform:scaleY(1);} }
@keyframes panelUp { from{opacity:0;transform:translateY(14px);} to{opacity:1;transform:translateY(0);} }

/* ── Input Bar ── */
.input-bar {
  flex-shrink: 0; padding: 10px 14px 16px;
  display: flex; gap: 8px; align-items: flex-end;
  background: #F0F4F8;
  position: sticky;
  bottom: 0;
  z-index: 10;
}
.input-wrapper {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: #FFF;
  border: 1px solid #D1D9E6;
  border-radius: 999px;
  padding: 0 6px 0 16px;
  min-height: 46px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper:focus-within {
  border-color: #003366;
  box-shadow: 0 0 0 3px rgba(0,51,102,0.12);
}
.input-wrapper textarea {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 14px; color: #1A1A2E;
  background: transparent; min-width: 0;
  resize: none; max-height: 120px; overflow-y: auto;
  line-height: 1.4; padding: 13px 0;
}
.mic-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #E4EAF2; color: #1B3A5C;
  transition: all 0.2s;
}
.mic-btn:hover { background: #D1D9E6; }
.mic-btn.recording { background: #B3261E; color: #FFF; animation: micPulse 1.2s infinite; }
.mic-btn.disabled { opacity: 0.35; cursor: not-allowed; }
@keyframes micPulse { 0%{box-shadow:0 0 0 0 rgba(179,38,30,0.35);} 100%{box-shadow:0 0 0 12px rgba(179,38,30,0);} }

.send-btn {
  width: 46px; height: 46px;
  border-radius: 50%; border: none;
  cursor: pointer; background: #1B3A5C; color: #FFF;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(27,58,92,0.3);
  transition: background 0.2s;
}
.send-btn:hover { background: #003366; }

/* ── Buttons ── */
.btn {
  font-family: inherit; font-weight: 600;
  border: none; cursor: pointer;
  border-radius: 999px;
  transition: all 0.2s;
}
.btn-cancel { height:36px;padding:0 16px;border:1px solid #D1D9E6;background:#FFF;color:#5A6B7F;font-size:12.5px; }
.btn-cancel:hover { color:#B3261E;border-color:#B3261E; }
.btn-use { height:36px;padding:0 18px;background:#1B3A5C;color:#FFF;font-size:12.5px;font-weight:700; }
.btn-use:hover { background:#003366; }
.btn-outline { border:1px solid #D1D9E6;background:#FFF;font-size:12px;color:#5A6B7F;padding:6px 14px; }
.btn-outline:hover { color:#B3261E;border-color:#B3261E; }

/* ── Report View ── */
.report-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 16px 12px;
}
.back-btn {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: #003366; display: flex; align-items: center; gap: 4px; padding: 6px 0;
}

/* Success Banner */
.success-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: #E8F3EC; border: 1px solid #BBDCC7;
  border-radius: 12px; padding: 12px 14px;
  margin: 0 16px 12px;
  font-size: 12.5px; line-height: 1.5; color: #1A4227;
}
.success-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: #1E7A3C; color: #FFF;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Report Sheet */
.report-sheet {
  background: #FFF;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,51,102,0.10);
  padding: 24px 22px 26px;
  margin: 0 16px;
}
.report-letterhead {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border-bottom: 2px solid #003366;
  padding-bottom: 16px;
}
.report-logo { width: 64px; height: 64px; object-fit: contain; }
.report-title { font-size:16px;font-weight:800;letter-spacing:0.06em;color:#003366;text-align:center; }
.report-subtitle { font-size:12px;font-weight:700;letter-spacing:0.18em;color:#5A6B7F; }
.report-meta { display:flex;gap:16px;margin-top:4px;font-size:11.5px;color:#5A6B7F; }
.report-meta strong { color:#1A1A2E; }

/* Report Sections */
.report-section { padding-top: 18px; }
.report-section-title {
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em;
  color: #003366; text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1px solid #E4EAF2;
  margin-bottom: 4px;
}
.report-field {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px dashed #EDF1F7;
  border-radius: 6px;
  transition: background 0.8s;
}
.report-field.flash { animation: fieldFlash 1.6s ease both; }
.report-field-label {
  width: 118px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; color: #5A6B7F;
  padding-top: 2px;
}
.report-field-value {
  flex: 1; min-width: 0;
  font-size: 13.5px; font-weight: 600; color: #1A1A2E;
  line-height: 1.45; word-break: break-word;
}
.report-field-value.pending { font-weight: 500; color: #B6C2D1; }
.report-field-edit {
  border: none; background: none; cursor: pointer;
  color: #5A6B7F; padding: 2px 4px; flex-shrink: 0;
  opacity: 0.7; display: flex; align-items: center;
}
.report-field-edit:hover { opacity: 1; color: #003366; }
.report-field-input {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 13px; color: #1A1A2E;
  background: #FFF; border: 1px solid #003366;
  border-radius: 8px; padding: 6px 10px; outline: none;
  box-shadow: 0 0 0 3px rgba(0,51,102,0.12);
}
.report-field-save {
  border: none; background: #1B3A5C; color: #FFF;
  font-family: inherit; font-size: 11.5px; font-weight: 700;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
}

.report-footer {
  margin-top: 22px; padding-top: 14px;
  border-top: 1px solid #E4EAF2;
  font-size: 10.5px; color: #5A6B7F; line-height: 1.5;
  text-align: center;
}

/* Download Button */
.download-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 16px auto 24px;
  min-height: 52px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #2D2D2D;
  color: #FFF;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transition: background 0.2s;
  box-sizing: border-box;
  line-height: 1.4;
}
.download-btn:hover { background: #1B3A5C; }

.hidden { display: none !important; }

/* ── Responsive (desktop: wider layout) ── */
@media (min-width: 900px) {
  #app { max-width: 520px; }
}
@media (min-width: 1200px) {
  body { align-items: center; }
}

/* ── Print Styles ── */
.print-sheet {
  display: none;
  background: #FFF; color: #000;
  font-family: "Plus Jakarta Sans", sans-serif;
  padding: 0;
}
.print-letterhead {
  display:flex;align-items:center;gap:18px;
  padding-bottom:14px;border-bottom:3px double #000;
}
.print-main-title { font-size:20px;font-weight:800;letter-spacing:0.10em;color:#000; }
.print-sub-title { font-size:11px;font-weight:600;letter-spacing:0.28em;color:#444;margin-top:3px; }
.print-motto { font-size:9.5px;font-weight:500;letter-spacing:0.06em;color:#666;margin-top:4px; }
.print-meta-right { text-align:right;font-size:10px;color:#444;line-height:1.7; }
.print-report-no { font-size:13px;font-weight:800;color:#000;letter-spacing:0.04em; }
.print-filed-date { font-size:11px;font-weight:700;color:#000; }

.print-notice {
  display:flex;justify-content:space-between;align-items:center;
  padding:8px 0;border-bottom:1px solid #000;
  font-size:9px;letter-spacing:0.12em;color:#444;font-weight:600;
}

.print-section { padding-top:20px; break-inside:avoid; }
.print-section-header { display:flex;align-items:baseline;gap:10px;margin-bottom:8px; }
.print-section-title { font-size:11px;font-weight:800;letter-spacing:0.20em;text-transform:uppercase;color:#000;white-space:nowrap; }
.print-section-line { flex:1;border-bottom:1px solid #000; }
.print-field { display:flex;gap:14px;padding:7px 2px;border-bottom:1px solid #DDD;break-inside:avoid; }
.print-field-label { width:160px;flex-shrink:0;font-size:9.5px;font-weight:700;letter-spacing:0.10em;text-transform:uppercase;color:#555;padding-top:2px; }
.print-field-value { flex:1;font-size:12px;font-weight:500;color:#000;line-height:1.5;word-break:break-word; }
.print-field-value.empty { color:#AAA; }

.print-signatures { display:flex;gap:40px;margin-top:44px;break-inside:avoid; }
.print-sig-block { flex:1; }
.print-sig-line { border-bottom:1px solid #000;height:34px; }
.print-sig-label { font-size:9px;font-weight:700;letter-spacing:0.14em;color:#444;margin-top:5px; }
.print-sig-name { font-size:10.5px;font-weight:600;color:#000;margin-top:2px; }
.print-footer { margin-top:28px;padding-top:10px;border-top:2px solid #000;display:flex;justify-content:space-between;font-size:8.5px;letter-spacing:0.08em;color:#666; }

@media print {
  body * { visibility: hidden; }
  #printSheet, #printSheet * { visibility: visible; }
  #printSheet { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  @page { margin: 18mm 16mm; }
}

/* ── Cover Screen ── */
.cover-screen {
  position: fixed; inset: 0; z-index: 200;
  height: 100vh;
  height: 100dvh;
  background: #F0F4F8;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  transition: opacity 0.4s ease;
}
.cover-screen.fade-out { opacity: 0; pointer-events: none; }

.cover-content {
  max-width: 420px; width: 100%;
  padding: 48px 32px;
  display: flex; flex-direction: column; align-items: center;
}

.cover-logo {
  width: 88px; height: 88px;
  object-fit: contain;
  border-radius: 50%;
  border: 3px solid #D1D9E6;
  margin-bottom: 20px;
}
.cover-title {
    font-size: 22px; font-weight: 800;
    letter-spacing: 0.04em;
    color: #003366;
    margin-bottom: 6px;
    text-align: center;
  }
.cover-subtitle {
    font-size: 15px; font-weight: 600;
    color: #1A1A2E;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
  }
  .cover-tagline {
    font-size: 12px; font-weight: 500;
    color: #5A6B7F;
    margin-bottom: 28px;
    font-style: italic;
  }
.cover-welcome {
  font-size: 14.5px; line-height: 1.6;
  color: #1A1A2E; text-align: center;
  margin-bottom: 36px;
}

.cover-steps {
  width: 100%;
  margin-bottom: 36px;
  background: #FFFFFF;
  border: 1px solid #D1D9E6;
  border-radius: 14px;
  padding: 0 20px;
}
.cover-step {
  display: flex; gap: 16px;
  padding: 18px 0;
  border-top: 1px solid #E4EAF2;
}
.cover-step:last-child { border-bottom: 1px solid #D1D9E6; }
.cover-step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #003366;
  color: #FFF;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cover-step-text { padding-top: 4px; }
.cover-step-title {
  font-size: 14px; font-weight: 700;
  color: #003366; margin-bottom: 3px;
}
.cover-step-desc {
  font-size: 13px; line-height: 1.5;
  color: #5A6B7F;
}

.cover-btn {
  width: 100%; height: 54px;
  border: none; border-radius: 999px;
  background: #1A1A2E; color: #FFF;
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,26,46,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.cover-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26,26,46,0.25);
}

.app-hidden { display: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal-card {
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  padding: 32px 28px 24px;
  max-width: 340px; width: calc(100% - 48px);
  text-align: center;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}
.modal-overlay.active .modal-card {
  transform: translateY(0);
}
.modal-logo {
  width: 56px; height: 56px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid #D1D9E6;
  margin: 0 auto 16px;
  display: block;
}
.modal-title {
  font-size: 17px; font-weight: 700;
  color: #003366;
  margin-bottom: 8px;
}
.modal-message {
  font-size: 14px; line-height: 1.5;
  color: #5A6B7F;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex; gap: 10px;
}
.modal-btn {
  flex: 1; height: 44px;
  border: none; border-radius: 999px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-btn-cancel {
  background: #F0F4F8;
  color: #5A6B7F;
  border: 1px solid #D1D9E6;
}
.modal-btn-cancel:hover {
  background: #E4EAF2;
}
.modal-btn-confirm {
  background: #003366;
  color: #FFFFFF;
}
.modal-btn-confirm:hover {
  background: #1B3A5C;
}
.modal-btn-confirm.danger {
  background: #B3261E;
}
.modal-btn-confirm.danger:hover {
  background: #8B1E17;
}

/* ── Mobile welcome toggle ── */
.cover-welcome-short { display: none; }
.cover-welcome-full { display: none; }

@media (max-width: 768px) {
  .cover-welcome-short { display: none; }
  .cover-welcome-full { display: none; }
}
