:root {
  /* Core */
  --lifto-green: #1F3A34;
  --lifto-green-600: #35514A;
  --lifto-green-tint: #E9F0EC;
  --lifto-terracotta: #D96E48;
  --lifto-terra-tint: #F7E3D9;
  --lifto-paper: #F6F3EE;
  --lifto-sand: #D9CFBF;
  --lifto-sand-deep: #E7E0D3;
  --lifto-white: #FFFFFF;

  /* Text */
  --lifto-text: #1F3A34;
  --lifto-text-secondary: #6E675F;
  --lifto-text-muted: #9B948C;
  --lifto-border: #E3DED6;

  /* Semantic */
  --lifto-success: #3E7D5C;
  --lifto-success-bg: #E9F0EC;
  --lifto-warning: #8A6A1E;
  --lifto-warning-bg: #F5EBD3;
  --lifto-error: #B4452F;
  --lifto-error-bg: #F7E3D9;

  --lifto-shadow: 0 1px 4px rgba(31, 58, 52, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--lifto-paper);
  color: var(--lifto-text);
  font-size: 16px;
  line-height: 24px;
}
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.ph { vertical-align: -3px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--lifto-green);
  color: var(--lifto-paper);
  padding: 16px 0;
}
.topbar-inner {
  max-width: 1060px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--lifto-paper);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none;
}
.brand-mark .dot { width: 6px; height: 6px; border-radius: 50%; }
.brand-mark .dot-terra { background: var(--lifto-terracotta); }
.brand-mark .dot-green { background: var(--lifto-green); }
.brand-name {
  font-size: 22px; font-weight: 800; letter-spacing: -.03em; text-transform: lowercase;
}
.tagline { font-size: 14px; color: var(--lifto-sand); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.switcher { font-size: 14px; color: var(--lifto-sand); display: flex; align-items: center; gap: 8px; }
.switcher select {
  border: none; border-radius: 999px; padding: 8px 34px 8px 16px; max-width: 190px;
  background-color: var(--lifto-paper); color: var(--lifto-text); font-weight: 600;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%231F3A34' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- tabs ---------- */
.tabs-wrap { background: var(--lifto-white); border-bottom: 1px solid var(--lifto-border); position: sticky; top: 0; z-index: 20; }
.tabs { max-width: 1060px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 14px 14px 11px; cursor: pointer; color: var(--lifto-text-secondary); font-weight: 600; font-size: 14px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--lifto-text); }
.tab.active { color: var(--lifto-green); border-bottom-color: var(--lifto-terracotta); }
.tab .count-badge {
  background: var(--lifto-terracotta); color: #FFF8F3; border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ---------- layout ---------- */
.container { max-width: 1060px; margin: 0 auto; padding: 24px 24px 60px; }
.page-head { margin: 4px 0 24px; }
.page-head h1 {
  font-size: 32px; line-height: 36px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 6px; color: var(--lifto-text);
}
.page-head p { margin: 0; color: var(--lifto-text-secondary); font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 760px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.section { margin-bottom: 32px; }
.section > h2 {
  font-size: 12px; line-height: 16px; font-weight: 700; margin: 0 0 12px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--lifto-text-muted); display: flex; align-items: center; gap: 8px;
}
.section > h2 .ph { font-size: 15px; color: var(--lifto-green); }
.section > h2 .count-badge {
  background: var(--lifto-terracotta); color: #FFF8F3; border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
  text-transform: none; letter-spacing: 0;
}

/* ---------- cards ---------- */
.card {
  background: var(--lifto-white); border: 1px solid var(--lifto-border); border-radius: 14px;
  padding: 18px; box-shadow: var(--lifto-shadow); display: flex; flex-direction: column; gap: 12px;
}
.card.is-request { border: 1.5px dashed #C9BFAF; box-shadow: none; }
.card + .card { margin-top: 12px; }
.two-col .card + .card { margin-top: 0; }

/* card row 1: who + meta + chip */
.who-row { display: flex; align-items: center; gap: 10px; }
.who-main { flex: 1; min-width: 0; }
.who-title { font-size: 19px; line-height: 26px; font-weight: 700; color: var(--lifto-text); cursor: pointer; }
.who-title:hover { color: var(--lifto-green-600); }
.who-sub { font-size: 13px; color: var(--lifto-text-muted); font-weight: 600; }

/* route signature */
.route-row { display: flex; align-items: center; gap: 8px; }
.route-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.route-dot.origin { background: var(--lifto-green); }
.route-dot.dest { background: var(--lifto-white); border: 3px solid var(--lifto-terracotta); box-sizing: border-box; }
.route-dot.dest.is-request { border-color: var(--lifto-green); }
.route-label { font-size: 16px; font-weight: 800; color: var(--lifto-text); white-space: nowrap; }
.route-dash {
  flex: 1; height: 2px; min-width: 24px;
  background: repeating-linear-gradient(90deg, var(--lifto-terracotta) 0 6px, transparent 6px 12px);
}
.route-dash.is-request { background: repeating-linear-gradient(90deg, var(--lifto-green) 0 6px, transparent 6px 12px); }

/* compact route used inside list rows */
.route-mini { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--lifto-text); }
.route-mini .ph { color: var(--lifto-terracotta); font-size: 14px; }

.when { color: var(--lifto-text-secondary); font-size: 14px; }
.when b { color: var(--lifto-text); font-weight: 700; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notes { color: var(--lifto-text-secondary); font-size: 14px; background: var(--lifto-paper); border-radius: 10px; padding: 10px 12px; }
.meta-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- chips, badges, avatars ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px; background: var(--lifto-green-tint);
  border: 1px solid transparent; border-radius: 999px; padding: 4px 11px 4px 4px; cursor: pointer;
}
.chip:hover { border-color: var(--lifto-green); }
.chip-name { font-weight: 700; font-size: 13.5px; color: var(--lifto-text); }
.chip-rating { font-size: 12.5px; color: var(--lifto-text-muted); font-weight: 700; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--lifto-sand); color: var(--lifto-green);
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.md { width: 36px; height: 36px; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 700; line-height: 1;
}
.badge.confirmed { background: var(--lifto-success-bg); color: var(--lifto-success); }
.badge.pending { background: var(--lifto-warning-bg); color: var(--lifto-warning); }
.badge.cancelled { background: var(--lifto-error-bg); color: var(--lifto-error); }
.badge.neutral { background: var(--lifto-sand-deep); color: var(--lifto-green); }
.badge.mine { background: var(--lifto-terra-tint); color: var(--lifto-terracotta); }

.star { color: var(--lifto-sand); }
.star.on { color: var(--lifto-terracotta); }
.muted { color: var(--lifto-text-secondary); }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 999px; padding: 13px 24px; min-height: 48px; cursor: pointer;
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--lifto-terracotta); color: #FFF8F3; transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: #C45E39; }

.btn.green { background: var(--lifto-green); color: var(--lifto-paper); }
.btn.green:hover { background: var(--lifto-green-600); }

.btn.outline { background: transparent; color: var(--lifto-green); border: 1.5px solid var(--lifto-green); }
.btn.outline:hover { background: var(--lifto-green-tint); }

.btn.ghost { background: transparent; color: var(--lifto-paper); border: 1.5px solid rgba(246,243,238,.4); }
.btn.ghost:hover { background: rgba(246,243,238,.12); }

.btn.subtle { background: var(--lifto-sand-deep); color: var(--lifto-green); }
.btn.subtle:hover { background: var(--lifto-sand); }

.btn.danger { background: transparent; color: var(--lifto-terracotta); padding-left: 12px; padding-right: 12px; }
.btn.danger:hover { background: var(--lifto-terra-tint); }

.btn.small { padding: 8px 16px; min-height: 36px; font-size: 13px; }
.btn.danger.small { padding: 8px 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-card { gap: 4px; height: 100%; }
.form-card .form-title { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; margin: 0; color: var(--lifto-text); }
.form-card .form-title .ph { color: var(--lifto-green); font-size: 20px; }
.form-card .sub { color: var(--lifto-text-secondary); font-size: 14px; line-height: 20px; margin: 0 0 10px; min-height: 40px; }
/* keep both post forms symmetric: the submit button sits at the bottom of an equal-height card */
.form-card > .btn { margin-top: auto; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--lifto-text-secondary); }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; border: 1.5px solid var(--lifto-border); border-radius: 12px; padding: 13px 16px;
  background: var(--lifto-white); font-size: 16px; color: var(--lifto-text);
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--lifto-green); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-row .field { min-width: 0; display: flex; flex-direction: column; }
.field-row .field label { flex: 1; display: flex; align-items: flex-end; }
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px;
  background: var(--lifto-white); border: 1px solid var(--lifto-border); border-radius: 14px; padding: 12px;
}
.filter-bar input { border: 1.5px solid var(--lifto-border); border-radius: 999px; padding: 9px 14px; }
.filter-bar input[type="text"] { width: 150px; }

