:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4ee;
  --text: #17201a;
  --muted: #66736b;
  --line: #d9e2db;
  --accent: #237a57;
  --accent-strong: #14543c;
  --accent-soft: #dceee5;
  --warning: #9a5c00;
  --warning-bg: #fff4d9;
  --danger: #b93434;
  --shadow: 0 16px 48px rgba(31, 52, 40, 0.1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101814;
    --surface: #17211c;
    --surface-soft: #203329;
    --text: #edf4ef;
    --muted: #a8b8ae;
    --line: #304139;
    --accent: #55c68f;
    --accent-strong: #98e5bd;
    --accent-soft: #193d2d;
    --warning: #ffd27a;
    --warning-bg: #3a2a10;
    --danger: #ee6969;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(35, 122, 87, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      linear-gradient(135deg, rgba(85, 198, 143, 0.12), transparent 30%),
      linear-gradient(180deg, #14201a 0%, var(--bg) 100%);
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: #53635a;
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
}

button.danger {
  background: var(--danger);
}

button.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

button.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 1.7rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 12px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  resize: vertical;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 5vw, 2.3rem);
  line-height: 1.12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h2 {
  font-size: 1.05rem;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar > div {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.topbar > .icon-button.hidden {
  display: inline-grid !important;
  visibility: hidden;
  pointer-events: none;
}

.screen {
  display: grid;
  gap: 16px;
}

.panel,
.metric,
.vehicle-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.compact-form {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(130px, 0.6fr) auto;
  align-items: end;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 650;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.vehicle-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  text-align: left;
}

.vehicle-card button {
  width: 100%;
}

.vehicle-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vehicle-title strong {
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.vehicle-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 112px;
  padding: 15px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric strong {
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
}

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

.check-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
}

.check-field input {
  width: 20px;
  height: 20px;
}

.notice {
  margin: 14px 0 0;
  border: 1px solid #f1d28e;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--warning-bg);
  color: var(--warning);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface);
}

.record-head,
.record-actions,
.record-meta,
.data-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-head {
  margin-bottom: 8px;
}

.record-head strong {
  overflow-wrap: anywhere;
}

.record-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.record-actions {
  flex: 0 0 auto;
}

.record-actions button {
  min-height: 36px;
  padding: 8px 10px;
}

.cycle {
  margin-top: 10px;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 650;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  text-align: center;
}

.data-panel {
  align-items: center;
}

.file-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

dialog {
  width: min(430px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
  background: rgba(10, 20, 15, 0.36);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 820px) {
  .app-shell {
    padding-inline: 12px;
  }

  .compact-form,
  .layout,
  .data-panel {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 8px;
  }

  button.icon-button {
    width: 40px;
    min-width: 40px;
  }

  .vehicle-strip,
  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .record-head {
    display: grid;
  }

  .record-actions {
    width: 100%;
  }

  .record-actions button {
    flex: 1;
  }
}
