:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #18231e;
  background: #f4f6f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #18231e;
  --muted: #67736c;
  --line: #dfe5dd;
  --paper: #fff;
  --green: #176c4c;
  --green-dark: #10573c;
  --green-soft: #e6f2eb;
  --amber: #9c5e16;
  --amber-soft: #fbf0df;
  --red: #a64236;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background: #f4f6f2;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
[hidden] { display: none !important; }

.topbar {
  height: 64px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; color: white; background: var(--green); border-radius: 7px; font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection i { display: inline-block; width: 7px; height: 7px; background: #b17720; border-radius: 50%; }
.connection.online i { background: #32845f; }
.connection.offline i { background: #b64438; }

.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 64px; }
.page-heading, .records-heading, .summary-heading, .admin-heading, .form-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 20px; }
.page-heading time { padding-bottom: 4px; color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0 0 6px; color: #607269; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.35; }
h3 { margin-bottom: 16px; font-size: 14px; }

.entry-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .85fr); gap: 20px; align-items: stretch; }
.entry-form, .fleet-summary, .admin-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.entry-form { padding: 24px; }
.form-heading { align-items: center; margin-bottom: 22px; }
.required-note { color: #849087; font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; color: #39463f; font-size: 12px; font-weight: 650; }
.field b { color: var(--red); }
input, select {
  width: 100%;
  height: 41px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd8d0;
  border-radius: 5px;
  outline: none;
}
input:focus, select:focus { border-color: #4c9571; box-shadow: 0 0 0 3px rgba(40, 124, 83, .12); }
input::placeholder { color: #a1aaa4; }
.field-wide { grid-column: 1 / -1; }
.field small { min-height: 15px; color: #68766d; font-size: 11px; font-weight: 500; }
.field small.invalid { color: var(--red); }
.odometer-value { display: flex; min-height: 41px; align-items: center; padding: 0 11px; color: #506258; background: #f5f7f4; border: 1px solid #e6ebe5; border-radius: 5px; font-size: 13px; font-variant-numeric: tabular-nums; }
.form-footer { display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 12px; margin-top: 21px; padding-top: 16px; border-top: 1px solid #edf0ec; }
.message { min-height: 16px; margin: 0; color: var(--red); font-size: 12px; }
.message.success { color: var(--green); }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; font-weight: 700; transition: background .15s ease, border-color .15s ease; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-outline { color: var(--green-dark); background: #fff; border-color: #b6cbbd; }
.button-outline:hover:not(:disabled) { background: #f3f8f4; }
.button-quiet { min-height: 34px; color: #53635a; background: transparent; border-color: #d9e0d9; }
.button-quiet:hover { color: var(--green-dark); background: #f5f8f5; }
.button-full { width: 100%; }
.text-button { padding: 7px 0; color: #52635a; background: transparent; border: 0; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }

.fleet-summary { padding: 23px 22px; }
.summary-heading { align-items: center; margin-bottom: 14px; }
.summary-count { padding: 5px 8px; color: var(--green-dark); background: var(--green-soft); border-radius: 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
.fleet-list { display: grid; gap: 0; }
.fleet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 49px; border-top: 1px solid #edf0ec; }
.fleet-name { overflow: hidden; color: #46564c; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.fleet-km { color: var(--ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-state { margin: 16px 0 2px; color: #8a958d; font-size: 12px; line-height: 1.6; }

.records-section { margin-top: 30px; }
.records-heading { align-items: center; margin-bottom: 15px; }
.filters { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.filter-field { display: flex; width: 175px; flex-direction: column; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 650; }
.filter-field input, .filter-field select { height: 34px; padding-left: 9px; font-size: 11px; }
.filter-field:first-child { width: 160px; }
.filters .text-button { margin-left: auto; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
thead { background: #f7f9f6; }
th { height: 39px; padding: 0 14px; color: #718077; font-size: 10px; font-weight: 700; }
td { height: 48px; padding: 0 14px; color: #344138; border-top: 1px solid #edf0ec; font-size: 11px; font-variant-numeric: tabular-nums; }
td:nth-child(2), td:nth-child(3) { font-variant-numeric: normal; }
.table-empty { height: 96px; color: #88938c; text-align: center; }
.status-label { display: inline-flex; align-items: center; min-height: 21px; padding: 0 7px; border-radius: 3px; color: #2c7655; background: #e8f3ec; font-size: 10px; }
.status-label.withdrawn { color: #7c837e; background: #eef0ed; }
.row-action { margin-left: 9px; padding: 4px 7px; color: #a34337; background: #fff; border: 1px solid #eed4d0; border-radius: 4px; font-size: 10px; }
.row-action:hover { background: #fff6f4; }
.table-footnote { margin: 9px 1px 0; color: #7d8981; font-size: 10px; }

.admin-panel { margin-top: 31px; padding: 24px; }
.admin-heading { align-items: center; padding-bottom: 19px; border-bottom: 1px solid #e8ede7; }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 20px 0; }
.admin-block h3 { margin-bottom: 12px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.inline-form input, .vehicle-form input, .adjust-form input, .adjust-form select { height: 37px; font-size: 11px; }
.inline-form .button, .vehicle-form .button, .adjust-form .button { min-height: 37px; }
.admin-list { margin-top: 9px; border-top: 1px solid #e9eee8; }
.admin-row { display: flex; min-height: 43px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #edf0ec; }
.admin-row-main { min-width: 0; }
.admin-row-name { overflow: hidden; color: #39473f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-meta { margin-top: 3px; color: #8a958d; font-size: 10px; }
.admin-row button { flex: 0 0 auto; padding: 5px 7px; color: #59685e; background: #fff; border: 1px solid #dbe2db; border-radius: 4px; font-size: 10px; }
.admin-row button:hover { background: #f5f8f5; }
.vehicle-form { display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(100px, .8fr) auto; align-items: end; gap: 8px; }
.vehicle-form label, .adjust-form label { display: flex; min-width: 0; flex-direction: column; gap: 5px; color: var(--muted); font-size: 10px; }
.adjustments-block { padding-top: 20px; border-top: 1px solid #e8ede7; }
.admin-help { max-width: 720px; margin: -3px 0 14px; color: #7a867e; font-size: 10px; line-height: 1.6; }
.adjust-form { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(150px, .8fr) minmax(180px, 1.4fr) auto; align-items: end; gap: 8px; }
.adjustment-list { display: grid; margin-top: 13px; border-top: 1px solid #e9eee8; }
.adjustment-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; color: #657269; border-bottom: 1px solid #edf0ec; font-size: 10px; }
.adjustment-row strong { color: #3b4b40; font-weight: 650; }
.admin-message { margin-top: 12px; }

.login-dialog { width: min(390px, calc(100% - 32px)); padding: 23px; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 18px 55px rgba(25, 42, 31, .18); }
.login-dialog::backdrop { background: rgba(19, 31, 23, .34); }
.login-dialog form { display: grid; gap: 17px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { font-size: 17px; }
.icon-button { width: 30px; height: 30px; color: #59675e; background: transparent; border: 0; border-radius: 4px; font-size: 21px; line-height: 1; }
.icon-button:hover { background: #f0f3ef; }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: min(390px, calc(100% - 40px)); padding: 11px 14px; color: #fff; background: #263a2e; border-radius: 5px; box-shadow: 0 6px 24px rgba(20, 34, 25, .2); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(7px); transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 820px) {
  .entry-layout { grid-template-columns: 1.3fr .8fr; gap: 13px; }
  .entry-form { padding: 20px; }
  .fleet-summary { padding: 19px 16px; }
  .admin-columns { gap: 15px; }
  .vehicle-form { grid-template-columns: 1fr 1fr; }
  .vehicle-form .button { grid-column: 1 / -1; }
  .adjust-form { grid-template-columns: 1fr 1fr; }
  .adjust-reason { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .topbar { height: 58px; padding: 0 16px; }
  .top-actions { gap: 10px; }
  .connection { font-size: 10px; }
  .page-shell { width: calc(100% - 28px); padding-top: 24px; }
  .page-heading { margin-bottom: 15px; }
  h1 { font-size: 22px; }
  .entry-layout { grid-template-columns: 1fr; }
  .entry-form { padding: 19px 16px; }
  .fleet-summary { padding: 18px 16px; }
  .fleet-list { grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .fleet-row { min-width: 0; }
  .form-grid { gap: 15px 10px; }
  .form-footer { align-items: flex-start; flex-direction: column; }
  .form-footer .button { width: 100%; }
  .records-section { margin-top: 26px; }
  .records-heading { align-items: flex-end; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .filter-field, .filter-field:first-child { width: auto; }
  .filters .text-button { justify-self: start; margin-left: 0; }
  th, td { padding: 0 10px; }
  .admin-panel { padding: 19px 15px; }
  .admin-columns { grid-template-columns: 1fr; gap: 22px; }
  .adjust-form { grid-template-columns: 1fr 1fr; }
  .adjust-form .button { grid-column: 1 / -1; }
  .adjustment-row { flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* ---- 顶栏扫码入口与导出说明 ---- */
.top-link { color: #53635a; font-size: 12px; text-decoration: none; }
.top-link:hover { color: var(--green-dark); text-decoration: underline; text-underline-offset: 3px; }
.records-actions { display: flex; align-items: center; gap: 10px; }
.export-note { color: #8a958d; font-size: 10px; }

/* ---- 批量导入名单 ---- */
.bulk-import { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #e3e9e3; }
.bulk-import summary { color: #4b6a58; font-size: 11px; font-weight: 650; cursor: pointer; }
.bulk-import textarea {
  width: 100%;
  margin: 10px 0 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd8d0;
  border-radius: 5px;
  font: inherit;
  font-size: 12px;
  line-height: 1.7;
  outline: none;
  resize: vertical;
}
.bulk-import textarea:focus { border-color: #4c9571; box-shadow: 0 0 0 3px rgba(40, 124, 83, .12); }
.bulk-import .button { width: 100%; min-height: 34px; }

/* ---- 空库提示 ---- */
.seed-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--amber-soft);
  border: 1px solid #f0dfc4;
  border-radius: 6px;
}
.seed-banner strong { display: block; margin-bottom: 3px; color: #7d4d12; font-size: 12px; }
.seed-banner p { margin: 0; color: #8a6224; font-size: 10px; line-height: 1.55; }

/* ---- 管理行多按钮 ---- */
.admin-row-actions { display: flex; flex: 0 0 auto; gap: 6px; }

/* ---- 扫码页 ---- */
.qr-layout { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
.qr-card {
  padding: 26px 24px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.qr-frame { display: inline-block; padding: 14px; background: #fff; border: 1px solid #e6ebe5; border-radius: 6px; }
.qr-frame canvas { display: block; width: min(300px, 62vw); height: auto; image-rendering: pixelated; }
.qr-url { margin: 14px 0 0; color: #5d6b63; font-size: 11px; word-break: break-all; }
.qr-actions { display: flex; justify-content: center; gap: 9px; margin-top: 16px; }
.qr-card .message { margin: 12px 0 0; }
.qr-side { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.qr-side h2 { margin-bottom: 14px; }
.qr-steps { margin: 0 0 20px; padding-left: 18px; color: #43514a; font-size: 12px; line-height: 1.85; }
.qr-steps li { margin-bottom: 8px; }
.qr-tip { padding: 14px; background: #f6f9f6; border: 1px solid #e4ebe3; border-radius: 6px; }
.qr-tip strong { display: block; margin-bottom: 5px; color: #33433a; font-size: 12px; }
.qr-tip p { margin: 0 0 12px; color: #7a867e; font-size: 11px; line-height: 1.6; }
.qr-note { margin: 16px 0 0; color: #8a958d; font-size: 10px; line-height: 1.65; }

@media (max-width: 720px) {
  .qr-layout { grid-template-columns: 1fr; }
  .qr-card, .qr-side { padding: 20px 16px; }
  .export-note { display: none; }
}

@media (max-width: 400px) {
  .topbar { padding: 0 12px; }
  .top-actions { gap: 8px; }
  .top-link { font-size: 11px; }
  .connection { font-size: 0; }
}

@media print {
  .topbar, .qr-side, .qr-actions, .qr-card .message, .page-heading .eyebrow { display: none !important; }
  body { background: #fff; }
  .page-shell { width: auto; padding: 0; }
  .qr-layout { display: block; }
  .qr-card { border: 0; padding: 0; }
  .qr-frame { border: 0; padding: 0; }
  .qr-frame canvas { width: 78mm; }
  .qr-url { font-size: 11px; }
}

/* ---- 记录区提示与首屏计时（?timing=1） ---- */
.table-footnote { display: flex; flex-wrap: wrap; gap: 10px; }
.footnote-hint { color: #9c5e16; }
.timing-badge {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 12px;
  color: #eef3ef;
  background: rgba(24, 35, 30, .92);
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.65;
  cursor: pointer;
  user-select: none;
}
.timing-badge strong { margin-bottom: 3px; color: #fff; font-size: 12px; }

/* ---- 登记人记忆提示 ---- */
.field-hint { margin-top: -3px; color: #6b7d72; font-size: 10px; font-weight: 400; }