/* ---------- bids ---------- */
.bids-block { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--lifto-border); padding-top: 12px; }
.bids-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bids-head h3 {
  margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--lifto-text-muted);
  display: flex; align-items: center; gap: 6px;
}
.bids-head h3 .ph { color: var(--lifto-green); font-size: 14px; }
.sort-chips { display: flex; gap: 5px; }
.sort-chip {
  border: 1px solid var(--lifto-border); background: var(--lifto-white); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; font-weight: 700; color: var(--lifto-text-secondary); cursor: pointer;
}
.sort-chip.active { background: var(--lifto-green); color: var(--lifto-paper); border-color: var(--lifto-green); }
.bid-row {
  border: 1px solid var(--lifto-border); border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--lifto-paper);
}
.bid-row.accepted { border-color: var(--lifto-success); background: var(--lifto-success-bg); }
.bid-row.declined { opacity: .55; }
.bid-main { flex: 1; min-width: 180px; }
.bid-msg { font-size: 13px; color: var(--lifto-text-secondary); margin-top: 2px; }
.bid-amount { font-size: 17px; font-weight: 800; color: var(--lifto-text); }
.bid-actions { display: flex; gap: 4px; align-items: center; }
.fit-badge {
  font-size: 11.5px; font-weight: 700; color: var(--lifto-green); background: var(--lifto-green-tint);
  border-radius: 999px; padding: 3px 9px;
}

