/* ---------------------------------------------------------------------------
   FormHub - Traum Woodworking
   --------------------------------------------------------------------------- */

:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --border: #e2ddd6;
  --border-strong: #cfc7bc;
  --text: #1c1917;
  --text-muted: #6b6259;
  --text-faint: #948a7f;
  --accent: #a2601b;
  --accent-hover: #834d15;
  --accent-soft: #fdf3e6;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --success: #2f7a4a;
  --success-soft: #eef8f1;
  --ring: rgba(162, 96, 27, 0.18);
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 16px rgba(28, 25, 23, 0.07);
  --radius: 10px;
  --radius-lg: 14px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --surface: #211e18;
    --surface-2: #1a1813;
    --border: #35302a;
    --border-strong: #4a443c;
    --text: #f0ece6;
    --text-muted: #a8a099;
    --text-faint: #7d766e;
    --accent: #d99845;
    --accent-hover: #eab063;
    --accent-soft: #2c2419;
    --danger: #f2837a;
    --danger-soft: #2e1a19;
    --success: #71c894;
    --success-soft: #17251d;
    --ring: rgba(217, 152, 69, 0.22);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- layout --------------------------------------------------------------- */

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wordmark {
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.wordmark .mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: block;
}

/* Black artwork on transparency: invert rather than sit it on a white patch. */
@media (prefers-color-scheme: dark) {
  .wordmark .mark {
    filter: invert(1);
  }
}

.hero-mark {
  width: 60px;
  height: 60px;
  display: block;
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .hero-mark {
    filter: invert(1);
  }
}

.topbar-spacer {
  flex: 1;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.back-link:hover {
  color: var(--accent);
}

/* --- page header ---------------------------------------------------------- */

.page-head {
  padding: 44px 0 28px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.022em;
  font-weight: 660;
}

.page-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 16px;
  max-width: 56ch;
}

.required-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-faint);
}

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

/* --- form index ----------------------------------------------------------- */

.form-grid {
  display: grid;
  gap: 12px;
}

.form-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.form-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.form-card .icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 17px;
  flex: none;
}

.form-card h2 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.form-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.form-card .chevron {
  margin-left: auto;
  align-self: center;
  color: var(--text-faint);
  font-size: 18px;
}

/* --- form ----------------------------------------------------------------- */

.form-card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 8px 26px 26px;
}

.field {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.field:last-of-type {
  border-bottom: none;
}

.field-label {
  display: block;
  font-size: 15px;
  font-weight: 580;
  letter-spacing: -0.005em;
  margin-bottom: 3px;
}

.field-label .req {
  color: var(--danger);
  margin-left: 3px;
}

.field-help {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.field-label + .field-control,
.field-label + .field-help {
  margin-top: 9px;
}

.field-help + .field-control {
  margin-top: 0;
}

input[type='text'],
input[type='email'],
input[type='date'],
input[type='number'],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

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

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

/* Native date pickers render dark-on-dark without this nudge. */
@media (prefers-color-scheme: dark) {
  input[type='date'] {
    color-scheme: dark;
  }
}

/* --- choices -------------------------------------------------------------- */

.choices {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface-2);
  font-size: 15px;
  transition: border-color 0.12s, background 0.12s;
}

.choice:hover {
  border-color: var(--accent);
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice input {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  margin: 0;
  flex: none;
}

.choice-other {
  align-items: center;
  flex-wrap: wrap;
}

.choice-other input[type='text'] {
  flex: 1;
  min-width: 140px;
  width: auto;
  padding: 5px 9px;
  font-size: 14px;
  background: var(--surface);
}

/* --- combobox ------------------------------------------------------------- */

.combobox {
  position: relative;
}

.combobox-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 246px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 4px;
  margin: 0;
  list-style: none;
}

.combobox-list[hidden] {
  display: none;
}

.combobox-list li {
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14.5px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.combobox-hint {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.combobox-list li[aria-selected='true'],
.combobox-list li:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.combobox-list .empty {
  color: var(--text-faint);
  cursor: default;
  font-style: italic;
}

.combobox-list .empty:hover {
  background: none;
  color: var(--text-faint);
}

/* --- section heading ------------------------------------------------------ */

.section-heading {
  padding: 26px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.section-heading:first-child {
  border-top: none;
  margin-top: 0;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.012em;
}

.section-heading p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* --- repeater ------------------------------------------------------------- */

.field:has(> .repeater) {
  border-bottom: none;
  padding-top: 14px;
}

.repeater-items {
  display: grid;
  gap: 14px;
}

.repeater-item {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 0 18px 6px;
}

.repeater-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 2px;
  border-bottom: 1px solid var(--border);
}

.repeater-item-num {
  font-size: 13px;
  font-weight: 660;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--accent);
}

.repeater-remove {
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  font-weight: 520;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 3px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, opacity 0.15s;
}

.repeater-remove:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}

.repeater-remove:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Inside a card the inputs sit on --surface-2, so lift them to --surface. */
.repeater-item input[type='text'],
.repeater-item input[type='email'],
.repeater-item input[type='date'],
.repeater-item input[type='number'],
.repeater-item textarea,
.repeater-item .choice {
  background: var(--surface);
}

.repeater-item .field:last-of-type {
  border-bottom: none;
}

.btn-add {
  margin-top: 14px;
  width: 100%;
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--accent);
  font-weight: 560;
  padding: 11px;
}

