:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel2: #1b2330;
  --line: #2b3545;
  --text: #f1f5f9;
  --muted: #93a4b8;
  --accent: #58a6ff;
  --accent2: #1f6feb;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, #172a45 0, transparent 30%), var(--bg);
  color: var(--text);
  font:
    15px/1.45 system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  min-height: 100vh;
}
.wrap {
  max-width: 1050px;
  margin: auto;
  padding: 0 18px;
}
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo {
  border: 0;
  background: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--accent2);
  border-radius: 10px;
}
.spacer {
  flex: 1;
}
.user-badge {
  color: var(--muted);
  font-size: 13px;
}
.small,
.primary,
.danger,
.back,
.tab {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel2);
  color: var(--text);
  padding: 8px 11px;
  font-weight: 650;
  cursor: pointer;
}
.small:hover,
.back:hover,
.tab:hover {
  border-color: #53647c;
}
.primary {
  border-color: var(--accent2);
  background: var(--accent2);
}
.danger {
  background: #431d23;
  border-color: #7b2b31;
  color: #ffb4b4;
}
.ghost {
  background: transparent;
}
.small.danger {
  background: transparent;
  border-color: #573039;
  color: #ff9490;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(88, 166, 255, 0.35);
  outline-offset: 2px;
}
main {
  padding-top: 34px !important;
  padding-bottom: 50px !important;
}
h1 {
  font-size: 32px;
  margin: 0 0 3px;
}
h2 {
  font-size: 18px;
  margin: 0 0 14px;
}
.sub,
.hint {
  color: var(--muted);
}
.sub {
  margin: 0 0 24px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.card {
  background: linear-gradient(
    145deg,
    rgba(27, 35, 48, 0.95),
    rgba(20, 27, 36, 0.95)
  );
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.vehicle-card {
  text-align: left;
  color: var(--text);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.vehicle-card:hover {
  transform: translateY(-2px);
  border-color: #47566c;
}
.vc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 13px;
}
.vc-icon {
  font-size: 29px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #0d141e;
  border-radius: 11px;
}
.vc-name {
  font-weight: 800;
  font-size: 17px;
}
.vc-year {
  color: var(--muted);
  font-size: 13px;
}
.vc-body {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}
.vc-miles {
  font-size: 20px;
}
.status-line {
  margin-top: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}
.dot.ok,
.bar.ok {
  background: var(--ok);
}
.dot.soon,
.bar.soon {
  background: var(--warn);
}
.dot.overdue,
.bar.overdue {
  background: var(--bad);
}
.status-text.ok {
  color: #7ee787;
}
.status-text.soon {
  color: #e3b341;
}
.status-text.overdue {
  color: #ff7b72;
}
.detail-head {
  display: flex;
  gap: 13px;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}
.detail-title {
  font-size: 26px;
  font-weight: 800;
}
.detail-meta {
  color: var(--muted);
}
.pill,
.badge {
  border-radius: 999px;
  padding: 5px 9px;
  background: #101722;
  border: 1px solid var(--line);
  font-size: 12px;
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.entry,
.rem {
  padding: 16px 17px;
  border-bottom: 1px solid var(--line);
}
.entry:last-child,
.rem:last-child {
  border-bottom: 0;
}
.e-top,
.rem-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.e-type,
.rem-name {
  font-weight: 800;
}
.e-cost {
  margin-left: auto;
  font-weight: 800;
}
.e-sub,
.rem-detail {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}
.e-actions,
.rem-actions {
  display: flex;
  gap: 7px;
  margin-top: 11px;
}
.rem-actions {
  margin: 0 0 0 auto;
}
.rem-detail {
  display: flex;
  justify-content: space-between;
}
.badge.ok {
  color: #7ee787;
}
.badge.soon {
  color: #e3b341;
}
.badge.overdue {
  color: #ff7b72;
}
.meter {
  height: 7px;
  background: #0d141e;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}
.meter div {
  height: 100%;
  border-radius: 99px;
}
.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}
.cost-total {
  font-size: 32px;
  font-weight: 850;
}
.stats {
  padding: 20px;
}
.bars {
  height: 175px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  overflow-x: auto;
}
.bar-col {
  height: 150px;
  min-width: 65px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.bar-val,
.bar-year {
  font-size: 11px;
  color: var(--muted);
}
.bar {
  width: 32px;
  background: var(--accent);
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  margin: 5px 0;
}
.type-totals {
  width: 100%;
  border-collapse: collapse;
}
.type-totals td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.type-totals td:last-child {
  text-align: right;
}
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 30;
}
.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 21px;
  box-shadow: var(--shadow);
}
.field {
  margin-bottom: 14px;
}
.specs-form-fields {
  display: block;
}
.specs-form-fields .field {
  width: 100%;
}
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0d141e;
  color: var(--text);
  border-radius: 9px;
  padding: 11px;
  font: inherit;
}
.field textarea {
  min-height: 80px;
  resize: vertical;
}
.row2 {
  display: flex;
  gap: 12px;
}
.row2 > * {
  flex: 1;
}
.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
}
.auth-panel {
  width: min(430px, 100%);
  margin: 9vh auto 0;
  padding: 26px;
}
.auth-panel h1 {
  font-size: 27px;
}
.auth-panel .primary {
  width: 100%;
  padding: 11px;
}
.error {
  color: #ff9490;
  min-height: 22px;
}
.sr-only {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #20334d;
  border: 1px solid #3c5f8b;
  padding: 11px 14px;
  border-radius: 9px;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s;
  z-index: 50;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: none;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child {
  border: 0;
}
.user-info {
  flex: 1;
}
.tag {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
}
footer {
  color: #627287;
  font-size: 12px;
  padding-bottom: 24px !important;
  text-align: center;
}
@media (max-width: 650px) {
  .wrap {
    padding-left: 14px;
    padding-right: 14px;
  }
  .topbar {
    gap: 6px;
    min-height: 60px;
  }
  .logo-text {
    display: none;
  }
  .logo {
    margin-right: auto;
  }
  .topbar > .spacer {
    display: none;
  }
  .topbar .small {
    font-size: 0;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
  }
  .topbar .small:after {
    font-size: 13px;
  }
  .user-badge {
    display: none;
  }
  main {
    padding-top: 24px !important;
  }
  h1 {
    font-size: 28px;
  }
  .row2 {
    display: block;
  }
  .primary,
  .danger,
  .back,
  .tab,
  .small {
    min-height: 44px;
  }
  .detail-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    margin-top: 14px;
  }
  .detail-head > .spacer {
    display: none;
  }
  .detail-head > .pill {
    grid-column: 1/-1;
    justify-self: start;
  }
  .detail-head > .small {
    min-width: 0;
    width: 100%;
  }
  .detail-head > .small:first-of-type {
    grid-column: 1/2;
  }
  .detail-head > .small:last-of-type {
    grid-column: 2/3;
  }
  .detail-title {
    font-size: 23px;
  }
  .detail-meta,
  .e-sub {
    overflow-wrap: anywhere;
  }
  .tabs {
    overflow: visible;
  }
  .tab {
    flex: 1;
    min-width: 0;
    padding: 10px 6px;
  }
  .toolbar .primary {
    width: 100%;
  }
  .rem-head {
    flex-wrap: wrap;
  }
  .rem-actions {
    display: flex;
    width: 100%;
    margin-left: 0;
  }
  .e-actions .small,
  .rem-actions .small {
    flex: 1;
  }
  .rem-detail {
    display: block;
  }
  .rem-detail span {
    display: block;
    margin-top: 4px;
  }
  .modal-back {
    padding: 10px;
  }
  .modal {
    padding: 17px;
    max-height: calc(100vh - 20px);
  }
  .modal-actions {
    flex-wrap: wrap;
  }
  .modal-actions > .danger {
    width: 100%;
  }
  .modal-actions > .spacer {
    display: none;
  }
  .modal-actions > .small,
  .modal-actions > .primary {
    flex: 1;
  }
  .user-row {
    align-items: flex-start;
  }
  .user-info {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .stats {
    padding: 16px;
  }
  .cost-total {
    font-size: 29px;
  }
  .empty {
    padding: 24px 12px;
  }
}
@media (max-width: 380px) {
  .topbar {
    gap: 4px;
  }
  .topbar .small {
    min-width: 40px;
    padding: 7px;
  }
  .topbar .small:after {
    font-size: 12px;
  }
}
.brand-mark {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}
.settings-card {
  padding: 20px;
  max-width: 560px;
}
.settings-card form {
  margin: 0;
}
.settings-card .hint {
  font-size: 13px;
  margin-top: 6px;
}
@media (max-width: 650px) {
  .brand-mark {
    width: 40px;
    height: 40px;
  }
}
.receipts {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 11px;
}
.receipts img {
  width: 66px;
  height: 66px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  display: block;
}
.receipt {
  position: relative;
}
.receipt > .small {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 26px;
  min-height: 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}
.token-list {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}
.vc-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 11px;
  display: block;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-weight: 700;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent2);
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.checkbox-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: none;
}
.field label.checkbox-inline {
  display: flex;
  margin-bottom: 0;
  font-weight: 700;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-weight: 700;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  accent-color: var(--accent2);
}

