/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --border: #e0e0e0;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --grey: #9ca3af;
  --low-battery: #fef2f2;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --text: #e5e5e5;
  --text-secondary: #999;
  --border: #404040;
  --low-battery: #3b1a1a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.25rem; font-weight: 600; }

.header-controls { display: flex; align-items: center; gap: 1rem; }

.status { font-size: 0.875rem; color: var(--text-secondary); }

#theme-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
}

/* === Main === */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.card h2 {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

/* === Map === */
#map { height: 400px; width: 100%; }

/* === Table === */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tr.low-battery { background: var(--low-battery); }

/* === Footer === */
footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* === Responsive === */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  main { padding: 1rem; }
  #map { height: 300px; }
  footer { flex-direction: column; gap: 0.25rem; }
}
