/* Dataset Dashboard - Mobile-first */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #333;
}

.dashboard {
  min-height: 100vh;
  padding-bottom: 2rem;
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #1a5f4a;
  color: white;
}

.back-link {
  color: white;
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 1rem;
}

.stat-card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a5f4a;
}

.stat-label {
  font-size: 0.85rem;
  color: #666;
}

.charts {
  display: grid;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.chart-card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-card h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.chart-card canvas {
  max-height: 220px;
}

.table-section {
  padding: 0 1rem 1rem;
}

.table-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.table-controls {
  margin-bottom: 0.5rem;
}

.table-controls input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
}

.table-wrapper {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.routes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.routes-table th,
.routes-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.routes-table th {
  background: #f8f8f8;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.routes-table th:hover {
  background: #eee;
}

.routes-table tbody tr:hover {
  background: #f9f9f9;
}

.routes-table .btn-inspect {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: #1a5f4a;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.routes-table .btn-inspect:hover {
  background: #145040;
}

.inspector-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.inspector-overlay.open {
  display: flex;
}

.inspector-panel {
  background: white;
  border-radius: 8px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #1a5f4a;
  color: white;
}

.inspector-header h2 {
  margin: 0;
  font-size: 1rem;
}

.inspector-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.inspector-content {
  overflow-y: auto;
  padding: 1rem;
}

.inspector-section {
  margin-bottom: 1rem;
}

.inspector-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #666;
}

.inspector-section pre {
  margin: 0;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f5f5f5;
  padding: 0.75rem;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.inspector-section ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.inspector-section li {
  margin-bottom: 0.25rem;
}

.sort-icon::after {
  content: ' ⇅';
  opacity: 0.5;
}

.sort-icon.asc::after {
  content: ' ↑';
  opacity: 1;
}

.sort-icon.desc::after {
  content: ' ↓';
  opacity: 1;
}

@media (min-width: 768px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .charts {
    grid-template-columns: repeat(3, 1fr);
  }
}
