:root {
  --accent: #118ff6;
  --accent-tint: #a9d3fb;
  --card-bg: #f7fafd;
  --page-bg: #eef2f7;
  --ink: #1c2b3a;
  --ink-soft: #4a5a6a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-bg);
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
  color: var(--ink);
}
.wrap {
  max-width: 720px;
  margin: 30px auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 40px;
}
.wrap.wide { max-width: 1100px; }
.wrap.full { max-width: 1500px; }
.wrap.narrow { max-width: 360px; }
h1.page-title { margin: 0; font-size: 26px; }
h2.section {
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 8px;
  margin: 28px 0 18px;
}
h2.section:first-child { margin-top: 0; }
p.section-body {
  background: var(--card-bg);
  border-left: 3px solid var(--accent-tint);
  border-radius: 8px;
  padding: 14px 16px;
  margin: -8px 0 18px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.field {
  background: var(--card-bg);
  border-left: 3px solid var(--accent-tint);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.q-label { display: block; font-weight: 500; font-size: 17px; margin-bottom: 8px; }
.q-label .req { color: #d33; margin-left: 2px; }
table.admin-table .q-view strong { font-size: 19px; }
.q-edit-form input[type=text], .q-edit-form input[type=password], .q-edit-form select,
#inviteForm input[type=text], #inviteForm select { font-size: 19px; }
.field .q-desc { font-size: 12px; color: var(--ink-soft); margin: -4px 0 8px; }
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field input[type=date],
.field textarea {
  width: 100%; padding: 10px; border: 1px solid #ccd6e0; border-radius: 6px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field .range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); }
.field input[type=checkbox], .field input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; vertical-align: middle; }
.field .choice-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.field img.ref-photo { max-width: 100%; border-radius: 6px; margin-bottom: 10px; display: block; }
.field .stars { font-size: 24px; letter-spacing: 4px; cursor: pointer; }
.field .stars .star { color: #ccd6e0; }
.field .stars .star.active { color: #f2b400; }
canvas.sig-pad { width: 100%; height: 160px; border: 1px solid #ccd6e0; border-radius: 6px; background: #fff; touch-action: none; }
.sig-clear { margin-top: 6px; font-size: 12px; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.camera-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.camera-thumb { position: relative; width: 72px; height: 72px; border-radius: 6px; overflow: hidden; background: #000; }
.camera-thumb img, .camera-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-thumb .camera-thumb-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 12px; line-height: 18px;
  cursor: pointer; padding: 0;
}
.camera-modal {
  position: fixed; inset: 0; background: #000; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.camera-modal video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.camera-modal-controls {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 20px;
  display: flex; align-items: center; justify-content: center; gap: 24px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}
.camera-shutter {
  width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 4px solid rgba(255,255,255,0.5);
  cursor: pointer; flex-shrink: 0;
}
.camera-shutter.recording { background: #d33; }
.camera-modal-close, .camera-modal-done {
  background: rgba(255,255,255,0.15); color: #fff; border: none; border-radius: 20px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.camera-modal-error { color: #fff; text-align: center; padding: 20px; max-width: 320px; }

.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 12px 24px; font-weight: 600; font-size: 15px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn:hover { filter: brightness(0.93); }
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.danger { background: #d33; }

/* Admin */
.site-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid #e6ecf2;
}
.brand-link { font-size: 16px; font-weight: 700; color: var(--accent); text-decoration: underline; }
.brand-link:hover { color: var(--ink); }
.page-heading-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 8px; }
.page-heading-row a.link { font-size: 14px; }
.btn.small.active { background: var(--accent); color: #fff; }

.stat-tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 24px; }
.stat-tile {
  background: var(--card-bg); border-left: 3px solid var(--accent-tint); border-radius: 8px;
  padding: 14px 18px; min-width: 130px; text-decoration: none; color: inherit; display: block;
}
a.stat-tile:hover { border-left-color: var(--accent); background: #f0f8ff; }
.stat-tile.active { border-left-color: var(--accent); background: #f0f8ff; }
.stat-tile .num { font-size: 28px; font-weight: 700; color: var(--ink); display: block; line-height: 1.2; }
.stat-tile .label { font-size: 13px; color: var(--ink-soft); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e6ecf2; }
table.admin-table th { color: var(--ink-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.draft { background: #fff3cd; color: #8a6800; }
.badge.published { background: #d4f4dd; color: #147a3a; }
.badge.archived { background: #eee; color: #777; }
.badge.super { background: #ede4fd; color: #6b3fa0; }
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; }
.toolbar select, .toolbar input[type=text] { padding: 8px 10px; border: 1px solid #ccd6e0; border-radius: 6px; }

/* General form control polish */
select, input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], textarea {
  border: 1px solid #ccd6e0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink, #1c2b3a);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a5a6a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: #118ff6;
  box-shadow: 0 0 0 3px rgba(17,143,246,0.15);
}
.btn, button {
  transition: filter .12s, transform .05s;
}
.btn:active { transform: translateY(1px); }
label { cursor: pointer; }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }
.builder-layout { display: flex; gap: 24px; align-items: flex-start; }
.builder-sidebar {
  position: sticky; top: 20px; width: 220px; flex-shrink: 0;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.builder-main { flex: 1; min-width: 0; }
.sidebar-type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.sidebar-type-grid .type-card { padding: 10px 4px; font-size: 12px; line-height: 1.3; }
.sidebar-type-grid .type-card .icon { font-size: 19px; }

.qbuilder-row { border: 1px solid #e6ecf2; border-radius: 8px; padding: 14px; margin-bottom: 10px; background: #fbfcfe; display: flex; gap: 10px; }
.qbuilder-row.dragging-lifted {
  position: relative; z-index: 10; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  border-color: var(--accent); background: #fff; pointer-events: none;
}
.drag-placeholder {
  border: 2px dashed var(--accent-tint); border-radius: 8px; margin-bottom: 10px; background: #f0f8ff;
}
.drag-handle { cursor: grab; color: #ccd6e0; font-size: 18px; padding-top: 2px; user-select: none; flex-shrink: 0; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.qbuilder-row-body { flex: 1; min-width: 0; }
.qbuilder-row .row1 { display: flex; gap: 10px; margin-bottom: 8px; }
.qbuilder-row select, .qbuilder-row input[type=text], .qbuilder-row textarea, .qbuilder-row input[type=number] {
  padding: 8px; border: 1px solid #ccd6e0; border-radius: 6px; font-family: inherit; font-size: 13px;
}
.qbuilder-row .grow { flex: 1; }
.small-note { font-size: 12px; color: var(--ink-soft); margin-top: 20px; }
.detail-note { font-size: 17px; color: var(--ink-soft); }

.q-view { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.q-actions button { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--accent); padding: 0; }
.q-actions button.danger { color: #d33; }
.q-edit-form { display: none; margin-top: 10px; }

.type-card {
  border: 2px solid #e6ecf2; border-radius: 8px; background: #fff; padding: 12px 8px; text-align: center;
  cursor: pointer; font-size: 12px; color: var(--ink-soft); transition: border-color .15s, background .15s;
}
.type-card .icon { font-size: 22px; display: block; margin-bottom: 4px; }
.type-card:hover { border-color: var(--accent-tint); }
.type-card.selected { border-color: var(--accent); background: #f0f8ff; color: var(--accent); font-weight: 600; }

.share-box {
  display: flex; align-items: center; gap: 8px; background: #f0f8ff; border: 1px solid var(--accent-tint);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 20px; font-size: 13px;
}
.share-box code { flex: 1; overflow-x: auto; white-space: nowrap; }
.flash { background: #d4f4dd; color: #147a3a; padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

.subm-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.subm-search { width: 260px; }
.table-scroll { overflow-x: auto; border: 1px solid #e6ecf2; border-radius: 8px; }
table.subm-table { white-space: nowrap; }
table.subm-table th, table.subm-table td { border-right: 1px solid #f0f3f7; }
table.subm-table th:last-child, table.subm-table td:last-child { border-right: none; }
table.subm-table th { background: #f7fafd; position: sticky; top: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
table.subm-table td.subm-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.subm-text { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.subm-empty { color: #ccd6e0; }
.subm-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; vertical-align: middle; }

/* Forms dashboard (sidebar + folder table) */
.dash-layout { display: flex; gap: 24px; align-items: flex-start; }
.dash-sidebar {
  width: 240px; flex-shrink: 0; position: sticky; top: 20px;
  max-height: calc(100vh - 40px); overflow-y: auto; padding-right: 4px;
}
.dash-side-link {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 13px;
}
.dash-side-link.dash-all { font-weight: 600; margin-bottom: 10px; align-items: center; }
.dash-side-link:hover { background: var(--card-bg); }
.dash-side-link.active { background: #f0f8ff; color: var(--accent); font-weight: 600; }
.dash-side-label { flex: 1; min-width: 0; line-height: 1.3; }
.dash-side-link .dash-side-icon { margin-top: 1px; }
.dash-side-count { flex-shrink: 0; font-size: 11px; color: var(--ink-soft); padding-left: 6px; }
.dash-side-link.active .dash-side-count { color: var(--accent); }
.dash-side-icon {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 5px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; color: #fff;
}
.dash-cat-group { margin-bottom: 14px; }
.dash-cat-head {
  display: flex; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-soft); text-decoration: none; padding: 4px 8px; border-radius: 6px;
}
a.dash-cat-head:hover { background: var(--card-bg); }
.dash-cat-head.active { color: var(--accent); }
.dash-cat-head .dash-side-count { text-transform: none; letter-spacing: normal; font-weight: 600; }
.dash-side-empty { display: block; padding: 4px 8px; font-size: 12px; color: #ccd6e0; }

.dash-main { flex: 1; min-width: 0; }
.dash-main-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.dash-main-title { margin: 0; font-size: 19px; }
.dash-new-form { display: flex; gap: 8px; }
.dash-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e6ecf2; margin-bottom: 16px; }
.dash-tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dash-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.dash-main table.admin-table td .dash-side-icon { margin-right: 6px; vertical-align: middle; }

/* Row inline expand (click a form to reveal its options below it) */
button.row-toggle {
  display: flex; align-items: center; gap: 6px; background: none; border: none; padding: 0; margin: 0;
  font: inherit; font-size: 14px; color: var(--accent); cursor: pointer; text-align: left;
}
button.row-toggle:hover { text-decoration: underline; }
.row-toggle-caret { display: inline-block; font-size: 10px; transition: transform .15s; color: var(--ink-soft); }
button.row-toggle.open .row-toggle-caret { transform: rotate(90deg); }
tr.form-options-row td { padding: 0; border-bottom: 1px solid #e6ecf2; }
tr.form-options-row[hidden] { display: none; }
.inline-options {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--card-bg);
  border-left: 3px solid var(--accent-tint); padding: 12px 16px; margin: 0;
}
.inline-options form.opt-chip-form { display: contents; }
a.opt-chip, button.opt-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid #dde6ee;
  border-radius: 20px; background: #fff; color: var(--ink); text-decoration: none; font-size: 12.5px;
  font-family: inherit; font-weight: 600; cursor: pointer;
}
a.opt-chip:hover, button.opt-chip:hover { border-color: var(--accent-tint); color: var(--accent); background: #f0f8ff; }
button.opt-chip.opt-chip-danger { color: #d33; }
button.opt-chip.opt-chip-danger:hover { border-color: #d33; background: #fff5f5; color: #d33; }
.opt-move-form { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.opt-move-form label { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.opt-move-form select { padding: 6px 26px 6px 10px; font-size: 12.5px; }
.opt-move-form .btn.secondary { padding: 6px 14px; font-size: 12.5px; }
.thankyou { text-align: center; padding: 40px 0; }
.thankyou .big { font-size: 40px; }
footer.app-footer { text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 20px; }
