:root {
  --bg: #f7f8fb;
  --text: #111827;
  --card: #ffffff;
  --border: #dfe3ea;
  --muted: #566070;
  --button: #1f2430;
  --button-text: #ffffff;
  --secondary: #e7e9ee;
  --secondary-text: #111827;
  --danger-bg: #fff0f0;
  --danger-text: #b00000;
  --danger-border: #ffc5c5;
  --input-bg: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.dark {
  --bg: #151515;
  --text: #f2f2f2;
  --card: #222;
  --border: #444;
  --muted: #aaa;
  --button: #f2f2f2;
  --button-text: #111;
  --secondary: #333;
  --secondary-text: #f2f2f2;
  --danger-bg: #442020;
  --danger-text: #ffd7d7;
  --danger-border: #704040;
  --input-bg: #181818;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 24px 28px;
  margin-bottom: 22px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
}

h2 {
  margin: 0;
  font-size: 1.45rem;
}

.subtle {
  color: var(--muted);
  margin: 0;
}

.hidden {
  display: none !important;
}

.header-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preference-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

#travelForm {
  padding: 22px 24px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 12px;
}

.optional {
  font-weight: 500;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}

button,
.file-button {
  padding: 10px 18px;
  border: 0;
  border-radius: 5px;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.secondary,
.file-button {
  background: var(--secondary);
  color: var(--secondary-text);
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.actions,
.favorite-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.result-card {
  padding: 40px 34px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.empty-result {
  color: var(--muted);
  font-size: 1rem;
}

.big-result {
  font-size: 2.7rem;
  font-weight: 800;
  margin-bottom: 26px;
}

.big-result span {
  font-size: 1.35rem;
}

.result-card p {
  font-size: 1.05rem;
  margin: 0 0 18px;
}

.traffic-delay {
  color: #e13600;
}

.favorites-card {
  overflow: hidden;
}

.favorites-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 24px 12px;
}

#favorites {
  padding: 0 24px 18px;
}

.favorite {
  display: grid;
  grid-template-columns: 2fr 0.9fr 0.9fr 0.9fr 1.2fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--border);
  border-bottom: 0;
  padding: 16px;
}

.favorite:first-child {
  border-radius: 6px 6px 0 0;
}

.favorite:last-child {
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
}

.favorite:only-child {
  border-radius: 6px;
}

.favorite-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.favorite-route,
.favorite-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.favorite-value {
  font-weight: 700;
  margin-top: 4px;
}

.favorite-status {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  width: fit-content;
}

.status-good {
  background: #e8f8ec;
  color: #06751d;
  border: 1px solid #78c98a;
}

.status-close {
  background: #fff7e8;
  color: #b55300;
  border: 1px solid #e8a35d;
}

.status-over {
  background: #fff0f0;
  color: #b00000;
  border: 1px solid #e89a9a;
}

body.dark .status-good {
  background: #1f4d2a;
  color: #d8f8de;
}

body.dark .status-close {
  background: #594711;
  color: #fff1c2;
}

body.dark .status-over {
  background: #5c2525;
  color: #ffd7d7;
}

.favorite-actions {
  justify-content: flex-end;
}

.favorite-actions button {
  padding: 8px 13px;
}

.favorite-edit {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--card), var(--bg) 35%);
}

.app-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  background: color-mix(in srgb, var(--card), var(--bg) 30%);
}

.footer-tools {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.utility-button {
  width: 190px;
  height: 44px;
  padding: 0 18px;
  justify-content: center;
  white-space: nowrap;
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.file-button input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  margin: 0;
  font-weight: normal;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.switch input:checked + .slider {
  background: var(--button);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

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

  .favorite {
    grid-template-columns: 1fr;
  }

  .favorite-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 16px;
  }

  .app-header,
  .favorites-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    justify-content: flex-start;
  }

  .footer-tools {
    justify-content: flex-start;
  }
}

.favorite-create {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

.favorite-create {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.inline-options {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.checkbox-line input {
  width: auto;
  margin: 0;
}

@media (max-width: 620px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}