:root {
  --bg-canvas: #0b0f17;
  --bg-surface: #131a26;
  --bg-elevated: #1b2434;
  --bg-input: #101622;
  --border-subtle: #273349;
  --border-focus: #38bdf8;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --brand-primary: #0284c7;
  --brand-primary-hover: #0369a1;
  --brand-tint: rgba(56, 189, 248, 0.14);
  --brand-text: #e0f2fe;
  --accent-emerald: #059669;
  --accent-emerald-bg: rgba(5, 150, 105, 0.18);
  --accent-emerald-text: #6ee7b7;
  --accent-amber: #f59e0b;
  --danger-bg: #991b1b;
  --danger-border: #ef4444;
  --danger-text: #fecaca;
  --radius-card: 14px;
  --radius-btn: 10px;
  --radius-pill: 999px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 14px;
  --space-lg: 20px;
  --tap-min: 44px;
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* Launch splash */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease;
}

.splash.hide {
  opacity: 0;
  pointer-events: none;
}

.splash-name {
  display: flex;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.splash-name span {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.4s ease forwards;
}

.splash-name span:nth-child(1) { animation-delay: 0.05s; }
.splash-name span:nth-child(2) { animation-delay: 0.12s; }
.splash-name span:nth-child(3) { animation-delay: 0.19s; }
.splash-name span:nth-child(4) { animation-delay: 0.26s; }
.splash-name span:nth-child(5) { animation-delay: 0.33s; }
.splash-name span:nth-child(6) { animation-delay: 0.4s; }

.splash-bar {
  width: 0;
  height: 3px;
  margin-top: 14px;
  border-radius: var(--radius-pill);
  background: var(--border-focus);
  animation: grow 0.55s ease 0.35s forwards;
}

.splash-sub {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  animation: rise 0.4s ease 0.5s forwards;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes grow {
  to {
    width: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash,
  .splash-name span,
  .splash-bar,
  .splash-sub {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* App Shell */
.shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.role-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--brand-tint);
  color: var(--brand-text);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.role-switch {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  overflow: hidden;
  background: var(--bg-input);
}

.role-btn {
  background: transparent;
  border: 0;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.role-btn.active {
  background: var(--brand-primary);
  color: var(--brand-text);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.build-note {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
}

/* Main App Container */
main {
  flex: 1;
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0;
}

.phone-app {
  display: none;
  width: 100%;
}

.phone-app.active {
  display: flex;
  justify-content: center;
}

.phone {
  width: 100%;
  min-height: calc(100dvh - 57px);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: var(--space-md) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  gap: var(--space-sm);
}

.screen.active {
  display: flex;
}

/* Tablet & Desktop Adaptive Shell */
@media (min-width: 640px) {
  main {
    padding: var(--space-lg) var(--space-md);
    align-items: flex-start;
  }

  .phone {
    max-width: 520px;
    min-height: 680px;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    overflow: hidden;
  }

  .screen {
    padding: var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .phone {
    max-width: 860px;
  }

  .desktop-split {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: var(--space-md);
    align-items: start;
  }
}

.app-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-head p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--brand-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}

.avatar.small {
  width: 40px;
  height: 40px;
}

/* Form Controls */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 4px 0 5px;
}

input,
select {
  width: 100%;
  min-height: var(--tap-min);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 8px;
}

input::placeholder {
  color: var(--text-muted);
}

.primary {
  width: 100%;
  min-height: var(--tap-min);
  padding: 11px 16px;
  background: var(--brand-primary);
  color: var(--brand-text);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease;
}

.primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
}

.danger-btn {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 14px;
  background: rgba(153, 27, 27, 0.35);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
}

.link {
  display: block;
  width: 100%;
  min-height: 40px;
  background: transparent;
  border: 0;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--border-focus);
}

.link.muted {
  color: var(--text-muted);
  font-weight: 500;
}

.error {
  display: block;
  min-height: 18px;
  color: #fca5a5;
  font-size: 12px;
  margin: 2px 0 4px;
}

.status-msg {
  display: block;
  font-size: 12px;
  color: var(--accent-emerald-text);
  min-height: 16px;
}

/* Segmented & Chip Pickers */
.segment {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  padding: 3px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: 0;
  min-height: 38px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  color: var(--text-muted);
}

.seg-btn.active {
  background: var(--brand-primary);
  color: var(--brand-text);
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pick-chip {
  flex: 1;
  min-width: 96px;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pick-chip.active {
  background: var(--brand-tint);
  border-color: var(--border-focus);
  color: var(--brand-text);
}

/* Map Container */
.map-shell {
  position: relative;
  width: 100%;
  height: 220px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .map-shell {
    height: 340px;
  }
}

.map-canvas {
  width: 100%;
  height: 100%;
  position: relative;
}

.map-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  max-width: calc(100% - 20px);
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(11, 15, 23, 0.86);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(6px);
}

.map-pin-mode {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

/* Cards & Rows */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 13px;
}

.info-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.info-box.highlight {
  background: var(--brand-tint);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--brand-text);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap-min);
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-size: 13px;
  cursor: pointer;
}

.field-row:hover {
  border-color: var(--border-focus);
}

.field-row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.dot.pickup { background: var(--border-focus); }
.dot.drop { background: #fb7185; border-radius: 2px; }

.field-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 36px;
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  gap: 8px;
}

.btn-pair {
  display: flex;
  gap: 8px;
}

.btn-pair > * {
  flex: 1;
}

/* Progress Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
}

.step .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
}

.step.done {
  color: var(--accent-emerald-text);
  border-color: rgba(110, 231, 183, 0.35);
}

.step.done .dot {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.step.current {
  color: var(--brand-text);
  border-color: var(--border-focus);
  background: var(--brand-tint);
}

.step.current .dot {
  background: var(--border-focus);
  border-color: var(--border-focus);
}

/* Metrics, Wallet, Queue */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.metrics div {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
}

.metrics span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.metrics strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  font-weight: 700;
}

.coin-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  background: var(--brand-tint);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-btn);
  padding: 6px 12px;
}

