* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: #0F172A;
  color: #F8FAFC;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

.view { min-height: 100vh; }
.center { display: flex; align-items: center; justify-content: center; }

/* Spinner */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #334155;
  border-top-color: #4F46E5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth view */
#auth-view {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}
.header { text-align: center; margin-bottom: 40px; }
.plane { font-size: 64px; margin-bottom: 8px; }
.header h1 { font-size: 32px; font-weight: 700; }
.subtitle { color: #94A3B8; font-size: 16px; margin-top: 4px; }

.card {
  background: #1E293B;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.card h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

input {
  width: 100%;
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px;
  color: #F8FAFC;
  font-size: 16px;
  margin-bottom: 14px;
  font-family: inherit;
}
input::placeholder { color: #6B7280; }
input:focus { outline: none; border-color: #4F46E5; }

.btn-primary {
  width: 100%;
  background: #4F46E5;
  border: none;
  border-radius: 10px;
  padding: 16px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  cursor: pointer;
}
.btn-primary.small { width: auto; padding: 8px 14px; font-size: 14px; margin-bottom: 0; }
.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  flex: 1;
  background: transparent;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
  color: #94A3B8;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-link {
  background: none;
  border: none;
  color: #6366F1;
  font-size: 14px;
  text-align: center;
  width: 100%;
  cursor: pointer;
  padding: 4px;
}

.error {
  background: #450A0A;
  color: #FCA5A5;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Home view */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  background: #1E293B;
}
.topbar-title { font-size: 22px; font-weight: 700; }
.topbar-sub { font-size: 13px; color: #94A3B8; margin-top: 2px; }
.topbar .btn-link { width: auto; }

.status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1E293B;
  padding: 10px 20px;
  font-size: 13px;
  color: #94A3B8;
}
.status-banner.error { background: #450A0A; }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #EF4444;
  flex-shrink: 0;
}
.status-dot.ok { background: #22C55E; }

.notif-banner {
  background: #1E293B;
  border: 1px solid #4F46E5;
  border-radius: 12px;
  margin: 16px 20px 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.notif-banner p { font-size: 14px; color: #CBD5E1; line-height: 1.4; }

.section { padding: 20px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.section-header h2 { margin-bottom: 0; }

.empty-card, .alert-card, .info-card {
  background: #1E293B;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid #334155;
}
.empty-card { text-align: center; padding: 32px; }
.empty-card .icon { font-size: 40px; margin-bottom: 12px; }
.empty-card h3 { font-size: 18px; margin-bottom: 8px; }
.empty-card p { color: #94A3B8; line-height: 1.4; }

.alert-card { margin-bottom: 12px; }
.alert-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.alert-route { font-size: 18px; font-weight: 700; }
.delete-link { color: #EF4444; font-size: 14px; background: none; border: none; cursor: pointer; }

.alert-tags { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tag {
  background: #0F172A;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #6366F1;
}
.alert-date { color: #475569; font-size: 12px; }

.info-card { display: flex; flex-direction: column; gap: 12px; }
.info-card p { color: #94A3B8; font-size: 14px; line-height: 1.4; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.modal {
  width: 100%;
  background: #1E293B;
  border-radius: 24px 24px 0 0;
  padding: 28px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}
.modal h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.modal .subtitle { margin-bottom: 24px; }

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.form-label { display: block; color: #94A3B8; font-size: 14px; font-weight: 500; margin-bottom: 8px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { display: none; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  border-radius: 28px;
  transition: 0.2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background-color: #4F46E5; }
.switch input:checked + .slider:before { transform: translateX(22px); }

.stop-buttons { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.stop-btn {
  border: 1px solid #334155;
  background: transparent;
  border-radius: 8px;
  padding: 10px 14px;
  color: #94A3B8;
  font-size: 14px;
  cursor: pointer;
}
.stop-btn.active { background: #4F46E5; border-color: #4F46E5; color: #fff; font-weight: 600; }

.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn-primary { flex: 1; margin-bottom: 0; }
