* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #17202a;
  background: #f4f6f8;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 56px;
}

button {
  min-width: 112px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  color: #ffffff;
  background: #1769aa;
}

.secondary-button,
.upload-button {
  color: #17202a;
  background: #d8dee6;
}

.upload-button {
  display: inline-grid;
  place-items: center;
  min-width: 112px;
  height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.camera-box,
.result-box {
  border: 1px solid #d7dde4;
  border-radius: 8px;
  background: #ffffff;
}

.camera-box {
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: hidden;
}

video,
.preview {
  width: 100%;
  height: 100%;
  min-height: 520px;
  background: #111820;
}

video {
  object-fit: cover;
}

.preview {
  object-fit: contain;
}

.result-box {
  min-height: 520px;
  padding: 24px;
}

.label {
  color: #66717f;
  font-size: 14px;
}

.status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.45;
}

.status.idle {
  color: #2e4053;
  background: #edf1f5;
}

.status.success {
  color: #0f5132;
  background: #d1e7dd;
}

.status.warning {
  color: #664d03;
  background: #fff3cd;
}

.status.error {
  color: #842029;
  background: #f8d7da;
}

.plate {
  margin-top: 22px;
  min-height: 72px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0;
  color: #111820;
}

.details {
  display: grid;
  gap: 14px;
  margin: 8px 0 0;
}

.details div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf0f3;
}

dt {
  color: #66717f;
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.diagnostics {
  margin-top: 18px;
  color: #8a1f11;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .page {
    width: min(100vw - 16px, 560px);
    padding: 8px 0 14px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 74px 92px;
    gap: 8px;
    min-height: 46px;
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 6px 0;
    background: #f4f6f8;
  }

  button,
  .upload-button {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 8px;
    font-size: 14px;
    white-space: nowrap;
  }

  .result-panel {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .result-box {
    order: 1;
    min-height: 0;
    padding: 12px;
  }

  .camera-box {
    order: 2;
    min-height: 0;
    height: min(58vh, 430px);
  }

  video,
  .preview {
    min-height: 0;
    height: 100%;
  }

  .label {
    font-size: 13px;
  }

  .status {
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .plate {
    margin-top: 10px;
    min-height: 42px;
    font-size: 30px;
  }

  .details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
  }

  .details div {
    display: block;
    padding-bottom: 8px;
  }

  dt {
    font-size: 12px;
  }

  dd {
    margin-top: 3px;
    text-align: left;
    font-size: 14px;
  }

  .diagnostics {
    margin-top: 8px;
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .toolbar {
    grid-template-columns: 1fr 64px 82px;
  }

  button,
  .upload-button {
    font-size: 13px;
  }
}
