:root {
  /* ===== Palette — "site inspection" identity: blueprint blue on warm drawing paper ===== */
  --paper: #f6f5f0;
  --card-bg: #ffffff;
  --ink: #1b2321;
  --ink-muted: #5c6b66;
  --line: #dbd7cb;

  --blue: #1f4b99;
  --blue-deep: #163a7a;
  --blue-tint: #e8edf7;

  --amber: #c07819;
  --amber-tint: #faf1e1;
  --green: #2f7d5a;
  --green-tint: #e7f3ec;
  --danger: #b23a2e;

  /* rating scale 1→5, dissatisfied to satisfied */
  --rate-1: #b23a2e;
  --rate-2: #c2632a;
  --rate-3: #c0900f;
  --rate-4: #5f9a4f;
  --rate-5: #2f7d5a;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(27, 35, 33, .06);

  --font-display: "Segoe UI Semibold", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* faint drafting-grid backdrop */
body {
  background-image:
    linear-gradient(rgba(31, 75, 153, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 75, 153, .05) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--blue-deep);
  color: #fff;
  border-bottom: 3px solid var(--amber);
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .04em;
  border: 1px solid rgba(255,255,255,.55);
  padding: 3px 7px;
  border-radius: 3px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .01em;
}

.status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: rgba(255,255,255,.85); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #e8b64a;
  display: inline-block;
}
.dot.online { background: #59c98a; }
.dot.offline { background: #e0685a; }

/* ===== Layout ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 12px 56px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 0;
  margin-bottom: 20px;
  position: sticky;
  top: 51px;
  z-index: 9;
  background: var(--paper);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 10px 10px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.tab.active {
  color: var(--blue-deep);
  border-bottom-color: var(--blue);
}

.badge {
  display: inline-block;
  min-width: 17px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--blue-tint);
  color: var(--blue-deep);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.panel { display: none; }
.panel.active { display: block; }

/* ===== Form hero (title block) ===== */
.form-hero {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  padding: 20px 20px 16px;
  margin-bottom: 20px;
}

.form-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.form-desc {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 62ch;
  color: var(--ink-muted);
}

.form-required-note {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.req { color: var(--danger); }

/* ===== Sections ===== */
form#surveyForm { counter-reset: section; }

.card {
  counter-increment: section;
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--line);
  padding: 18px 20px 20px;
  margin-bottom: 16px;
}

/* corner registration marks — a small nod to survey/site-plan drawings */
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  pointer-events: none;
}
.card::before {
  top: -1px; left: -1px;
  border-top: 2px solid var(--blue);
  border-left: 2px solid var(--blue);
}
.card::after {
  bottom: -1px; right: -1px;
  border-bottom: 2px solid var(--blue);
  border-right: 2px solid var(--blue);
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.card-title::before {
  content: counter(section, decimal-leading-zero);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--blue);
  margin-right: 9px;
}

/* ===== Fields ===== */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

#studentId, #room {
  font-family: var(--font-mono);
  letter-spacing: .01em;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-tint);
}

textarea { resize: vertical; min-height: 80px; }

input[type="file"] {
  width: 100%;
  font-size: 13px;
  padding: 8px 0;
}

.photo-preview {
  margin-top: 10px;
  max-width: 100%;
  border: 1px dashed var(--line);
  padding: 5px;
  background: #fff;
  border-radius: var(--radius-sm);
}

/* ===== Likert groups ===== */
.likert-scale-hint {
  font-size: 13px;
  color: var(--ink-muted);
  margin: -6px 0 16px;
}

.likert-group { margin-bottom: 22px; }
.likert-group:last-child { margin-bottom: 0; }

.likert-group-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-deep);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--blue-tint);
}

.likert-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.likert-item:last-child { border-bottom: none; }

.likert-item-label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}

.likert-scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.likert-option {
  flex: 1;
  text-align: center;
  position: relative;
  z-index: 1;
}

.likert-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.likert-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}

.likert-option .num {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  transition: all .15s;
}

.likert-option .txt {
  font-size: 10px;
  color: var(--ink-muted);
  line-height: 1.2;
}

.likert-option input:checked + label .num {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.likert-option:nth-child(1) input:checked + label .num { background: var(--rate-1); border-color: var(--rate-1); }
.likert-option:nth-child(2) input:checked + label .num { background: var(--rate-2); border-color: var(--rate-2); }
.likert-option:nth-child(3) input:checked + label .num { background: var(--rate-3); border-color: var(--rate-3); }
.likert-option:nth-child(4) input:checked + label .num { background: var(--rate-4); border-color: var(--rate-4); }
.likert-option:nth-child(5) input:checked + label .num { background: var(--rate-5); border-color: var(--rate-5); }

.likert-option input:checked + label .txt {
  color: var(--ink);
  font-weight: 700;
}

.likert-option label:hover .num {
  border-color: var(--blue);
}

/* ===== Overall scale ===== */
.overall-scale {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.overall-option { flex: 1; text-align: center; }

.overall-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.overall-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 10px 2px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--card-bg);
  transition: all .15s;
}

.overall-option .emoji { font-size: 21px; }
.overall-option .txt { font-size: 10px; color: var(--ink-muted); }

.overall-option input:checked + label {
  border-color: var(--blue);
  background: var(--blue-tint);
}

.overall-option:nth-child(1) input:checked + label { border-color: var(--rate-1); background: color-mix(in srgb, var(--rate-1) 12%, white); }
.overall-option:nth-child(2) input:checked + label { border-color: var(--rate-2); background: color-mix(in srgb, var(--rate-2) 12%, white); }
.overall-option:nth-child(3) input:checked + label { border-color: var(--rate-3); background: color-mix(in srgb, var(--rate-3) 12%, white); }
.overall-option:nth-child(4) input:checked + label { border-color: var(--rate-4); background: color-mix(in srgb, var(--rate-4) 12%, white); }
.overall-option:nth-child(5) input:checked + label { border-color: var(--rate-5); background: color-mix(in srgb, var(--rate-5) 12%, white); }

.overall-option input:checked + label .txt {
  color: var(--ink);
  font-weight: 700;
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, transform .05s;
}

.btn-primary:hover { background: var(--blue-deep); }
.btn-primary:active { transform: scale(.99); }

.btn-secondary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-deep);
  background: var(--blue-tint);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-ghost {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 10px;
}

/* ===== Queue ===== */
.queue-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.record-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-item {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: 14px 16px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.record-title { font-weight: 700; font-size: 14px; }
.record-sub { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }

.record-status {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.record-status.pending { background: var(--amber-tint); color: var(--amber); }
.record-status.synced { background: var(--green-tint); color: var(--green); }

.record-list .record-item:has(.record-status.pending) { border-left-color: var(--amber); }
.record-list .record-item:has(.record-status.synced) { border-left-color: var(--green); }

.record-meta {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
}

.record-photo {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.record-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.record-actions button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.record-actions button.danger { color: var(--danger); border-color: #e6c3bd; }

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  padding: 40px 12px;
  border: 1px dashed var(--line);
  display: none;
}

.empty-state.show { display: block; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 420px) {
  .likert-option .txt { display: none; }
  .form-title { font-size: 18px; }
}

.geo-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
 
#geoStatus.geo-ok {
  color: #1a7f37;
  font-weight: 500;
}
 
.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
}
 
.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
 