:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6876;
  --line: #d9e0ea;
  --primary: #1f6feb;
  --primary-dark: #1557bd;
  --courier: #1f6feb;
  --sender: #12805c;
  --warning: #f59e0b;
  --danger: #b42318;
  --danger-bg: #fff4f2;
  --shadow: 0 20px 40px rgba(20, 32, 50, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 18px;
  text-decoration: none;
}

.brand img {
  display: block;
  width: min(215px, 64vw);
  height: auto;
}

.setup-logo {
  display: block;
  width: min(215px, 70vw);
  height: auto;
  margin: 0 auto 22px;
}


.site-header {
  padding: 38px min(5vw, 64px) 22px;
}

.site-header > div {
  max-width: 1040px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 1;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

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

.intro {
  max-width: 860px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 420px) 1fr minmax(290px, 360px);
  gap: 18px;
  padding: 0 min(5vw, 64px) 44px;
}

.panel, .map-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.form-panel, .routes-panel {
  align-self: start;
}

.map-section {
  overflow: hidden;
  min-width: 0;
}

.map-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.map-toolbar p,
.panel-note {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#map {
  width: 100%;
  height: min(68vh, 700px);
  min-height: 500px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 18px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 5px;
  border-radius: 999px;
  vertical-align: -1px;
}

.courier-dot {
  background: var(--courier);
}

.sender-dot {
  background: var(--sender);
}

label,
.stop-header {
  display: block;
  margin: 16px 0 7px;
  color: var(--text);
  font-weight: 750;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin: 0 0 9px;
  font-weight: 800;
}

.role-choice {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.choice-card {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  cursor: pointer;
}

.choice-card:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.choice-card input {
  width: auto;
  margin-top: 3px;
}

.choice-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  font: inherit;
  background: #fbfcff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.two-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.role-fields {
  margin-top: 2px;
  padding-top: 2px;
}

.stop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stop-header label {
  margin: 0;
}

.location-stops {
  display: grid;
  gap: 8px;
}

.stop-row {
  display: grid;
  grid-template-columns: 34px 1fr 40px;
  gap: 8px;
  align-items: center;
}

.stop-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
  background: #fff;
}

.stop-input {
  min-width: 0;
}

.remove-stop {
  min-width: 0;
  min-height: 40px;
  border-radius: 12px;
  padding: 0;
  color: var(--danger);
  background: var(--danger-bg);
}

.remove-stop:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.help-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.compact-help {
  margin-top: -6px;
  margin-bottom: 12px;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef2f8;
}

.button-row,
.routes-heading-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.routes-heading-row {
  justify-content: space-between;
}

.button-row {
  margin-top: 18px;
}

.button-row.compact {
  margin-top: 12px;
}

button,
.share-link,
.contact-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  background: #fff;
  cursor: pointer;
}

button:hover,
.share-link:hover,
.contact-link:hover {
  border-color: var(--primary);
}

button.primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

button.primary:hover {
  background: var(--primary-dark);
}

button.secondary,
.filter-button {
  background: #f8fafc;
}

button.danger {
  border-color: #f2c8c2;
  color: var(--danger);
  background: var(--danger-bg);
}

.text-button {
  min-height: auto;
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
}

.status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.status.success {
  color: var(--sender);
}

.status.error {
  color: var(--danger);
}

.filter-row {
  margin-top: 14px;
}

.filter-button.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef5ff;
}

.search-input {
  margin-top: 12px;
}

.routes-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 36vh;
  overflow: auto;
  padding-right: 4px;
}

.route-card {
  display: grid;
  justify-items: start;
  width: 100%;
  min-height: 0;
  border-radius: 14px;
  padding: 13px;
  text-align: left;
  background: #fbfcff;
}

.route-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.route-card strong {
  margin-bottom: 4px;
}

.route-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.route-card .travel-date-line {
  color: var(--text);
  font-weight: 700;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 7px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #fff !important;
  font-size: 0.75rem !important;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.role-badge.courier {
  background: var(--courier);
}

.role-badge.sender {
  background: var(--sender);
}

.selected-details {
  margin-top: 16px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfcff;
}

.detail-card p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.42;
}

.detail-list {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.detail-list li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  line-height: 1.35;
}

.detail-list strong {
  color: var(--text);
}

.contact-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #eef5ff;
}

.contact-box p {
  margin: 0;
  color: var(--text);
}

.contact-actions,
.match-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.match-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.match-card {
  width: 100%;
  min-height: auto;
  border-radius: 12px;
  padding: 10px;
  justify-content: start;
  text-align: left;
}

.empty-state {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 4px;
}

.leaflet-popup-content span {
  display: block;
  color: #4b5563;
}

.role-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.22);
}

.role-marker.courier {
  background: var(--courier);
}

.role-marker.sender {
  background: var(--sender);
}

.role-marker.preview {
  background: var(--warning);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.poster-rating,
.rating-line {
  color: var(--muted);
}

.rating-line {
  font-weight: 750;
}

.reviews-section {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reviews-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.reviews-header h3 {
  margin: 0;
}

.review-summary-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  background: #fff;
}

.review-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
}

.review-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.review-form label {
  margin-top: 0;
}

