:root {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text-main: #222222;
  --text-muted: #555555;
  --border: #dddddd;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               sans-serif;
  background: var(--bg);
  color: var(--text-main);
  padding: 1.5rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.header-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

h1 {
  font-size: 1.4rem;
}

#status-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

button#refresh-btn,
button#show-all-btn,
button#ongoing-filter-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
}

button#refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button#show-all-btn {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

button#show-all-btn:hover {
  background: #0056b3;
  border-color: #0056b3;
}

button#ongoing-filter-btn.active {
  background: #fd7e14;
  color: white;
  border-color: #fd7e14;
}

button#ongoing-filter-btn.active:hover {
  background: #e66b02;
  border-color: #e66b02;
}

#last-update {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  user-select: none;
}

.legend-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.legend-item.has-incident {
  background: rgba(253, 126, 20, 0.1);
  border: 1px solid rgba(253, 126, 20, 0.3);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 0 10px rgba(253, 126, 20, 0.2);
}

.legend-item.filtered {
  background: var(--border);
  color: #999;
  opacity: 0.5;
}

.legend-item.active {
  background: rgba(0, 123, 255, 0.1);
  border: 1px solid rgba(0, 123, 255, 0.3);
  color: var(--text-main);
  font-weight: 600;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

#timeline-container {
  max-width: 800px;
  margin: 0.5rem auto 0;
  position: relative;
}

#timeline {
  border-left: 2px solid var(--border);
  padding-left: 1.5rem;
  position: relative;
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
}

.timeline-dot {
  position: absolute;
  left: -7px;
  top: 0.6rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 3px solid var(--border);
}

.timeline-card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.timeline-card.resolved {
  border-top: 3px solid #28a745;
}

.timeline-card.unresolved {
  border-top: 3px solid #fd7e14;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.timeline-source {
  font-weight: 600;
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.timeline-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.timeline-title a:hover {
  border-bottom-color: currentColor;
}

.timeline-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-line;
}

.empty-message,
.error-message {
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.error-message {
  color: #b00020;
}

footer {
  margin-top: 2rem;
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

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

  header {
    flex-direction: column;
    align-items: flex-start;
  }
}