:root {
  --navy: #14325c;
  --navy-light: #1c4880;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1c1c1c;
  --muted: #667085;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

.topbar {
  height: 64px;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: white;
  color: var(--navy);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.brand-name { font-size: 17px; font-weight: 600; }
.brand-tag { color: #cdd9ea; font-size: 13px; border-left: 1px solid rgba(255,255,255,0.25); padding-left: 18px; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  max-width: 1280px;
  margin: 28px auto;
  gap: 24px;
  padding: 0 24px;
  align-items: start;
}

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  position: sticky;
  top: 28px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sidebar-header h2 { font-size: 15px; margin: 0; color: var(--navy); text-transform: uppercase; letter-spacing: 0.5px; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 15px;
  color: var(--navy);
}
.icon-btn:hover { background: var(--bg); }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfc;
}
.history-card .title { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.history-card .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.history-card .links { display: flex; flex-direction: column; gap: 6px; }

.pdf-btn-group { display: flex; gap: 6px; }
.pdf-view-btn, .pdf-download-btn {
  font-size: 11.5px;
  font-family: inherit;
  color: var(--navy);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 5px;
  background: white;
  cursor: pointer;
  flex: 1;
  text-align: center;
}
.pdf-view-btn:hover, .pdf-download-btn:hover { background: var(--navy); color: white; }
.pdf-download-btn { flex: 0 0 auto; }

.empty-state { color: var(--muted); font-size: 13px; padding: 12px 0; }

.main { min-width: 0; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.form-panel h1 { margin-top: 0; font-size: 22px; color: var(--navy); }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 620px; }

form { margin-top: 22px; display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.field input {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(20,50,92,0.12); }
.field-inline { max-width: 220px; }

.checkbox-row { display: flex; gap: 22px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; cursor: pointer; }
.checkbox-item input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--navy); }

.tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 0; }
.tag-chip {
  background: #eef3fa;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid #d4e0f0;
}

.primary-btn {
  align-self: flex-start;
  background: var(--navy);
  color: white;
  border: none;
  padding: 12px 26px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
.primary-btn:hover { background: var(--navy-light); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.status-box {
  margin-top: 26px;
  background: #eef3fa;
  border-left: 4px solid var(--navy);
  padding: 18px 20px;
  border-radius: 6px;
  max-width: 620px;
}

.steps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 30px;
  bottom: -9px;
  width: 2px;
  background: var(--border);
}
.step-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.step.done .step-icon { border-color: #2e8b46; background: #2e8b46; }
.step.done .step-icon::after { content: "\2713"; color: white; font-size: 12px; font-weight: 700; }
.step.active .step-icon { border-color: var(--navy); }
.step.active .step-icon::after {
  content: "";
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--navy);
  animation: pulse 1s ease-in-out infinite;
}
.step.done .step-label { color: var(--text); }
.step.active .step-label { color: var(--navy); font-weight: 700; }
.step.skipped { opacity: 0.4; }
.step.skipped .step-label { text-decoration: line-through; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.7); } }

.step-body { flex: 1; min-width: 0; padding-top: 1px; }
.step-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step-progress {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
  width: 100%;
  display: none;
}
.step.active .step-progress, .step.done .step-progress { display: block; }
.step-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--navy);
  transition: width 0.4s ease;
}
.step-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.status-current-text {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}

.result-box {
  margin-top: 26px;
  background: #f0f9f2;
  border-left: 4px solid #2e8b46;
  padding: 16px 18px;
  border-radius: 6px;
  max-width: 620px;
}
.result-box h3 { margin: 0 0 12px; font-size: 15px; color: #1f6b30; }
.result-links { display: flex; gap: 14px; flex-wrap: wrap; }

.result-links .pdf-btn-group { gap: 8px; }
.result-links .pdf-view-btn, .result-links .pdf-download-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  flex: none;
}
.result-links .pdf-view-btn { background: var(--navy); color: white; }
.result-links .pdf-view-btn:hover { background: var(--navy-light); }
.result-links .pdf-download-btn { background: white; color: var(--navy); border: 1px solid var(--navy); }
.result-links .pdf-download-btn:hover { background: #eef3fa; }

.error-box {
  margin-top: 26px;
  background: #fdf0f0;
  border-left: 4px solid #c0392b;
  color: #922b21;
  padding: 14px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  max-width: 620px;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.pdf-modal.hidden { display: none; }
.pdf-modal::before { content: ""; position: absolute; inset: 0; }
.pdf-modal-bar {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 92vw);
  background: var(--navy);
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  z-index: 1001;
}
.pdf-modal-actions { display: flex; align-items: center; gap: 10px; }
.pdf-modal-actions .pdf-download-btn {
  background: white;
  color: var(--navy);
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
.pdf-modal-actions #pdf-modal-close {
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  font-size: 20px;
  line-height: 1;
  width: 30px; height: 30px;
}
.pdf-modal-frame {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 92vw);
  height: calc(100vh - 110px);
  border: none;
  border-radius: 0 0 10px 10px;
  background: white;
  z-index: 1001;
}

.hidden { display: none !important; }
