:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --surface: #1a1e26;
    --text: #f2f3f5;
    --text-muted: #9aa1ac;
    --border: #2a2f3a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 2rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active { background: var(--primary-dark); }

.btn-block { width: 100%; }

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.hidden { display: none !important; }

.search-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .search-list { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.card-route {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: rgba(22,163,74,0.15); color: var(--success); }
.badge-inactive { background: rgba(107,114,128,0.15); color: var(--text-muted); }

.card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.card-actions .btn {
  flex: 1;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.card-actions .btn.danger { color: var(--danger); }

.offers {
  border-top: 1px dashed var(--border);
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.offer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: 0.4rem 0.6rem;
}

.offer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.offer-links .offer-link {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
}

.offer-price {
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.offer-link { color: var(--primary); text-decoration: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 1rem 1.25rem 1.5rem;
}

@media (min-width: 640px) {
  .modal { border-radius: var(--radius); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form input, .form select {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.toggle-option {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  font-size: 0.9rem;
  color: var(--text);
}

.toggle-option input { min-height: auto; width: auto; }

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem !important;
}

.checkbox-row input { min-height: auto; width: auto; }
