:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f3f9fd;
  --text: #3a3a3a;
  --muted: #667085;
  --line: #d8e9f5;
  --accent: #2a8bcb;
  --accent-strong: #1b4f72;
  --blue: #5fade2;
  --yellow: #ffd34e;
  --amber: #9b6a00;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(27, 79, 114, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: clamp(118px, 14vw, 170px);
  height: auto;
}

.nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -14px 35px rgba(27, 79, 114, 0.08);
}

.nav[hidden] {
  display: none;
}

.bottom-nav-item {
  display: grid;
  gap: 4px;
  min-height: 58px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.bottom-nav-item.is-active {
  color: var(--accent);
}

.nav-icon {
  display: block;
  width: 24px;
  height: 24px;
  background: currentColor;
  mask: var(--icon) center / contain no-repeat;
}

.nav-icon.home {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 11 9-8 9 8'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E");
}

.nav-icon.history {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7'/%3E%3Cpath d='M3 4v6h6'/%3E%3Cpath d='M12 7v5l4 2'/%3E%3C/svg%3E");
}

.nav-icon.reward {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12v10H4V12'/%3E%3Cpath d='M2 7h20v5H2z'/%3E%3Cpath d='M12 22V7'/%3E%3Cpath d='M12 7H7.5a2.5 2.5 0 1 1 0-5C11 2 12 7 12 7Z'/%3E%3Cpath d='M12 7h4.5a2.5 2.5 0 1 0 0-5C13 2 12 7 12 7Z'/%3E%3C/svg%3E");
}

.nav-icon.profile {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}

.nav-icon.grid {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='7' height='7' x='3' y='3' rx='1'/%3E%3Crect width='7' height='7' x='14' y='3' rx='1'/%3E%3Crect width='7' height='7' x='14' y='14' rx='1'/%3E%3Crect width='7' height='7' x='3' y='14' rx='1'/%3E%3C/svg%3E");
}

.nav-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.nav-button.is-active {
  border-color: var(--line);
  background: var(--surface-alt);
  color: var(--accent-strong);
  box-shadow: 0 8px 20px rgba(27, 79, 114, 0.06);
}

.nav-button.danger {
  border-color: rgba(180, 35, 24, 0.18);
  color: var(--danger);
}

.alert {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.06);
  color: var(--danger);
}

.account-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--accent-strong);
}

.step-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.step-list span {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--accent-strong);
  font-weight: 800;
}

.step-list strong {
  color: var(--text);
  font-weight: 700;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(22px, 4vw, 48px) 0 calc(96px + env(safe-area-inset-bottom));
}

.auth-grid,
.workspace,
.section-grid,
.admin-grid {
  display: grid;
  gap: 18px;
}

.auth-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.95fr);
  align-items: start;
  min-height: calc(100vh - 140px);
}

.auth-intro {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: clamp(18px, 3vw, 28px) 0;
}

.auth-logo {
  display: block;
  width: min(300px, 78vw);
  height: auto;
}

