:root {
  --primary-blue: #1e3a8a;
  --accent-blue: #3b82f6;
  --bg-soft: #f8fafc;
  --page-bg: var(--bg-soft);
  --page-fg: #0f172a;
  --surface-bg: white;
  --surface-border: rgba(30, 41, 59, 0.08);
  --card-header-border: rgba(15, 23, 42, 0.08);
  --muted-text: #64748b;
  --navbar-fg: white;
  --theme-icon-bg: rgba(255, 255, 255, 0.12);
  --airborne: #10b981;
  --landed: #64748b;
  --leader-active: #4338ca;
}

body {
  background: var(--page-bg);
  color: var(--page-fg);
}

body[data-theme="dark"] {
  --page-bg: #0f172a;
  --page-fg: #e2e8f0;
  --surface-bg: #111827;
  --surface-border: rgba(148, 163, 184, 0.18);
  --card-header-border: rgba(148, 163, 184, 0.18);
  --muted-text: #94a3b8;
  --navbar-fg: #e5e7eb;
  --theme-icon-bg: rgba(255, 255, 255, 0.14);
}

body[data-theme="dark"] .card-header.bg-white,
body[data-theme="dark"] .card-header {
  background: transparent !important;
}

body[data-theme="dark"] #noteModal .modal-content {
  background: var(--surface-bg);
  color: var(--page-fg);
}

body[data-theme="dark"] #noteModal .modal-body,
body[data-theme="dark"] #noteModal .modal-footer {
  background: var(--surface-bg);
  color: var(--page-fg);
}

body[data-theme="dark"] #noteModal .modal-header {
  background: var(--primary-blue) !important;
  color: #fff !important;
}

.bg-primary-blue,
.btn-primary,
.btn-success,
.btn-info {
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
}

.navbar.bg-primary-blue,
.footer-blue {
  background: var(--primary-blue) !important;
}

.navbar .nav-link,
.navbar .navbar-brand,
.navbar .badge {
  color: var(--navbar-fg) !important;
}

.theme-toggle-btn {
  min-width: 2.25rem;
  background: var(--theme-icon-bg);
  border-color: rgba(255, 255, 255, 0.25);
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.footer-link {
  color: #dbeafe;
  text-decoration: none;
}

.footer-link:hover {
  color: white;
  text-decoration: underline;
}

.pwa-install-banner {
  border-radius: 1rem;
}

.card {
  border: 0;
  border-radius: 1rem;
  background: var(--surface-bg);
  color: var(--page-fg);
}

.card-header {
  border-bottom: 1px solid var(--card-header-border);
  border-radius: 1rem 1rem 0 0 !important;
}

.flight-start-panel {
  background-color: rgba(148, 163, 184, 0.12);
}

.leader-panel {
  background-color: rgba(14, 165, 233, 0.14);
}

.active-flight-panel {
  color: #000;
}

.active-flight-land-btn {
  color: #111827 !important;
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="dark"] .flight-start-panel {
  background-color: rgba(148, 163, 184, 0.12) !important;
}

body[data-theme="dark"] .flight-start-panel .card-body {
  background: transparent !important;
}

body[data-theme="dark"] .leader-panel {
  background-color: rgba(14, 165, 233, 0.14) !important;
}

body[data-theme="dark"] .leader-panel .card-body {
  background: transparent !important;
}

body[data-theme="dark"] .active-flight-panel {
  color: #e2e8f0;
}

body[data-theme="dark"] .active-flight-panel strong,
body[data-theme="dark"] .active-flight-panel .small,
body[data-theme="dark"] .active-flight-panel div {
  color: #e2e8f0 !important;
}

body[data-theme="dark"] .active-flight-land-btn {
  color: #fff !important;
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
}

.stat-box,
.notice-box,
.log-box {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 0.9rem;
  padding: 0.9rem;
}

.stat-box .label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted-text);
  letter-spacing: 0.04em;
}

.stat-box .value {
  font-size: 1.05rem;
  font-weight: 700;
}

.wind-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wind-arrow {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  font-size: 0.85rem;
  line-height: 1;
  transform: rotate(calc(var(--wind-angle, 0deg) + 180deg));
  transform-origin: center;
}

.status-airborne {
  background: var(--airborne);
}

.status-landed {
  background: var(--landed);
}

.status-leader {
  background: var(--leader-active);
}

.legal-copy p {
  margin-bottom: 0.75rem;
}

.bg-light-subtle {
  background-color: rgba(148, 163, 184, 0.12) !important;
}

.bg-warning-subtle {
  background-color: rgba(245, 158, 11, 0.14) !important;
}

.bg-info-subtle {
  background-color: rgba(14, 165, 233, 0.14) !important;
}

