* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  touch-action: pan-x pan-y;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

h1 {
  margin-bottom: 1.5rem;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* --- Controls --- */

.controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

#facility-select {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

#weeks-select {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* --- Tabs --- */

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid #ddd;
}

.tab {
  padding: 0.6rem 1.2rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #333;
}

.tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
  font-weight: 600;
}

.tab-content {
  background: #fff;
  border-radius: 0 0 8px 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
}

/* --- Heatmap --- */

.heatmap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  white-space: nowrap;
}

.heatmap-table th {
  padding: 0.2rem 0.1rem;
  font-weight: 500;
  color: #888;
  font-size: 0.65rem;
  text-align: center;
  position: sticky;
  top: 0;
  background: #fff;
}

.heatmap-day {
  font-weight: 600;
  padding-right: 0.5rem;
  text-align: right;
  color: #555;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.heatmap-row {
  cursor: pointer;
}

.heatmap-row:hover td {
  opacity: 0.85;
}

.heatmap-cell {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: opacity 0.1s;
}

.heatmap-cell.heatmap-best {
  border: 2px solid #f9a825;
  box-shadow: 0 0 0 1px #f9a825;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #666;
}

.legend-bar {
  width: 200px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, hsl(120, 75%, 45%), hsl(60, 75%, 45%), hsl(0, 75%, 45%));
}

/* --- Day buttons --- */

.day-buttons {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.day-btn {
  padding: 0.35rem 0.7rem;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.day-btn:hover {
  background: #f0f0f0;
}

.day-btn.active {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}

/* --- Empty message --- */

.empty-msg {
  text-align: center;
  color: #888;
  padding: 2rem 0;
}

/* --- Scrape Status --- */

.status-section {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.status-section summary {
  cursor: pointer;
  list-style: revert;
  padding: 0.5rem 0;
}

.status-section[open] summary {
  margin-bottom: 1rem;
}

.status-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.status-section th,
.status-section td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
}

.status-section th {
  font-weight: 600;
  color: #555;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-success {
  background: #e6f4ea;
  color: #1e7e34;
}

.badge-error {
  background: #fce8e6;
  color: #c5221f;
}

/* --- Chart touch handling --- */

#tab-pattern canvas,
#tab-live canvas {
  touch-action: none;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .container {
    padding: 1rem 0.5rem;
  }

  .tab-content {
    padding: 1rem;
  }

  .heatmap-cell {
    width: 22px;
    min-width: 22px;
    height: 22px;
  }
}
