:root {
  --primary: #2563eb;
  --primary-weak: #eff6ff;
  --primary-dark: #1d4ed8;
  --success: #15803d;
  --success-weak: #ecfdf5;
  --danger: #b91c1c;
  --danger-weak: #fef2f2;
  --warning: #b45309;
  --ink: #111827;
  --text: #374151;
  --muted: #6b7280;
  --line: #d9dee7;
  --line-soft: #eef1f5;
  --panel: #ffffff;
  --page: #f6f7f9;
  --chip: #f3f4f6;
  --seat-free: #f8fafc;
  --seat-booked: #9aa1aa;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
  --font: Vazirmatn, IRANSans, Tahoma, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

h1,
h2,
h3,
p,
ol {
  margin: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 32px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}

.header-icon {
  color: var(--primary);
  flex: 0 0 auto;
}

.logo {
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.logo span {
  color: var(--text);
  font-weight: 500;
}

.header-spacer {
  flex: 1;
}

.api-base-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(430px, 46vw);
  direction: ltr;
}

.api-base-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.api-base-form input {
  width: 100%;
  min-width: 180px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.api-base-form input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.16);
  border-color: var(--primary);
}

.server-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  max-width: min(360px, 42vw);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
  direction: ltr;
  font-size: 12px;
  text-align: left;
  overflow: hidden;
}

.server-state span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex: 0 0 auto;
}

.status-dot.is-ok {
  background: var(--success);
}

.status-dot.is-busy {
  background: var(--warning);
}

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

.flow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 920px;
  margin: 24px auto;
  padding: 0 16px;
  list-style: none;
}

.flow-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: #9ca3af;
}

.flow-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: calc(100% - 30px);
  height: 2px;
  background: var(--line);
  transform: translateY(-50%);
  z-index: 0;
}

.flow-steps li.is-done:not(:last-child)::after {
  background: var(--primary);
}

.step-index {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.step-label {
  position: relative;
  z-index: 1;
  max-width: 96px;
  padding: 0 3px;
  background: var(--page);
  color: inherit;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-steps li.is-active {
  color: var(--primary);
  font-weight: 700;
}

.flow-steps li.is-active .step-index,
.flow-steps li.is-done .step-index {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.flow-steps li.is-done {
  color: var(--text);
}

.app-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 64px;
}

.surface {
  margin-bottom: 16px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.flow-panel {
  display: none;
}

.flow-panel.is-active {
  display: block;
}

.section-head,
.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
}

.card-title svg {
  color: currentColor;
  flex: 0 0 auto;
}

h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.is-hidden {
  display: none !important;
}

.search-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr) 160px 118px 160px;
  align-items: end;
  gap: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #c9d1dd;
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 8px;
}

.form-actions.is-wide {
  grid-column: 1 / -1;
  margin-top: 2px;
}

.split-actions {
  justify-content: space-between;
  flex-wrap: wrap;
}

.primary,
.secondary,
.danger,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

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

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

.secondary {
  border: 1px solid #c9d1dd;
  background: #fff;
  color: var(--text);
}

.secondary:hover:not(:disabled) {
  background: #f8fafc;
}

.danger {
  border: 1px solid #f3b4b4;
  background: var(--danger-weak);
  color: var(--danger);
}

.danger:hover:not(:disabled) {
  border-color: var(--danger);
}

.icon-button {
  width: 40px;
  padding: 0;
  border: 1px solid #c9d1dd;
  background: #fff;
  color: var(--primary);
}

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

