:root {
  --bg: #f4f4f5;
  --ink: #111111;
  --muted: #9a9a9f;
  --border: #d8d8dc;
  --field-bg: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute always wins over display rules below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 32px 24px;
}

/* Full-height card with three anchored zones so the top (logo + toggle) and
   bottom (printer + status) never move when the middle content changes. */
.card {
  width: 100%;
  max-width: 420px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transition: max-width .2s ease;
}

/* Auto mode: widen so the full ~54-char data matrix is visible in the field. */
.card.auto {
  max-width: 640px;
}

/* Login screen: a single centred box instead of the three zones. */
.card-login {
  justify-content: center;
}

.login-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.logo {
  width: 200px;
  max-width: 60%;
  height: auto;
}

/* Three equal-height zones, each vertically centring its own content, so
   nothing moves when the middle content changes. */
.top,
.middle,
.bottom {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.top { gap: 40px; }
.bottom { gap: 16px; }

.middle {
  gap: 16px;
  padding: 24px 0;
}

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e8e8ea;
  border-radius: 10px;
}

.mode-option {
  padding: 8px 22px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}

.mode-option:hover { color: var(--ink); }

.mode-option.is-active {
  color: var(--ink);
  background: var(--field-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  width: 100%;
  padding: 16px 18px;
  font-size: 17px;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field::placeholder { color: var(--muted); }

.field:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
}

.print {
  width: 100%;
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  background: var(--ink);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity .15s ease, transform .05s ease;
}

.print:hover { opacity: .88; }
.print:active { transform: translateY(1px); }

.batch-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

/* Visually-hidden checkbox drives the switch state (keeps it accessible). */
.switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  background: #d3d3d8;
  border-radius: 999px;
  transition: background .18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}

.switch-input:checked + .switch {
  background: var(--ink);
}

.switch-input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-input:focus-visible + .switch {
  box-shadow: 0 0 0 3px rgba(17, 17, 17, .15);
}

.switch-input:disabled + .switch {
  opacity: .5;
}

/* Compact confirmation modal, bottom-centre, that fades in/out. */
.result {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(10px);
  width: auto;
  max-width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 18px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  text-align: center;
}

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

.result-line {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.result-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Always occupies its slot; only becomes visible when an error is set, so
   showing/hiding it never moves the form. */
.error {
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 12px 18px;
  font-size: 15px;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius);
  text-align: center;
  visibility: hidden;
}

.error.show {
  visibility: visible;
}

.printer-row {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.printer-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.printer-select {
  flex: 1;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
}

.printer-select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
}

/* Locked (in-progress) states — clearly greyed out and non-interactive. */
.field:disabled,
.printer-select:disabled {
  background: #ececee;
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}

.print:disabled {
  background: #c8c8cc;
  color: #ffffff;
  cursor: not-allowed;
  opacity: 1;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #15803d; /* green */
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-green 1.6s ease-out infinite;
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); }
  70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.status.printing {
  color: #b45309; /* amber */
}

.status.printing .status-dot {
  background: #f59e0b;
  animation: pulse-amber 1s ease-out infinite;
}

@keyframes pulse-amber {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, .5); }
  70%  { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
