* {
  box-sizing: border-box;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --money: #16a34a;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgb(17 24 39 / 0.06);
  --radius: 0.875rem;
  --sidebar-w: 15rem;
  --bottom-nav-h: calc(56px + env(safe-area-inset-bottom, 0px));
  --keyboard-offset: 0px;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--brand);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

input, select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgb(37 99 235 / 0.35);
  outline-offset: 1px;
  border-color: var(--brand);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 0.625rem;
  padding: 0.85rem 1rem;
  font-weight: 600;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.55rem 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.55rem 0.75rem;
}

.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.loading, .login {
  min-height: 100dvh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(1.5rem + env(safe-area-inset-top)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
}

.login {
  align-content: center;
  max-width: 24rem;
  margin: 0 auto;
  gap: 1.25rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.login-brand h1 {
  font-size: 1.2rem;
  margin: 0;
}

.login-brand p {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.35;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login form label input {
  min-height: 2.75rem;
}

.login .btn-primary {
  min-height: 2.75rem;
  font-size: 1rem;
}

.error {
  color: var(--danger);
  margin: 0;
  font-size: 0.875rem;
}

.app-shell {
  /* Mobile-first column: content stacks above the tab bar.
     Desktop switches to row (sidebar | main). A row flex on phones
     parks the bottom nav beside the page — that was the broken mobile UI. */
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.5rem 1.25rem;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 0.95rem;
}

.brand-text span {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--brand);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}

.who-name {
  font-weight: 600;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  border: none;
  background: rgb(17 24 39 / 0.35);
  z-index: 30;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
  z-index: 20;
}

.mobile-who {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.mobile-who .brand-mark {
  flex: none;
}

.who-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1rem calc(1.5rem + var(--bottom-nav-h));
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
}

.page-head {
  margin-bottom: 1.25rem;
}

.kicker {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  line-height: 1.15;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  display: none;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.view-toggle button,
.section-header button,
.actions button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.view-toggle button.active,
button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  padding: 1rem;
  box-shadow: none;
  margin-bottom: 0.75rem;
}

.hint {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px dashed #d1d5db;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.hint.active-trip {
  background: var(--brand-soft);
  color: var(--brand);
}

.manual-block {
  margin-top: 1rem;
  padding-top: 0;
  border-top: none;
}

.mileage-manual-inline {
  margin-top: 0.9rem;
}

.capture-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.capture-card,
.confirm-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.875rem 0.95rem;
}

.capture-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.status-pill {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.status-pill.ok {
  color: var(--money);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.confirm-card {
  margin-top: 0.75rem;
}

.confirm-value {
  margin: 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.manual-label {
  margin: 0 0 0.5rem;
  font-size: 0.625rem;
  letter-spacing: 0.07em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.manual-row {
  display: flex;
  gap: 0.5rem;
}

.manual-row input {
  flex: 1;
  min-width: 0;
}

.end-trip-form label {
  margin-top: 0.75rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.875rem;
  box-shadow: none;
}

.stat-label {
  margin: 0;
  font-size: 0.625rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: -0.03em;
}

.stat-money {
  color: var(--money);
}

.stat-caption {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.trip-history {
  list-style: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.trip-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.6875rem;
}

.trip-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.trip-main strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.trip-sub {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-family: ui-monospace, Menlo, monospace;
}

.trip-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.trip-stats strong {
  font-size: 0.9375rem;
  font-family: ui-monospace, Menlo, monospace;
  font-weight: 600;
}

.trip-stats span {
  font-size: 0.6875rem;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--danger);
}

.empty-row, .empty {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: none;
}

.item-list, .trip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 0.85rem;
  border: 1px solid var(--line);
  box-shadow: none;
}

.item-card.low-stock {
  border-color: #f59e0b;
}

.item-summary {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.item-summary img {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  border-radius: 0.375rem;
}

.meta {
  font-size: 0.875rem;
  color: var(--muted);
}

.flag {
  color: #d97706;
  font-weight: 600;
}

.location-stock {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.location-stock li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stock-editor {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.stock-editor input {
  width: 4rem;
}

.inv-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.inv-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-block {
  margin-bottom: 0.75rem;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.location-manager h2 {
  display: block;
  margin: 0;
  font-size: 1.05rem;
}

.location-manage-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.location-groups {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.location-group-label {
  margin: 0 0 0.4rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.location-manage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
}

.location-add-form {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.location-kind-toggle {
  margin-bottom: 0.75rem;
}

.loc-filter {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}

.loc-filter::-webkit-scrollbar {
  display: none;
}

.loc-chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.loc-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.loc-chip--warehouse:not(.active) {
  background: #f8fafc;
}

.loc-chip--site:not(.active) {
  background: #fff;
}

.stock-card-qty-caption + .stock-card-qty-caption {
  margin-top: 0.1rem;
}


.inv-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.fab {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgb(37 99 235 / 0.35);
}

.fab--dock {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-h) + 0.75rem);
  z-index: 25;
}

.keyboard-open .fab--dock {
  bottom: calc(var(--keyboard-offset) + 0.75rem);
}

.stock-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 700px) {
  .stock-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.stock-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.stock-card.low-stock {
  border-color: #fecaca;
  background: #fff;
}

.stock-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.stock-card-photo {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.5rem;
  background: repeating-linear-gradient(135deg, #eef2f7 0 6px, #f8fafc 6px 12px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stock-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.stock-card-info {
  flex: 1;
  min-width: 0;
}

.stock-card-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge-low {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #dc2626;
  background: #fee2e2;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.stock-card-meta {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.stock-card-qty {
  flex: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.15rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.stock-card-qty:hover {
  border-color: var(--line);
}

.stock-card-qty-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: ui-monospace, Menlo, monospace;
}

.stock-card-qty-value.low {
  color: #dc2626;
}

.stock-card-qty-caption {
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.stock-stepper {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.stock-stepper-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.stock-stepper-row button {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
}

.stock-stepper-input {
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  font-weight: 700;
  font-size: 1.1rem;
}

.stock-stepper-expires {
  margin-top: 0.5rem;
}

.add-item-hint {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.exp-toggle-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.exp-toggle-row {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
}

.exp-toggle-row strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
}

.exp-toggle-hint {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
  margin-bottom: 0.6rem;
}

.stock-delete-item {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  text-align: center;
}

.deliveries-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.deliveries-sort {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.delivery-groups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.delivery-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.delivery-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.pill-static {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

.delivery-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.delivery-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.delivery-card-foot {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.delivery-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
}

.delivery-table th, .delivery-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.sort-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.totals-list, .entries-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.kind {
  text-transform: capitalize;
  color: var(--brand);
}

.clock-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.clock-card label {
  margin-bottom: 0;
}

.app.nav-open .sidebar {
  display: flex;
}

.app.nav-open .sidebar-backdrop {
  display: block;
}

@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100dvh;
    flex: none;
  }

  .main {
    flex: 1;
    overflow: visible;
  }

  .content {
    padding: 1.5rem 2rem 2rem;
    max-width: 58rem;
    overflow: visible;
  }

  .page-head {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
  }

  .page-head h1 {
    font-size: 1.75rem;
  }

  .section-header h2 {
    display: block;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
  }

  .subsection-title {
    margin: 1.25rem 0 0.75rem;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
  }

  .inv-head-row,
  .deliveries-head-row {
    margin-bottom: 1rem;
    align-items: center;
  }

  .view-toggle {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .stock-card-photo {
    width: 3.75rem;
    height: 3.75rem;
  }

  .stock-card-qty {
    cursor: pointer;
    min-width: 3.5rem;
  }

  .stock-card-qty:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
  }

  .mileage-page .panel:first-child,
  .hours-page .clock-card-v2 {
    max-width: 36rem;
  }

  .hours-page .range-card,
  .hours-page .payout-card {
    max-width: none;
  }

  .entries-table li {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.4fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0.65rem;
    border-radius: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
  }

  .entry-job { font-weight: 600; }
  .entry-who, .entry-when { color: var(--muted); font-size: 0.875rem; }
  .entry-duration { text-align: right; font-variant-numeric: tabular-nums; }

  .overview-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    align-items: start;
  }

  .admin-layout {
    display: grid;
    grid-template-columns: 1fr 18rem;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1.25rem;
  }

  .admin-aside {
    position: sticky;
    top: 1.5rem;
  }

  .admin-create {
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .admin-audit-details {
    max-width: none;
    white-space: nowrap;
  }

  .admin-audit-scroll {
    overflow-x: auto;
  }

  .admin-audit-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }

  .admin-danger-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
  }

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

  .order-card-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }

  .sort-btn.deliveries-sort {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
  }

  .login {
    max-width: 28rem;
  }

  .sheet-overlay {
    align-items: center;
    justify-content: center;
    padding: 2rem;
  }

  .sheet-panel {
    max-width: 26rem;
    max-height: min(85vh, 40rem);
    border-radius: 1rem;
    animation: dialog-in 0.2s ease;
  }

  @keyframes dialog-in {
    from {
      opacity: 0;
      transform: scale(0.96) translateY(8px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .app-shell--customer .content {
    max-width: 32rem;
  }

  .bottom-nav {
    position: static;
    box-shadow: none;
    mask-image: none;
    -webkit-mask-image: none;
    transform: none !important;
  }

  .fab--dock {
    position: static;
    bottom: auto;
    right: auto;
  }

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

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .manual-row {
    flex-direction: column;
  }

  .manual-row .btn-secondary {
    width: 100%;
  }

  .trip-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .trip-stats {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
}

.bottom-nav {
  flex: none;
  z-index: 30;
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 4px 4px calc(8px + env(safe-area-inset-bottom));
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -1px 8px rgb(17 24 39 / 0.06);
  transition: transform 0.2s ease;
  mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.keyboard-open .bottom-nav {
  transform: translateY(100%);
}

.bottom-nav-item {
  flex: 1 0 auto;
  min-width: 3.25rem;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  background: transparent;
  padding: 8px 4px 4px;
  color: var(--muted);
}

.bottom-nav-item.active {
  background: #eff6ff;
  color: var(--brand);
  border-radius: 14px;
}

.bottom-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: #cbd5e1;
}

.bottom-nav-item.active .bottom-dot {
  background: var(--brand);
}

.bottom-label {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.mileage-primary {
  width: 100%;
  padding: 1.15rem 1rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 10px rgb(37 99 235 / 0.25);
}

.mileage-dash-box {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.65rem;
  border: 1px dashed #d1d5db;
  border-radius: 0.625rem;
  background: #f8fafc;
}

.mileage-ghost {
  flex: none;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 0.5rem;
  background: repeating-linear-gradient(135deg, #e0f2fe 0 5px, #f8fafc 5px 10px);
}

.mileage-dash-text {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.odo-input {
  width: 100%;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.875rem;
  padding: 0.7rem 0.75rem;
  border-radius: 0.5625rem;
}

.mileage-page .confirm-value {
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: -0.03em;
}

.rate-panel {
  margin-top: 0.75rem;
}

.rate-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.rate-value {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 1rem;
}

.rate-slider {
  width: 100%;
  accent-color: var(--brand);
}

.rate-panel-range {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Hours tab */

.clock-card-v2 {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.clock-display {
  text-align: center;
  padding: 1rem 0;
}

.clock-time {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.clock-caption {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.clock-start {
  background: #15803d;
}

.clock-stop {
  background: #b91c1c;
}

.manual-hours-row .manual-row {
  gap: 0.5rem;
}

.range-card .view-toggle {
  margin-bottom: 0.75rem;
}

.range-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.range-total {
  display: block;
  font-size: 0.95rem;
}

.range-total-value {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 1.25rem;
  font-weight: 700;
}

.daily-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.daily-bar-row {
  display: grid;
  grid-template-columns: 3rem 1fr 4rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}

.daily-bar-label {
  color: var(--brand);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.daily-bar-track {
  height: 0.5rem;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.daily-bar-fill {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

.daily-bar-value {
  text-align: right;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--muted);
}

.payout-card .stat-grid {
  margin-bottom: 0.5rem;
}

.rate-suffix {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.payout-mark-paid {
  margin-top: 1rem;
  background: #15803d;
}

.payout-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
}

.payout-history-head h3 {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.payout-history {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.payout-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.payout-row-amount {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Overview tab */

.overview-week {
  margin-bottom: 0.9rem;
}

.overview-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

@media (min-width: 700px) {
  .overview-tiles {
    grid-template-columns: repeat(4, 1fr);
  }
}

.overview-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.overview-tile-value-warn {
  color: #d97706;
}

.overview-payouts {
  margin-bottom: 0.75rem;
}

.overview-payouts-head {
  margin-bottom: 0.6rem;
}

.overview-lowstock {
  margin-bottom: 0.75rem;
}

.overview-section-head {
  margin-bottom: 0.5rem;
}

.overview-section-head h3, .overview-lowstock h3, .overview-activity h3 {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.overview-lowstock-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.overview-lowstock-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff7ed;
  border-radius: 0.625rem;
  padding: 0.6rem 0.75rem;
}

.overview-lowstock-dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #d97706;
}

.overview-lowstock-info {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
}

.overview-lowstock-ratio {
  font-family: ui-monospace, Menlo, monospace;
  font-weight: 600;
  color: #d97706;
  font-size: 0.875rem;
}

.overview-activity h3 {
  margin-bottom: 0.5rem;
}

.overview-activity-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}

.overview-activity-row:first-child {
  border-top: none;
}

.overview-activity-kind {
  text-transform: uppercase;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.overview-activity-date {
  color: var(--muted);
  font-size: 0.75rem;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.form-error {
  color: var(--danger);
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.admin-page .section-header h2 {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.admin-create {
  display: grid;
  gap: 0.75rem;
}

.admin-user-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.admin-user-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.admin-user-row.inactive {
  opacity: 0.65;
}

.admin-user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-danger {
  color: var(--danger);
}

.admin-role-pick {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-role-pick select {
  font: inherit;
}

.admin-audit-head {
  margin-top: 0.5rem;
}

.admin-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.admin-audit-table th,
.admin-audit-table td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.admin-audit-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-audit-details {
  max-width: 16rem;
  word-break: break-word;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}

.form-ok {
  color: var(--money);
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.app-shell--customer {
  --brand: #0f766e;
  --brand-soft: #ccfbf1;
  --bg: #f4faf8;
}

.app-shell--customer .brand-mark {
  background: #0f766e;
}

.app-shell--customer .bottom-nav {
  display: none !important;
}

.app-shell--customer .content {
  max-width: 26rem;
  padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

.app-shell--customer .cust-order {
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}

.app-shell--customer .sidebar-foot {
  margin-top: auto;
}

.cust-hero {
  margin-bottom: 1.25rem;
}

.cust-hero h1 {
  margin: 0 0 0.4rem;
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.cust-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.cust-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}

.cust-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cust-card-n {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

.cust-photo {
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.cust-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cust-photo input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.cust-photo--wide {
  width: 100%;
  height: 9.5rem;
  margin-bottom: 0.85rem;
  border-radius: 0.85rem;
  background: var(--brand-soft);
  color: var(--brand);
}

.cust-photo--wide span {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 1rem;
  text-align: center;
}

.cust-photo--wide strong {
  font-size: 1rem;
}

.cust-photo--wide em {
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.8;
}

.cust-name input {
  font-size: 1.05rem;
  padding: 0.75rem 0.85rem;
}

.cust-qty {
  margin-top: 0.35rem;
}

.cust-qty span {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.cust-qty-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.cust-qty-row button {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 1.35rem;
  line-height: 1;
}

.cust-qty-row strong {
  font-size: 1.5rem;
  min-width: 2rem;
  text-align: center;
}

.cust-add {
  width: 100%;
  margin: 0.15rem 0 0.5rem;
  padding: 0.85rem;
  border: 1.5px dashed var(--line);
  border-radius: 0.85rem;
  background: transparent;
  color: var(--brand);
  font-weight: 600;
}

.cust-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 75%, rgb(244 250 248 / 0));
}

.keyboard-open .cust-dock {
  bottom: var(--keyboard-offset);
}

.cust-dock .btn-primary {
  font-size: 1.05rem;
  padding: 1rem;
  min-height: 3rem;
}

.cust-thanks {
  text-align: center;
  padding: 2rem 0.5rem 1.5rem;
}

.cust-thanks-mark {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.cust-thanks h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.cust-thanks p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.45;
}

.cust-thanks .btn-secondary {
  margin-top: 0.5rem;
  justify-content: center;
}

.cust-history {
  margin-top: 0.5rem;
  padding-bottom: 1.5rem;
}

.cust-history-toggle {
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 0.75rem 0;
  text-align: center;
}

.orders-page .section-header h2 {
  display: block;
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.orders-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.order-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.order-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.order-lines li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.order-line-name {
  flex: 1;
  font-weight: 600;
}

.order-line-qty {
  color: var(--muted);
}

.order-thumb {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  border-radius: 0.5rem;
}

@media (min-width: 768px) {
  .bottom-nav,
  .mobile-topbar {
    display: none;
  }

  .cust-dock {
    position: sticky;
    left: auto;
    right: auto;
    padding: 0.75rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  }

  .app-shell--customer .content {
    padding-bottom: 1rem;
  }

  .app-shell--customer .cust-order {
    padding-bottom: 0;
  }
}

/* Bottom sheet overlays */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(17 24 39 / 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sheet-fade-in 0.2s ease;
}

.sheet-panel {
  width: 100%;
  max-width: 28rem;
  max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top)));
  display: flex;
  flex-direction: column;
  background: #fafbfc;
  border-radius: 1.125rem 1.125rem 0 0;
  animation: sheet-slide-up 0.22s ease;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  flex: none;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.sheet-close {
  flex: none;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 1rem;
}

.sheet-foot {
  flex: none;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sheet-form label > span:first-child,
.sheet-form .field-label,
.form-field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.sheet-actions .btn-primary {
  flex: 1;
  min-height: 2.75rem;
}

.sheet-actions .btn-secondary,
.sheet-actions .btn-ghost {
  flex: none;
  min-height: 2.75rem;
}

@keyframes sheet-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.deliveries-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.deliveries-head-row .btn-primary.mobile-only {
  display: none;
}

@media (max-width: 767px) {
  .page-head .kicker {
    display: none;
  }

  .page-head h1 {
    font-size: 1.25rem;
  }

  .page-head {
    margin-bottom: 0.85rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .card,
  .panel {
    padding: 0.875rem;
    border-radius: 0.75rem;
  }

  .inv-head-actions .fab {
    display: none;
  }

  .deliveries-head-row .btn-primary:not(.mobile-only) {
    display: none;
  }

  .deliveries-head-row .fab--dock {
    display: grid;
  }

  .empty {
    padding: 1.5rem 0.5rem;
    text-align: center;
    line-height: 1.5;
  }
}

@media (min-width: 768px) {
  .fab--dock.deliveries-fab {
    display: none;
  }
}
