:root {
  color-scheme: dark;
  --background: #090e12;
  --surface: #11181e;
  --surface-raised: #172128;
  --surface-hover: #1d2931;
  --line: #29363e;
  --line-strong: #3b4b54;
  --text: #f2f5f6;
  --muted: #93a1a8;
  --accent: #f3a52b;
  --accent-hover: #ffb43e;
  --danger: #ff7168;
  --success: #73d6a3;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { min-height: 100vh; margin: 0; color: var(--text); background: var(--background); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.site-header { min-height: 72px; padding: 0 max(24px, calc((100vw - 960px) / 2)); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); background: rgba(9, 14, 18, .96); }
.brand { padding: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--text); font-weight: 750; font-size: 16px; cursor: pointer; }
.brand svg { width: 27px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-nav { justify-self: center; display: flex; align-items: center; gap: 4px; }
.nav-button { padding: 9px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.nav-button:hover { color: var(--text); background: var(--surface); }
.nav-button.active { color: var(--text); background: var(--surface-raised); }
.logout-button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: #bdc8cc; cursor: pointer; }
.logout-button:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface); }
.logout-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { width: min(960px, calc(100% - 40px)); margin: 0 auto; }
.loading-view, .login-view { min-height: calc(100vh - 73px); display: grid; place-items: center; color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 45px rgba(0, 0, 0, .18); }
.login-card { width: min(100%, 400px); padding: 34px; }
h1 { margin: 0; color: var(--text); font-size: clamp(26px, 4vw, 34px); line-height: 1.15; letter-spacing: -.035em; }
.login-card h1 { margin-bottom: 30px; }