/* Header controls */
.header-menu {
  position: relative;
}
.icon-btn {
  font-size: 21px;
  line-height: 1;
  min-width: 40px;
}
.menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 170px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.menu-panel.open {
  display: grid;
}
.menu-panel button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  border-radius: 7px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.menu-panel button:hover {
  background: var(--panel2);
}
/* New settings and cost displays */
.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px !important;
  font-weight: 700;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px;
  flex: none;
  margin: 0;
  padding: 0;
  accent-color: var(--accent2);
}
.cost-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.vc-mpg {
  margin-top: 2px;
}
@media (max-width: 650px) {
  .icon-btn {
    font-size: 21px;
    min-width: 44px;
  }
  .menu-panel button {
    min-height: 44px;
  }
  .cost-summary {
    gap: 20px;
  }
}

.vehicle-view-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: -10px 0 18px;
}
.vehicle-view-toggle .check-row {
  margin: 0 !important;
  padding: 8px 11px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.vehicle-view-toggle > .hint {
  font-size: 13px;
}

/* Keep vehicle-card structure aligned even when only some cards have costs. */
.vehicle-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.vc-head {
  min-height: 74px;
}
.vc-body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.vehicle-specs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: -7px 0 17px;
}
.vehicle-specs > div {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.vehicle-specs dt,
.mod-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.vehicle-specs dd,
.mod-details dd {
  margin: 0;
}
.mod-details {
  margin-top: 11px;
  padding: 9px 11px;
  background: #101722;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.mod-details summary {
  cursor: pointer;
  font-weight: 700;
}
.mod-details dl {
  display: grid;
  gap: 7px;
  margin: 9px 0 0;
}
.mod-details dl > div {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
}
.mod-details a {
  color: var(--accent);
}
@media (max-width: 650px) {
  .vehicle-specs {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 0;
  }
  .mod-details dl > div {
    grid-template-columns: 60px 1fr;
  }
}

@media (max-width: 650px) {
  .topbar [data-action="refresh"]:after {
    content: "↻";
    font-size: 21px;
  }
  .topbar [data-action="toggle-menu"]:after {
    content: "☰";
    font-size: 21px;
  }
}

@media (max-width: 650px) {
  .tabs {
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .tab {
    flex: 0 0 auto;
    min-width: max-content;
    padding: 10px 12px;
  }
}

.specs-tab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 16px;
}
.specs-tab-grid > div {
  min-width: 0;
}
.specs-tab-grid dd {
  overflow-wrap: anywhere;
}
@media (max-width: 650px) {
  .specs-tab-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

/* Mod cards stay scannable in two columns on wide screens and one on phones. */
.mods-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.mod-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(
    145deg,
    rgba(27, 35, 48, 0.95),
    rgba(20, 27, 36, 0.95)
  );
  box-shadow: var(--shadow);
}
.entry-number {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101722;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.mod-card .e-type {
  min-width: 0;
  overflow-wrap: anywhere;
}
.mod-card .e-actions {
  margin-top: auto;
}
.mod-card {
  display: flex;
  flex-direction: column;
}
.mod-card .e-actions {
  padding-top: 11px;
}
@media (max-width: 650px) {
  .mods-grid {
    grid-template-columns: 1fr;
  }
}

/* Group detailed specs into readable label-value sections instead of a card wall. */
.spec-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.spec-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}
.spec-section {
  min-width: 0;
  padding: 18px 20px;
  background: linear-gradient(
    145deg,
    rgba(27, 35, 48, 0.95),
    rgba(20, 27, 36, 0.95)
  );
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.spec-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.spec-section dl {
  margin: 0;
}
.spec-row {
  display: grid;
  grid-template-columns: minmax(118px, 35%) minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  align-items: start;
}
.spec-row dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.spec-row dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: left;
}
@media (max-width: 650px) {
  .spec-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
  }
  .spec-column {
    display: contents;
  }
  .spec-section {
    order: var(--spec-order);
    padding: 15px 16px;
  }
  .spec-row {
    grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
    gap: 10px;
  }
}

