:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #17231f;
  --muted: #566560;
  --line: #cfd8d4;
  --accent: #0f4c9c;
  --accent-dark: #012b59; /* matches the banner's navy, so the two blend */
  --accent-soft: #e6eefa;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
h1:focus, main:focus { outline: none; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text small { color: var(--muted); font-size: 0.75rem; }
.lang-menu {
  flex: none;
  min-height: 44px;
  padding-left: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
}
.lang-menu:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-menu img { display: block; width: 24px; height: auto; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }
.lang-menu select {
  min-height: 42px;
  padding: 0 6px 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.lang-menu select:focus { outline: none; }
@media (max-width: 380px) { .brand-text small { display: none; } }

.page { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lead { color: var(--muted); }
.checklist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li { padding-left: 28px; position: relative; }
.checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.stepper { display: flex; flex-direction: column; gap: 6px; }
.step-count { color: var(--muted); font-size: 0.85rem; }
.tabs { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tabs button {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tabs button:not(:disabled) { cursor: pointer; }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.tab-number {
  width: 100%;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}
.tabs .past .tab-number { background: #bcd0ee; }
.tabs .current .tab-number { background: var(--accent); color: #fff; }
.tab-name { display: none; font-size: 0.7rem; line-height: 1.2; text-align: center; }
.tabs .current .tab-name { color: var(--ink); font-weight: 600; }

.page.page-full { max-width: none; padding: 0; }
.intro-body { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; }
.hero { position: relative; overflow: hidden; background: var(--accent-dark); color: #fff; }
/* The scenery is pale and fades to nothing, left and downward, so only navy remains under the text. */
.hero-scene {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right top;
  opacity: 0.28;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 70%), linear-gradient(to bottom, #000 35%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent 0%, #000 70%), linear-gradient(to bottom, #000 35%, transparent 100%);
  mask-composite: intersect;
}
.hero-inner {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hero-text { max-width: 520px; }
.hero-flags { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 340px; }
.hero-flags img { display: block; width: 100%; height: auto; border-radius: 5px; }
.hero h1, .hero-text, .hero-notice { text-shadow: 0 1px 6px rgba(1, 43, 89, 0.9); }
.hero-cta {
  align-self: stretch;
  min-height: 54px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #4fc23a, #17933a);
  color: #fff;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.hero-cta:hover { background: linear-gradient(180deg, #45b331, #137f32); }
.hero-cta:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.hero-notice { padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.35); font-size: 0.85rem; }
.section-list { margin: 0; padding-left: 24px; display: grid; gap: 4px; }
.rules { padding: 12px; border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.rules ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 0.9rem; }
.subheading { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

.field { display: flex; flex-direction: column; gap: 4px; }
.label { font-weight: 600; font-size: 0.95rem; }
.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.help { color: var(--muted); font-size: 0.85rem; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #9aa8a3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit; /* 16px keeps iOS from zooming on focus */
}
textarea.input { resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.error { color: var(--danger); font-size: 0.85rem; font-weight: 500; }
.error:empty { display: none; }
.has-error .input { border-color: var(--danger); background: var(--danger-soft); }
.banner { padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.check-field.has-error .check input { outline: 2px solid var(--danger); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-soft); }
.btn-quiet { background: transparent; color: var(--accent); }
.btn-quiet:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
.btn-wide { width: 100%; }
.actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 4px; }

.uploads { display: flex; flex-direction: column; gap: 20px; }
.upload-group { display: flex; flex-direction: column; gap: 8px; }
.upload-group:focus { outline: none; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slots.single { grid-template-columns: 1fr; }
.slot {
  min-width: 0;
  padding: 10px;
  border: 1px dashed #9aa8a3;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slot.filled { border-style: solid; border-color: var(--accent); }
.upload-group.has-error .slot:not(.filled) { border-color: var(--danger); background: var(--danger-soft); }
.slot-title { font-weight: 600; font-size: 0.9rem; }
.slot-preview {
  width: 100%;
  height: 120px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.slot-preview.empty { color: var(--muted); font-size: 2rem; }
.slot-preview.pdf { color: var(--accent); font-weight: 700; }
.slot-name { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.slot-actions .btn { flex: 1 1 auto; }
.visually-hidden, .trap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  clip-path: inset(50%);
}
.visually-hidden:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.reply-file { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reply-choose { align-self: flex-start; margin-top: 4px; }
.draft-notice { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.send-progress { width: 100%; height: 10px; accent-color: var(--accent); }
.privacy { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 0.875rem; }

.review { display: flex; flex-direction: column; gap: 16px; }
.review-section { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.review dl { margin: 0; }
.review-row { padding: 6px 0; border-top: 1px solid #e8edea; }
.review dt { color: var(--muted); font-size: 0.8rem; }
.review dd { margin: 0; overflow-wrap: anywhere; }

.done { align-items: center; text-align: center; }
.done-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
}
.ref-label { color: var(--muted); font-size: 0.85rem; margin-bottom: -12px; }
.ref {
  font: 700 1.6rem/1.2 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.04em;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.receipt { width: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 8px; text-align: left; }
.receipt h2 { margin-bottom: 2px; }
.receipt dl { margin: 10px 0 0; }
.receipt dt { color: var(--muted); font-size: 0.8rem; }
.receipt dd { margin: 0; overflow-wrap: anywhere; }
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.footer { padding: 16px; background: var(--accent); }
.footer p { max-width: 688px; margin: 0 auto; color: #fff; font-size: 0.8rem; text-align: center; }

@media (min-width: 640px) {
  .page { padding: 28px 16px; }
  .card { padding: 28px; }
  .slots.single { grid-template-columns: 1fr 1fr; }
  .slot-preview { height: 150px; }
  .tab-name { display: block; }
  .hero-inner { padding: 56px 16px; }
  .hero h1 { max-width: 620px; font-size: 2.75rem; line-height: 1.15; }
  .hero-scene { width: 60%; opacity: 0.6; }
  .hero-cta { align-self: flex-start; }
  .hero-flags { grid-template-columns: repeat(9, 1fr); max-width: 620px; }
  .hero-notice { max-width: 620px; }
  .intro-body { padding: 28px 16px; }
  .section-list { grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .review-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
  .actions { display: flex; justify-content: space-between; }
  .actions .btn { min-width: 170px; }
}

@media print {
  .topbar, .done-actions, .done .btn-quiet { display: none; }
  body { background: #fff; }
  .card { border: 0; }
  .done { padding: 0; gap: 10px; }
  .done-mark { display: none; }
  .footer { background: #fff; padding: 8px 0 0; }
  .footer p { color: #000; }
}

/* --- Owner area --- */
.page-wide, .admin .topbar-inner { max-width: 1040px; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
.app-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.app-item {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}
.app-item:hover { border-color: var(--accent); }
.app-item:focus-visible { outline: 2px solid var(--accent); }
.app-name { font-weight: 600; overflow-wrap: anywhere; }
.app-meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.chip {
  align-self: start;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.empty-state { color: var(--muted); text-align: center; padding: 24px 0; }
.status-box { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border-radius: 8px; background: var(--accent-soft); }
.status-note { color: var(--accent-dark); font-size: 0.85rem; font-weight: 500; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.doc {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
}
.doc:hover { border-color: var(--accent); }
.doc img, .doc-pdf {
  width: 100%;
  height: 130px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--bg);
}
.doc-pdf { display: grid; place-items: center; color: var(--accent); font-weight: 700; }
.correction-reply { margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: var(--accent-soft); overflow-wrap: anywhere; }
#correction-link-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.history { margin: 0; padding: 0; list-style: none; font-size: 0.875rem; color: var(--muted); }

@media (min-width: 640px) {
  .filters { grid-template-columns: 1fr 240px; }
  .status-box { grid-template-columns: 1fr auto; align-items: center; }
}
