:root {
  --bg: #f9f9f9;
  --text: #222;
  --primary: #dcdcdc;
  --secondary: #f0f0f0;
  --hover: #e0e0e0;
  --accent: #7ED321;
  --panel-bg: #ffffff;
  --panel-border: #eeeeee;
  --shadow: 0 2px 8px rgba(0,0,0,.04);
  --shadow-strong: 0 4px 14px rgba(0,0,0,.08);
  --toggle-bg: #f5f7fb;
  --toggle-border: #e6e8ef;
  --toggle-active-bg: #4A90E2;
  --toggle-active-text: #fff;
  --toggle-shadow: 0 2px 6px rgba(0,0,0,.06);
  --focus: 0 0 0 3px rgba(74,144,226,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-container {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 40px;
  padding-right: 20px;
}

header {
  background: #fff;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.site-name { font-size: 20px; font-weight: 700; }

.nav-menu { list-style: none; display: flex; gap: 20px; margin: 0; padding: 0; }
.nav-menu a { text-decoration: none; color: #000; font-weight: 500; }
.nav-menu a:hover, .nav-menu a.active { color: #d90c1a; }

.intro-flex {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  max-width: 1200px;
  margin: 40px auto 20px auto;
  padding: 0 20px;
}

.intro-image {
  width: 200px; height: auto; border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
  margin-top: .5em; flex-shrink: 0;
}

.intro-text-block { flex: 1; padding-left: 20px; max-width: 800px; }
h1.left-aligned { font-size: 26px; margin: 0 0 20px 0; }
#description { font-size: 15px; line-height: 1.5; color: #000; }
#description p { margin: 10px 0 14px 0; }

.viz-wrap { max-width: 1200px; margin: 20px auto; padding: 0 20px 20px; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}
.panel:hover { box-shadow: var(--shadow-strong); }
.panel h2 { font-size: 18px; margin: 0 0 0 0; line-height: 1.3; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.controls-top {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.control-btn {
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  background: var(--secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  font-family: inherit;
}
.control-btn:hover { background: var(--hover); transform: translateY(-1px); }
.control-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.legend-container {
  margin-top: 18px;
  margin-bottom: 20px;
  padding: 0;       
  background: none; 
  border: none;     
  box-shadow: none; 
}

.legend-container h3 { 
  margin: 0 0 15px 0; 
  font-size: 16px; 
  color: white; 
  font-weight: 600; 
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.legend-grid { 
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.legend-item:hover { 
  background: rgba(255,255,255,1);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.legend-item.inactive {
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.812);
}
.legend-color { 
  width: 16px; 
  height: 16px; 
  border-radius: 50%; 
  margin-right: 10px; 
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.chart-container {
  width: 100%;
  min-height: 500px;
  background: #efefef;
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.06);
  position: relative;
  padding: 20px;
}

.tooltip {
  position: absolute;
  background: #efefef;
  color: rgb(32, 30, 30);
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1000;
  max-width: 300px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  backdrop-filter: blur(10px);
}
.tooltip strong { color: #302e2e; display: block; margin-bottom: 3px; font-size: 14px; }

.axis-label {
  font-size: 14px;
  font-weight: 600;
  fill: #444;
}

.grid-line {
  stroke: rgba(133, 64, 64, 0.835);
  stroke-width: 1;
  stroke-dasharray: 2,2;
}

.axis text {
  font-size: 12px;
  fill: #666;
}

.axis path,
.axis line {
  stroke: #999;
  stroke-width: 1;
}

.line {
  fill: none;
  stroke-width: 3;
  opacity: 0.9;
  transition: all 0.3s ease;
}

.line:hover {
  stroke-width: 4;
  opacity: 1;
}

.line.inactive {
  opacity: 0.2;
  stroke-width: 2;
}

.dot {
  stroke-width: 1;
  stroke: white;
  transition: all 0.2s ease;
}

.dot:hover {
  r: 6;
  stroke-width: 3;
}

.dot.inactive {
  opacity: 0.3;
}

footer { margin-top: auto; padding: 20px 0; text-align: center; color: #666; font-size: 14px; }

@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(10px); } 
  to { opacity: 1; transform: translateY(0); } 
}
.chart-container { animation: fadeIn 0.5s ease-out; }

@media (max-width: 1000px) {
  .content-container { padding-left: 20px; padding-right: 20px; }
  .legend-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

@media (max-width: 700px) {
  .panel-top { flex-direction: column; align-items: flex-start; gap: 6px; }
  #description { font-size: 14px; }
  .intro-flex { flex-direction: column; margin: 40px auto 10px auto; }
  .intro-text-block { padding-left: 0; }
  .viz-wrap { margin: 10px auto 20px auto; }
  .controls-top { justify-content: center; }
  .control-btn { font-size: 13px; padding: 6px 10px; }
  .chart-container { min-height: 400px; }
}

@media (max-width: 500px) {
  .site-name { font-size: 18px; }
  .nav-menu { gap: 15px; }
  .nav-menu a { font-size: 14px; }
  h1.left-aligned { font-size: 22px; }
  .legend-container { padding: 10px; }
  .legend-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media print {
  header, footer, .controls-top { display: none; }
  .chart-container { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; }
  .legend-container { break-inside: avoid; }
}
