:root {
  --bg: #0b1220;
  --surface: #151d2e;
  --surface-2: #1d2739;
  --line: #2a3550;
  --text: #eef2f8;
  --muted: #98a4bb;
  --accent: #3b82f6;
  --accent-dim: #1e40af;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --pad: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding:
    calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + var(--pad))
    calc(env(safe-area-inset-bottom) + 32px) calc(env(safe-area-inset-left) + var(--pad));
  max-width: 640px;
  margin-inline: auto;
  overscroll-behavior-y: contain;
}

h1 {
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.error {
  color: var(--bad);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

/* Classes that set `display` would otherwise beat the UA `[hidden]` rule. */
[hidden] {
  display: none !important;
}

.screen {
  animation: fade 0.18s ease-out;
}
.center {
  min-height: 78vh;
  display: grid;
  place-items: center;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.app-header {
  margin: 8px 0 18px;
}
.app-header.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.app-header p {
  margin: 4px 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card h1 {
  margin: 10px 0 2px;
}
.login-card form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand img {
  border-radius: 14px;
}

/* ------------------------------- inputs -------------------------------- */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

input,
select,
textarea {
  font: inherit;
  font-size: 17px; /* keeps iOS from zooming on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  width: 100%;
  appearance: none;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
input[type='date'] {
  min-height: 49px;
}
textarea {
  min-height: 84px;
  resize: vertical;
}

.odo-input {
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 16px 12px;
}
.odo-input.detected {
  border-color: var(--good);
  box-shadow: 0 0 0 3px rgb(52 211 153 / 18%);
}

/* ------------------------------- buttons ------------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active {
  transform: scale(0.985);
}
.btn.block {
  display: block;
  width: 100%;
}
.btn.big {
  padding: 18px;
  font-size: 1.05rem;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.danger {
  color: var(--bad);
}
.btn.ghost {
  background: transparent;
}
.btn.icon {
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row .btn {
  flex: 1;
}

.seg {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  flex: 1;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 11px 8px;
  cursor: pointer;
}
.seg button[aria-pressed='true'] {
  background: var(--accent);
  color: #fff;
}

/* ------------------------------- status -------------------------------- */
.status {
  margin-bottom: 16px;
}
.status .big-line {
  font-size: 1.15rem;
  font-weight: 650;
  margin-bottom: 10px;
}
.status.done {
  border-color: var(--good);
  background: linear-gradient(180deg, rgb(52 211 153 / 12%), transparent), var(--surface);
}
.status.done .big-line {
  color: var(--good);
}
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.status .meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.totals div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.totals b {
  display: block;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}
.totals span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-title {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* -------------------------------- trips -------------------------------- */
.trip {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.trip .km {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 74px;
  text-align: right;
}
.trip .desc {
  flex: 1;
  min-width: 0;
}
.trip .desc strong {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trip .desc span {
  font-size: 0.8rem;
  color: var(--muted);
}
.tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 6px;
}
.tag.business {
  background: rgb(59 130 246 / 20%);
  color: #93c5fd;
}
.tag.personal {
  background: rgb(148 163 184 / 18%);
  color: #cbd5e1;
}
.tag.pending {
  background: rgb(251 191 36 / 18%);
  color: var(--warn);
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.open-trip {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgb(59 130 246 / 14%), transparent), var(--surface);
  margin-bottom: 16px;
}
.open-trip h2 {
  margin-bottom: 6px;
}

.footer-actions {
  margin-top: 24px;
}

/* -------------------------------- sheet -------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 55%);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 8px calc(env(safe-area-inset-left) + var(--pad))
    calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-right) + var(--pad));
  animation: rise 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes rise {
  from {
    transform: translateY(100%);
  }
}
.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 6px auto 14px;
}
.sheet h2 {
  margin-bottom: 4px;
}
.sheet .stack {
  padding-bottom: 4px;
}

.photo-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.85rem;
  color: var(--muted);
}
.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------- overlays ------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%);
  background: #f8fafc;
  color: #0b1220;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 11px 18px;
  border-radius: 99px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 45%);
  z-index: 80;
  max-width: 90vw;
  text-align: center;
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}
.offline-bar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  background: var(--warn);
  color: #422006;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  padding: calc(env(safe-area-inset-top) + 5px) 10px 5px;
  z-index: 90;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
