:root {
  --navy: #172349;
  --navy-2: #25386e;
  --blue: #156da8;
  --sky: #eaf5fb;
  --orange: #f47b20;
  --green: #1f9d68;
  --red: #b73838;
  --ink: #17213b;
  --muted: #667085;
  --line: #dce3ec;
  --surface: #ffffff;
  --background: #f4f7fb;
  --shadow: 0 18px 50px rgba(23, 35, 73, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px max(24px, calc((100% - 1240px) / 2));
  color: white;
  background: linear-gradient(115deg, var(--navy), var(--navy-2));
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: var(--navy); background: white; font-size: 24px; font-weight: 800; font-style: italic; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 2px; color: #cbd5ef; font-size: 12px; }
.service-status { display: flex; align-items: center; gap: 8px; color: #dce6ff; font-size: 13px; }
.service-status span { width: 9px; height: 9px; border-radius: 50%; background: #52d394; box-shadow: 0 0 0 4px rgba(82, 211, 148, .16); }

main { max-width: 1240px; margin: 0 auto; padding: 42px 24px 56px; }
.intro { max-width: 760px; margin-bottom: 28px; }
.eyebrow, .step { margin: 0 0 7px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; letter-spacing: -.035em; }
.intro > p:last-child { margin: 14px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr); gap: 24px; align-items: start; }
.panel { padding: 26px; border: 1px solid rgba(220, 227, 236, .9); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
h2, h3 { margin: 0; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

.trip-switch { display: flex; padding: 4px; border-radius: 11px; background: #edf1f7; }
.trip-switch label { cursor: pointer; }
.trip-switch input { position: absolute; opacity: 0; pointer-events: none; }
.trip-switch span { display: block; padding: 8px 11px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.trip-switch input:checked + span { color: white; background: var(--navy); }

.field-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.three-columns { grid-template-columns: repeat(3, 1fr); }
.route-grid { grid-template-columns: 1fr 42px 1fr; align-items: end; }
.markup-grid { grid-template-columns: 1fr 1.35fr; }
.field { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 109, 168, .12); }
.field input::placeholder { color: #98a2b3; }
.swap-button { width: 42px; height: 42px; margin-bottom: 2px; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); background: white; cursor: pointer; font-size: 20px; }
.swap-button:hover { background: var(--sky); }

fieldset { margin: 22px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 12px; font-size: 14px; font-weight: 800; }
.field-help { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.filter-grid { margin-top: 12px; }
.primary-button, .secondary-button { border: 0; border-radius: 11px; cursor: pointer; font-weight: 800; }
.primary-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; margin-top: 24px; padding: 0 18px; color: white; background: linear-gradient(110deg, var(--navy), var(--blue)); box-shadow: 0 10px 22px rgba(21, 109, 168, .2); }
.primary-button:hover { filter: brightness(1.06); }
.primary-button:disabled { cursor: wait; opacity: .65; }
.form-note { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.result-panel { position: sticky; top: 20px; min-height: 520px; }
.status-badge { padding: 7px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.status-badge.idle { color: var(--muted); background: #edf1f5; }
.status-badge.running { color: #935d09; background: #fff0c7; }
.status-badge.completed { color: #14714b; background: #dff7eb; }
.status-badge.failed { color: var(--red); background: #ffe4e4; }

.empty-state, .loading-state { display: grid; place-items: center; min-height: 390px; text-align: center; }
.empty-state p, .loading-state p { max-width: 340px; margin: 10px auto 0; color: var(--muted); line-height: 1.55; }
.plane { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 18px; border-radius: 50%; color: var(--blue); background: var(--sky); font-size: 32px; }
.loader { width: 48px; height: 48px; margin-bottom: 20px; border: 4px solid #dceaf3; border-top-color: var(--blue); border-radius: 50%; animation: spin .9s linear infinite; }
.progress-track { width: min(320px, 90%); height: 7px; margin-top: 28px; overflow: hidden; border-radius: 10px; background: #edf1f5; }
.progress-track div { width: 42%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--orange)); animation: progress 1.8s ease-in-out infinite alternate; }

.price-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 9px; margin-bottom: 16px; }
.price-item { padding: 12px; border-radius: 12px; background: var(--sky); }
.price-item span { display: block; color: var(--muted); font-size: 11px; }
.price-item strong { display: block; margin-top: 5px; color: var(--navy); font-size: 15px; }
#quote-text { margin: 0; padding: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfe; font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.copy-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.secondary-button { width: 100%; min-height: 46px; padding: 8px 12px; color: white; background: var(--green); }
.secondary-button.neutral { background: var(--navy); }
.card-settings { margin-top: 22px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.card-settings summary { padding: 14px; cursor: pointer; color: var(--navy); font-size: 13px; font-weight: 800; }
.card-settings > p { margin: 0; padding: 0 14px 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.card-rate-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; padding: 0 14px 14px; }
.rate-field { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.rate-field input { width: 100%; min-height: 38px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 14px 14px; }
.settings-actions span { margin-right: auto; color: var(--green); font-size: 12px; }
.small-button { min-height: 38px; padding: 7px 13px; border: 0; border-radius: 8px; color: white; background: var(--blue); cursor: pointer; font-weight: 700; }
.message { margin-top: 16px; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.error-message { color: #8f2525; background: #ffe8e8; }
.error-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
footer { padding: 22px; text-align: center; color: var(--muted); font-size: 12px; }
[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress { from { transform: translateX(-12%); } to { transform: translateX(150%); } }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .result-panel { position: static; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; padding: 14px 18px; }
  .service-status { display: none; }
  main { padding: 30px 14px 44px; }
  .panel { padding: 20px 16px; border-radius: 16px; }
  .panel-heading { display: grid; }
  .trip-switch { width: 100%; }
  .trip-switch label { flex: 1; text-align: center; }
  .two-columns, .three-columns, .markup-grid { grid-template-columns: 1fr; }
  .route-grid { grid-template-columns: 1fr 38px; }
  .route-grid .field:last-child { grid-column: 1 / -1; }
  .swap-button { grid-column: 2; grid-row: 1; }
  .price-summary { grid-template-columns: 1fr; }
  .copy-actions { grid-template-columns: 1fr; }
  .card-rate-grid { grid-template-columns: repeat(3, 1fr); }
}
