:root {
  --bg: #f6f7fb;
  --text: #111;
  --muted: #555;
  --accent: #0f62fe;
  --card: #fff;
  --input-stoke: #ccc;
  --error: #d9534f;
  --transition: 0.3s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --text: #f9fafb;
  --muted: #94a3b8;
  --card: #1e293b;
  --input-stoke: #63a4ff;
  --accent: #63a4ff;
  --error: #d9534f;
}

* {
  transition: background var(--transition), color var(--transition), fill var(--transition), stroke var(--transition);
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

header {
  text-align: center;
  position: relative;
  padding: 0;
  flex-shrink: 0;
}

.top-controls {
  position: static;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 0;
}

.lang-btn {
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: all var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-btn:hover,
.lang-btn:active {
  background: var(--accent);
  color: #fff;
}

.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:hover,
.theme-btn:active {
  color: var(--accent);
}

h1 {
  font-size: clamp(2rem, 8vw, 2.75rem);
  font-weight: 800;
  margin: 0 0 12px;
  line-height: 1.2;
}

h2 {
  font-size: clamp(0.95rem, 4vw, 1.125rem);
  color: var(--muted);
  max-width: clamp(50%, 70vw, 90%);
  margin: 0 auto 32px;
  line-height: 1.5;
  font-weight: 400;
}

.center {
  position: static;
  transform: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}

input {
  padding: 16px;
  border-radius: 12px;
  border: 2px solid var(--input-stoke);
  font-size: 16px;
  background: var(--card);
  color: var(--text);
  width: 100%;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.2);
}

button {
  padding: 16px 20px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
  min-height: 56px;
}

button:active {
  transform: translateY(1px);
}

#theme-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

#charts-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
}


.chart-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  width: 600px;
  aspect-ratio: 10/6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.chart-title {
  font-weight: 700;
  color: var(--text);
}

.chart-stats {
  padding-left: 0.5%;
}

.chart-stat {
  font-size: clamp(0.7rem, 2.6vw, 1rem);
  font-weight: 100;
  margin-inline-end: 10px;
  color: var(--text);
}

.chart-sub {
  font-size: 0.975rem;
  color: var(--muted);
}

.chart-wrap {
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 100%;
}

.chart-grid {
  stroke: var(--input-stoke);
  stroke-dasharray: 4 4;
}

.chart-ylabel, .chart-xlabel {
  font-size: 12px;
  fill: var(--muted);
  font-family: system-ui, sans-serif;
}

.chart-line {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
}

.chart-dot {
  fill: var(--accent);
  cursor: pointer;
  transition: r 0.5s ease;
}

.chart-dot:hover {
  r: 6;
}

.chart-area {
  fill: url(#gradArea);
}

.chart-tooltip-bg {
  fill: var(--accent);
  opacity: 0.8;
}

.chart-tooltip-text {
  fill: #fff;
  font-size: 12px;
  font-family: system-ui, sans-serif;
}

#overlay-loader {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

#overlay-loader.active {
  display: flex;
  opacity: 1;
}

.loader {
  width: 64px;
  height: 64px;
  border: 6px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#error-message {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
  line-height: 1.2;
  padding: 0 8px;
}

.months-selector {
  width: 100%;
  max-width: 500px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 16px 0;
}

.months-selector button {
  width: 100%;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.months-selector button:hover {
  border: 3px solid var(--accent);
}

.months-selector button.active {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 480px) {
  body {
    padding: 12px 8px;
  }

  .top-controls {
    margin-bottom: 20px;
  }

  h2 {
    max-width: 100%;
  }

  form {
    padding: 0;
  }

  .lang-btn {
    padding: 12px 18px;
  }
  
  .loader { width: 48px; height: 48px; border-width: 5px; }
}