:root {
  --blue: #0067a8;
  --blue-dark: #004f80;
  --blue-soft: #e8f3fa;
  --ink: #17212b;
  --muted: #5e6d79;
  --line: #d8e2e8;
  --surface: #ffffff;
  --page: #f3f7f9;
  --success: #16794b;
  --danger: #b42318;
  --warning-bg: #fff4d8;
  --warning-ink: #624a09;
  --radius: 18px;
  --shadow: 0 12px 35px rgba(29, 65, 86, .09);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--page); }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 78px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.brand > span:last-child { display: grid; line-height: 1.15; }
.brand small { color: var(--muted); margin-top: 4px; }
.brand-emblem {
  width: 58px;
  height: 58px;
  border-radius: 16px 16px 16px 5px;
  background: linear-gradient(145deg, #0a74b8, #00598e);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -.04em;
  box-shadow: 0 8px 18px rgba(0, 104, 168, .22);
}
.brand-emblem.small { width: 44px; height: 44px; border-radius: 13px 13px 13px 4px; font-size: 14px; }
.prototype-banner { background: var(--warning-bg); color: var(--warning-ink); text-align: center; padding: 9px 16px; font-size: 14px; border-bottom: 1px solid #ead8a4; }

.page-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 46px 0 70px; }
.hero { max-width: 790px; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 800; color: var(--blue); }
h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.02; letter-spacing: -.035em; margin: 0 0 14px; }
h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
h3 { margin: 14px 0 8px; }
.hero > p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.55; margin: 0; }
.steps { display: flex; align-items: center; gap: 8px; margin-top: 28px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.step b { width: 24px; height: 24px; border: 1px solid var(--line); display: grid; place-items: center; border-radius: 50%; font-size: 12px; }
.step.active { color: var(--blue-dark); background: var(--blue-soft); font-weight: 700; }
.step.active b { color: white; background: var(--blue); border-color: var(--blue); }

.layout-grid { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(330px, .78fr); gap: 24px; align-items: start; margin-top: 32px; }
.panel, .preview-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-panel { padding: 30px; }
.panel-title, .preview-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 24px; }
.required-note { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; font-weight: 700; font-size: 14px; }
.field > span, .fieldset-clean legend { display: block; }
.field small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.fieldset-clean { padding: 0; margin: 0; border: 0; }
.fieldset-clean legend { margin-bottom: 8px; }
input, select {
  width: 100%; min-height: 48px; border: 1.5px solid #b9c7d0; border-radius: 10px; padding: 0 13px; color: var(--ink); background: white; outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 103, 168, .13); }
input:disabled { background: #f4f7f8; color: #55636f; }
#nom { text-transform: uppercase; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); border: 1.5px solid #b9c7d0; border-radius: 11px; overflow: hidden; }
.segmented label { position: relative; cursor: pointer; }
.segmented label + label { border-left: 1px solid #b9c7d0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.segmented span { min-height: 48px; display: grid; place-items: center; font-weight: 700; color: var(--muted); background: #fff; }
.segmented input:checked + span { background: var(--blue-soft); color: var(--blue-dark); box-shadow: inset 0 0 0 2px var(--blue); }
.segmented input:focus-visible + span { outline: 3px solid rgba(0, 103, 168, .22); outline-offset: -3px; }

.section-break { display: flex; align-items: center; gap: 14px; color: var(--blue-dark); font-weight: 800; font-size: 14px; margin-top: 2px; }
.section-break::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.auto-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.auto-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; background: #f8fbfc; display: grid; gap: 5px; }
.auto-grid span { color: var(--muted); font-size: 12px; font-weight: 650; }
.auto-grid strong { font-size: 15px; }

.actions { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.actions p { margin: 0; font-size: 13px; line-height: 1.45; }
.primary-btn, .secondary-btn {
  border-radius: 10px; min-height: 46px; padding: 0 18px; display: inline-flex; justify-content: center; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.primary-btn { color: white; background: var(--blue); box-shadow: 0 6px 16px rgba(0, 103, 168, .18); }
.primary-btn:hover { background: var(--blue-dark); }
.primary-btn:disabled { opacity: .55; cursor: wait; }
.secondary-btn { color: var(--blue-dark); background: white; border-color: #b9c7d0; }
.secondary-btn:hover { background: #f4f8fa; }
.compact { min-height: 40px; padding: 0 14px; font-size: 13px; }
.block { width: 100%; }

.preview-card { padding: 24px; position: sticky; top: 102px; }
.preview-head { margin-bottom: 20px; }
.status-badge { border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-badge.idle { color: #63707a; background: #eef2f4; }
.status-badge.loading { color: #6b4e00; background: #fff0c7; }
.status-badge.ready { color: var(--success); background: #e9f7f0; }
.status-badge.error { color: var(--danger); background: #ffefed; }
.empty-preview { min-height: 405px; border: 1px dashed #c5d2da; border-radius: 13px; background: #fafcfd; display: grid; place-content: center; text-align: center; padding: 24px; }
.empty-preview p { color: var(--muted); margin: 0; line-height: 1.45; }
.doc-icon { width: 62px; height: 72px; border: 2px solid #aac0ce; border-radius: 8px; margin: 0 auto; color: var(--blue-dark); display: grid; place-items: center; font-size: 13px; font-weight: 900; background: #fff; }
.pdf-preview { display: none; width: 100%; height: 540px; border: 1px solid var(--line); border-radius: 10px; background: #eef1f3; }
.pdf-preview.visible { display: block; }
.download-area { display: grid; gap: 10px; margin-top: 14px; }
.hidden { display: none !important; }

.footer { width: min(1180px, calc(100% - 36px)); margin: 0 auto 28px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; line-height: 1.5; }
.alert { background: #ffefed; color: var(--danger); border: 1px solid #f1b8b1; border-radius: 10px; padding: 12px 13px; font-size: 14px; font-weight: 700; }

.auth-body { background: radial-gradient(circle at 15% 15%, #e6f3fa 0, #f3f7f9 34%, #f3f7f9 100%); display: grid; place-items: center; padding: 34px 18px; }
.auth-shell { width: min(980px, 100%); min-height: 620px; display: grid; grid-template-columns: 1.04fr .96fr; overflow: hidden; border-radius: 24px; background: white; border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(23, 54, 72, .14); }
.auth-intro { padding: 60px 54px; background: linear-gradient(145deg, #eaf5fb, #f8fbfd); display: flex; flex-direction: column; justify-content: center; }
.auth-intro h1 { font-size: clamp(38px, 5vw, 56px); }
.lead { color: var(--muted); font-size: 17px; line-height: 1.6; }
.specimen-note { margin-top: 28px; padding: 16px; border-radius: 12px; background: var(--warning-bg); color: var(--warning-ink); display: grid; gap: 5px; font-size: 13px; line-height: 1.45; }
.auth-card { align-self: center; padding: 56px 48px; }
.auth-card h2 { font-size: 32px; margin-bottom: 10px; }
.stack-lg { display: grid; gap: 20px; margin-top: 26px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 92px; }
.ghost-icon { position: absolute; right: 7px; top: 7px; height: 34px; border: 0; background: transparent; color: var(--blue-dark); font-weight: 800; cursor: pointer; border-radius: 7px; padding: 0 9px; }
.ghost-icon:hover { background: var(--blue-soft); }
.mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 30px; }

@media (max-width: 940px) {
  .layout-grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .auth-shell { grid-template-columns: 1fr; max-width: 560px; min-height: 0; }
  .auth-intro { display: none; }
  .mobile-brand { display: flex; }
}

@media (max-width: 640px) {
  .topbar { height: 68px; padding: 0 16px; }
  .brand small { display: none; }
  .brand-emblem.small { width: 40px; height: 40px; }
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 30px; }
  .form-panel, .preview-card { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: 1; }
  .auto-grid { grid-template-columns: 1fr; }
  .actions { align-items: stretch; flex-direction: column; }
  .actions .primary-btn { width: 100%; }
  .footer { width: calc(100% - 24px); flex-direction: column; gap: 4px; }
  .auth-card { padding: 34px 24px; }
  .auth-body { padding: 16px 12px; }
  .pdf-preview { height: 460px; }
}
