:root {
  --font-sans: "Trebuchet MS", "Verdana", "Geneva", "Tahoma", sans-serif;
  --bs-body-bg: #f5f7fb;
  --bs-body-color: #111827;
  --bs-border-color: #e2e8f0;
  --bs-link-color: #2563eb;
  --bs-link-hover-color: #1d4ed8;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --muted: #6b7280;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

:root[data-theme="dark"] {
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  --bs-border-color: #2b3445;
  --bs-link-color: #93c5fd;
  --bs-link-hover-color: #bfdbfe;
  --surface: #111827;
  --surface-muted: #1f2937;
  --muted: #9aa4b2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

.container-xxl {
  flex: 1 0 auto;
}

@media (min-width: 1400px) {
  .container-xxl {
    max-width: 1584px;
  }
}

.icon {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.navbar {
  background-color: var(--surface) !important;
  border-bottom: 1px solid var(--bs-border-color);
}

header {
  position: sticky;
  top: 0;
  z-index: 1030;
}

header .navbar {
  margin-bottom: 0 !important;
}

.navbar-toggler {
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

.navbar-toggler-icon {
  background-image: none;
  width: 1.25rem;
  height: 1.25rem;
  position: relative;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after,
.navbar-toggler-icon {
  border-top: 2px solid currentColor;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
}

.navbar-toggler-icon::before {
  top: 0.35rem;
}

.navbar-toggler-icon::after {
  top: 0.7rem;
}

.navbar .navbar-brand,
.navbar .nav-link,
.navbar .navbar-text,
.navbar .text-dark {
  color: var(--bs-body-color) !important;
}

.navbar .dropdown-menu {
  border-radius: var(--radius-md);
  border-color: var(--bs-border-color);
}

.navbar .dropdown-item.active,
.navbar .dropdown-item:active {
  background-color: var(--bs-link-color);
  color: #fff;
}

@media (min-width: 992px) {
  .navbar .dropdown:hover .dropdown-menu {
    display: block;
    margin-top: 0;
  }
}

.card,
.list-group-item,
.table {
  background-color: var(--surface);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.table {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--surface);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-striped-bg: color-mix(in srgb, var(--surface-muted) 75%, var(--surface) 25%);
  --bs-table-hover-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--surface-muted) 65%, var(--surface) 35%);
}

.table td,
.table th,
table.dataTable tbody td,
table.dataTable tbody th {
  color: var(--bs-body-color) !important;
}

.table thead th,
table.dataTable thead th {
  color: var(--muted) !important;
}

.encryption-panel {
  border-radius: var(--radius-md);
  border: 1px solid var(--bs-border-color);
  background-color: var(--surface);
  box-shadow: var(--shadow);
}

.encryption-panel .form-control {
  min-height: 140px;
}

.encryption-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.field-error {
  color: #dc3545;
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.table thead th {
  color: var(--muted);
}

.dataTables_wrapper {
  color: var(--bs-body-color);
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background-color: var(--surface);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--radius-sm);
}

.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_info {
  color: var(--muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
}

.form-control,
.form-select {
  background-color: var(--surface);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
  border-radius: var(--radius-sm);
}

.form-control::placeholder {
  color: var(--muted);
}

.btn-outline-secondary {
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
}

.btn-outline-secondary:hover {
  background-color: var(--surface-muted);
}

.btn {
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.text-muted {
  color: var(--muted) !important;
}

.flex-min-0 {
  min-width: 0;
}

.theme-toggle {
  min-width: 120px;
}

.brand-logo {
  height: 28px;
  width: auto;
}

.footer-logo {
  height: 20px;
  width: auto;
}

.auth-logo {
  height: 56px;
  width: auto;
}

.app-splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  overflow: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.app-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-splash-card {
  width: 100%;
  height: 100%;
  text-align: center;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.app-splash-logo {
  width: 140px;
  height: auto;
  margin-bottom: 1rem;
}

.app-splash-title {
  font-weight: 700;
  color: var(--bs-body-color);
  font-size: clamp(1.2rem, 2.5vw, 2rem);
}

.app-splash::before,
.app-splash::after {
  content: "";
  position: absolute;
  left: -10%;
  width: 120%;
  height: 240px;
  background-repeat: no-repeat;
  background-size: 140% 100%;
  opacity: 0.75;
  pointer-events: none;
}

.app-splash::before {
  bottom: -40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='%23cbd5f5' fill-opacity='0.85' d='M0,96L60,90.7C120,85,240,75,360,90.7C480,107,600,149,720,170.7C840,192,960,192,1080,170.7C1200,149,1320,107,1380,85.3L1440,64L1440,320L0,320Z'/%3E%3C/svg%3E");
  animation: splash-wave 14s linear infinite;
}

.app-splash::after {
  bottom: -60px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='%2394a3b8' fill-opacity='0.25' d='M0,160L48,149.3C96,139,192,117,288,112C384,107,480,117,576,144C672,171,768,213,864,218.7C960,224,1056,192,1152,181.3C1248,171,1344,181,1392,186.7L1440,192L1440,320L0,320Z'/%3E%3C/svg%3E");
  animation: splash-wave 18s linear infinite reverse;
}

@keyframes splash-wave {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-6%);
  }
  100% {
    transform: translateX(0);
  }
}

.theme-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

:root[data-theme="light"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: none;
}

.logo-dropzone {
  border: 2px dashed var(--bs-border-color);
  background-color: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.logo-dropzone.is-dragover {
  border-color: var(--bs-link-color);
  background-color: rgba(37, 99, 235, 0.08);
}

.logo-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.logo-preview img {
  max-height: 120px;
  max-width: 100%;
  object-fit: contain;
}

.building-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 100%;
}

.building-card-image {
  height: 110px;
  background-color: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.building-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.building-card .card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.building-card .card-title,
.building-card .card-text {
  margin-bottom: 0;
}

.building-card .card-actions {
  margin-top: auto;
}

.modal-content,
.toast,
.dropdown-menu {
  background-color: var(--surface);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
  border-radius: var(--radius-md);
}

.list-group-item {
  border-radius: var(--radius-md);
  border: 1px solid var(--bs-border-color);
  margin-bottom: 0.75rem;
}

.list-group {
  gap: 0.75rem;
}

.pagination .page-link {
  background-color: var(--surface);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
}

.pagination .page-link:hover {
  background-color: var(--surface-muted);
}

.pagination .page-item.active .page-link {
  background-color: var(--bs-link-color);
  border-color: var(--bs-link-color);
  color: #fff;
}

.pagination .page-item.disabled .page-link {
  color: var(--muted);
  background-color: var(--surface-muted);
}

.location-picker {
  position: relative;
}

.location-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background-color: var(--surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}

.location-suggestion {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--bs-body-color);
  cursor: pointer;
}

.location-suggestion:hover,
.location-suggestion:focus {
  background-color: var(--surface-muted);
}

.password-strength {
  width: 100%;
  height: 6px;
  background-color: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
}

.password-strength-fill {
  display: block;
  height: 100%;
  width: 0%;
  background-color: #dc3545;
  transition: width 0.2s ease;
}

.password-strength-fill.strength-very-weak {
  background-color: #dc3545;
}

.password-strength-fill.strength-weak {
  background-color: #fd7e14;
}

.password-strength-fill.strength-fair {
  background-color: #ffc107;
}

.password-strength-fill.strength-good {
  background-color: #20c997;
}

.password-strength-fill.strength-strong {
  background-color: #198754;
}

.password-strength-text {
  font-weight: 500;
}

.password-strength-text.strength-very-weak {
  color: #dc3545;
}

.password-strength-text.strength-weak {
  color: #fd7e14;
}

.password-strength-text.strength-fair {
  color: #ffc107;
}

.password-strength-text.strength-good {
  color: #20c997;
}

.password-strength-text.strength-strong {
  color: #198754;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

@media (max-width: 575.98px) {
  .navbar .navbar-collapse {
    padding-top: 0.5rem;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
  }

  .navbar .d-flex.align-items-center.gap-2 {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .theme-toggle {
    min-width: auto;
  }
}

@media (max-width: 767.98px) {
  .container-xxl {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .table-responsive {
    font-size: 0.9rem;
  }

  .dataTables_wrapper .row {
    row-gap: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-splash {
    transition: none;
  }
}


.live-resource-tile {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-muted);
  padding: 0.85rem;
  height: 100%;
}

.live-resource-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.live-resource-chart {
  position: relative;
  height: 150px;
}