.btn-add:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-add:disabled {
  opacity: 0.4;
  cursor: default;
  color: var(--text-muted);
}

/* --- validation ----------------------------------------------------------- */

.field.has-error input,
.field.has-error textarea,
.field.has-error select {
  border-color: var(--danger);
}

.field-error {
  display: none;
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--danger);
  font-weight: 500;
}

.field.has-error .field-error {
  display: block;
}

/* --- actions -------------------------------------------------------------- */

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 24px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 570;
  padding: 11px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #17150f;
  }
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--danger);
}

.form-status {
  font-size: 14px;
  color: var(--danger);
  font-weight: 500;
}

/* --- confirmation --------------------------------------------------------- */

.confirmation {
  text-align: center;
  padding: 52px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.confirmation .check {
  width: 50px;
  height: 50px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid;
  place-items: center;
  font-size: 24px;
}

.confirmation h2 {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.confirmation p {
  margin: 0 auto 22px;
  color: var(--text-muted);
  max-width: 44ch;
}

/* The confirmation is an instruction sheet, not a receipt — the request does
   nothing until a printout reaches the shop, so these read left-aligned and
   numbered rather than as centred reassurance. */
.next-steps {
  text-align: left;
  max-width: 46ch;
  margin: 0 auto 22px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
}

.next-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
  font-size: 15.5px;
  line-height: 1.5;
}

.next-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 680;
  display: grid;
  place-items: center;
}

@media (prefers-color-scheme: dark) {
  .next-steps li::before {
    color: #17150f;
  }
}

.confirm-callout {
  text-align: left;
  max-width: 46ch;
  margin: 0 auto 24px;
  padding: 13px 16px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14.5px;
  line-height: 1.55;
}

.confirm-callout strong {
  display: block;
  color: var(--danger);
  font-weight: 680;
  margin-bottom: 2px;
}

.confirm-callout span {
  color: var(--text);
}

.confirmation-links {
  display: flex;
  gap: 22px;
  justify-content: center;
  font-size: 14.5px;
  font-weight: 520;
}

.confirmation-links a {
  color: var(--accent);
  text-decoration: none;
}

.confirmation-links a:hover {
  text-decoration: underline;
}

/* --- admin ---------------------------------------------------------------- */

.shell-wide {
  max-width: 1080px;
}

.btn-linkish {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.login-panel {
  max-width: 380px;
  padding: 8px 24px 20px;
}

.admin-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.admin-controls #q {
  flex: 1 1 260px;
  width: auto;
}

.admin-controls select,
.admin-controls input[type='date'] {
  width: auto;
  flex: 0 0 auto;
}

.btn-export {
  text-decoration: none;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.btn-export:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table th {
  font-size: 12px;
  font-weight: 660;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-2);
  white-space: nowrap;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table .nowrap {
  white-space: nowrap;
}

.cell-sub {
  font-size: 12.5px;
  color: var(--text-faint);
}

.row-clickable {
  cursor: pointer;
}

.row-clickable:hover {
  background: var(--accent-soft);
}

.row-open {
  color: var(--accent);
  font-size: 13px;
  font-weight: 560;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 580;
  white-space: nowrap;
}

.pill-delivered { background: var(--success-soft); color: var(--success); }
.pill-failed    { background: var(--danger-soft);  color: var(--danger); }
.pill-pending   { background: var(--accent-soft);  color: var(--accent); }
.pill-skipped   { background: var(--surface-2);    color: var(--text-faint); }

.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
}

.pager-label {
  font-size: 13.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- detail modal --------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.5);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}

.modal-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: min(760px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px 26px 26px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0 0 3px;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 17px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.summary-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  overflow-x: auto;
}

.raw-details {
  margin-top: 14px;
}

.raw-details summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 540;
  margin-bottom: 10px;
}

/* --- misc ----------------------------------------------------------------- */

.skeleton {
  padding: 60px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 15px;
}

.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.footnote {
  margin-top: 26px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

@media (max-width: 560px) {
  .page-head {
    padding: 30px 0 22px;
  }
  .page-head h1 {
    font-size: 25px;
  }
  .form-card-panel {
    padding: 4px 18px 20px;
    border-radius: var(--radius);
  }
  .actions {
    flex-wrap: wrap;
  }
}