/* ---------- match rows ---------- */
.match-row {
  border: 1.5px dashed var(--lifto-sand); background: var(--lifto-green-tint); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.match-main { flex: 1; min-width: 180px; }
.match-sub { font-size: 13px; color: var(--lifto-text-secondary); margin-top: 2px; }

/* ---------- empty state ---------- */
.empty {
  border: 1.5px dashed var(--lifto-sand); border-radius: 14px; padding: 32px 20px; text-align: center;
  color: var(--lifto-text-secondary); background: var(--lifto-white);
}
.empty .ph { font-size: 30px; display: block; margin-bottom: 8px; color: var(--lifto-terracotta); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31, 58, 52, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px 16px; overflow-y: auto;
}
.modal {
  background: var(--lifto-white); border-radius: 20px; width: 100%; max-width: 470px; padding: 24px;
  position: relative; box-shadow: 0 24px 60px rgba(31, 58, 52, .25);
}
.modal h2 { margin: 0 0 4px; font-size: 19px; font-weight: 700; color: var(--lifto-text); }
.modal .sub { color: var(--lifto-text-secondary); font-size: 14px; margin: 0 0 16px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; border: none; background: var(--lifto-sand-deep); color: var(--lifto-green);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--lifto-sand); }

/* ---------- profile modal ---------- */
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.profile-head .name { font-size: 19px; font-weight: 700; color: var(--lifto-text); }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--lifto-paper); border: 1px solid var(--lifto-border); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 17px; color: var(--lifto-text); }
.stat span { font-size: 11.5px; color: var(--lifto-text-muted); font-weight: 600; }
.review { border-top: 1px solid var(--lifto-border); padding: 10px 0; }
.review .who { font-size: 13px; font-weight: 700; color: var(--lifto-text); }
.review .txt { font-size: 13.5px; color: var(--lifto-text-secondary); margin-top: 2px; }

/* ---------- star picker ---------- */
#star-picker { display: flex; gap: 4px; margin: 6px 0 2px; }
#star-picker .pick {
  border: none; background: none; font-size: 30px; cursor: pointer; color: var(--lifto-sand); padding: 0 2px; line-height: 1;
}
#star-picker .pick.on { color: var(--lifto-terracotta); }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--lifto-green); color: var(--lifto-paper); border-radius: 12px; padding: 12px 18px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(31, 58, 52, .35); animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- misc ---------- */
.status-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-note { font-size: 13px; color: var(--lifto-text-secondary); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  /* header: brand on its own line, controls in one tidy row below */
  .topbar { padding: 12px 0; }
  .topbar-inner { padding: 0 16px; row-gap: 10px; }
  .tagline { display: none; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .switcher { flex: none; min-width: 0; white-space: nowrap; }
  .switcher-label { display: none; }
  .switcher select { flex: none; max-width: 62vw; min-width: 0; }
  .btn.ghost.small { white-space: nowrap; }

  .tabs { padding: 0 16px; }
  .container { padding: 20px 16px 48px; }
  .page-head h1 { font-size: 27px; line-height: 32px; }
  .card { padding: 16px; }

  /* filter bar: symmetric grid instead of ragged wrapping */
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filter-bar input { width: 100% !important; min-width: 0; }
  .filter-bar input[type="date"] { grid-column: 1 / -1; }
  .filter-bar .btn { width: 100%; }

  /* card header: keep the chip pinned to the top line, not floating mid-title */
  .who-row { align-items: flex-start; }
  .who-row > .badge { margin-top: 4px; }
  .who-title { font-size: 17px; line-height: 24px; }
  .route-label { font-size: 15px; }
  .route-row { gap: 6px; }

  /* card footer: stack info above actions, stretch buttons edge-to-edge */
  .card-row { flex-direction: column; align-items: stretch; }
  .card-row .status-strip { justify-content: stretch; }
  .card-row .status-strip .btn { flex: 1; }
  .card-row .status-strip .badge { justify-content: center; flex: 1; }

  /* bid & match rows: actions get their own full-width line */
  .bid-row, .match-row { align-items: flex-start; }
  .bid-actions { width: 100%; justify-content: flex-end; }
  .bids-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .sort-chips { width: 100%; }
  .sort-chip { flex: 1; text-align: center; }

  .profile-stats { gap: 6px; }
  .modal { padding: 20px; }
  .modal form > .btn { width: 100%; }
}
