:root {
  --red: #c4121a;
  --gold: #b08968;
  --black: #111111;
  --cream: #f4f0ea;
  --ink: #1c1c1c;
  --muted: #6b6560;
  --ok: #2e7d4f;
  --issue: #b42318;
  --line: #e7e0d6;
  --white: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #2a2623;
  line-height: 1.4;
}

button,
input,
textarea,
select {
  font: inherit;
}

#shell {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--cream);
  box-shadow: 0 0 48px rgba(0, 0, 0, 0.35);
  position: relative;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}

.top {
  background: var(--black);
  color: var(--white);
  padding: calc(18px + var(--safe-top)) 20px 22px;
}

.top.compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 8px 10px;
  min-height: calc(56px + var(--safe-top));
}

.top h1 {
  margin: 14px 0 0;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 700;
}

.logo {
  height: 46px;
  width: auto;
  display: block;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--white);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn.dark {
  color: var(--ink);
}

.top-title {
  flex: 1;
  font-weight: 700;
  font-size: 1.1rem;
}

.body {
  flex: 1;
  padding: 20px 16px calc(24px + var(--safe-bottom));
}

.body.scroll {
  overflow: auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.82rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grow {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.btn.block {
  width: 100%;
}

.btn.primary {
  background: var(--red);
  color: var(--white);
}

.btn.primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.ghost {
  background: transparent;
  border-color: #d9d2c8;
  color: var(--ink);
}

.btn.text {
  background: transparent;
  min-height: 40px;
  color: var(--red);
  font-weight: 600;
  padding: 0 8px;
}

.btn.small {
  min-height: 40px;
  border-radius: 10px;
}

.switch {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
}

.switch input {
  appearance: none;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #d9d2c8;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
}

.switch input::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  top: 3px;
  left: 3px;
  transition: transform 0.15s ease;
}

.switch input:checked {
  background: var(--red);
}

.switch input:checked::after {
  transform: translateX(20px);
}

label.field {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid #d9d2c8;
  border-radius: 12px;
  padding: 14px 12px;
  background: var(--white);
  color: var(--ink);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid #d9d2c8;
  background: var(--white);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 500;
}

.chip.ok.selected {
  border-color: var(--ok);
  color: var(--ok);
  background: rgba(46, 125, 79, 0.16);
  font-weight: 700;
}

.chip.issue.selected {
  border-color: var(--issue);
  color: var(--issue);
  background: rgba(180, 35, 24, 0.14);
  font-weight: 700;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.seg button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid #d9d2c8;
  background: var(--white);
  cursor: pointer;
  font-weight: 600;
}

.seg button.selected {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.progress {
  height: 8px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--red);
}

.station-item {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  cursor: pointer;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--white);
  flex-shrink: 0;
  font-size: 1.1rem;
}

.avatar.lock {
  background: var(--line);
  color: var(--ink);
}

.avatar.edit {
  background: var(--gold);
}

.avatar.done {
  background: var(--ok);
}

.check-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.check-card h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.status-box {
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
}

.status-box.lock {
  background: #fff4e8;
}

.status-box.open {
  background: #eaf6ee;
}

.photos {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.photo {
  position: relative;
  aspect-ratio: 1;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.photo .x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: var(--white);
  cursor: pointer;
}

.bottom-bar {
  padding: 8px 16px calc(16px + var(--safe-bottom));
  background: var(--cream);
  border-top: 1px solid var(--line);
}

.menu {
  position: relative;
}

.menu-list {
  position: absolute;
  right: 8px;
  top: 52px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  min-width: 220px;
  z-index: 5;
  overflow: hidden;
}

.menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  background: var(--white);
  cursor: pointer;
}

.menu-list button:hover {
  background: var(--cream);
}

.scanner {
  background: #000;
  color: var(--white);
}

.scanner .stage {
  position: relative;
  flex: 1;
  background: #000;
  min-height: 280px;
}

.scanner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.scanner .hint {
  position: relative;
  padding: 16px 20px calc(24px + var(--safe-bottom));
  background: rgba(0, 0, 0, 0.72);
}

.scanner .hint p {
  margin: 0 0 12px;
}

.scanner .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.qr-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.qr-box {
  width: 108px;
  height: 108px;
  background: var(--white);
  flex-shrink: 0;
  padding: 8px;
}

.qr-box img,
.qr-box canvas {
  width: 92px !important;
  height: 92px !important;
}

.code {
  color: var(--red);
  font-weight: 800;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 380px;
  z-index: 40;
}

#toast[hidden] {
  display: none !important;
}

.form-error {
  color: var(--issue);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.dialog {
  background: var(--white);
  border-radius: 16px;
  padding: 20px;
  width: min(360px, 100%);
}

.dialog h3 {
  margin: 0 0 8px;
}

.dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.report-page {
  background: var(--white);
  color: #111;
  padding: 16px;
}

.report-head {
  background: #111;
  padding: 10px 12px;
  display: flex;
  align-items: center;
}

.report-head img {
  height: 28px;
}

.kv {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 0.9rem;
}

.kv td {
  border: 1px solid var(--line);
  padding: 6px 8px;
}

.kv td:first-child {
  font-weight: 700;
  width: 34%;
}

.station-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.check-line {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.check-line .ok {
  color: var(--ok);
  font-weight: 700;
}

.check-line .issue {
  color: var(--issue);
  font-weight: 700;
}

.check-line .open {
  color: var(--issue);
  font-weight: 700;
}

.note {
  margin: 0 0 6px 88px;
  color: var(--muted);
  font-size: 0.82rem;
}

.thumbs {
  margin: 0 0 8px 88px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thumbs img {
  width: 120px;
  height: 88px;
  object-fit: cover;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.warn {
  color: var(--issue);
}

@media print {
  body {
    background: #fff;
  }

  #shell {
    max-width: none;
    box-shadow: none;
  }

  .no-print {
    display: none !important;
  }

  .report-page {
    padding: 0;
  }
}
