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

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --navy:      #1e3a5f;
  --navy-d:    #152c47;
  --blue:      #2563eb;
  --blue-d:    #1d4ed8;
  --bg:        #f5f4f1;
  --surface:   #ffffff;
  --border:    #dddbd4;
  --border-s:  #c8c5bc;
  --text:      #111827;
  --muted:     #6b6f7a;
  --green:     #065f46;
  --green-bg:  #f0fdf4;
  --green-brd: #bbf7d0;
  --amber-bg:  #fffbeb;
  --amber-brd: #fde68a;
  --amber-tx:  #78350f;
  --red:       #dc2626;
  --red-bg:    #fef2f2;
  --red-brd:   #fecaca;
  --r:         6px;
  --r-lg:      10px;
  --max:       1100px;
  --form-max:  540px;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
p { line-height: 1.65; }

/* ── Language ────────────────────────────────────────────────────────────── */
body.lang-es .show-en { display: none; }
body.lang-en .show-es { display: none; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  background: var(--navy);
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  min-width: 0;
}
.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.nav-tagline {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.pill-sm {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}
.lang-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  border-radius: var(--r);
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.15s;
  flex-shrink: 0;
}
.lang-btn:hover { background: rgba(255,255,255,0.2); }

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

/* ── Form layout: form + sidebar ─────────────────────────────────────────── */
.form-layout {
  display: grid;
  grid-template-columns: var(--form-max) 1fr;
  gap: 2rem;
  align-items: start;
}

/* ── Form card ───────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.form-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.form-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.field { margin-bottom: 1.1rem; }
label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.45rem;
}
.field-note {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}
input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 0.95rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* Drop zone */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border-s);
  border-radius: var(--r);
  background: #fafaf8;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  min-height: 100px;
}
.drop-zone.over, .drop-zone:focus-within {
  border-color: var(--blue);
  background: #eff6ff;
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.drop-inner svg { opacity: 0.4; }
.drop-inner p { font-size: 0.88rem; }
.link { color: var(--blue); font-weight: 500; }
.drop-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 1rem;
  pointer-events: none;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--r);
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  font-size: 0.83rem;
  color: var(--navy);
  font-weight: 500;
  max-width: 260px;
}
.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.15rem;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.file-remove:hover { color: var(--red); background: #fee2e2; }

/* Error */
.error-box {
  padding: 0.7rem 1rem;
  background: var(--red-bg);
  border: 1px solid var(--red-brd);
  border-radius: var(--r);
  color: var(--red);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Submit */
button[type="submit"] {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s;
  letter-spacing: -0.01em;
}
button[type="submit"]:hover { background: var(--navy-d); }
.btn-arrow { font-size: 1.1rem; }

/* ── Trust sidebar ───────────────────────────────────────────────────────── */
.trust-sidebar { padding-top: 0.25rem; }
.trust-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
}
.trust-card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.trust-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.trust-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.trust-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.trust-list strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.trust-list p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.trust-list code {
  background: #f1f0ec;
  padding: 0.05em 0.3em;
  border-radius: 3px;
  font-size: 0.85em;
}
.trust-note {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.55;
}

/* ── Processing ──────────────────────────────────────────────────────────── */
.state-screen {
  padding: 2rem 0;
  display: flex;
  justify-content: flex-start;
}
.state-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  width: 100%;
  max-width: var(--form-max);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.progress-wrap { width: 100%; margin-bottom: 0.5rem; }
.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--navy);
  border-radius: 999px;
}
.state-label { font-size: 0.9rem; color: var(--muted); }

/* ── Report ──────────────────────────────────────────────────────────────── */
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.report-header h2 { font-size: 1.2rem; font-weight: 700; }
.report-subhead { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }
.btn-outline {
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--border-s);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 0.84rem;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }

