/* The complaint form. Semco maroon as a restrained accent, neutral everywhere
   else, and no colour that reads as bad news for a normal answer: out of
   warranty is a customer, not an error, so it is never painted red. */

:root {
  --brand: #7a0019;
  --brand-hover: #5f0014;
  --brand-tint: #f8eef0;
  --canvas: #f4f4f5;
  --surface: #ffffff;
  --ink: #18181b;
  --body: #3f3f46;
  --muted: #5f5f68;
  --border: #d4d4d8;
  --border-soft: #e4e4e7;
  --focus: #7a0019;
  --error: #b42318;
  --error-tint: #fef3f2;
  --ok: #067647;
  --ok-tint: #ecfdf3;
  --info-tint: #f4f4f5;
  --radius: 10px;
  --radius-small: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #e0707f;
    --brand-hover: #eb95a1;
    --brand-tint: #2a171b;
    --canvas: #111113;
    --surface: #1b1b1f;
    --ink: #f4f4f5;
    --body: #d4d4d8;
    --muted: #a1a1aa;
    --border: #3f3f46;
    --border-soft: #2e2e33;
    --focus: #e0707f;
    --error: #f97066;
    --error-tint: #2b1614;
    --ok: #47cd89;
    --ok-tint: #10261a;
    --info-tint: #232327;
    color-scheme: dark;
  }
  .logo { filter: brightness(0) invert(0.92); }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

#main { flex: 1; padding-top: 28px; padding-bottom: 48px; outline: none; }

h1, h2 { color: var(--ink); line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 12px; }

a { color: var(--brand); }
a:hover { color: var(--brand-hover); }

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius-small);
  z-index: 10;
}
.skip:focus { left: 8px; }

/* Header and footer */

.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--brand);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}
.logo { height: 20px; width: auto; display: block; }
.header-label { font-size: 0.875rem; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border-soft);
  font-size: 0.875rem;
  color: var(--muted);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.site-footer p { margin: 0; }

/* Intro and progress */

.intro { margin-bottom: 20px; }
.lede { font-size: 1.05rem; }

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 3px solid var(--border-soft);
  font-size: 0.875rem;
  color: var(--muted);
  min-width: 0;
}
.steps li[data-state="current"] { border-top-color: var(--brand); color: var(--ink); font-weight: 600; }
.steps li[data-state="done"] { border-top-color: var(--brand); }
.step-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.75rem;
}
.steps li[data-state="current"] .step-num,
.steps li[data-state="done"] .step-num { background: var(--brand); border-color: var(--brand); color: var(--surface); }
.step-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
@media (max-width: 480px) {
  .card { padding: 18px 16px; }
  h1 { font-size: 1.4rem; }
}

.hint { color: var(--muted); font-size: 0.95rem; }

/* Fields */

.field { margin: 18px 0 0; }
label, .machine-legend { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; }

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 11px 12px;
  min-height: 46px;
}
textarea { resize: vertical; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; text-transform: uppercase; }
.input-row input::placeholder { text-transform: none; }
@media (max-width: 420px) {
  .input-row { flex-direction: column; }
}

.field-error { color: var(--error); font-size: 0.9rem; margin: 6px 0 0; }

/* Buttons */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-small);
  min-height: 46px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.2;
}
.btn[disabled] { cursor: not-allowed; opacity: 0.55; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--brand-hover); }
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #1b0a0d; }
}
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); white-space: nowrap; }
.btn-secondary:hover:not([disabled]) { background: var(--info-tint); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn-ghost:hover { background: var(--info-tint); }
.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  padding: 8px 0;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-inline { min-height: 0; padding: 0; margin-left: 8px; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: 0.9rem; }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}
@media (max-width: 420px) {
  .actions { flex-direction: column-reverse; align-items: stretch; }
  .actions > span:empty { display: none; }
}

/* Serial lookup results */

.lookup:empty { display: none; }
.lookup { margin-top: 10px; }

.result {
  border-radius: var(--radius-small);
  padding: 12px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--border-soft);
  background: var(--info-tint);
}
.result p:last-child { margin-bottom: 0; }
.result-title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.result-found { background: var(--ok-tint); border-color: transparent; }
.result-found .result-title { color: var(--ok); }
.result dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 6px 0 0; }
.result dt { color: var(--muted); }
.result dd { margin: 0; color: var(--ink); }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 8px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Notices */

.notice {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--info-tint);
  border: 1px solid var(--border-soft);
}
.notice p:last-child { margin-bottom: 0; }
.notice-title { font-weight: 600; color: var(--ink); }
.notice-error { background: var(--error-tint); border-color: transparent; color: var(--ink); }
.notice-error strong { color: var(--error); }

/* Machines in step 3 */

.machine {
  position: relative;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin: 18px 0 0;
  min-width: 0;
}
.machine-legend { padding: 0 6px; margin-left: -6px; }
.btn-remove { position: absolute; top: 2px; right: 14px; }
.machine .field:first-of-type { margin-top: 4px; }
.machine-found {
  font-size: 0.95rem;
  background: var(--info-tint);
  border-radius: var(--radius-small);
  padding: 10px 12px;
  margin-top: 4px;
}
.machine-found strong { color: var(--ink); }

#add-machine { margin-top: 8px; }

.review {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 12px;
  border-top: 1px solid var(--border-soft);
  margin-top: 20px;
  padding-top: 16px;
}
.review-label { flex-basis: 100%; color: var(--muted); font-size: 0.875rem; margin: 0; }
.review-value { color: var(--ink); margin: 0; overflow-wrap: anywhere; }
.review .btn-link { min-height: 0; padding: 0; }

/* Confirmation */

.done { text-align: center; padding-top: 32px; padding-bottom: 32px; border-top: 4px solid var(--brand); }
.done-kicker { color: var(--ok); font-weight: 600; margin-bottom: 4px; }
.done-title { font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.complaint-no {
  font-size: clamp(2rem, 9vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin: 4px 0 12px;
  overflow-wrap: anywhere;
  user-select: all;
}
.done-message { margin: 18px auto 0; max-width: 440px; }

.next-list { margin: 8px 0 16px; padding-left: 20px; }
.next-list li { margin-bottom: 6px; }

.again { text-align: center; }

@media print {
  .site-header { border-bottom-color: #000; }
  .site-footer, .again, #copy-number { display: none; }
  .card { border: none; }
}
