:root {
  --bg: #eef2f0;
  --bg-2: #e2eae5;
  --ink: #152019;
  --muted: #5a6b60;
  --card: #f7faf8;
  --line: #c5d2ca;
  --accent: #1f6b4a;
  --accent-2: #164f37;
  --warn: #8a5a12;
  --warn-bg: #fff3d9;
  --err: #8b2e2e;
  --err-bg: #fdeceb;
  --ok: #1f6b4a;
  --ok-bg: #dff3e8;
  --shadow: 0 10px 30px rgba(21, 32, 25, 0.08);
  --radius: 18px;
  --font: "DM Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, #d9ebe1 0%, transparent 42%),
    radial-gradient(circle at 90% 10%, #d5e0ef 0%, transparent 35%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.top {
  margin-bottom: 18px;
}

.brand {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.status-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

.pill[data-ok="1"] {
  background: var(--ok-bg);
  border-color: #b7ddc8;
  color: var(--ok);
}

.pill[data-ok="0"] {
  background: var(--warn-bg);
  border-color: #efd7a4;
  color: var(--warn);
}

.card-block,
.scanner-block,
.result,
.error-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.upload-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .upload-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.upload-title {
  font-weight: 700;
}

.upload-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.upload input[type="file"] {
  font-size: 0.85rem;
}

.msg {
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--muted);
}

.msg.ok {
  color: var(--ok);
}

.msg.err {
  color: var(--err);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-2);
}

.btn.secondary {
  background: #e8f1ec;
  color: var(--accent-2);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.scan-main h2 {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.15rem;
  color: var(--ink);
}

.ready-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.ready-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(31, 107, 74, 0.45);
  animation: pulse 1.6s ease infinite;
}

.ready-dot.busy {
  background: var(--warn);
  animation: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 107, 74, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(31, 107, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 107, 74, 0); }
}

.scan-form {
  display: flex;
  gap: 8px;
}

.scan-form input {
  flex: 1;
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 16px 16px;
  font: inherit;
  font-family: var(--mono);
  font-size: 1.05rem;
  background: #fff;
  outline: none;
}

.scan-form input:focus {
  box-shadow: 0 0 0 4px rgba(31, 107, 74, 0.15);
}

.scan-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.camera-opt {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.camera-opt summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.reader {
  overflow: hidden;
  border-radius: 14px;
  background: #101611;
  min-height: 220px;
}

.reader video {
  border-radius: 14px !important;
}

.scanner-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.result {
  text-align: center;
  animation: pop 0.28s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.result-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  font-weight: 700;
}

.result-pedido {
  margin: 6px 0 18px;
  font-family: var(--mono);
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  word-break: break-all;
}

.result-parada {
  margin: 6px 0 10px;
  font-family: var(--mono);
  font-size: clamp(4rem, 18vw, 6rem);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.result-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.result-address {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.35;
}

.error-box {
  background: var(--err-bg);
  border-color: #f0bcbc;
  color: var(--err);
  font-weight: 500;
}

.reset-btn {
  margin-top: 12px;
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

.field select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 0.95rem;
}

.printer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-print {
  margin: 12px 0 0;
  color: var(--ok);
  font-size: 0.92rem;
  font-weight: 700;
}

.result-print.err {
  color: var(--err);
}

#reprintBtn {
  margin-top: 14px;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 16px;
}

@media (min-width: 720px) {
  .modal {
    place-items: center;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 22, 17, 0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
  animation: pop 0.22s ease;
}

.modal-card h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.modal-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  font-family: var(--mono);
  word-break: break-all;
}

.choice-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.choice-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: start;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7faf8;
  padding: 12px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice-key {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  background: #fff;
}

.choice-key-empty {
  visibility: hidden;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  padding: 22px 16px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  margin: 14px 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--ok-bg);
}

.dropzone input[type="file"] {
  display: none;
}

.drop-title {
  font-weight: 700;
  font-size: 1.05rem;
  word-break: break-all;
}

.drop-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.convert-btn {
  width: 100%;
}

.footer-link {
  text-align: center;
  margin-top: 8px;
}

.footer-link a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.footer-link a:hover {
  text-decoration: underline;
}

.choice-item:hover,
.choice-item:focus-visible {
  border-color: var(--accent);
  background: var(--ok-bg);
  outline: none;
}

.choice-stop {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--accent);
  line-height: 1;
  min-width: 2.4ch;
}

.choice-body {
  display: grid;
  gap: 4px;
}

.choice-addr {
  font-size: 0.95rem;
  line-height: 1.35;
}

.choice-eta {
  color: var(--muted);
  font-size: 0.85rem;
}