/* Report body — rendered markdown */
.report-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2.25rem 2.5rem;
  font-size: 0.94rem;
  line-height: 1.75;
}
.report-body h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--navy);
}
.report-body h1:first-child { margin-top: 0; }
.report-body h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}
.report-body h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1.25rem 0 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.report-body p  { margin-bottom: 0.85rem; }
.report-body ul, .report-body ol { margin: 0.5rem 0 0.85rem 1.4rem; }
.report-body li { margin-bottom: 0.35rem; }
.report-body strong { font-weight: 700; }
.report-body blockquote {
  border-left: 3px solid var(--blue);
  padding: 0.5rem 0 0.5rem 1rem;
  color: var(--muted);
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
/* Inline code — keep subtle */
.report-body code {
  background: #f1f0ec;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.87em;
  font-family: inherit;
}
/* Code blocks — render as a financial ledger, not a terminal */
.report-body pre {
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-family: inherit;     /* use body font, not monospace */
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;    /* wrap long lines */
}
.report-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
.report-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* Tables */
.report-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.25rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.report-body thead { background: var(--navy); }
.report-body thead th {
  color: rgba(255,255,255,0.9);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.9rem;
  text-align: left;
  border: none;
}
.report-body tbody tr:nth-child(odd)  td { background: var(--surface); }
.report-body tbody tr:nth-child(even) td { background: #fafaf8; }
.report-body tbody tr:hover td { background: #f0f4ff; }
.report-body td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.report-body tbody tr:last-child td { border-bottom: none; }

/* ── Streaming bar ───────────────────────────────────────────────────────── */
.streaming-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.84rem;
  color: var(--muted);
}
.pulse-dot {
  width: 7px; height: 7px;
  background: var(--blue);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.25; transform: scale(0.6); }
}

/* ── Invite codes ────────────────────────────────────────────────────────── */
.codes-block {
  margin-top: 2rem;
  background: var(--green-bg);
  border: 1px solid var(--green-brd);
  border-radius: var(--r-lg);
  padding: 1.5rem;
}
.codes-header h3 { font-size: 1rem; font-weight: 700; color: var(--green); margin-bottom: 0.5rem; }
.codes-header p  { font-size: 0.88rem; color: #166534; margin-bottom: 1rem; }
.code-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip {
  background: var(--surface);
  border: 1.5px solid var(--green-brd);
  border-radius: var(--r);
  padding: 0.45rem 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: all;
  color: var(--navy);
}
.chip:hover { background: #dcfce7; border-color: #4ade80; }
.chip.copied { border-color: var(--green); color: var(--green); }
.chip.copied::after { content: ' ✓'; }

.report-close-note {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: var(--navy);
  color: rgba(255,255,255,0.55);
  padding: 1.5rem;
  font-size: 0.82rem;
  margin-top: 3rem;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: rgba(255,255,255,0.5); }
.footer-links a:hover { color: rgba(255,255,255,0.85); text-decoration: none; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  nav,
  #upload-section,
  #processing-section,
  #streaming-bar,
  .streaming-bar,
  .report-header .btn-outline,
  .codes-block,
  .report-close-note,
  footer { display: none !important; }

  #report-section { display: block !important; }
  .report-body { border: none !important; padding: 0 !important; font-size: 0.9rem; }
  .report-body table { page-break-inside: avoid; }
  body { background: white !important; }
  main { padding: 0 !important; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .form-layout {
    grid-template-columns: 1fr;
  }
  .trust-sidebar { order: -1; }
}
@media (max-width: 600px) {
  .hero { padding: 2rem 1.25rem; }
  main { padding: 1.5rem 1.25rem 3rem; }
  .form-card { padding: 1.5rem; }
  .report-body { padding: 1.25rem; font-size: 0.88rem; }
  .report-body table { font-size: 0.78rem; }
  .report-body thead th, .report-body td { padding: 0.45rem 0.6rem; }
  .report-header { flex-direction: column; }
}

/* ── Step animation ──────────────────────────────────────────────────────── */
.steps {
  list-style: none;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--r);
  opacity: 0.3;
  transition: opacity 0.35s ease, background 0.35s ease;
}

.step.active {
  opacity: 1;
  background: rgba(37, 99, 235, 0.06);
}

.step.done {
  opacity: 0.6;
}

.step-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.step-text {
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
}

.step-check {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s ease;
  flex-shrink: 0;
}

.step.done .step-check { opacity: 1; }

/* Active step has a subtle left accent */
.step.active .step-icon { filter: none; }
.step:not(.active):not(.done) .step-icon { filter: grayscale(1); }

.step-note {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ── PDF hint ────────────────────────────────────────────────────────────── */
.pdf-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  line-height: 1.45;
}
