:root {
  --bg: #f5f7fa;
  --text: #1f2937;
  --card-bg: white;
  --header-bg: #4f46e5;
  --accent: #4f46e5;
  --border-color: #e5e7eb;
}

body.dark {
  --bg: #1f2937;
  --text: #f3f4f6;
  --card-bg: #374151;
  --header-bg: #111827;
  --accent: #6366f1;
  --border-color: #4b5563;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg);
  color: white;
  padding: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.header-right input, .header-right select, .header-right button {
  flex: 1 1 120px;
}

.header-container h1 {
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

select {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  font-size: 0.9rem;
  background: white;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

button#themeToggle {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: 0.2s;
}

button#themeToggle:hover {
  background: #4338ca;
}

main {
  flex: 1;
  padding: 40px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 16px rgba(0,0,0,0.08);
}

.full-width {
  grid-column: span 2;
}

.table-controls {
  margin-bottom: 10px;
}

#searchInput {
  padding: 8px 10px;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  outline: none;
  background: var(--bg);
  color: var(--text);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--accent);
  color: white;
}

th, td {
  padding: 10px;
  text-align: left;
}

tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.03);
}

tbody tr:hover {
  background: rgba(0,0,0,0.05);
  cursor: pointer;
}

th {
  cursor: pointer;
}

footer {
  background: var(--header-bg);
  color: white;
  text-align: center;
  padding: 15px 0;
  font-size: 0.9rem;
  margin-top: auto;
}

@media (max-width: 700px) {
  .full-width {
    grid-column: span 1;
  }

  .header-container {
    flex-direction: column;
    gap: 10px;
  }
}

/* Summary Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  text-align: center;
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-5px);
}

.card h3 {
  font-size: 1rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a73e8;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  background: #ffffff;
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.chart-card h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #333;
}

.table-section {
  margin-top: 2rem;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-controls {
  margin-bottom: 10px;
}

#searchInput {
  padding: 8px 10px;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  outline: none;
  background: var(--bg);
  color: var(--text);
}

#dataTable th {
  cursor: pointer;
  user-select: none;
}

#dataTable th:hover {
  background: rgba(0,0,0,0.1);
}

.dark #dataTable th:hover {
  background: rgba(255,255,255,0.1);
}

.export-buttons {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.export-buttons button {
  padding: 8px 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.export-buttons button:hover {
  background: #0f5ad0;
}

.dark .export-buttons button {
  background: #2563eb;
}

.dark .export-buttons button:hover {
  background: #1e40af;
}

/* small layout for date inputs and auth modal */
.header-right input[type="date"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
}

.export-buttons {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.export-buttons button {
  padding: 8px 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.export-buttons button:hover { background: #0f5ad0; }

/* Modal */
.modal { position: fixed; inset: 0; display:flex; align-items:center; justify-content:center; background: rgba(0,0,0,0.4);}
.modal.hidden { display:none; }
.modal-content { background: var(--card-bg); padding: 20px; border-radius: 12px; width: 90%; max-width: 360px; box-shadow: 0 8px 20px rgba(0,0,0,0.25); position: relative;}
.modal-content input { width:100%; padding:8px 10px; margin-bottom:8px; border-radius:6px; border:1px solid var(--border-color); }
.modal-content button#closeModal { position:absolute; top:8px; right:10px; background:transparent; border:none; font-size:1.1rem; cursor:pointer; color:var(--text); }