/* Base variables for light mode */
:root {
  --primary-color: #004d9e;
  --primary-light: #e6f0f9;
  --primary-dark: #003a77;
  --accent-color: #ffa000;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --text-color: #2c3345;
  --muted-text: #6b7280;
  --border-color: #e5e7eb;
}

/* Dark mode overrides */
body.dark {
  --primary-color: #1e293b;
  --primary-light: #334155;
  --primary-dark: #0f172a;
  --accent-color: #f59e0b;
  --bg-color: #1f2937;
  --card-bg: #334155;
  --text-color: #f3f4f6;
  --muted-text: #94a3b8;
  --border-color: #475569;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--primary-color);
  color: #fff;
  padding: 1.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.5rem;
  margin: 0;
}

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.toggle input {
  accent-color: var(--accent-color);
}

main {
  flex: 1;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.filters > * {
  flex: 1 1 150px;
  min-width: 140px;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--primary-color);
  color: #fff;
  font-size: 1rem;
}
button.secondary {
  background: var(--accent-color);
  color: #fff;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
thead {
  background: var(--primary-light);
}
th, td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
tbody tr:nth-child(even) {
  background: var(--card-bg);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.pagination button {
  padding: 0.375rem 0.75rem;
}

.chart-container {
  margin-top: 1rem;
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bar-label {
  width: 60px;
  font-size: 0.875rem;
}
.bar-value {
  background: var(--accent-color);
  height: 1rem;
  border-radius: 0.25rem;
  /* Smooth transition for changing bar width */
  transition: width 0.4s ease;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal.show {
  display: flex;
  opacity: 1;
}
.modal-content {
  background: var(--card-bg);
  color: var(--text-color);
  padding: 1.5rem;
  border-radius: 0.5rem;
  max-height: 90vh;
  overflow-y: auto;
  width: 90%;
  max-width: 500px;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  position: relative;
}
.modal.show .modal-content {
  transform: translateY(0);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  cursor: pointer;
  color: var(--text-color);
}

/* Footer styles */
#footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--muted-text);
}

/* Loading overlay */
#loadingOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  color: #fff;
  font-size: 1.25rem;
}

@media (max-width: 768px) {
  table thead {
    display: none;
  }
  table, tbody, tr, td {
    display: block;
    width: 100%;
  }
  tr {
    margin-bottom: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem;
  }
  td {
    padding: 0.25rem 0;
    border: none;
    display: flex;
    justify-content: space-between;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted-text);
  }
}