:root {
  --bg: #0b1220;
  --bg-card: #121a2b;
  --bg-hover: #1a2438;
  --border: #243049;
  --text: #e8edf5;
  --text-muted: #8b9bb4;
  --accent: #22d3ee;
  --accent-dim: #0891b2;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.12);
  --kilo: #38bdf8;
  --valkea: #a78bfa;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(34, 211, 238, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(167, 139, 250, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2.2rem;
  line-height: 1;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.price-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  text-align: center;
}

.price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
}

.price-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-dim);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  min-width: 140px;
}

.toggle-group {
  justify-content: flex-end;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  padding-top: 18px;
}

.toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.last-updated {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  align-self: center;
  font-family: "JetBrains Mono", monospace;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card.kilo {
  border-top: 3px solid var(--kilo);
}

.stat-card.valkea {
  border-top: 3px solid var(--valkea);
}

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

.stat-card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.stat-card .city {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.2;
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.calendar-section {
  margin-bottom: 32px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-swatch.available {
  background: var(--green-bg);
  border: 1px solid rgba(52, 211, 153, 0.45);
}

.legend-swatch.unavailable {
  background: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.45);
}

.legend-swatch.kilo {
  background: var(--kilo);
}

.legend-swatch.valkea {
  background: var(--valkea);
}

.calendar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cal-month-label {
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.cal-grid {
  display: flex;
  flex-direction: column;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.cal-weekday {
  padding: 10px 8px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.cal-weeks {
  display: flex;
  flex-direction: column;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 140px;
  border-bottom: 1px solid var(--border);
}

.cal-week:last-child {
  border-bottom: none;
}

.cal-cell {
  border-right: 1px solid var(--border);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  background: var(--bg-card);
}

.cal-cell:last-child {
  border-right: none;
}

.cal-cell--pad {
  background: rgba(0, 0, 0, 0.15);
  opacity: 0.35;
}

.cal-cell--today {
  background: rgba(34, 211, 238, 0.06);
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.35);
}

.cal-cell--unpublished {
  background: rgba(0, 0, 0, 0.1);
}

.cal-cell-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.cal-day-num {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-cell--today .cal-day-num {
  background: var(--accent);
  color: var(--bg);
}

.cal-day-num.muted {
  color: var(--text-muted);
}

.cal-day-badge {
  font-size: 0.6rem;
  font-family: "JetBrains Mono", monospace;
  background: var(--green-bg);
  color: var(--green);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.cal-cell-slots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.cal-cell-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  opacity: 0.5;
}

.cal-cell-empty.unpublished {
  font-size: 0.75rem;
  font-style: italic;
}

.time-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: default;
}

.time-card.available {
  background: var(--green-bg);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--green);
}

.time-card.unavailable {
  background: var(--red-bg);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--red);
}

.time-card-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
}

.time-card-loc {
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
}

.time-card-loc.kilo { color: var(--kilo); }
.time-card-loc.valkea { color: var(--valkea); }

.time-card-detail {
  font-size: 0.58rem;
  font-family: "JetBrains Mono", monospace;
  opacity: 0.85;
  text-align: right;
}

.empty-state {
  padding: 32px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.error-state {
  padding: 16px 18px;
  color: var(--red);
  font-size: 0.875rem;
}

.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@media (max-width: 900px) {
  .cal-week,
  .cal-cell {
    min-height: 110px;
  }

  .time-card-time {
    font-size: 0.62rem;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
  }

  .last-updated {
    margin-left: 0;
    width: 100%;
  }

  .cal-weekday {
    font-size: 0.6rem;
    padding: 8px 2px;
  }

  .cal-cell {
    padding: 4px 3px;
    min-height: 90px;
  }

  .cal-day-num {
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
  }
}
