/* Amphi Apply — shared styles (matches V4 onboarding visual language). */
:root {
  --lime:        #1A6B4A;
  --lime-dark:   #155538;
  --lime-light:  #DCEFCB;
  --slate:       #1F2937;
  --muted:       #64748B;
  --bg:          #F8FAF7;
  --card-bg:     #FFFFFF;
  --border:      #E2E8F0;
  --err-bg:      #FBE0E0;
  --err-text:    #991B1B;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--slate);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrap { flex: 1; max-width: 880px; width: 100%; margin: 0 auto; padding: 24px 18px; }
.topbar {
  background: var(--lime);
  color: white;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.topbar .logout { color: white; text-decoration: underline; font-weight: 500; }
.topbar-links { display: flex; gap: 16px; align-items: center; }
.topbar-link { color: white; text-decoration: none; font-weight: 500; opacity: 0.92; }
.topbar-link:hover { text-decoration: underline; opacity: 1; }
.foot { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 30px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
h1 { margin: 0 0 6px; font-size: 26px; color: var(--slate); }
h1 .sub { color: var(--muted); font-weight: 400; font-size: 18px; }
h1 .brand { color: var(--lime); }
h2 { margin: 22px 0 8px; font-size: 18px; color: var(--slate); }
.lead { color: var(--slate); margin: 0 0 16px; }
.hint { color: var(--muted); margin: 8px 0; font-size: 14px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.loginform { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.loginform label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--slate); }
.loginform input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; color: var(--slate); background: white;
}
.loginform input:focus { outline: 2px solid var(--lime); outline-offset: -1px; }

button.primary, .btn {
  background: var(--lime); color: white; border: none;
  padding: 12px 18px; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button.primary:hover, .btn:hover { background: var(--lime-dark); }
button.primary:disabled { background: var(--muted); cursor: not-allowed; }
button.big { padding: 14px 22px; font-size: 17px; }

.err {
  background: var(--err-bg); color: var(--err-text);
  border: 1px solid #F4C7C7; border-radius: 8px;
  padding: 10px 14px; margin: 12px 0; font-size: 14px;
}

.qrbox {
  display: flex; gap: 24px; align-items: center;
  background: var(--lime-light); padding: 20px; border-radius: 10px;
  margin: 10px 0 18px;
}
.qrimg { width: 180px; height: 180px; background: white; padding: 8px; border-radius: 6px; }

ul { line-height: 1.7; padding-left: 22px; }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; font-size: 14px; }
.flash.ok  { background: var(--lime-light); color: var(--lime-dark); border: 1px solid #B7D8A6; }
.flash.err { background: var(--err-bg); color: var(--err-text); border: 1px solid #F4C7C7; }
.flash.warn { background: #FEF6E7; color: #7C4A03; border: 1px solid #F3D9A4; }

/* Course catalogue (Setup tab) */
.course-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin: 10px 0;
  background: #FBFCFB;
}
.course-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.course-uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.upload-form .row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.upload-form input[type=file] { font-size: 13px; flex: 1; }

/* Drag-and-drop dropzone */
.dropzone {
  position: relative;
  margin-top: 6px;
  padding: 18px 14px;
  border: 2px dashed #B7D8A6;
  border-radius: 10px;
  background: #F4FBF0;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.dropzone:hover { background: #ECF7E4; }
.dropzone.dz-over {
  background: var(--lime-light);
  border-color: var(--lime);
  transform: scale(1.01);
}
.dropzone.dz-filled {
  background: #E8F4E0;
  border-style: solid;
  border-color: var(--lime);
}
.dz-input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dz-msg { pointer-events: none; }
.dz-filename { margin-top: 6px; font-size: 12px; pointer-events: none; }
.dz-filename:not(:empty) { color: var(--lime-dark); font-weight: 600; }

/* Course card with expandable summary (<details>/<summary>) */
.course-details { padding: 0; }
.course-details > summary {
  list-style: none; cursor: pointer;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  border-radius: 10px;
}
.course-details > summary::-webkit-details-marker { display: none; }
.course-details > summary:hover { background: #F4FBF0; }
.dz-chevron {
  display: inline-block;
  color: var(--lime);
  font-size: 18px;
  width: 16px;
  text-align: center;
  transition: transform .15s ease;
  flex-shrink: 0;
}
.course-details[open] > summary .dz-chevron { transform: rotate(90deg); }
.summary-main { flex: 1; min-width: 0; }
.summary-main strong { display: block; font-size: 15px; color: var(--slate); }
.summary-main .small { display: block; margin-top: 2px; }
.summary-toggle {
  color: var(--lime-dark);
  text-decoration: underline;
  font-weight: 600;
  flex-shrink: 0;
}
.course-details[open] > summary .summary-toggle::after { content: " ▴"; }
.course-details:not([open]) > summary .summary-toggle::after { content: " ▾"; }
.summary-right { flex-shrink: 0; }
.summary-content {
  padding: 6px 16px 16px;
  border-top: 1px solid var(--border);
  background: #FBFCFB;
}
table.qual-summary {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.qual-summary th {
  text-align: left; padding: 6px 10px;
  color: var(--muted); font-weight: 500; width: 200px;
  vertical-align: top; border-bottom: 1px solid #F1F4F1;
}
table.qual-summary td {
  padding: 6px 10px; color: var(--slate);
  border-bottom: 1px solid #F1F4F1;
}

/* Catalogue browser table */
.cat-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.cat-table th { text-align: left; padding: 8px 10px; background: var(--lime); color: white; font-weight: 600; }
.cat-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cat-table tr:hover td { background: #FBFCFB; }
.course-form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.course-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.course-form input, .course-form select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.btn-link {
  background: none; border: none; color: var(--err-text); text-decoration: underline; cursor: pointer; padding: 0;
}
.btn.small { padding: 6px 10px; font-size: 13px; }

/* Status badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; margin-left: 4px;
}
.badge.ok        { background: var(--lime-light); color: var(--lime-dark); }
.badge.warn      { background: #FFE9C7; color: #92400E; }
.badge.new       { background: #DBEAFE; color: #1E3A8A; }
.badge.progress  { background: #FEF3C7; color: #92400E; }
.badge.shortlist { background: #E0E7FF; color: #4338CA; }
.badge.decline   { background: var(--err-bg); color: var(--err-text); }

/* Applications inbox styles */
.cat-table td.num { text-align: center; font-weight: 600; }
.chip-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 5px 11px; border-radius: 16px;
  font-size: 12px; font-weight: 600;
  background: #F1F4F1; color: var(--slate); border: 1px solid var(--border);
  text-decoration: none;
}
.chip.active { background: var(--lime); color: white; border-color: var(--lime); }
.chip:hover { background: var(--lime-light); }

.action-row { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.btn-danger {
  background: #B91C1C; color: white; border: none;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #991B1B; }

.doc-block { margin-bottom: 16px; }
.doc-block strong { display: block; margin-bottom: 6px; color: var(--slate); }
.doc-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.doc-thumbs img {
  max-width: 140px; max-height: 180px; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; background: #FAFBFA;
}
.doc-link {
  display: inline-block; padding: 10px 14px;
  background: var(--lime-light); color: var(--lime-dark);
  border-radius: 6px; text-decoration: none; font-size: 13px;
}
.pdf-embed {
  width: 100%; min-width: 320px;
  border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; background: #FAFBFA;
}
.pdf-embed embed { display: block; width: 100%; }
.pdf-actions { padding: 8px 12px; background: #F1F4F1; text-align: center; }

/* Applicant landing — role cards */
.roles { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.role-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; background: #FBFCFB;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.role-card p { margin: 6px 0 0; font-size: 14px; color: var(--slate); }
.empty-courses {
  border: 1px dashed var(--border); border-radius: 10px; padding: 16px; color: var(--muted);
}

/* ── Applicant form ── */
.progress-bar {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.progress-step {
  flex: 1; padding: 8px 10px; border-radius: 6px;
  background: #E2E8F0; color: var(--muted);
  font-size: 12px; font-weight: 600; text-align: center;
}
.progress-step.active { background: var(--lime); color: white; }
.progress-step.done   { background: var(--lime-light); color: var(--lime-dark); }

.step { display: none; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field label { font-size: 13px; color: var(--slate); font-weight: 600; }
.field label .req { color: #B91C1C; }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; color: var(--slate); background: white;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--lime); outline-offset: -1px;
}

.tile {
  border: 2px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 10px 0; background: white;
  transition: border-color .15s;
}
.tile.tile-empty   { border-color: #FBA5A5; background: #FEF6F6; }
.tile.tile-partial { border-color: #FFCC85; background: #FFF8EE; }
.tile.tile-ok      { border-color: var(--lime); background: #F4FBF0; }
.tile-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.tile-status { font-size: 12px; font-weight: 600; }
.tile-empty .tile-status   { color: #991B1B; }
.tile-partial .tile-status { color: #92400E; }
.tile-ok .tile-status      { color: var(--lime-dark); }
/* Optional additional-document tiles — softer than "Required" red */
.tile-optional             { background: #F8FAFC; border-color: #CBD5E1; }
.tile-optional .tile-status{ color: #475569; }
.optional-section-head     { margin-top: 18px; padding-top: 14px;
                             border-top: 1px dashed #CBD5E1; }
.tile-pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.page-thumb {
  width: 90px; height: 110px; border-radius: 6px; overflow: hidden;
  position: relative; background: #F1F4F1; border: 1px solid var(--border);
}
.page-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-pdf {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-size: 22px; color: var(--lime-dark);
  background: var(--lime-light);
}
.page-cap {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 2px 6px; background: rgba(0,0,0,0.55); color: white; font-size: 11px;
}
.page-x {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.65); color: white; font-size: 14px;
  line-height: 1; cursor: pointer; font-weight: bold;
}
.prev-thumb {
  background: var(--lime-light); border-color: var(--lime);
  position: relative;
}
.prev-thumb .page-cap {
  background: var(--lime); color: white;
  font-weight: 600;
}
.tile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.id-type-toggle { display: flex; gap: 16px; margin: 10px 0 14px; }
.id-type-toggle label {
  display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer;
}

.step-nav {
  display: flex; justify-content: flex-start; gap: 10px; margin-top: 18px;
  align-items: center; flex-wrap: wrap;
}
.step-nav-spacer { flex: 1; }
.step-nav .btn-back {
  background: white; color: var(--slate); border: 1px solid var(--border);
}
.btn-cancel {
  background: white; color: var(--err-text);
  border: 1px solid #FBA5A5;
}
.btn-cancel:hover { background: var(--err-bg); color: #6E1010; }

.contract-frame {
  width: 100%; min-height: 800px; height: 85vh; max-height: 1100px;
  border: 1px solid var(--border);
  border-radius: 8px; margin: 10px 0 14px;
  background: #FAFBFA;
}
.ack-row {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--lime-light); padding: 12px 14px; border-radius: 8px;
  margin: 12px 0;
}
.ack-row input { margin-top: 3px; }

.canvas-wrap {
  border: 2px dashed #CBD5E1; border-radius: 8px;
  background: #FAFBFA; margin: 8px 0;
}
.canvas-wrap canvas {
  display: block; width: 100%; height: 180px; touch-action: none;
  cursor: crosshair; background: white; border-radius: 6px;
}
.canvas-actions {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; font-size: 12px; color: var(--muted);
}

/* Form section header inside the multi-step form */
.form-section {
  font-size: 14px; font-weight: 700; color: var(--lime-dark);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 20px 0 8px; padding-bottom: 4px;
  border-bottom: 2px solid var(--lime-light);
}

/* Landing choice (New vs Continue) */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.choice-card {
  border: 2px solid var(--border); border-radius: 12px;
  padding: 22px 20px; cursor: pointer; background: white;
  transition: border-color .15s, background .15s, transform .05s;
  text-align: left; text-decoration: none; color: var(--slate);
  display: flex; flex-direction: column; gap: 6px;
}
.choice-card:hover { border-color: var(--lime); background: #F4FBF0; transform: translateY(-1px); }
.choice-card .choice-title { font-size: 18px; font-weight: 700; color: var(--lime); }
.choice-card .choice-desc { font-size: 13px; color: var(--muted); }
@media (max-width: 540px) { .choice-cards { grid-template-columns: 1fr; } }

/* Camera modal */
.cam-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.cam-box {
  background: #111; color: white; border-radius: 12px;
  width: 100%; max-width: 720px; display: flex; flex-direction: column;
  max-height: 95vh; overflow: hidden;
}
.cam-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #1f1f1f; gap: 12px;
}
.cam-picker {
  flex: 1; padding: 6px 10px; border-radius: 6px;
  border: 1px solid #333; background: #222; color: white; font-size: 13px;
}
.cam-close {
  background: transparent; border: none; color: white; font-size: 22px;
  cursor: pointer; padding: 0 8px;
}
.cam-stage {
  flex: 1; background: #000; min-height: 320px;
  display: flex; align-items: center; justify-content: center;
}
.cam-stage video, .cam-stage img {
  max-width: 100%; max-height: 60vh; display: block; background: #000;
}
.cam-actions {
  display: flex; gap: 10px; justify-content: center;
  padding: 12px 14px; background: #1f1f1f;
}
.cam-actions button { min-width: 130px; }

@media (max-width: 540px) {
  .wrap { padding: 16px 12px; }
  .card { padding: 20px 18px; }
  .qrbox { flex-direction: column; align-items: flex-start; }
  .course-uploads { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr; }
  .role-card { flex-direction: column; align-items: flex-start; }
  .field-grid { grid-template-columns: 1fr; }
  .progress-step { font-size: 10px; padding: 6px 4px; }
  .cam-actions { flex-wrap: wrap; }
  .cam-actions button { flex: 1; min-width: 100px; }
}