/* Keep all vehicle navigation visible on phones and preserve metadata as chips. */
@media (max-width: 650px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }
  .tab {
    min-width: 0;
    padding: 10px 3px;
    font-size: 12px;
    text-align: center;
  }
  .vehicle-specs {
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }
  .vehicle-specs > div {
    width: max-content;
    max-width: 100%;
  }
}

.warning {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #7c5b1d;
  border-radius: 10px;
  background: #2a2112;
  color: #f5d78e;
  line-height: 1.45;
}
.warning b {
  color: #ffe4a3;
}

/* Vehicle card cost block: every card shows the same four rows (Total, Service, Fuel,
   Mods) at a fixed row height, so spacing never shifts when a category is $0. */
.vehicle-card .vc-cost {
  display: grid;
  grid-template-columns: minmax(64px, auto) auto;
  grid-auto-rows: 20px;
  align-content: start;
  column-gap: 18px;
  row-gap: 2px;
  width: max-content;
  min-width: 160px;
  max-width: 100%;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}
.vc-cost-row {
  display: contents;
}
.vc-cost-row > :last-child {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}
.vc-cost-total > span,
.vc-cost-total > strong {
  color: var(--text);
}
.vc-cost-zero > span {
  opacity: 0.55;
}
.vehicle-card .status-line {
  margin-bottom: 10px;
}

