:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f0;
  --ink: #17211f;
  --muted: #68736f;
  --line: #d9e1dd;
  --green: #0f6b4d;
  --green-2: #164f3f;
  --orange: #b96812;
  --red: #b3261e;
  --blue: #315e9d;
  --shadow: 0 14px 34px rgba(23, 33, 31, 0.11);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 880px;
  margin: 0 auto 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(15, 107, 77, 0.24);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

main {
  max-width: 880px;
  margin: 0 auto;
}

.icon-button,
.primary-action,
.secondary-action {
  border: 0;
  min-height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

.icon-button {
  width: 44px;
  color: var(--green);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 20px;
}

.icon-button.subtle {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.primary-action {
  color: #fff;
  background: var(--green);
  padding: 0 14px;
}

.secondary-action {
  color: var(--green-2);
  background: var(--surface-2);
  padding: 0 14px;
}

.wide-action {
  width: 100%;
  margin-top: 4px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 12px;
}

.stats-strip div {
  background: var(--surface);
  padding: 13px 10px;
}

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

.stats-strip small {
  color: var(--muted);
  display: block;
  margin-top: 6px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 12px;
}

.segmented button {
  border: 0;
  border-radius: 6px;
  min-height: 36px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.segmented button.active {
  background: var(--surface);
  color: var(--green-2);
  box-shadow: 0 2px 8px rgba(23, 33, 31, 0.08);
}

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

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

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

.tire-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.tire-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.quantity-badge {
  min-width: 72px;
  text-align: center;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: rgba(15, 107, 77, 0.12);
  font-weight: 800;
}

.quantity-badge.low {
  color: var(--orange);
  background: rgba(185, 104, 18, 0.13);
}

.quantity-badge.empty {
  color: var(--red);
  background: rgba(179, 38, 30, 0.12);
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 13px;
}

.card-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green-2);
  font-weight: 700;
}

.card-actions button.danger {
  color: var(--red);
}

.empty-state,
.settings-panel,
.logs-panel {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.bottom-tabs button {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
}

.bottom-tabs button span:first-child {
  font-size: 18px;
}

.bottom-tabs button.active {
  color: var(--green);
  background: rgba(15, 107, 77, 0.1);
}

dialog {
  width: min(92vw, 560px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(12, 20, 18, 0.36);
}

.dialog-panel {
  padding: 18px;
  background: var(--surface);
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.full {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 107, 77, 0.12);
}

.form-error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--red);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.log-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  text-align: left;
}

.log-row:last-child {
  border-bottom: 0;
}

.log-row strong {
  display: block;
  margin-bottom: 4px;
}

.log-row small {
  color: var(--muted);
}

.delta-plus {
  color: var(--green);
  font-weight: 800;
}

.delta-minus {
  color: var(--red);
  font-weight: 800;
}

.settings-list {
  display: grid;
  gap: 10px;
  text-align: left;
}

.settings-list p {
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 520px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 25px;
  }

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

  .primary-action {
    width: 100%;
  }

  .segmented button {
    font-size: 13px;
  }

  .card-actions {
    grid-template-columns: repeat(2, 1fr);
  }

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