label, .setting-field > span:first-child { display: block; margin-bottom: 9px; color: #c7d0d4; font-size: 13px; font-weight: 650; }
input { width: 100%; height: 52px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; color: var(--text); background: #0d1419; font-size: 16px; }
input::placeholder { color: #64747c; }
input:focus { border-color: #6a7e88; box-shadow: 0 0 0 3px rgba(126, 149, 160, .13); }
input[aria-invalid="true"] { border-color: var(--danger); }
.location-input-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: 10px; }
.current-location-button { width: 52px; height: 52px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-raised); color: #b7c4c9; cursor: pointer; }
.current-location-button:hover { color: var(--accent); border-color: #596c75; background: var(--surface-hover); }
.current-location-button:disabled { color: var(--accent); cursor: wait; opacity: .7; }
.current-location-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.location-error { margin: 9px 0 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.password-field, .number-input { position: relative; display: block; }
.password-field input { padding-right: 88px; }
.input-button { position: absolute; top: 6px; right: 6px; height: 40px; padding: 0 11px; border: 0; border-radius: 7px; background: var(--surface-hover); color: #c9d2d6; font-size: 12px; cursor: pointer; }

.primary-button, .secondary-button { min-height: 48px; padding: 0 22px; border-radius: 9px; font-weight: 750; cursor: pointer; }
.primary-button { width: 100%; margin-top: 28px; border: 0; background: var(--accent); color: #1b1a16; }
.primary-button:hover { background: var(--accent-hover); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--line-strong); background: transparent; color: #d0d8dc; }
.secondary-button:hover { background: var(--surface-hover); }
.form-error { margin: 14px 0 0; color: var(--danger); font-size: 13px; line-height: 1.45; }

.content-view { padding: 64px 0 90px; }
.page-title { margin-bottom: 32px; }
.calculator-title-row h1 { margin-bottom: 0; }
.pricing-controls { display: flex; align-items: stretch; gap: 14px; }

.tariff-switch { flex: 1 1 auto; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: #0c1217; }
.tariff-option { min-width: 178px; min-height: 62px; padding: 9px 12px; display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.tariff-option:hover { color: var(--text); background: var(--surface); }
.tariff-option[aria-pressed="true"] { color: var(--text); border-color: var(--line-strong); background: var(--surface-raised); box-shadow: 0 4px 12px rgba(0, 0, 0, .22); }
.tariff-option > svg { width: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tariff-option strong, .tariff-option small { display: block; }
.tariff-option strong { font-size: 13px; line-height: 1.15; }
.tariff-option small { margin-top: 4px; color: #74858d; font-size: 10px; }
.tariff-option b { color: #dfe5e7; font-size: 13px; white-space: nowrap; }

.surcharge-control { flex: 0 0 245px; padding: 9px 10px 9px 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 12px; background: #0c1217; }
.surcharge-label strong, .surcharge-label small { display: block; }
.surcharge-label strong { font-size: 13px; }
.surcharge-label small { margin-top: 4px; color: #74858d; font-size: 10px; white-space: nowrap; }
.stepper { height: 42px; display: grid; grid-template-columns: 36px 36px 36px; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.stepper button { height: 100%; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 21px; cursor: pointer; }
.stepper button:hover:not(:disabled) { background: var(--surface-hover); color: var(--accent); }
.stepper button:disabled { color: #4d5b62; cursor: default; }
.stepper output { font-size: 14px; font-weight: 750; text-align: center; }

.calculator-grid { display: block; }
.calculator-grid.has-result { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr); gap: 22px; align-items: start; }
.route-card { position: relative; padding: 34px; }
.route-card .pricing-controls { margin-top: 32px; padding-top: 32px; flex-direction: column; border-top: 1px solid var(--line); }
.route-card .surcharge-control { flex: 0 0 auto; min-height: 62px; }
.autocomplete { position: relative; }
.autocomplete[data-location="to"] { margin-top: 0; }
.swap-button { position: static; width: 40px; height: 40px; margin: 14px auto; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-raised); color: #aebbc1; font-size: 18px; cursor: pointer; }
.swap-button:hover { color: var(--text); background: var(--surface-hover); }

.suggestions { position: absolute; z-index: 20; top: calc(100% + 7px); left: 0; right: 0; max-height: 280px; overflow-y: auto; margin: 0; padding: 6px; list-style: none; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-raised); box-shadow: 0 18px 38px rgba(0, 0, 0, .4); }
.suggestions li { display: flex; gap: 11px; padding: 11px; border-radius: 7px; cursor: pointer; }
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--surface-hover); }
.suggestions svg { flex: 0 0 auto; width: 17px; margin-top: 2px; fill: none; stroke: var(--accent); stroke-width: 1.7; }
.suggestions strong, .suggestions small { display: block; }
.suggestions strong { color: var(--text); font-size: 13px; line-height: 1.35; }
.suggestions small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.suggestion-message { color: var(--muted); font-size: 13px; cursor: default !important; }

.result-card { min-height: 340px; padding: 32px; border: 1px solid #34454d; border-radius: 14px; background: #142128; box-shadow: 0 18px 45px rgba(0, 0, 0, .2); }
.result-header { padding-bottom: 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.result-header > div > span { display: block; margin-bottom: 7px; color: #98a9af; font-size: 12px; }
.result-header strong { display: block; color: var(--success); font-size: 40px; letter-spacing: -.04em; }
.info-button { flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border: 1px solid #49606a; border-radius: 50%; background: transparent; color: #bac7cc; font-family: Georgia, serif; font-size: 18px; font-weight: 700; cursor: pointer; }
.info-button:hover, .info-button[aria-expanded="true"] { border-color: var(--success); color: var(--success); background: rgba(115, 214, 163, .08); }
.route-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 25px 0; }
.route-stats dt { color: #82949b; font-size: 11px; }
.route-stats dd { margin: 5px 0 0; color: var(--text); font-size: 14px; font-weight: 700; }
.formula-value { padding: 12px; border-radius: 8px; background: rgba(255,255,255,.055); color: #aebdc2; text-align: center; font-size: 11px; line-height: 1.4; }
.passenger-prices { margin-top: 25px; }
.passenger-prices h2 { margin: 0 0 14px; font-size: 14px; }
.passenger-prices table { width: 100%; border-collapse: collapse; font-size: 12px; }
.passenger-prices th { padding: 8px 0; color: #82949b; font-weight: 500; text-align: left; border-bottom: 1px solid rgba(255,255,255,.1); }
.passenger-prices td { padding: 9px 0; color: #cdd6d9; border-bottom: 1px solid rgba(255,255,255,.065); }
.passenger-prices th:nth-child(2), .passenger-prices td:nth-child(2) { text-align: center; }
.passenger-prices th:last-child, .passenger-prices td:last-child { text-align: right; }
.passenger-prices td:last-child { color: var(--success); font-weight: 700; }
.passenger-prices tr:last-child td { border-bottom: 0; }
.result-details { margin-top: 25px; padding-top: 2px; border-top: 1px solid rgba(255,255,255,.12); }

.settings-view { max-width: 760px; }
.settings-card { padding: 34px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.setting-field { margin: 0; }
.number-input input { padding-right: 72px; }
.number-input b { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.settings-actions { margin-top: 32px; display: flex; justify-content: flex-end; gap: 11px; }
.settings-actions .primary-button { width: auto; margin: 0; }

@media (max-width: 840px) {
  .tariff-switch { width: 100%; }
  .tariff-option { min-width: 0; }
  .calculator-grid.has-result { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-header { padding: 15px 18px 12px; grid-template-columns: 1fr auto; gap: 12px; }
  .brand { grid-column: 1; grid-row: 1; justify-self: start; }
  .logout-button { grid-column: 2; grid-row: 1; justify-self: end; }
  .app-nav { width: 100%; grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(2, 1fr); }
  .nav-button { padding: 9px 7px; }
  main { width: min(100% - 28px, 960px); }
  .loading-view, .login-view { min-height: calc(100vh - 120px); }
  .content-view { padding: 38px 0 64px; }
  .page-title { margin-bottom: 24px; }
  .pricing-controls { flex-direction: column; }
  .surcharge-control { flex: 0 0 auto; min-height: 62px; }
  .tariff-option { min-height: 66px; padding: 8px; grid-template-columns: 22px 1fr; gap: 7px; }
  .tariff-option b { grid-column: 2; font-size: 12px; }
  .tariff-option small { margin-top: 2px; }
  .route-card, .settings-card { padding: 24px; }
  .result-card { padding: 26px; }
  .settings-grid { grid-template-columns: 1fr; gap: 22px; }
}

@media (max-width: 390px) {
  .brand { font-size: 15px; }
  .tariff-option > svg { display: none; }
  .tariff-option { grid-template-columns: 1fr; }
  .tariff-option b { grid-column: 1; }
  .settings-actions { flex-direction: column-reverse; }
  .settings-actions .primary-button, .settings-actions .secondary-button { width: 100%; }
}