.review-fields {
  align-items: end;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-list {
  display: grid;
  gap: 8px;
}

.review-card {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  justify-content: space-between;
}

.review-meta span,
.review-context {
  color: var(--muted);
  font-size: 0.86rem;
}

.star-rating {
  color: #8a6200;
  letter-spacing: 0.03em;
}

.review-comment,
.review-context {
  margin: 7px 0 0 !important;
  line-height: 1.4;
}

.review-comment.muted {
  color: var(--muted);
}

.danger-text {
  margin-top: 7px;
  color: var(--danger) !important;
}

@media (max-width: 1250px) {
  .layout {
    grid-template-columns: minmax(320px, 420px) 1fr;
  }

  .routes-panel {
    grid-column: 1 / -1;
  }

  .routes-list {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .site-header {
    padding: 28px 18px 18px;
  }

  .layout {
    display: block;
    padding: 0 14px 28px;
  }

  .panel, .map-section {
    margin-bottom: 16px;
  }

  .map-toolbar {
    display: block;
  }

  .toolbar-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  #map {
    height: 62vh;
    min-height: 360px;
  }

  .two-field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}


.map-fallback {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 2rem;
  text-align: center;
  background: #f8fafc;
  color: #475569;
}

.map-fallback strong {
  color: #0f172a;
}

[hidden] {
  display: none !important;
}

/* Account/sign-in additions */
.site-header > .header-grid {
  max-width: 1440px;
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 20px;
  align-items: start;
}

.header-copy {
  max-width: 920px;
}

.auth-panel {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin-bottom: 8px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 10px;
}

.auth-tab {
  width: 100%;
  border-radius: 12px;
  background: #f8fafc;
}

.auth-tab.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef5ff;
}

.auth-form {
  display: grid;
  gap: 0;
}

.auth-form button[type="submit"] {
  margin-top: 14px;
}

.signed-in-line {
  margin-bottom: 4px;
  color: var(--text);
}

.account-email,
.owner-line {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

#auth-post-help {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid #f5d58b;
  border-radius: 12px;
  background: #fff8e6;
  color: #7a4b00;
}

#auth-post-help.signed-in {
  border-color: #b8e1ce;
  background: #edfdf5;
  color: var(--sender);
}

.owner-pill {
  display: inline-flex !important;
  align-items: center;
  width: fit-content;
  margin: 4px 0 8px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--primary) !important;
  font-size: 0.75rem !important;
  font-weight: 800;
  background: #eef5ff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

/* Account and sign-in additions */
.site-header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 22px;
  align-items: start;
  max-width: 1400px !important;
}

.site-header-copy {
  max-width: 860px;
}

.auth-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h2,
.auth-card h3 {
  margin-bottom: 10px;
}

.auth-form {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.auth-form label {
  margin: 4px 0 0;
}

.auth-form button {
  margin-top: 5px;
}

.signed-in-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
}

.signed-in-card strong,
.signed-in-card span {
  display: block;
}

.signed-in-card span:not(.account-avatar) {
  color: var(--muted);
  font-size: 0.9rem;
  word-break: break-word;
}

.account-avatar {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  background: var(--sender);
}

.auth-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.auth-message.success,
.auth-message.status.success {
  color: var(--sender);
}

.auth-message.error,
.auth-message.status.error {
  color: var(--danger);
}

.form-account-note {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #fbfcff;
  line-height: 1.4;
}

.form-account-note.signed-in {
  border-color: rgba(18, 128, 92, 0.28);
  color: var(--sender);
  background: #edfdf6;
}

.contact-box.locked {
  background: #fff8e8;
}

.owner-line,
.owner-note,
.owner-badge {
  color: var(--sender) !important;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-width: 980px) {
  .site-header-inner {
    grid-template-columns: 1fr;
  }
}

.reviews-heading-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.reviews-heading-row h3 {
  margin: 0 0 4px;
}

.review-summary {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.review-form-state {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
}

.review-form-state p {
  margin: 0 0 5px;
}

.review-form-state p:last-child {
  margin-bottom: 0;
}

.reviews-list {
  display: grid;
  gap: 8px;
}

.review-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.stars {
  color: #8a6200;
  letter-spacing: 0.03em;
  font-weight: 800;
}

.review-source {
  color: var(--muted) !important;
  font-size: 0.88rem;
}

/* Comments and nearby-match notifications */
.comment-count-line {
  font-weight: 700;
}

.comments-section {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.comment-form {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.comment-form label {
  margin-top: 0;
}

.comment-list {
  display: grid;
  gap: 8px;
}

.comment-card {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.comment-card p {
  margin: 8px 0 0 !important;
  color: var(--text);
  line-height: 1.42;
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.comment-meta span {
  color: var(--muted);
  font-size: 0.86rem;
}

.notifications-panel {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.notifications-panel[hidden] {
  display: none !important;
}

.notifications-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notifications-heading h3 {
  margin: 0;
}

.notification-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0 7px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  background: var(--danger);
}

.notifications-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 3px;
}

.notification-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

.notification-card.unread {
  border-color: rgba(31, 111, 235, 0.35);
  background: #eef5ff;
}

.notification-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.34;
}

.notification-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.compact-empty {
  padding: 10px;
  font-size: 0.9rem;
}

/* Payment and verification additions */
.account-badges,
.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.verification-panel {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.verification-panel[hidden] {
  display: none !important;
}

.verification-actions {
  align-items: center;
}

.trust-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.trust-badge.verified {
  border-color: rgba(18, 128, 92, 0.28);
  background: #eaf8f1;
  color: #0d694d;
}

.trust-badge.pending {
  border-color: rgba(245, 158, 11, 0.35);
  background: #fff7e8;
  color: #8a5a00;
}

.trust-badge.unverified {
  border-color: rgba(100, 116, 139, 0.25);
  background: #f8fafc;
  color: #64748b;
}

.trust-line,
.payment-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.payment-line {
  font-weight: 800;
}

.payment-lock {
  border-color: rgba(31, 111, 235, 0.24);
  background: #eef5ff;
}

#verification-status a {
  color: var(--primary);
  font-weight: 800;
}

.subscription-panel {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.subscription-panel[hidden] {
  display: none !important;
}

.subscription-actions {
  align-items: center;
}
