:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d6dbe5;
  --brand: #0b5cab;
  --brand-dark: #0a4784;
  --red: #c1272d;
  --ok: #1c8b4d;
  --warn: #b97500;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: radial-gradient(circle at 20% -20%, #d9ecff 0, transparent 30%), var(--bg);
}

.container {
  width: min(1080px, 94vw);
  margin: 24px auto 40px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

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

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

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

button {
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  transition: background 0.2s ease;
}

button:hover {
  background: var(--brand-dark);
}

button.secondary {
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #f5f8ff;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row > * {
  flex: 1;
}

.ball {
  display: inline-flex;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.ball.front {
  background: #1e63b8;
}

.ball.back {
  background: #f5ab00;
}

.draw-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.small {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

.info {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.summary {
  display: grid;
  gap: 4px;
  font-weight: 600;
  font-size: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

th {
  background: #eef3fb;
}

.video-wrap {
  position: relative;
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #f7fafc;
}

#scanVideo {
  width: 100%;
  max-height: 320px;
  display: block;
}

#scanCanvas {
  display: none;
}

.upload-btn {
  width: 100%;
  padding: 16px 14px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  background: linear-gradient(135deg, #0b5cab 0%, #0a4784 100%);
  box-shadow: 0 6px 16px rgba(11, 92, 171, 0.25);
}

.crop-wrap {
  margin-top: 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #f7fafc;
}

#cropCanvas {
  width: 100%;
  display: block;
  touch-action: none;
}

.crop-actions {
  margin-top: 10px;
}

.crop-actions > button:first-child {
  font-weight: 700;
}

.crop-result-wrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}

#cropResultCanvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  margin-top: 6px;
  background: #f8fafc;
}

.linkbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.linkbar a {
  color: var(--brand);
  font-size: 13px;
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.review-actions #confirmAllBtn {
  width: auto;
  min-width: 96px;
  padding: 8px 12px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  background: #fbfdff;
}

.review-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.review-label {
  width: 46px;
  font-size: 12px;
  color: var(--muted);
}

.num-chip {
  width: 54px;
  min-width: 54px;
  padding: 12px 0;
  border-radius: 12px;
  font-weight: 700;
  font-size: 16px;
}

.num-chip.front {
  background: #edf4ff;
  color: #1e63b8;
  border-color: #b9d0f8;
}

.num-chip.back {
  background: #fff6e5;
  color: #b97500;
  border-color: #f0d29a;
}

.num-chip.confirmed {
  outline: 2px solid var(--ok);
  color: var(--ok);
  background: #f3fff8;
  border-color: #9ed9b8;
}

.num-chip.unconfirmed::after {
  content: '*';
  margin-left: 1px;
  color: var(--red);
}

.review-plus {
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 900px) {
  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .ball {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .num-chip {
    width: 48px;
    min-width: 48px;
    padding: 10px 0;
  }

  .review-actions {
    width: 100%;
    justify-content: space-between;
  }
}