.auth-intro h1 {
  margin-bottom: 0;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.divider::before,
.divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.passkey-button {
  min-height: 54px;
}

.workspace {
  grid-template-columns: minmax(0, 1fr);
}

.section-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

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

.panel,
.stat,
.trip-row,
.reward-card,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.hero-panel {
  align-content: start;
  background: #ffffff;
}

.hero-logo {
  display: block;
  width: min(300px, 78vw);
  height: auto;
  margin-bottom: clamp(20px, 4vw, 34px);
}

.panel,
.auth-card {
  padding: clamp(18px, 3vw, 28px);
}

.panel.compact {
  padding: 18px;
}

.span-4 {
  grid-column: span 4;
}

.span-3 {
  grid-column: span 3;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 14px;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.lead,
.muted {
  color: var(--muted);
}

.lead {
  max-width: 680px;
  font-size: 1.08rem;
}

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.choice-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 800;
}

.check-field input {
  width: 18px;
  min-height: 18px;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 128px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(42, 139, 203, 0.2);
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.warning {
  background: var(--yellow);
  color: var(--text);
}

.button.danger {
  background: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.stat {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 18px;
}

.stat-value {
  color: var(--accent-strong);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 850;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-weight: 700;
}

.speed-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.speed-card h3 {
  margin-bottom: 6px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.speed-display {
  display: grid;
  min-width: 132px;
  place-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--accent-strong);
}

.speed-display strong {
  font-size: clamp(2.2rem, 8vw, 4rem);
  line-height: 0.92;
}

.speed-display span {
  color: var(--muted);
  font-weight: 800;
}

.estimate-card {
  display: grid;
  gap: 14px;
}

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.estimate-card .stat {
  min-height: 108px;
  box-shadow: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--accent-strong);
  font-weight: 800;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot.off {
  background: var(--danger);
}

.mode-bars {
  display: grid;
  gap: 12px;
}

.tracker-panel {
  display: grid;
  gap: 16px;
}

.tracker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tracking-diagnostics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tracking-diagnostics div,
.tracking-test-note {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.tracking-diagnostics strong,
.tracking-test-note strong {
  color: var(--accent-strong);
  font-size: 0.88rem;
}

.tracking-diagnostics span,
.tracking-test-note span {
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-bar {
  display: grid;
  gap: 6px;
}

.mode-line {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef5fa;
}

.mode-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.mode-fill.bike {
  background: var(--blue);
}

.mode-fill.ebike {
  background: #6cc6a1;
}

.mode-fill.train,
.mode-fill.bus {
  background: #3aa76d;
}

.mode-fill.carpool {
  background: #b6a03b;
}

.mode-fill.car {
  background: var(--amber);
}

.mode-fill.motorized {
  background: var(--yellow);
}

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

.trip-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) repeat(4, minmax(92px, 0.7fr)) minmax(180px, 1.2fr);
  gap: 10px;
  align-items: center;
  padding: 14px;
}

.trip-row.header {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--accent-strong);
  font-weight: 800;
}

.badge.blue {
  background: #e8f0fa;
  color: var(--blue);
}

.badge.amber {
  background: #fff4c7;
  color: var(--amber);
}

.badge.green {
  background: #e8f7ef;
  color: #166534;
}

.reward-badge {
  background: var(--yellow);
  color: var(--text);
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.reward-card {
  display: grid;
  gap: 12px;
  min-height: 210px;
  padding: 18px;
  border-top: 4px solid var(--yellow);
}

.reward-goal {
  display: grid;
  gap: 14px;
  border-top: 4px solid var(--yellow);
}

.reward-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-alt);
}

.reward-progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--accent));
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 136px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #f4fbff);
}

.achievement-card h3 {
  margin-bottom: 6px;
}

.achievement-medal,
.celebration-badge {
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 24%, #fff6b8, var(--yellow) 46%, #e6a900 100%);
  color: var(--text);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55), 0 16px 28px rgba(230, 169, 0, 0.24);
  font-weight: 900;
}

.achievement-medal {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
}

.achievement-medal strong,
.celebration-badge strong {
  line-height: 1;
}

.achievement-medal small,
.celebration-badge small {
  color: rgba(52, 54, 57, 0.72);
  font-size: 0.66rem;
  font-weight: 900;
}

.celebration-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(27, 79, 114, 0.22);
  backdrop-filter: blur(10px);
}

.celebration-card {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(27, 79, 114, 0.2);
  text-align: left;
}

.celebration-card.achievement-celebration {
  text-align: center;
}

.celebration-card h2,
.celebration-card p {
  margin-bottom: 0;
}

.celebration-card strong {
  color: var(--accent-strong);
}

.celebration-badge {
  width: 96px;
  height: 96px;
  justify-self: center;
  animation: medal-pop 520ms cubic-bezier(0.2, 0.9, 0.25, 1.2);
}

@keyframes medal-pop {
  0% {
    opacity: 0;
    transform: scale(0.72) translateY(10px);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.privacy-list,
.redemption-list,
.feedback-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.privacy-list li,
.redemption-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.feedback-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.feedback-item p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  overflow-x: auto;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 0.84rem;
}

.settings-list {
  display: grid;
  gap: 14px;
}

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

.mini-grid,
.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.compact-grid {
  margin: 14px 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  .topbar {
    align-items: center;
    flex-direction: row;
  }

    .auth-grid,
    .admin-grid,
    .tracker-grid,
    .tracking-diagnostics,
    .estimate-grid,
    .achievement-grid,
    .reward-grid {
      grid-template-columns: 1fr;
    }

  .span-4,
  .span-3,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: 1 / -1;
  }

  .trip-row,
  .trip-row.header,
  .mini-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .speed-card {
    align-items: stretch;
    flex-direction: column;
  }

  .trip-row.header {
    display: none;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 22px, 1180px);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bottom-nav-item {
    min-height: 56px;
  }

  .split {
    align-items: flex-start;
    flex-direction: column;
  }
}