/* Mobile optimization pass (phones). Everything below is scoped to small screens;
   desktop layout is unchanged. Grounded in WCAG 2.5.8 target size, Apple HIG 44pt
   touch targets, Material 48dp guidance, and iOS Safari's 16px form-control rule. */
@media (max-width: 650px) {
  /* The vehicle photo earns real space on the detail page: a full-width banner
     instead of the 42px card icon. Emoji-only headers get a modest bump. */
  .vc-head .vc-icon {
    width: 52px;
    height: 52px;
    font-size: 34px;
  }
  .detail-head .vc-icon {
    width: 56px;
    height: 56px;
    font-size: 36px;
    border-radius: 14px;
  }
  .detail-head .vc-icon:has(.vc-photo) {
    grid-column: 1 / -1;
    width: 100%;
    height: 160px;
    overflow: hidden;
    /* As a grid item of .vc-icon (place-items: center), the img's height: 100%
       resolves as indefinite, so it kept its natural height and overflowed the
       160px banner, showing the top of the photo. Pin it to the banner box so
       object-fit crops centered. */
    position: relative;
  }
  .detail-head .vc-icon:has(.vc-photo) .vc-photo {
    position: absolute;
    inset: 0;
    object-position: center;
  }
  .detail-head .vc-icon:has(.vc-photo) + div {
    grid-column: 1 / -1;
  }

  /* Form controls at 16px so iOS Safari does not zoom the page on focus. */
  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
  }

  /* Thumb-friendly targets and no double-tap delay. */
  button,
  .tab {
    touch-action: manipulation;
  }
  .check-row {
    min-height: 44px;
  }
  .topbar .small {
    min-width: 44px;
  }
  .receipts img {
    width: 84px;
    height: 84px;
  }
  .receipt > .small {
    min-width: 32px;
    min-height: 32px;
    width: 32px;
    height: 32px;
  }

  /* Section tabs stay on screen while scrolling long vehicle pages. The bottom
     spacing moves from margin to padding so the sticky background covers it. */
  .tabs {
    position: sticky;
    top: 61px;
    z-index: 5;
    background: var(--bg);
    margin-bottom: 0;
    padding: 6px 0 14px;
  }

  /* Dynamic viewport height for modals and safe-area padding for notched phones. */
  .modal {
    max-height: calc(100dvh - 20px);
  }
  .wrap {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
  }
  #toast {
    left: 14px;
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    text-align: center;
  }
}
/* Compact mode for tiny, near-square screens such as flip-phone cover displays
   (Motorola Razr outer screen, roughly 360-500px on each side). Scoped by height
   and aspect ratio so regular portrait phones keep the 650px mobile layout above
   and desktop is untouched. Goal: two to three vehicle cards on screen at once
   while keeping tap targets at 40px. */