.coin-head span {
  font-size: 12px;
  color: var(--brand-text);
}

.coin-head strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.online {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 0;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-emerald);
  color: #ecfdf5;
}

.online.offline {
  background: #475569;
  color: #e2e8f0;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  flex: 1;
  min-height: 40px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.tab-btn.active {
  background: var(--brand-primary);
  border-color: var(--border-focus);
  color: var(--brand-text);
}

.request-list,
.wallet-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.request-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px;
}

.request-card p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.chip {
  min-height: 36px;
  padding: 6px 14px;
  background: var(--brand-primary);
  color: var(--brand-text);
  border: 0;
  border-radius: var(--radius-btn);
  font-size: 12px;
  font-weight: 600;
}

.wallet-balance {
  text-align: center;
  padding: 16px;
}

.wallet-balance span,
.wallet-balance small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.wallet-balance strong {
  display: block;
  margin: 4px 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--border-focus);
}

.preset-amounts {
  display: flex;
  gap: 8px;
}

.preset-amounts button {
  flex: 1;
  min-height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 600;
}

.amount.positive { color: var(--accent-emerald-text); font-weight: 700; }
.amount.negative { color: #fca5a5; font-weight: 700; }

/* Receipt & Ratings */
.receipt .row {
  padding: 4px 0;
}

.divider {
  border-top: 1px solid var(--border-subtle);
  margin: 8px 0;
}

.total span {
  font-size: 15px;
  font-weight: 700;
}

.paid {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald-text);
  font-size: 12px;
  font-weight: 600;
}

.rate-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px;
  font-size: 13px;
}

.rate-buttons {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.rate-buttons button {
  flex: 1;
  min-height: var(--tap-min);
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  font-size: 14px;
  font-weight: 700;
}

.rate-buttons button.selected {
  background: var(--brand-primary);
  color: var(--brand-text);
  border-color: var(--border-focus);
}

/* Chat & SOS */
.chat-thread {
  flex: 1;
  min-height: 220px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}

.chat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  word-break: break-word;
}

.chat-bubble.them {
  background: var(--bg-elevated);
  align-self: flex-start;
}

.chat-bubble.me {
  background: var(--brand-primary);
  color: var(--brand-text);
  align-self: flex-end;
}

.sos {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 700;
}

.call-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  min-height: var(--tap-min);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.suggestion-item strong {
  font-size: 13px;
  color: var(--text-primary);
}

.suggestion-item small {
  font-size: 11px;
  color: var(--text-muted);
}

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  padding-top: 8px;
  gap: 4px;
}

.bottom-nav button {
  flex: 1;
  min-height: var(--tap-min);
  background: transparent;
  border: 0;
  border-radius: var(--radius-btn);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 4px;
}

.bottom-nav button.active {
  color: var(--border-focus);
  background: var(--brand-tint);
}

.nav-card {
  background: var(--brand-tint);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-card);
  padding: 12px;
}

.nav-card span,
.nav-card small {
  display: block;
  font-size: 12px;
  color: var(--brand-text);
}

.nav-card strong {
  display: block;
  font-size: 16px;
  margin: 3px 0;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.stars-static {
  color: var(--accent-amber);
  letter-spacing: 2px;
  font-size: 14px;
  margin-top: 4px;
}
