:root {
  --secure: #2e7d32;
  --insecure: #f9a825;
  --bogus: #c62828;
  --unreachable: #78909c;
  --error: #6a1b9a;
  --bg: #fafafa;
  --fg: #1d1d1f;
  --muted: #666;
  --border: #ddd;
  --link: #1565c0;
  --link-hover: #0d3d7a;
}

a { color: var(--link); text-decoration-color: rgba(21, 101, 192, 0.4); }
a:hover { color: var(--link-hover); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
}

header, .controls, .timeline-section, .drilldown {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

header { padding-top: 1.5rem; }
h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.sub { margin: 0 0 0.5rem; color: var(--muted); max-width: 60ch; }
.attribution { margin: 0 0 1rem; font-size: 0.9rem; color: var(--muted); }

footer {
  max-width: 1100px;
  margin: 2.5rem auto 1.5rem;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: stretch;
}
/* Vertically centre each fieldset's contents so the grouped boxes line up. */
.controls fieldset { align-items: center; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding: 0.5rem 1rem 0.75rem;
}
legend { color: var(--muted); padding: 0 0.4rem; font-size: 0.85rem; }
fieldset label { white-space: nowrap; cursor: pointer; }

.scale-toggle { font-size: 0.85rem; white-space: nowrap; cursor: pointer; }

.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.6rem;
}

/* Usage tips on a single line between the controls and the chart. */
.timeline-hints { margin: 0 0 0.6rem; }

.tld-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.tld-filter label { color: var(--muted); }
#tld-filter {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 16rem;
}
.tld-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.2rem 0.1rem 0.55rem;
}
.tld-chip.unknown { opacity: 0.5; text-decoration: line-through; }
.tld-chip .x {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.25rem;
  color: var(--muted);
}
.tld-chip .x:hover { color: #000; }
#tld-clear { font-size: 0.78rem; cursor: pointer; }

.date-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.date-range label { color: var(--muted); }
.date-range .dash { color: var(--muted); }
.date-range input {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.85rem; }
.legend .legend-item { cursor: pointer; user-select: none; }
/* Legend swatches double as checkboxes: a white check marks a shown status;
   hiding one clears the check and dims the entry. */
.legend .swatch {
  display: inline-block;
  position: relative;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: -3px;
}
.legend .legend-item .swatch::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.legend .legend-item.off { opacity: 0.5; }
.legend .legend-item.off .swatch::after { content: none; }

.swatch.secure { background: var(--secure); }
.swatch.insecure { background: var(--insecure); }
.swatch.bogus { background: var(--bogus); }
.swatch.unreachable { background: var(--unreachable); }
.swatch.error { background: var(--error); }

#timeline { width: 100%; }
#timeline svg { width: 100%; height: auto; display: block; cursor: crosshair; }
.band { stroke: none; }
.day-marker { stroke: #000; stroke-width: 1; pointer-events: none; }
.selrect { fill: rgba(0, 0, 0, 0.08); stroke: #555; stroke-dasharray: 3 3; pointer-events: none; }
.yscale-bg { fill: #ececec; }
.yscale-gutter { cursor: ns-resize; }
.yscale-gutter:hover { fill: rgba(0, 0, 0, 0.04); }
.yscale-cue { fill: #999; pointer-events: none; }
.yscale-gutter:hover ~ .yscale-cue { fill: #555; }
#reset-zoom { font-size: 0.78rem; cursor: pointer; margin-left: 0.25rem; }
#range-label { margin-left: 0.5rem; color: var(--muted); }
.axis text { font-size: 11px; fill: var(--muted); }
.axis line, .axis path { stroke: var(--border); }
.axis-caption { font-size: 11px; fill: var(--muted); }

.hint { color: var(--muted); font-size: 0.85rem; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: #111;
  color: #fff;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  z-index: 10;
  max-width: 260px;
}
.tooltip table { border-collapse: collapse; }
.tooltip td { padding: 0 0.3rem; }
/* Statuses hidden from the chart still appear, dimmed. */
.tooltip tr.off { opacity: 0.5; }

.drilldown { padding-bottom: 3rem; }
#drilldown-close {
  font-size: 0.8rem;
  margin-left: 0.75rem;
  cursor: pointer;
}

.waffle {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 1rem;
}
.waffle .cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  cursor: pointer;
}
.waffle .group-label {
  width: 100%;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.5rem;
  cursor: pointer;
  user-select: none;
}
/* Hidden class/status: fade toward the background so the colour still shows. */
.waffle .cell.faded { opacity: 0.2; }
.waffle .group-label.faded { opacity: 0.5; text-decoration: line-through; }
.cell.secure { background: var(--secure); }
.cell.insecure { background: var(--insecure); }
.cell.bogus { background: var(--bogus); }
.cell.unreachable { background: var(--unreachable); }
.cell.error { background: var(--error); }

.table-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
#search { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.chip.off { opacity: 0.35; }
.chip .dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: -1px;
}

#detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
#detail-table .idn { color: var(--muted); }
#detail-table .ede { cursor: help; text-decoration: underline dotted; }
#detail-table th, #detail-table td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
#detail-table th { white-space: nowrap; }
#detail-table th[data-sort] { cursor: pointer; }
#detail-table th.pick, #detail-table td.pick { width: 1.5rem; text-align: center; padding: 0; }
#detail-table td.pick input { cursor: pointer; }
#detail-table th:hover { color: #000; }
.status-pill {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
}
#detail-table tr.status-group td {
  cursor: pointer;
  user-select: none;
  background: var(--panel, #f4f4f6);
  font-weight: 600;
}
#detail-table tr.status-group:hover td { background: #ececf0; }
#detail-table tr.status-group .caret {
  display: inline-block;
  width: 1em;
  color: var(--muted);
}
#detail-table tr.status-group .group-count { color: var(--muted); font-weight: 400; }
.status-pill.secure { background: var(--secure); }
.status-pill.insecure { background: var(--insecure); color: #000; }
.status-pill.bogus { background: var(--bogus); }
.status-pill.unreachable { background: var(--unreachable); }
.status-pill.error { background: var(--error); }
tr.highlight td { background: #fff7cc; }