@media (max-width: 650px) and (max-height: 600px) and (min-aspect-ratio: 3/4) {
  .wrap {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .topbar {
    min-height: 48px;
    gap: 4px;
  }
  .brand-mark {
    width: 30px;
    height: 30px;
  }
  .logo {
    min-height: 40px;
  }
  .topbar .small,
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 4px;
  }
  .topbar [data-action="refresh"]:after,
  .topbar [data-action="toggle-menu"]:after {
    font-size: 18px;
  }
  .menu-panel button {
    min-height: 40px;
  }
  main {
    padding-top: 10px !important;
    padding-bottom: 24px !important;
  }
  h1 {
    font-size: 20px;
    line-height: 1.2;
  }
  h2 {
    font-size: 16px;
    margin-bottom: 10px;
  }
  .sub {
    font-size: 13px;
    margin-bottom: 8px;
  }
  .primary,
  .danger,
  .back,
  .tab,
  .small {
    min-height: 40px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .check-row {
    min-height: 40px;
  }

  /* Garage list: the admin toggle hint and the card padding are the big wins. */
  .vehicle-view-toggle {
    margin: 0 0 10px;
  }
  .vehicle-view-toggle .check-row {
    padding: 4px 10px;
    font-size: 14px;
  }
  .vehicle-view-toggle > .hint {
    display: none;
  }
  .grid {
    gap: 8px;
  }
  .card {
    border-radius: 11px;
  }
  .vc-head {
    min-height: 0;
    gap: 9px;
    padding: 8px 10px;
  }
  .vc-head .vc-icon {
    width: 34px;
    height: 34px;
    font-size: 22px;
    border-radius: 9px;
  }
  .vc-photo {
    border-radius: 9px;
  }
  .vc-name {
    font-size: 15px;
    line-height: 1.2;
  }
  .vc-year {
    font-size: 12px;
  }
  /* Mileage and status on the left, the cost rows beside them on the right,
     so the card is half as tall without dropping any information. */
  .vc-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-auto-rows: min-content;
    column-gap: 10px;
    align-content: start;
    padding: 7px 10px 8px;
    font-size: 12px;
    line-height: 16px;
  }
  .vc-body > * {
    grid-column: 1;
    min-width: 0;
  }
  .vc-miles {
    font-size: 16px;
    line-height: 20px;
  }
  .vc-mpg {
    margin-top: 0;
  }
  .vehicle-card .status-line {
    margin: 3px 0 0;
  }
  .dot {
    margin-right: 5px;
  }
  .vehicle-card .vc-cost {
    grid-column: 2;
    grid-row: 1 / span 5;
    align-self: start;
    min-width: 0;
    margin: 0;
    padding: 0 0 0 10px;
    border-top: 0;
    border-left: 1px solid var(--line);
    grid-template-columns: auto auto;
    grid-auto-rows: 16px;
    column-gap: 10px;
    row-gap: 1px;
    font-size: 12px;
    line-height: 16px;
  }

  /* Vehicle detail page. */
  .detail-head {
    gap: 8px;
    margin: 6px 0 10px;
  }
  .detail-head .vc-icon {
    width: 40px;
    height: 40px;
    font-size: 26px;
    border-radius: 10px;
  }
  .detail-head .vc-icon:has(.vc-photo) {
    height: 110px;
  }
  .detail-title {
    font-size: 19px;
    line-height: 1.2;
  }
  .detail-meta {
    font-size: 12px;
    line-height: 1.35;
  }
  .pill,
  .badge {
    padding: 3px 8px;
  }
  .tabs {
    top: 49px;
    padding: 2px 0 8px;
  }
  .tab {
    min-height: 40px;
    padding: 4px 2px;
    font-size: 12px;
  }
  .toolbar {
    margin: 8px 0;
  }
  .entry,
  .rem {
    padding: 10px 11px;
  }
  .e-sub,
  .rem-detail {
    font-size: 12px;
    margin-top: 3px;
  }
  .e-actions,
  .rem-actions {
    margin-top: 8px;
  }
  .rem-actions {
    margin-top: 0;
  }
  .meter {
    margin-top: 8px;
  }
  .stats {
    padding: 12px;
  }
  .cost-total {
    font-size: 22px;
  }
  .cost-summary {
    gap: 10px;
  }
  .spec-section {
    padding: 11px 12px;
  }
  .spec-row {
    padding: 6px 0;
    gap: 8px;
  }
  .specs-tab-grid {
    padding: 10px;
  }
  .vehicle-specs {
    gap: 6px;
    margin-bottom: 10px;
  }
  .vehicle-specs > div {
    padding: 5px 8px;
  }
  .empty {
    padding: 16px 10px;
  }
  .receipts img {
    width: 60px;
    height: 60px;
  }
  .modal-back {
    padding: 6px;
  }
  .modal {
    padding: 12px;
    max-height: calc(100dvh - 12px);
  }
}
@media (max-width: 650px) and (max-height: 600px) and (min-aspect-ratio: 3/4) {
  /* Keep the title beside the small icon instead of in a column sized by the
     Update mileage button below it. */
  .detail-head {
    grid-template-columns: 40px auto minmax(0, 1fr);
  }
  .detail-head > .vc-icon + div {
    grid-column: 2 / -1;
  }
  .detail-head > .small:first-of-type {
    grid-column: 1 / 3;
  }
  .detail-head > .small:last-of-type {
    grid-column: 3 / 4;
  }
}

