:root {
  --ink: #182326;
  --muted: #677579;
  --line: #dce3e4;
  --soft: #f3f6f6;
  --paper: #ffffff;
  --green: #0e6b54;
  --green-dark: #095341;
  --green-soft: #e4f1ec;
  --amber: #d48a16;
  --amber-soft: #fff3d6;
  --red: #c53d35;
  --red-soft: #fde9e7;
  --blue: #2d648c;
  --shadow: 0 12px 34px rgba(25, 44, 48, 0.09);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eef2f2; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef2f2;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { width: 19px; height: 19px; stroke-width: 2; }

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
}
.icon-button:hover { background: var(--soft); }
.icon-button.danger { color: var(--red); }
.icon-button.danger:hover { background: var(--red-soft); }

.app-header {
  height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--green);
  color: white;
}
.header-actions { display: flex; align-items: center; gap: 9px; }
.header-title { font-size: 17px; font-weight: 700; }

.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: white;
  font-weight: 650;
}
.btn:hover { background: var(--green-dark); }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--soft); }
.btn.danger { background: var(--paper); color: var(--red); border-color: #efc5c1; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: grid; gap: 7px; }
.field label { font-size: 13px; color: #4d5d61; font-weight: 650; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd8da;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}
.field textarea { min-height: 92px; resize: vertical; }
.field select[multiple] { min-height: 132px; padding: 5px; }
.field select[multiple] option { padding: 8px 9px; border-radius: 4px; }
.field select[multiple] option:checked { background: var(--green-soft); color: var(--green-dark); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(14,107,84,.1); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field-grid .span-2 { grid-column: 1 / -1; }

.mobile-shell { width: min(100%, 520px); min-height: calc(100vh - 64px); margin: 0 auto; background: var(--paper); }
.mobile-content { padding: 24px 20px 40px; }
.section-kicker { margin: 0 0 6px; color: var(--green); font-size: 13px; font-weight: 700; }
.page-heading { margin: 0; font-size: 25px; line-height: 1.25; }
.subtle { color: var(--muted); font-size: 13px; }

.scanner-stage {
  min-height: 430px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 26px;
  text-align: center;
}
.scan-frame {
  width: min(68vw, 270px);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  background: #f4f7f6;
  overflow: hidden;
}
.scan-frame::before, .scan-frame::after, .scan-corners::before, .scan-corners::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  border-color: var(--green);
  border-style: solid;
}
.scan-frame::before { top: 0; left: 0; border-width: 4px 0 0 4px; }
.scan-frame::after { top: 0; right: 0; border-width: 4px 4px 0 0; }
.scan-corners::before { bottom: 0; left: 0; border-width: 0 0 4px 4px; }
.scan-corners::after { bottom: 0; right: 0; border-width: 0 4px 4px 0; }
.scan-glyph {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
}
.scan-glyph svg { width: 42px; height: 42px; }
.scan-beam { position: absolute; left: 13%; right: 13%; top: 50%; height: 2px; background: var(--green); box-shadow: 0 0 12px rgba(14,107,84,.5); }
.scan-heading { margin: 0 0 7px; font-size: 20px; }
.scan-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.lookup { border-top: 1px solid var(--line); padding-top: 20px; }
.lookup-row { display: flex; gap: 8px; }
.lookup-row input { flex: 1; min-width: 0; }
.quick-list { display: grid; gap: 8px; margin-top: 14px; }
.quick-vehicle {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}
.plate { font-weight: 800; font-size: 18px; }

.camera-sheet { position: fixed; inset: 0; z-index: 100; background: #101818; color: white; display: none; }
.camera-sheet.open { display: grid; grid-template-rows: 64px 1fr auto; }
.camera-sheet header { padding: 0 18px; display: flex; align-items: center; justify-content: space-between; }
.camera-sheet video { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.camera-footer { padding: 18px; text-align: center; background: rgba(0,0,0,.45); }

.vehicle-photo { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--soft); }
.vehicle-identity { padding: 18px 20px 16px; border-bottom: 1px solid var(--line); }
.vehicle-identity h1 { margin: 0 0 5px; font-size: 28px; }
.vehicle-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); }
.vehicle-meta span { display: inline-flex; align-items: center; gap: 5px; }
.vehicle-category { min-height: 24px; padding: 2px 8px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 700; }
.status-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.status-item { padding: 15px 20px; }
.status-item + .status-item { border-left: 1px solid var(--line); }
.status-label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.status-value { font-weight: 700; }
.status-value.warning { color: var(--amber); }
.status-value.expired { color: var(--red); }
.alert {
  margin: 16px 20px 0;
  padding: 12px 13px;
  border-radius: 6px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--amber-soft);
  color: #79500e;
  font-size: 13px;
}
.alert.danger { background: var(--red-soft); color: #872c27; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--soft); border-radius: 7px; }
.tab {
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}
.tab.active { background: white; color: var(--green); box-shadow: 0 1px 4px rgba(30,50,54,.12); }
.record-form { display: grid; gap: 14px; margin-top: 18px; }
.record-section { padding: 24px 20px; border-bottom: 1px solid var(--line); }
.record-section h2, .history-section h2 { margin: 0 0 15px; font-size: 18px; }
.history-section { padding: 24px 20px 40px; }
.record-list { display: grid; }
.record-row { padding: 15px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: start; }
.record-icon { width: 38px; height: 38px; border-radius: 7px; display: grid; place-items: center; background: var(--soft); color: var(--green); }
.record-title { font-weight: 700; margin-bottom: 4px; }
.record-meta { color: var(--muted); font-size: 12px; }
.record-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 18px);
  z-index: 300;
  padding: 11px 15px;
  border-radius: 6px;
  background: #1c2a2d;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  white-space: nowrap;
  max-width: calc(100vw - 30px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

.admin-body { background: #f3f5f5; }
.admin-shell { display: grid; grid-template-columns: 226px 1fr; min-height: 100vh; }
.sidebar { background: #17272a; color: white; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px 25px; }
.nav { display: grid; gap: 5px; }
.nav-button {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c6d0d2;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.nav-button.active, .nav-button:hover { background: #284043; color: white; }
.sidebar-footer { position: absolute; left: 16px; right: 16px; bottom: 20px; }
.user-chip { padding: 12px; border-top: 1px solid #35494c; color: #c6d0d2; font-size: 13px; }
.admin-main { min-width: 0; }
.admin-topbar { height: 64px; padding: 0 28px; border-bottom: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; }
.admin-content { padding: 26px 28px 48px; max-width: 1500px; }
.admin-title-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 22px; }
.admin-title-row h1 { font-size: 24px; margin: 0 0 4px; }
.admin-title-row p { margin: 0; color: var(--muted); font-size: 13px; }
.view { display: none; }
.view.active { display: block; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { min-height: 116px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.stat-icon { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.stat-value { margin-top: 10px; font-size: 30px; font-weight: 800; }
.panel { background: white; border: 1px solid var(--line); border-radius: 7px; }
.panel-header { min-height: 58px; padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-header h2 { margin: 0; font-size: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; background: white; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 14px; text-align: left; color: var(--muted); background: #fafbfb; font-weight: 650; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fafcfc; }
.table-photo { width: 58px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--soft); }
.row-actions { display: flex; align-items: center; gap: 6px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: #536367; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: #895b10; }
.badge.red { background: var(--red-soft); color: var(--red); }
.consumption-value { font-weight: 700; white-space: nowrap; }
.consumption-value.abnormal, .consumption-abnormal { color: var(--red); }
.consumption-range { margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.range-description { margin: 0 0 16px; }
.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-group label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: white; cursor: pointer; font-size: 13px; }
.check-group input { accent-color: var(--green); width: 16px; height: 16px; }
.range-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 6px; }
.range-row { display: grid; grid-template-columns: minmax(170px, 1fr) 110px 28px 110px; gap: 12px; align-items: end; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.range-row:last-child { border-bottom: 0; }
.range-separator { padding-bottom: 12px; color: var(--muted); text-align: center; }
.maintenance-panel .interval-input { width: 100px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.overview-breakdowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.overview-breakdowns .panel:last-child { grid-column: 1 / -1; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 14px; }
.warning-list { padding: 3px 16px; }
.warning-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.warning-row:last-child { border-bottom: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.page-btn { min-height: 32px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 6px; background: white; color: #2f4548; cursor: pointer; font-size: 13px; }
.page-btn:hover:not(:disabled) { background: var(--soft); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }
.page-info { color: var(--muted); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16,28,31,.54); z-index: 200; display: none; place-items: center; padding: 18px; }
.modal-backdrop.open { display: grid; }
.modal { width: min(100%, 600px); max-height: calc(100vh - 36px); overflow-y: auto; background: white; border-radius: 8px; box-shadow: var(--shadow); }
.modal.small { width: min(100%, 430px); }
.modal-header { min-height: 62px; padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.photo-upload { border: 1px dashed #aebbbd; min-height: 150px; border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: var(--soft); color: var(--muted); text-align: center; }
.photo-upload img { width: 100%; height: 190px; object-fit: cover; }
.photo-upload img[hidden] { display: none; }
.qr-preview { padding: 10px; text-align: center; }
.qr-preview img { width: min(100%, 320px); margin: 0 auto 12px; }
.qr-preview img[hidden] { display: none; }
.qr-loading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 220px; color: var(--muted); font-size: 14px; }
.qr-loading[hidden] { display: none; }
.button-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; display: inline-block; animation: vp-spin .7s linear infinite; }
.button-spinner[hidden] { display: none; }
@keyframes vp-spin { to { transform: rotate(360deg); } }
.account-button { width: 100%; margin-top: 10px; justify-content: center; }
.account-button[hidden] { display: none; }

.login-screen { position: fixed; inset: 0; z-index: 500; background: #edf1f1; display: grid; place-items: center; padding: 20px; }
.login-screen.hidden { display: none; }
.login-box { width: min(100%, 390px); background: white; border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: var(--shadow); }
.login-box .brand { margin-bottom: 26px; }
.login-box h1 { margin: 0 0 6px; font-size: 22px; }
.login-box p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 14px; }
.login-demo { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.7; }

@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 18px 11px; }
  .sidebar .brand span, .nav-button span, .user-chip { display: none; }
  .sidebar .brand { justify-content: center; padding: 0 0 24px; }
  .nav-button { justify-content: center; padding: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-breakdowns { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-header { padding: 0 16px; }
  .mobile-content { padding-left: 16px; padding-right: 16px; }
  .admin-shell { display: block; }
  .sidebar { position: fixed; left: 0; right: 0; top: auto; bottom: 0; height: 66px; z-index: 80; padding: 7px 10px; border-top: 1px solid #31484b; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .nav { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .nav-button { height: 51px; }
  .admin-topbar { padding: 0 16px; }
  .admin-content { padding: 20px 14px 86px; }
  .stats { gap: 9px; }
  .stat { min-height: 100px; padding: 14px; }
  .stat-value { font-size: 25px; }
  .admin-title-row { align-items: flex-start; }
  .admin-title-row .btn span { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span-2 { grid-column: auto; }
  .status-item { padding-left: 16px; padding-right: 16px; }
  .record-section, .history-section { padding-left: 16px; padding-right: 16px; }
  .range-row { grid-template-columns: 1fr 1fr; }
  .range-row > div:first-child { grid-column: 1 / -1; }
  .range-separator { display: none; }
}

.fuel-tank-total {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-soft);
}
.fuel-tank-total-label { font-size: 14px; font-weight: 700; }
.fuel-tank-total-value { color: var(--muted); font-size: 13px; margin-top: 3px; }
.tank-project { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.tank-project-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tank-project-head .subtle { margin-left: auto; }
.tank-list { display: grid; gap: 8px; padding-left: 4px; }
.tank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.tank-row-main { flex: 1 1 auto; min-width: 0; }
.tank-row-name { font-size: 14px; }
.tank-battery {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  overflow: hidden;
}
.tank-battery::after {
  content: "";
  position: absolute;
  top: 8px;
  right: -8px;
  width: 5px;
  height: 10px;
  border-radius: 0 3px 3px 0;
  background: var(--ink);
}
.tank-battery-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--green);
  transition: width .2s ease;
}
.tank-battery-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
}

@media (max-width: 680px) {
  .tank-row { flex-wrap: wrap; }
  .tank-row .row-actions { width: 100%; justify-content: flex-end; }
  .tank-project-head { flex-wrap: wrap; }
  .tank-project-head .subtle { width: 100%; margin-left: 0; }
}

.batch-delete-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 0 8px;
}
.batch-delete-row .field { min-width: 150px; }
.batch-delete-row .btn { margin-left: auto; }

.load-mode-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; }
.range-pair { display: flex; align-items: center; gap: 6px; }
.range-pair input { min-width: 68px; flex: 1 1 0; }

.gauge-row { display: flex; gap: 10px; }
.gauge-row .field { flex: 1; min-width: 0; }

@media (max-width: 680px) {
  .gauge-row { flex-wrap: wrap; }
  .gauge-row .field { flex: 1 1 45%; }
}

@media (max-width: 680px) {
  .load-mode-grid { grid-template-columns: 1fr; }
}
