:root {
  --bg: #0b0f14;
  --surface: rgba(18, 24, 34, 0.72);
  --border: #252c36;
  --border-hover: #3a4350;
  --text: #e2e9f1;
  --text-muted: #8493a2;
  --accent: #6dacff;
  --accent-dim: rgba(109, 172, 255, 0.1);
  --swedish-yellow: #ffd133;
  --yellow-dim: rgba(255, 209, 51, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --radius: 10px;
  --radius-lg: 14px;
  --cell: 10px;
  --gap: 3px;
  --l0: #161d27;
  --l1: #45390f;
  --l2: #7d6614;
  --l3: #bd9a1e;
  --l4: #ffd133;
}
*,
::before,
::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font:
    16px/1.7 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: radial-gradient(
    ellipse at 30% 0%,
    #0f1520 0%,
    var(--bg) 60%
  );
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
main {
  width: 100%;
  max-width: 880px;
  padding: 48px 24px 64px;
}
h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -1px;
  text-align: center;
}
h1 .blue {
  color: #3b7dd8;
}
h1 .yellow {
  color: var(--swedish-yellow);
}
.submark {
  display: block;
  text-align: center;
  font-size: 0.98rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.panel {
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.panel-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-head p {
  font-size: 0.84rem;
  color: var(--text-muted);
}
.status-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}
.status-note.error {
  color: #ff8d7e;
}

/* --- heatmap --- */
.year {
  margin-bottom: 18px;
}
.year:last-child {
  margin-bottom: 0;
}
.year-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.year-label {
  width: 42px;
  flex: none;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 18px; /* below month labels */
  text-align: right;
}
.grid-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}
.months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc(var(--cell) + var(--gap));
  font-size: 0.66rem;
  color: var(--text-muted);
  height: 14px;
  margin-left: calc(var(--cell) + var(--gap) + 14px); /* weekday gutter */
}
.months span {
  grid-row: 1;
  white-space: nowrap;
}
.grid-body {
  display: flex;
  gap: var(--gap);
}
.weekdays {
  display: grid;
  grid-template-rows: repeat(7, calc(var(--cell) + var(--gap)));
  font-size: 0.62rem;
  color: var(--text-muted);
  width: calc(var(--cell) + 14px);
  flex: none;
}
.weekdays span {
  line-height: calc(var(--cell) + var(--gap));
  text-align: right;
  padding-right: 4px;
}
.grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--cell));
  grid-auto-columns: var(--cell);
  gap: var(--gap);
}
.day {
  width: var(--cell);
  height: var(--cell);
  border-radius: 2px;
  background: var(--l0);
  outline: 1px solid rgba(255, 255, 255, 0.03);
  outline-offset: -1px;
}
.day.pad {
  visibility: hidden;
}
.day[data-level="1"] {
  background: var(--l1);
}
.day[data-level="2"] {
  background: var(--l2);
}
.day[data-level="3"] {
  background: var(--l3);
}
.day[data-level="4"] {
  background: var(--l4);
}
.day:hover {
  outline: 1px solid var(--text-muted);
}
.day.working {
  animation: pulse 1.6s ease-in-out infinite;
  outline: 1px solid var(--accent);
  z-index: 1;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 2px 1px rgba(109, 172, 255, 0.35);
  }
  50% {
    box-shadow: 0 0 7px 3px rgba(109, 172, 255, 0.85);
  }
}

.legend {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.legend .day {
  cursor: default;
}
.legend .working-demo {
  margin-left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --- tooltip --- */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: #131a24;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 280px;
  z-index: 10;
  display: none;
}
#tooltip .tt-date {
  font-weight: 600;
  color: var(--text);
}
#tooltip .tt-total {
  color: var(--swedish-yellow);
}
#tooltip .tt-type {
  color: var(--text-muted);
}
#tooltip .tt-working {
  color: var(--accent);
}

footer {
  margin-top: 36px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}
footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* --- search bar & autocomplete --- */
.search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.search-input {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #131a24;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}
.search-results.visible {
  display: block;
}
.search-result-item {
  padding: 8px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}
.search-result-item:hover,
.search-result-item.active {
  background: var(--accent-dim);
}
.search-result-item .sr-name {
  color: var(--text);
}
.search-result-item .sr-party {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.search-result-item .sr-location {
  font-size: 0.73rem;
  color: var(--text-muted);
  opacity: 0.7;
}
.search-no-results {
  padding: 12px 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
}
.facts-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.facts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--border);
}
.facts-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}
.facts-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}
.facts-reset:hover {
  color: var(--text);
}
.facts-meta {
  padding: 8px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
}
.facts-row {
  display: contents;
}
.facts-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.facts-value {
  font-size: 0.82rem;
  color: var(--text);
  text-align: right;
}

/* --- politician highlight on heatmap --- */
.day.highlighted {
  background: rgba(109, 172, 255, 0.35);
  z-index: 1;
}
.day.highlighted.working {
  background: rgba(109, 172, 255, 0.55);
  box-shadow: 0 0 8px 3px rgba(109, 172, 255, 0.7);
}