body[data-theme="dark"] .bg-light-subtle,
body[data-theme="dark"] .bg-warning-subtle,
body[data-theme="dark"] .bg-info-subtle,
body[data-theme="dark"] .alert-light,
body[data-theme="dark"] .alert-warning,
body[data-theme="dark"] .alert-info {
  color: #000 !important;
}

body[data-theme="dark"] .bg-warning-subtle .h6,
body[data-theme="dark"] .bg-info-subtle .h6 {
  color: #e2e8f0 !important;
}

body[data-theme="dark"] .leader-list,
body[data-theme="dark"] .leader-list-item {
  background: transparent !important;
}

body[data-theme="dark"] .history-days-list,
body[data-theme="dark"] .history-day-item,
body[data-theme="dark"] .history-incidents-list,
body[data-theme="dark"] .history-incident-item {
  background: transparent !important;
}

body[data-theme="dark"] .live-present-list,
body[data-theme="dark"] .live-present-item,
body[data-theme="dark"] .documents-list,
body[data-theme="dark"] .documents-item {
  background: transparent !important;
}

body[data-theme="dark"] .documents-item,
body[data-theme="dark"] .documents-item.list-group-item-action {
  background-color: transparent !important;
  color: #e2e8f0 !important;
  border-color: var(--surface-border) !important;
}

body[data-theme="dark"] .admin-documents-list,
body[data-theme="dark"] .admin-documents-item {
  background: transparent !important;
}

body[data-theme="dark"] .documents-item:hover,
body[data-theme="dark"] .documents-item:focus {
  background-color: rgba(148, 163, 184, 0.12) !important;
}

body[data-theme="dark"] .admin-documents-item:hover,
body[data-theme="dark"] .admin-documents-item:focus {
  background-color: rgba(148, 163, 184, 0.12) !important;
  color: #93c5fd !important;
}

body[data-theme="dark"] .documents-item:hover,
body[data-theme="dark"] .documents-item:focus,
body[data-theme="dark"] .history-day-item:hover,
body[data-theme="dark"] .history-day-item:focus,
body[data-theme="dark"] .live-present-item:hover,
body[data-theme="dark"] .live-present-item:focus,
body[data-theme="dark"] .history-incident-item:hover,
body[data-theme="dark"] .history-incident-item:focus,
body[data-theme="dark"] .leader-list-item:hover,
body[data-theme="dark"] .leader-list-item:focus {
  color: #93c5fd !important;
}

body[data-theme="dark"] #incidentForm,
body[data-theme="dark"] #incidentForm .small,
body[data-theme="dark"] #incidentForm textarea,
body[data-theme="dark"] #incidentForm .form-control {
  color: #e2e8f0 !important;
}

body[data-theme="dark"] #incidentForm textarea::placeholder {
  color: #94a3b8 !important;
}

.text-muted {
  color: var(--muted-text) !important;
}

.list-group-item,
.table,
.table > :not(caption) > * > * {
  color: inherit;
}

.table > :not(caption) > * > * {
  background: transparent;
}

.list-group-item,
.table,
.table-responsive {
  border-color: var(--surface-border);
}

.btn-lg,
.form-control-lg,
.form-select-lg {
  border-radius: 0.85rem;
}

.form-control,
.form-select {
  background-color: var(--surface-bg);
  color: var(--page-fg);
  border-color: var(--surface-border);
}

.form-control:focus,
.form-select:focus {
  color: var(--page-fg);
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select,
body[data-theme="dark"] textarea.form-control,
body[data-theme="dark"] input.form-control {
  background-color: #111827 !important;
  color: #e2e8f0 !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
  caret-color: #e2e8f0;
}

body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .form-select:focus,
body[data-theme="dark"] textarea.form-control:focus,
body[data-theme="dark"] input.form-control:focus {
  background-color: #111827 !important;
  color: #e2e8f0 !important;
}

body[data-theme="dark"] .form-control::placeholder,
body[data-theme="dark"] .form-select::placeholder,
body[data-theme="dark"] textarea.form-control::placeholder,
body[data-theme="dark"] input.form-control::placeholder {
  color: #cbd5e1 !important;
}

body[data-theme="dark"] .form-control:-webkit-autofill,
body[data-theme="dark"] .form-control:-webkit-autofill:hover,
body[data-theme="dark"] .form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: #e2e8f0;
  -webkit-box-shadow: 0 0 0 1000px #111827 inset;
  box-shadow: 0 0 0 1000px #111827 inset;
}

.alert-light,
.alert-warning,
.alert-info {
  color: inherit;
}

pre.log-box {
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1rem;
  }
}
