/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1a1a1a;
  background: #f5f6f8;
  line-height: 1.5;
}

.app-shell {
  max-width: 880px;
  margin: 32px auto;
  padding: 0 20px 64px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.2px;
}

.app-header .tagline {
  margin: 0 0 24px;
  color: #555;
  font-size: 14px;
}

.card {
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}

.muted { color: #6b7280; }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

.row { display: flex; align-items: center; gap: 14px; }
.row.between { justify-content: space-between; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  color: #4b5563;
  font-weight: 500;
  gap: 4px;
}

input[type="text"],
input[type="number"],
textarea {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid #cfd4dc;
  border-radius: 6px;
  background: #fff;
  width: 100%;
  color: #1a1a1a;
}

input[type="file"] {
  font: inherit;
  font-size: 13.5px;
  padding: 6px 0;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  resize: vertical;
  width: 100%;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  background: #eef0f3;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #1a4dbd;
  color: #fff;
  cursor: pointer;
  transition: background 120ms;
}

button:hover:not(:disabled) { background: #14409f; }
button:disabled {
  background: #c9cfd9;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  color: #1a4dbd;
  border: 1px solid #1a4dbd;
}
button.secondary:hover:not(:disabled) {
  background: #f0f4ff;
}

/* ── Loading bar ──────────────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 4px;
  background: #e6e9ee;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1a4dbd, #4a78dd);
  transition: width 200ms;
}

#status-text {
  font-weight: 500;
  font-size: 14.5px;
}
#status-detail {
  font-size: 12.5px;
  margin-top: 4px;
}

/* ── Report iframe container ──────────────────────────────────────────── */
/* The report renders inside an iframe (srcdoc) so the notebook's own
   styles (.page, .cover, .section-title, .scorecard, etc) don't clash
   with the app chrome. The iframe also makes "Save as PDF" trivial:
   we call print() on the iframe, so the PDF contains only the report. */
#report-output:empty { display: none; }

#report-output {
  max-width: 1040px;
  margin: 0 auto 64px;
}

#report-output iframe {
  display: block;
  width: 100%;
  border: 1px solid #e2e5ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* ── Error banner ─────────────────────────────────────────────────────── */
.error-banner {
  background: #fff0f0;
  border: 1px solid #ff8888;
  color: #8a1f1f;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 13px;
}

/* ── Footnotes / definitions ──────────────────────────────────────────── */
.footnotes {
  border-top: 1px solid #eceef1;
  padding-top: 10px;
  color: #6b7280;
}
.footnotes sup { color: #1a4dbd; font-weight: 700; }
label sup { color: #1a4dbd; font-weight: 700; }

.required-tag { color: #b4232b; font-weight: 600; }

/* ── Data-format documentation (collapsible) ──────────────────────────── */
.data-doc {
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 0 6px;
  background: #fbfcfd;
}
.data-doc > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1a4dbd;
  list-style: revert;
}
.data-doc[open] > summary { margin-bottom: 6px; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0;
}
.doc-table th,
.doc-table td {
  border: 1px solid #e2e5ea;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.doc-table th {
  background: #1a4080;
  color: #fff;
  font-weight: 600;
}
.doc-table tr:nth-child(even) td { background: #f5f7fa; }
.doc-table code { font-size: 11px; }

/* ── Print rules ──────────────────────────────────────────────────────────
   Save-as-PDF is triggered on the iframe directly (see app.js), so the host
   page's print stylesheet rarely matters. Keep no-print for fallback when
   users hit the browser's own Print menu instead of our button. */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  #report-output, #report-output iframe {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: 100%;
  }
}
