:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --text: #14211f;
  --muted: #63706d;
  --line: #dbe5e1;
  --green: #0f766e;
  --green-strong: #0b5e57;
  --red: #b42318;
  --amber: #9a6700;
  --button: #e9f3f0;
  --shadow: 0 12px 32px rgba(19, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 16px 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.header-total {
  min-width: 78px;
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.header-total span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.header-total small {
  color: var(--muted);
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px 12px 80px;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box,
.form-grid label,
.reconcile-item,
.file-action {
  display: grid;
  gap: 6px;
}

.dialog-panel label {
  display: grid;
  gap: 6px;
}

.search-box span,
.form-grid span,
.file-action span,
.dialog-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.tab-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.tab-button {
  min-height: 42px;
  padding: 8px 4px;
  border-radius: 8px;
  background: var(--button);
  color: #29423d;
  font-weight: 700;
}

.tab-button.active {
  background: var(--green);
  color: #ffffff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 2px 10px;
  color: var(--muted);
}

.section-heading h2 {
  color: var(--text);
}

.inventory-list,
.transaction-list,
.reconcile-list,
.form-grid,
.backup-grid {
  display: grid;
  gap: 10px;
}

.tire-card,
.transaction-card,
.empty-state,
.backup-grid,
.form-grid,
.import-preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tire-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.spec {
  font-size: 20px;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #edf4f2;
  color: #2b514b;
  font-size: 13px;
  font-weight: 700;
}

.tag.used {
  background: #fff4dc;
  color: #684700;
}

.quantity {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.quantity strong {
  font-size: 34px;
  line-height: 1;
}

.stepper {
  display: grid;
  grid-template-columns: 58px 58px;
  gap: 8px;
}

.card-actions {
  display: grid;
  gap: 8px;
}

.stepper button {
  min-height: 48px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.minus {
  background: var(--red);
}

.plus {
  background: var(--green);
}

.primary-action,
.secondary-action,
.danger-action {
  width: 100%;
  min-height: 50px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: #ffffff;
}

.secondary-action {
  background: var(--button);
  color: #23423c;
}

.small-action {
  min-height: 38px;
  border-radius: 8px;
  background: var(--button);
  color: #23423c;
  font-size: 14px;
  font-weight: 800;
}

.danger-action {
  background: #fff1f0;
  color: var(--red);
  border: 1px solid #ffd0cc;
}

.reconcile-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.reconcile-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.reconcile-item strong {
  overflow-wrap: anywhere;
}

.transaction-card {
  box-shadow: none;
}

.transaction-card strong {
  display: block;
  margin-bottom: 4px;
}

.transaction-card p {
  color: var(--muted);
  font-size: 14px;
}

.backup-grid {
  box-shadow: none;
}

.file-action {
  min-height: 64px;
  padding: 12px;
  border: 1px dashed var(--green);
  border-radius: 8px;
  background: #f6fbfa;
}

.file-action input {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.import-preview {
  margin-top: 12px;
  box-shadow: none;
}

.import-preview h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.import-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  box-shadow: none;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  display: none;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #10231f;
  color: #ffffff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.25);
}

.toast.show {
  display: block;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  padding: 16px 12px max(16px, env(safe-area-inset-bottom));
  background: rgba(8, 20, 17, 0.46);
}

.dialog-panel {
  display: grid;
  width: min(520px, 100%);
  margin: 0 auto;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hidden {
  display: none;
}

@media (min-width: 680px) {
  .app-header {
    padding-left: calc((100vw - 760px) / 2 + 12px);
    padding-right: calc((100vw - 760px) / 2 + 12px);
  }

  .backup-grid {
    grid-template-columns: 1fr 1fr;
  }
}
