:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #68727f;
  --line: #e2e7ee;
  --brand: #123a5e;
  --brand-2: #1d6fb8;
  --accent: #1d6fb8;
  --selected: #10668E;
  --ok: #1a8f5a;
  --err: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,32,55,.06), 0 6px 24px rgba(16,32,55,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--brand); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .2px; }
.logo { width: 40px; height: 40px; display: block; }
.admin-link { color: #cfe2f3; text-decoration: none; font-size: 14px; }
.admin-link:hover { color: #fff; text-decoration: underline; }

h1 { font-size: 26px; margin: 28px 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; }

.cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; text-align: left; box-shadow: var(--shadow);
  transition: transform .08s ease, border-color .08s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; }

.back { background: none; border: none; color: var(--brand-2); cursor: pointer; font-size: 14px; padding: 18px 0 8px; }
#form-header h2 { margin: 2px 0 4px; font-size: 22px; }
#form-header .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 4px; }
#form-header .review-note { background:#fdf3e2; border:1px solid #f0dcae; color:#7a5600;
  padding:10px 12px; border-radius:10px; font-size:13px; margin:12px 0; }

form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 20px 20px; box-shadow: var(--shadow); margin-bottom: 40px; }

.section-title { font-size: 15px; font-weight: 600; color: var(--brand);
  border-top: 1px solid var(--line); margin: 20px -20px 4px; padding: 16px 20px 0; }
.field { padding: 14px 0; border-bottom: 1px solid #f0f3f7; }
.field:last-child { border-bottom: none; }
.field > label.q { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.field .req { color: var(--err); margin-left: 3px; }
.field .help { color: var(--muted); font-size: 12.5px; margin: 2px 0 8px; white-space: pre-line; }

input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 12px 12px; font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none;
}
select { -webkit-appearance: none; appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29,111,184,.12); }
textarea { min-height: 84px; resize: vertical; }

.radios { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.radios label {
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 16px; cursor: pointer;
  font-size: 15px; background: #fff; user-select: none; min-height: 44px; display: flex; align-items: center;
}
.radios input { position: absolute; opacity: 0; width: 0; height: 0; }
.radios label.checked { border-color: var(--selected); background: var(--selected); color: #fff; font-weight: 600; }

.combo { position: relative; }
.combo-input { padding-right: 34px !important; }
.combo-caret { position: absolute; right: 12px; top: 12px; color: var(--muted); pointer-events: auto; cursor: pointer; font-size: 13px; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; max-height: 240px;
  overflow: auto; box-shadow: var(--shadow); }
.combo-list div { padding: 9px 12px; cursor: pointer; font-size: 14px; }
.combo-list div:hover, .combo-list div.active { background: #eaf3fb; }
.combo-list .empty { color: var(--muted); cursor: default; }
.combo-list div.selected { font-weight: 600; color: var(--selected); }

/* Custom dropdown: same look as a select, but its list has a fixed height and scrolls. */
.dd { position: relative; }
.dd-box { width: 100%; padding: 12px 36px 12px 12px; font: inherit; font-size: 16px; color: var(--ink); text-align: left;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; min-height: 48px; }
.dd-box.placeholder { color: var(--muted); }
.dd-box:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29,111,184,.12); }
.dd .combo-caret { pointer-events: none; top: 14px; }
.field.invalid .dd-box { border-color: var(--err); }

.radios.locked label, select.locked, .dd.locked { pointer-events: none; opacity: .75; }
input[readonly] { background: #f4f6f9; color: var(--muted); }

.suffix-box { position: relative; }
.suffix-box input { padding-right: 34px; }
.suffix-box .suffix { position: absolute; right: 14px; top: 12px; color: var(--muted); }

.checks { display: grid; gap: 6px; margin-top: 6px; }
.checks label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; cursor: pointer; font-size: 14.5px; background: #fff; min-height: 44px; }
.checks label.checked { border-color: var(--selected); background: #e7f1f5; }
.checks input { width: 18px; height: 18px; accent-color: var(--selected); }

.info-note { background: #fdf3e2; border: 1px solid #f0dcae; color: #7a5600; padding: 10px 12px;
  border-radius: 10px; font-size: 14px; white-space: pre-line; }

/* AppSheet "Side-by-side" form style: label left, answer right on wide screens. */
@media (min-width: 720px) {
  form.side-by-side .field { display: grid; grid-template-columns: 220px 1fr; column-gap: 20px; align-items: start; }
  form.side-by-side .field > label.q { grid-column: 1; grid-row: 1 / span 3; padding-top: 10px; }
  form.side-by-side .field > .help, form.side-by-side .field > .control,
  form.side-by-side .field > .field-error { grid-column: 2; }
  form.side-by-side .field > .help { margin-top: 0; }
}

.single-form #back-btn, .single-form #home-btn { display: none; }

.file-drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center;
  color: var(--muted); font-size: 13.5px; cursor: pointer; background:#fafbfc; }
.file-drop:hover, .file-drop:focus-visible, .file-drop.over { border-color: var(--brand-2); outline: none; }
.file-drop.over { background: #eef5fc; }
.file-hint { font-size: 12px; margin-top: 3px; opacity: .85; }
.file-names { margin-top: 8px; font-size: 13px; }
.file-chip { display:inline-flex; align-items:center; gap:4px; max-width:100%; background:#eef2f7; border-radius:7px;
  padding:3px 4px 3px 9px; margin:3px 4px 0 0; }
.file-chip > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.file-remove { border:none; background:none; color:var(--muted); font-size:16px; line-height:1; padding:2px 6px;
  border-radius:5px; cursor:pointer; }
.file-remove:hover { background:#dde4ec; color:var(--err); }
.file-note { color: var(--err); font-size: 12.5px; margin-top: 6px; }
.file-note:empty { display: none; }

.field-error { color: var(--err); font-size: 12.5px; margin-top: 6px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); }

.actions { display: flex; gap: 10px; align-items: center; padding-top: 22px; flex-wrap: wrap; }
button.primary { background: var(--brand-2); color: #fff; border: none; border-radius: 9px;
  padding: 14px 26px; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; min-height: 48px; }
/* Cancel | Submit, centred under the form. */
.form-actions { justify-content: center; }
#dynamic-form .form-actions button { min-width: 150px; min-height: 48px; padding: 12px 24px; font-size: 16px;
  border: 1px solid var(--line); }
#dynamic-form .form-actions button.primary { border-color: transparent; }
#dynamic-form > .form-error { text-align: center; margin-top: 10px; }
@media (max-width: 560px) {
  .form-actions { flex-wrap: nowrap; }
  #dynamic-form .form-actions button { flex: 1; min-width: 0; }
  h1 { font-size: 22px; }
}
button.primary:hover { background: #185d9c; }
button.primary:disabled { opacity: .6; cursor: default; }
button.ghost { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 11px 18px; cursor: pointer; font: inherit; }
.form-error { color: var(--err); font-size: 13.5px; }

.success-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 36px; text-align: center; box-shadow: var(--shadow); margin-top: 40px; }
.success-card .check { width: 56px; height: 56px; border-radius: 50%; background: #e6f6ee; color: var(--ok);
  font-size: 30px; display: grid; place-items: center; margin: 0 auto 10px; }
.ref { font-size: 22px; font-weight: 700; letter-spacing: .5px; color: var(--brand); margin: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }
.success-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

.foot { color: var(--muted); font-size: 12.5px; padding: 24px 16px 40px; text-align: center; }
[hidden] { display: none !important; }
