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

:root {
  --accent: #0000FF;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f9f9f7;
  color: #1a1a1a;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: min(80%, 1400px);
  margin: 0 auto;
  padding: clamp(20px, 2.2vw, 32px) clamp(16px, 2.5vw, 36px) clamp(8px, 1vw, 14px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vw, 16px);
}

/* -- Header ----------------------------------------------------------------- */

header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

h1 {
  font-size: clamp(1.3rem, 2.8vw, 2.2rem);
  font-weight: 900;
  line-height: 1.15;
  color: #111;
  letter-spacing: -0.02em;
  border-left: 5px solid var(--accent);
  padding-left: 14px;
}

.causa {
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  color: #333;
  line-height: 1.7;
  max-width: 820px;
  padding-left: 19px;
}

/* -- Panels ----------------------------------------------------------------- */

#panels {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: clamp(10px, 1.5vw, 18px);
  align-items: stretch;
}

.panel-label {
  font-size: clamp(0.72rem, 0.82vw, 0.8rem);
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* -- Panel calendario (izquierda) ------------------------------------------- */

#panel-calendar {
  flex: 25;
  min-height: 280px;
  background: #f0f0f0;
  border-radius: 10px;
  padding: clamp(95px, 11vw, 150px) clamp(12px, 1.5vw, 18px) clamp(12px, 1.5vw, 18px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.cal-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* -- Botones calendario ----------------------------------------------------- */

.cal-actions {
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.cal-actions button {
  font-size: clamp(0.62rem, 0.78vw, 0.72rem);
  padding: 7px 16px;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #fff;
  cursor: pointer;
  color: #444;
  font-family: inherit;
}

.cal-actions button:hover {
  background: #f5f5f5;
  border-color: #999;
}

/* -- Calendar heatmap ------------------------------------------------------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  user-select: none;
}

.cal-header {
  text-align: center;
  font-size: clamp(0.62rem, 0.7vw, 0.7rem);
  color: #888;
  font-weight: 600;
  padding-bottom: 2px;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(0, 0, 255, calc(0.06 + var(--pct) * 0.82));
  outline: 2.5px solid transparent;
  outline-offset: 0;
  transition: outline-color 0.1s;
}

.cal-cell.selected {
  outline-color: #111;
}

.cal-cell.weekend .cal-day {
  font-weight: 700;
}

.cal-day {
  font-size: clamp(0.62rem, 0.72vw, 0.72rem);
  color: #111;
}

/* -- Botón sonido ----------------------------------------------------------- */

#btn-play-sound {
  font-size: clamp(0.78rem, 1vw, 0.92rem);
  padding: 7px 16px;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #fff;
  cursor: pointer;
  color: #444;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
}

#btn-play-sound svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

#btn-play-sound:hover {
  background: #f5f5f5;
  border-color: #999;
}

#btn-play-sound.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* -- Panel derecho ---------------------------------------------------------- */

#panel-right {
  flex: 75;
  min-height: 280px;
  background: #ebebeb;
  border-radius: 10px;
  padding: clamp(14px, 1.8vw, 24px);
  display: flex;
  flex-direction: row;
  gap: clamp(16px, 2.5vw, 32px);
  align-items: center;
}

#equiv-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

#equiv-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#loss-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 1px solid #d0d0d0;
  padding-top: 12px;
}

/* -- Equiv numbers & labels ------------------------------------------------- */

.equiv-numero {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
}

.equiv-label {
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  font-weight: 600;
  color: #333;
}

.equiv-lugar {
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  font-weight: 600;
  color: #555;
}

.equiv-sub {
  font-size: clamp(0.72rem, 0.85vw, 0.82rem);
  color: #888;
}

.loss-number {
  font-size: clamp(1.6rem, 3.2vw, 2.6rem);
  font-weight: 900;
  color: #444;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.loss-sub {
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  font-weight: 600;
  color: #333;
}

/* -- Turbine grid ----------------------------------------------------------- */

#turbine-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, clamp(52px, 6vw, 84px));
  grid-auto-rows: clamp(52px, 6vw, 84px);
  gap: clamp(10px, 1.4vw, 18px);
  align-content: center;
  justify-content: center;
}

@keyframes spin-cw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.turbine-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.turbine-icon-wrap svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke-width: 1.5;
  animation: spin-cw var(--spin-dur, 2s) linear infinite;
  animation-play-state: paused;
}

.turbine-icon-wrap.active svg  { stroke: var(--accent); }
.turbine-icon-wrap.inactive svg { stroke: #888; }

#turbine-grid.spinning .turbine-icon-wrap.active svg {
  animation-play-state: running;
}

/* -- Footer ----------------------------------------------------------------- */

footer {
  border-top: 1px solid #d9d9d9;
  padding-top: clamp(8px, 1vw, 12px);
}

footer ul {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
}

footer p,
footer li {
  font-size: clamp(0.72rem, 0.82vw, 0.8rem);
  font-weight: 500;
  color: #777;
  line-height: 1.6;
}


/* -- Responsive ------------------------------------------------------------- */

@media (max-width: 680px) {
  #panels { flex-direction: column; }
  #panel-right { flex-direction: column; }
  .causa { padding-left: 0; }
}
