:root {
  --primary: #4f46e5;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 16px 36px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.header {
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 22px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  transition: all 0.3s ease;
}

.header h1 {
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

.nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px 0;
  flex-wrap: wrap;
}

.nav a {
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.nav a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.container {
  max-width: 1600px;
  margin: 24px auto 32px;
  padding: 0 24px;
}

body.dashboard-page .container {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

body.admin-page .container {
  display: block;
}

.info-panel,
.form-section,
.embed-info,
.tab-content,
.coordinate-builder,
.alert {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.info-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 150px);
  position: sticky;
  top: 24px;
}

.info-panel h2,
.form-section h3,
.embed-info h3,
.tab-content h3 {
  margin: 0;
  color: var(--text-dark);
  letter-spacing: -0.02em;
}

.bus-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.bus-card {
  background: var(--card-bg);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  transition: all 0.3s ease;
}

.bus-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.bus-card--empty {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
}

.bus-card h3 {
  color: var(--text-dark);
  margin: 0;
}

.bus-card p {
  margin: 0;
}

.bus-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.bus-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.bus-card__presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.bus-card__status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.bus-card__status-dot::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  opacity: 0.25;
  animation: pulse 1.8s ease-out infinite;
}

.bus-card__status-dot--active {
  background: var(--success);
}

.bus-card__status-dot--active::after {
  background: rgba(16, 185, 129, 0.45);
}

.bus-card__status-dot--stopped {
  background: var(--warning);
}

.bus-card__status-dot--stopped::after {
  background: rgba(245, 158, 11, 0.45);
}

.bus-card__status-dot--inactive {
  background: var(--danger);
}

.bus-card__status-dot--inactive::after {
  background: rgba(239, 68, 68, 0.4);
}

.bus-card__grid {
  display: grid;
  gap: 8px;
}

.bus-card__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.bus-card__label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.bus-card__value {
  color: var(--text-dark);
  font-weight: 600;
  text-align: right;
}

.bus-card__section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  display: grid;
  gap: 8px;
}

.bus-card__section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.bus-card__note {
  color: var(--warning);
  font-weight: 700;
  font-size: 0.78rem;
  margin-left: 6px;
}

.status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.status.active {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.status.stopped {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.status.inactive {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

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

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-dark);
}

.btn-primary:hover,
.btn-success:hover,
.btn-danger:hover {
  filter: brightness(0.96);
}

.btn-secondary:hover {
  background: #dbe4ee;
}

body.dashboard-page #map {
  height: calc(100vh - 150px);
  min-height: 560px;
}

body.admin-page #map {
  height: 400px;
}

#map {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

#map:hover {
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.map-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.legend-swatch {
  flex: 0 0 auto;
}

.legend-swatch--route {
  width: 28px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

.legend-swatch--stop {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  margin: 12px 14px;
  color: var(--text-dark);
}

.leaflet-popup-tip {
  box-shadow: none;
}

.route-popup .leaflet-popup-content-wrapper {
  border-color: rgba(79, 70, 229, 0.18);
}

.stop-popup .leaflet-popup-content-wrapper {
  border-color: rgba(16, 185, 129, 0.18);
}

#stopMap {
  height: 400px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table thead th {
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

table tbody tr {
  transition: background-color 0.3s ease;
}

table tbody tr:hover {
  background: #f1f5f9;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab-button {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 12px 20px;
  background: var(--card-bg);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  transition: all 0.3s ease;
}

.tab-button:hover {
  transform: translateY(-1px);
  color: var(--text-dark);
}

.tab-button.active {
  background: var(--card-bg);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 -2px 16px rgba(15, 23, 42, 0.04);
}

.tab-content {
  display: none;
  padding: 20px;
}

.tab-content.active {
  display: block;
}

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

.form-section {
  padding: 20px;
}

.form-section h3 {
  margin-bottom: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text-dark);
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.coordinate-builder {
  background: #f8fafc;
  padding: 15px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}

.coordinate-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
  transition: all 0.3s ease;
}

.coordinate-item:hover {
  transform: translateY(-1px);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list-section {
  margin-top: 20px;
}

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.24);
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  color: #7f1d1d;
  border: 1px solid rgba(239, 68, 68, 0.24);
}

.alert-info {
  background: rgba(14, 165, 233, 0.12);
  color: #0c4a6e;
  border: 1px solid rgba(14, 165, 233, 0.24);
}

.embed-info {
  padding: 18px;
}

.embed-info code {
  background: #eef2ff;
  color: var(--text-dark);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-form input[type='file'] {
  flex: 1;
}

.inline-form .form-group {
  margin: 0;
  flex: 1;
}

code {
  background: rgba(15, 23, 42, 0.04);
  padding: 3px 6px;
  border-radius: 6px;
}

.eta-bar-wrapper {
  position: fixed;
  left: 24px;
  right: 24px;
  top: 24px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 10000;
}

.eta-bar {
  display: flex;
  align-items: stretch;
  width: min(1100px, calc(100% - 48px));
  max-width: 1200px;
  border-radius: 40px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.eta-left {
  flex: 1 1 60%;
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: white;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.eta-right {
  width: 280px;
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 26px;
  border-left: 1px solid var(--border);
}

.eta-close {
  position: absolute;
  right: 34px;
  top: 12px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  transition: all 0.3s ease;
}

.eta-close:hover {
  transform: translateY(-1px);
}

.eta-small-note {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  margin-left: 8px;
  font-weight: 600;
}

@keyframes pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.4;
  }

  70% {
    transform: scale(1.55);
    opacity: 0;
  }

  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@media (max-width: 1100px) {
  body.dashboard-page .container {
    grid-template-columns: 1fr;
  }

  body.dashboard-page .info-panel {
    position: static;
    max-height: none;
  }

  body.dashboard-page #map {
    height: 60vh;
    min-height: 420px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

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

  .tabs {
    gap: 6px;
  }

  .tab-button {
    width: 100%;
    border-radius: 12px;
    border-bottom: 1px solid var(--border);
  }

  body.dashboard-page #map {
    height: 360px;
    min-height: 360px;
  }

  .nav {
    padding-left: 16px;
    padding-right: 16px;
  }

  .header {
    padding: 18px 16px;
  }

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

  .actions {
    width: 100%;
  }
}

