:root {
  --ink: #17201b;
  --muted: #68716c;
  --line: #dce3df;
  --soft: #f4f7f5;
  --green: #176b45;
  --green-dark: #105437;
  --green-soft: #e8f3ed;
  --amber: #9a6410;
  --amber-soft: #fff6df;
  --red: #b33a35;
  --white: #fff;
  --shadow: 0 14px 34px rgba(24, 40, 31, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  color: var(--ink);
  background: #f7f9f8;
  font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  letter-spacing: 0;
  max-width: 100%;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 8px; }
.brand-mark svg { width: 23px; height: 23px; }
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 17px; }
.brand span { font-size: 12px; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status > span { width: 7px; height: 7px; border-radius: 50%; background: #33a36b; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.auth-panel { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.compact { min-height: 34px; padding: 6px 10px; font-size: 12px; }

.workspace {
  width: min(1240px, calc(100% - 40px));
  margin: 32px auto 118px;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 32px;
}
.steps { position: sticky; top: 104px; height: max-content; display: grid; gap: 6px; }
.step {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 46px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  border-radius: 6px;
}
.step span { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 12px; background: white; }
.step.active { color: var(--green); background: var(--green-soft); font-weight: 700; }
.step.active span { color: white; border-color: var(--green); background: var(--green); }

.form-flow { min-width: 0; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.section { padding: 32px 36px; border-bottom: 1px solid var(--line); scroll-margin-top: 96px; }
.section:last-child { border-bottom: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.eyebrow { font-size: 12px; color: var(--green); font-weight: 800; }
h1, h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.section-state { padding: 5px 8px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); border-radius: 4px; font-size: 12px; }
.section-state.warning { color: var(--amber); border-color: #eddbac; background: var(--amber-soft); }
.section-state.success { color: var(--green); border-color: #bfddca; background: var(--green-soft); }

.upload-zone {
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 1px dashed #a8b8af;
  background: #fbfcfb;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--green); background: var(--green-soft); }
.upload-zone.drag-over { box-shadow: inset 0 0 0 2px rgba(23,107,69,.16); }
.upload-zone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { color: var(--green); width: 42px; height: 42px; display: grid; place-items: center; background: var(--green-soft); border-radius: 50%; }
.upload-zone strong { font-size: 15px; }
.upload-zone > span:last-child { color: var(--muted); font-size: 12px; }
.image-list { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.image-item { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; display: grid; place-items: center; background: rgba(23,32,27,.82); color: white; border-radius: 50%; }
.image-item button svg { width: 15px; }
.image-item em { position: absolute; left: 6px; bottom: 6px; padding: 4px 6px; background: rgba(255,255,255,.9); color: var(--ink); font-style: normal; font-size: 11px; border-radius: 3px; }
.ocr-progress { margin-top: 18px; }
.ocr-progress.hidden { display: none; }
.ocr-progress div { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.ocr-progress progress { width: 100%; height: 6px; border: 0; appearance: none; }
progress::-webkit-progress-bar { background: var(--soft); }
progress::-webkit-progress-value { background: var(--green); }

.field-grid { display: grid; gap: 16px; margin-bottom: 18px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field, .money-field { min-width: 0; display: grid; gap: 7px; }
.field > span, .money-field > span { color: #4e5953; font-size: 13px; font-weight: 700; }
.field b { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd8d3;
  border-radius: 5px;
  padding: 9px 11px;
  color: var(--ink);
  background: white;
  outline: 0;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,69,.1); }
.field.readonly input { color: var(--green); background: var(--green-soft); font-weight: 800; }
.field.flagged input:not(:valid) { border-color: #d7b864; background: #fffcf3; }
.route-row { display: grid; grid-template-columns: 1fr 42px 1fr; align-items: end; gap: 12px; margin-bottom: 18px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); background: white; color: var(--muted); display: grid; place-items: center; border-radius: 5px; }
.icon-button svg { width: 18px; }
.icon-button:hover { color: var(--green); border-color: var(--green); }
.swap { margin-bottom: 2px; }
.reason-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-bottom: 18px; }

.cost-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.money-field { padding: 17px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.money-field > span { display: flex; justify-content: space-between; gap: 8px; }
.money-field small { color: var(--green); font-weight: 400; }
.money-field > div { display: flex; align-items: center; gap: 5px; }
.money-field b { color: var(--muted); font-size: 14px; }
.money-field input { min-width: 0; width: 100%; border: 0; padding: 4px 0; outline: 0; font-size: 23px; font-weight: 700; color: var(--ink); }
.money-field.automatic { background: var(--green-soft); }
.money-field.automatic input { color: var(--green); background: transparent; }
.meal-field.disabled { background: #f6f7f6; }
.meal-field.disabled input { color: var(--muted); }
.meal-toggle { margin: 9px 0 4px; display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: 12px; font-weight: 700; }
.meal-toggle input { width: 15px; height: 15px; accent-color: var(--green); }
.car-rule-inputs { margin: 6px 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.car-rule-inputs label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.car-rule-inputs input {
  width: 100%;
  height: 32px;
  border: 1px solid #c8d6cf;
  border-radius: 4px;
  padding: 4px 6px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.car-rule-inputs input:read-only { color: var(--green); background: rgba(255,255,255,.68); }

.review-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(250px, .7fr); border: 1px solid var(--line); }
.summary-list { margin: 0; padding: 7px 20px; }
.summary-list div { padding: 11px 0; display: grid; grid-template-columns: 90px 1fr; gap: 12px; border-bottom: 1px solid var(--line); }
.summary-list div:last-child { border-bottom: 0; }
.summary-list dt { color: var(--muted); font-size: 12px; }
.summary-list dd { margin: 0; font-size: 13px; font-weight: 700; }
.total-panel { padding: 24px; display: flex; flex-direction: column; justify-content: center; background: var(--green); color: white; }
.total-panel > span { font-size: 12px; opacity: .8; }
.total-panel strong { margin: 6px 0 8px; font-size: 32px; }
.total-panel strong small { font-size: 16px; }
.total-panel em { font-style: normal; font-size: 11px; opacity: .78; }
.declaration-box { margin-top: 14px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid #eddbac; background: var(--amber-soft); color: #5b451e; font-size: 12px; line-height: 1.55; }
.declaration-box input { margin-top: 3px; accent-color: var(--green); }
.monthly-panel { margin-top: 14px; border: 1px solid var(--line); background: #fbfcfb; }
.monthly-heading { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.monthly-heading div { display: grid; gap: 3px; }
.monthly-heading strong { font-size: 15px; }
.monthly-heading span { color: var(--muted); font-size: 12px; }
#monthlyTripList { margin: 0; padding: 0; list-style: none; }
#monthlyTripList li { padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); font-size: 13px; }
#monthlyTripList li:first-child { border-top: 0; }
#monthlyTripList em { color: var(--green); font-style: normal; font-weight: 700; }
#monthlyTripList button { width: 30px; height: 30px; }
.monthly-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.stats-panel { margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); background: #fbfcfb; display: grid; gap: 10px; }
.stats-panel > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stats-panel span { color: var(--muted); font-size: 12px; }
.stats-panel strong { color: var(--green); font-size: 18px; }
.stats-panel strong b { font-size: 22px; }
.stats-panel p { margin: 0; color: var(--muted); font-size: 12px; }
.stats-panel ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.stats-panel li { padding-top: 6px; border-top: 1px solid var(--line); color: #39443e; font-size: 12px; }

.actionbar { position: fixed; z-index: 15; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%; min-height: 78px; padding: 14px max(24px, calc((100vw - 1240px) / 2)); display: flex; justify-content: flex-end; align-items: center; gap: 10px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.primary-button, .secondary-button { min-height: 42px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 5px; font-weight: 700; border: 1px solid var(--green); }
.primary-button { color: white; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: var(--green); background: white; }
.secondary-button:hover { background: var(--green-soft); }
.primary-button svg, .secondary-button svg { width: 17px; }
.primary-button.full { width: 100%; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #eef4f1; }
.login-shell { width: min(440px, calc(100% - 32px)); }
.login-panel { padding: 28px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.back-link svg { width: 16px; }
.login-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-heading h1 { font-size: 24px; }
.login-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); margin-bottom: 18px; }
.login-tabs.three { grid-template-columns: repeat(3, 1fr); }
.login-tabs button { min-height: 42px; border: 0; background: white; color: var(--muted); font-weight: 700; }
.login-tabs button.active { background: var(--green); color: white; }
.code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.login-toast { margin-top: 14px; min-height: 20px; color: var(--red); font-size: 13px; opacity: 0; transition: .18s; }
.login-toast.show { opacity: 1; }

.admin-page { background: #f7f9f8; }
.admin-shell { width: min(1120px, calc(100% - 40px)); margin: 32px auto 80px; display: grid; gap: 18px; }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.admin-card { padding: 22px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 8px; }
.admin-card span { color: var(--muted); font-size: 13px; }
.admin-card strong { color: var(--green); font-size: 30px; }
.admin-card b { font-size: 30px; }
.admin-table { padding: 24px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.admin-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table th { color: var(--muted); background: var(--soft); }

dialog { width: min(480px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 7px; padding: 0; box-shadow: 0 26px 70px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(19,29,24,.45); }
dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.dialog-heading h2 { font-size: 18px; }
dialog .field { margin-bottom: 16px; }
dialog menu { padding: 8px 0 0; margin: 0; display: flex; justify-content: flex-end; gap: 8px; }
.privacy-note { margin: -4px 0 8px; color: var(--muted); font-size: 12px; }
.image-item img { cursor: zoom-in; }
.image-item img:focus-visible { outline: 3px solid rgba(23,107,69,.22); outline-offset: 2px; }
.image-preview-dialog { width: min(760px, calc(100% - 28px)); background: #111; border-color: #111; }
.image-preview-dialog img { display: block; width: 100%; max-height: 82vh; object-fit: contain; background: #111; }
.image-preview-close { position: absolute; top: 10px; right: 10px; z-index: 1; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.92); }
.plate-builder { display: flex; align-items: center; gap: 6px; min-width: 0; }
.plate-builder > select, .plate-suffix select {
  height: 44px;
  border: 1px solid #cfd8d3;
  border-radius: 5px;
  padding: 0 7px;
  color: var(--ink);
  background: white;
  font-weight: 700;
  outline: 0;
}
.plate-builder > select { width: 58px; flex: 0 0 58px; }
.plate-suffix { display: grid; grid-template-columns: repeat(6, minmax(38px, 1fr)); gap: 5px; min-width: 0; flex: 1; }
.plate-suffix select { width: 100%; min-width: 0; padding: 0 2px; text-align: center; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 96px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 10px 14px; color: white; background: #1f2a24; border-radius: 5px; font-size: 13px; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.print-sheet { display: none; }

@media (max-width: 820px) {
  .topbar { padding: 10px 16px; }
  .status { display: none; }
  .workspace { width: 100%; margin-top: 0; display: block; }
  .steps { position: sticky; top: 64px; z-index: 10; width: 100%; max-width: 100%; overflow: hidden; grid-template-columns: repeat(4, minmax(0, 1fr)); background: white; border-bottom: 1px solid var(--line); }
  .step { justify-content: center; min-height: 48px; padding: 6px; font-size: 0; border-radius: 0; }
  .step span { font-size: 12px; }
  .form-flow { border: 0; box-shadow: none; }
  .section { padding: 25px 18px; }
  .section-heading { margin-bottom: 20px; }
  .section-heading .section-state { display: none; }
  .image-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-grid.two, .field-grid.three, .field-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-row { grid-template-columns: 1fr 38px 1fr; gap: 7px; }
  .cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-layout { grid-template-columns: 1fr; }
  .total-panel { min-height: 145px; }
  .actionbar { min-height: 70px; padding: 10px 12px; }
  .actionbar button { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: 12px; white-space: nowrap; overflow: hidden; }
}

@media (max-width: 520px) {
  .brand span { display: none; }
  .field-grid.two, .field-grid.three, .field-grid.four { grid-template-columns: 1fr; }
  .route-row { grid-template-columns: 1fr 36px; }
  .route-row .field:last-child { grid-column: 1 / -1; }
  .route-row .swap { grid-column: 2; grid-row: 1; }
  .reason-row { grid-template-columns: 1fr; }
  .image-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-grid { grid-template-columns: 1fr; }
  .actionbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actionbar #printButton { display: none; }
  .plate-builder { align-items: stretch; flex-wrap: wrap; }
  .plate-suffix { flex-basis: 100%; grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media print {
  body { background: white; }
  .topbar, .workspace, .actionbar, .toast, dialog { display: none !important; }
  .print-sheet { display: block; padding: 8mm; color: black; }
  .print-sheet h1 { text-align: center; font-size: 20px; margin-bottom: 20px; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { border: 1px solid #333; padding: 10px; text-align: left; font-size: 13px; }
  .print-sheet th { width: 25%; }
  .print-sheet p { margin-top: 24px; font-size: 12px; }
  .signatures { margin-top: 42px; display: flex; justify-content: space-between; }
}