/* The alternative login stays small and readable on narrow screens. */
.auth-mode-toggle {
  display: block;
  margin: 15px 0 20px;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--accent, #7db7ff);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-mode-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}
/* Hidden login modes must stay hidden even when .field sets display. */
.auth-panel [hidden] { display: none; }

/* Due summary on the garage home screen */
.due-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 16px;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.due-bar .dot {
  margin-right: 0;
}
.due-bar.overdue {
  border-color: var(--bad);
}
.due-bar.soon {
  border-color: var(--warn);
}
.due-parts {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}
.due-go {
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}
.due-section {
  margin-top: 22px;
  scroll-margin-top: 12px;
}
.due-section h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.due-count {
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 14px;
  vertical-align: middle;
}
.due-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.due-row {
  display: grid;
  grid-template-columns: 12px minmax(90px, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.due-row .dot {
  margin-right: 0;
}
.due-car {
  font-weight: 600;
}
.due-item {
  color: var(--muted);
}
.due-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.due-chip.overdue {
  background: rgba(248, 81, 73, 0.18);
  color: var(--bad);
}
.due-chip.soon {
  background: rgba(210, 153, 34, 0.2);
  color: var(--warn);
}
@media (max-width: 600px) {
  .due-row {
    grid-template-columns: 12px 1fr auto;
  }
  .due-item {
    grid-column: 2;
    grid-row: 2;
  }
  .due-chip {
    grid-column: 3;
    grid-row: 1 / 3;
  }
  .due-parts {
    font-size: 12px;
  }
}

/* Fuel entries describe the driving interval ending at this fill-up. */
.fuel-average-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.fuel-stat .cost-total { font-size: clamp(22px, 3vw, 32px); margin: 6px 0; }
.fuel-overall { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.fuel-method { margin: 12px 0 0; line-height: 1.5; }
.towing-badge { display: inline-block; color: #8fc8ff; background: #18354d; font-size: 12px; padding: 3px 8px; border-radius: 6px; vertical-align: middle; }
.fill-efficiency { font-size: 20px; font-weight: 650; margin: 8px 0; }
.towing-toggle { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.towing-toggle input { width: 24px; height: 24px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.towing-toggle span { display: grid; gap: 5px; }
.towing-toggle small { color: var(--muted); font-size: 13px; }
@media (max-width: 340px) { .fuel-average-grid { grid-template-columns: 1fr; gap: 16px; } }
@media (max-width: 340px) {
  .tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Archived vehicles */
.archived-section {
  margin-top: 22px;
}
.archived-section summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 0;
  list-style-position: inside;
}
.archived-section .due-count {
  background: var(--muted, #888);
}
.archived-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.archived-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.archived-open {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.archived-name {
  font-weight: 600;
}
.archived-pill {
  background: var(--muted, #888);
  color: #fff;
}

/* Links inside notes */
.e-sub a {
  color: var(--accent);
}