.compact {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.wide {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

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

.empty-state {
  display: grid;
  min-height: 108px;
  place-items: center;
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}

.service-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.service-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.service-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.service-group {
  display: grid;
  gap: 10px;
}

.service-group + .service-group {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.service-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.service-group-head strong {
  color: var(--ink);
  font-size: 14px;
}

.service-group-head span {
  color: var(--muted);
  font-size: 12px;
}

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

.compact-empty {
  min-height: 72px;
}

.service-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.service-title strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.badge,
.seat-chip,
.seat-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.service-title .badge:first-of-type {
  background: var(--primary-weak);
  color: var(--primary);
}

.service-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.fact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}

.fact span {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.fact strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.selected-summary,
.result-box {
  display: none;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.selected-summary.has-content,
.result-box.has-content {
  display: block;
}

.leg-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.leg-switcher .is-active {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
}

.seat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 20px;
  height: 20px;
  border: 1px solid #c9d1dd;
  border-radius: 6px;
  background: var(--seat-free);
}

.legend-box.is-selected {
  border-color: var(--primary);
  background: #dbeafe;
}

.legend-box.is-booked {
  border-color: var(--seat-booked);
  background: var(--seat-booked);
}

.legend-box.is-disabled {
  background: repeating-linear-gradient(135deg, #fff 0 5px, #e5e7eb 5px 8px);
}

.bus-shell {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  border: 2px solid #d7dce4;
  border-radius: var(--radius);
  background: #fff;
}

.bus-front {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.seat-map {
  direction: ltr;
  display: grid;
  gap: 8px;
  justify-content: center;
  align-content: center;
  min-height: 196px;
  overflow-x: auto;
  padding: 4px;
}

.seat {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid #c9d1dd;
  border-radius: var(--radius-sm);
  background: var(--seat-free);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.seat.is-available:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.seat.is-selected {
  border-color: var(--primary);
  background: #dbeafe;
  color: var(--primary-dark);
}

.seat.is-booked {
  border-color: var(--seat-booked);
  background: var(--seat-booked);
  color: #fff;
}

.seat-spacer {
  width: 54px;
  height: 54px;
}

.booking-form,
.form-block,
.passengers-list {
  display: grid;
  gap: 12px;
}

.passenger-leg-group {
  display: grid;
  gap: 12px;
}

.passenger-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.passenger-row-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.passenger-row-head strong {
  font-size: 14px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex: 0 0 auto;
}

.round-trip-field {
  align-self: end;
  height: 40px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  width: min(320px, 100%);
  gap: 4px;
  padding: 4px;
  border: 1px solid #c9d1dd;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 32px;
  place-items: center;
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.segmented input:checked + span {
  background: var(--primary);
  color: #fff;
}

.ticket-review {
  display: grid;
  gap: 14px;
}

.ticket-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.ticket-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 46px;
  border-bottom: 1px solid var(--line-soft);
}

.ticket-row:last-child {
  border-bottom: 0;
}

.ticket-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.ticket-cell.is-label {
  background: #f7f8fa;
  color: var(--text);
  justify-content: flex-start;
  border-left: 1px solid var(--line-soft);
}

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

.passenger-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
}

.passenger-summary span {
  color: var(--muted);
  font-size: 12px;
}

.json-output,
.mini-output {
  margin: 12px 0 0;
  border-radius: var(--radius-sm);
  background: #111827;
  color: #eef2ff;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.json-output {
  display: none;
  min-height: 110px;
  padding: 14px;
}

.json-output.has-content {
  display: block;
}

.mini-output {
  display: none;
  max-height: 280px;
  padding: 10px;
  font-size: 12px;
}

.mini-output.has-content {
  display: block;
}

.lookup-panel {
  display: grid;
  gap: 0;
  margin-top: 22px;
}

.toast-stack {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 36px));
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.toast.is-error {
  background: var(--danger);
}

.toast.is-success {
  background: var(--success);
}

@media (max-width: 760px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0 16px;
    padding-block: 10px;
  }

  .logo span {
    display: none;
  }

  .header-spacer {
    display: none;
  }

  .api-base-form {
    order: 3;
    width: 100%;
    min-width: 0;
  }

  .api-base-form input {
    min-width: 0;
  }

  .server-state {
    margin-inline-start: auto;
    max-width: 52vw;
  }

  .flow-steps {
    overflow-x: auto;
    margin: 18px auto;
  }

  .flow-steps li {
    flex: 0 0 112px;
  }

  .app-shell {
    width: min(100% - 20px, 920px);
  }

  .surface {
    padding: 18px 16px;
  }

  .section-head,
  .passenger-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .search-card {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .form-grid,
  .service-card,
  .service-facts,
  .passenger-row,
  .button-grid {
    grid-template-columns: 1fr;
  }

  .service-card {
    align-items: stretch;
  }

  .bus-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .bus-front {
    min-height: 34px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    writing-mode: horizontal-tb;
  }

  .ticket-row {
    grid-template-columns: 1fr;
  }

  .ticket-cell.is-label {
    border-left: 0;
    justify-content: center;
  }

  .form-actions,
  .split-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .secondary,
  .danger {
    width: 100%;
  }
}

.segmented label {
  position: relative;
}

.segmented input {
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

.segmented.is-three {
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  width: min(420px, 100%);
  margin-bottom: 12px;
}

.lookup-panel .field + .button-grid + .field,
.result-box .muted,
#issueNote {
  margin-top: 12px;
}

.result-box button {
  margin-top: 12px;
}

.developer-panel { max-width: 1100px; margin: 18px auto; padding: 18px; }
.developer-panel summary { cursor: pointer; font-weight: 700; }
.developer-panel .field { margin-top: 16px; }
.developer-panel pre { max-height: 220px; overflow: auto; direction: ltr; text-align: left; }

/* Location picker (canonical city / terminal autocomplete) */
.location-field > label {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.combobox {
  position: relative;
}

.location-field .location-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.location-field.is-selected input {
  border-color: var(--success);
}

.location-field.is-invalid input {
  border-color: var(--danger);
}

.location-field.is-invalid .location-hint {
  color: var(--danger);
}

.location-listbox {
  position: absolute;
  z-index: 30;
  inset-inline: 0;
  top: calc(100% + 4px);
  max-height: 320px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.location-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.location-option.is-active,
.location-option:hover {
  background: var(--primary-weak);
}

.location-option[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.72;
}

.location-option[aria-disabled="true"].is-active,
.location-option[aria-disabled="true"]:hover {
  background: var(--chip);
}

.location-option .location-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.location-option .location-detail,
.location-option .location-reason {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.location-option .location-reason {
  color: var(--warning);
}

.location-type {
  grid-row: span 2;
  align-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.location-type.is-terminal {
  background: var(--chip);
  color: var(--text);
}

.location-status {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

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

/* Search result additions */
.service-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.search-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-weak);
  color: var(--primary-dark);
  font-size: 12px;
}

.search-notice.is-warning {
  background: #fffbeb;
  color: var(--warning);
}

@media (max-width: 760px) {
  .location-listbox {
    max-height: 55vh;
  }

  .location-option {
    padding: 11px 10px;
  }
}

/* Provider bus types can be long feature lists; let title badges wrap instead of widening the card on phones. */
.service-title .badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.service-card > div {
  min-width: 0;
}
