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

:root {
  --bg: #f6f2ea;
  --bg-grid: rgba(20, 31, 58, 0.035);
  --panel: #fbfaf7;
  --panel-2: #f3efe7;
  --border: #ddd7cb;

  --text: #17213d;
  --muted: #6d7688;

  --navy: #182443;
  --navy-soft: #2e3f68;

  --sage: #a9c5bc;
  --sage-strong: #7ea998;

  --green: #2f7f73;
  --green-soft: #8fbfa8;

  --red: #b75a4a;

  --shadow: 0 10px 28px rgba(23, 33, 61, 0.06);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.app {
  width: 94%;
  max-width: 1440px;
  margin: 24px auto 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

h1 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  color: var(--navy);
  font-weight: 700;
}

h2 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 2rem;
  color: var(--navy);
}

h3 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.3rem;
  color: var(--navy);
}

p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.controls {
  display: flex;
  gap: 10px;
}

button {
  border: 1px solid var(--border);
  background: white;
  color: var(--navy);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
}

.main-panel {
  min-width: 0;
}

.scenario-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.scenario-tab {
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: white;
}

.scenario-tab.active {
  background: var(--navy);
  color: white;
}

.scenario-header {
  margin-bottom: 14px;
}

.info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.info-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

canvas {
  width: 100%;
  background: linear-gradient(180deg, #1d2748 0%, #11192f 100%);
  border-radius: 14px;
  margin-bottom: 12px;
}

.legend-panel,
.neural-panel,
.forecast-panel {
  margin-top: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.legend-item {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
}

.legend-icon {
  width: 10px;
  height: 10px;
}

.legend-icon.citizen { background: #b8c7da; border-radius: 50%; }
.legend-icon.signal { background: #a8cdbd; transform: rotate(45deg); }
.legend-icon.critical { background: #c98b8b; }
.legend-icon.zone { border: 2px solid #7ea998; border-radius: 50%; }

.sidebar .panel,
.log-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.decision-box {
  background: rgba(201,139,139,0.1);
  border: 1px solid rgba(169,83,83,0.3);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.social-box {
  background: rgba(158,183,216,0.1);
  border: 1px solid rgba(86,121,166,0.3);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.log-scroll {
  max-height: 260px;
  overflow-y: auto;
}

/* ===== NUEVO PANEL ===== */

.forecast-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.forecast-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: #b58a63;
}

.forecast-summary-card {
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 12px;
  width: 280px;
}

.forecast-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.forecast-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.forecast-kpi-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navy);
}

.forecast-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.forecast-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.forecast-bars {
  margin-top: 10px;
}

.forecast-bar-row {
  margin-bottom: 10px;
}

.forecast-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.forecast-bar-track {
  height: 10px;
  background: #e8e1d7;
  border-radius: 999px;
}

.forecast-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
}

.fill-72 { width: 72%; }
.fill-64 { width: 64%; }
.fill-41 { width: 41%; }
.fill-33 { width: 33%; }

.forecast-insight-card {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.forecast-bottom-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.forecast-table-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.forecast-action-main {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.forecast-tag {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-right: 6px;
}
/* ===== FIX SIDEBAR / COLUMNA DERECHA ===== */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar .panel,
.log-panel {
  width: 100%;
}

.sidebar .panel h3,
.log-panel h3 {
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: none;
  color: var(--navy);
  margin-bottom: 14px;
}

.sidebar label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.88rem;
  line-height: 1.25;
  color: var(--text);
}

.sidebar label span {
  justify-self: end;
  color: var(--navy-soft);
  font-weight: 600;
}

.sidebar input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 2px;
}

.log-panel {
  min-height: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.decision-box,
.social-box {
  margin-bottom: 0;
}

.decision-box strong,
.social-box strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.social-feed {
  max-height: 180px;
  overflow-y: auto;
  padding-right: 6px;
}

.log-scroll {
  flex: 1;
  min-height: 260px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}

.log-entry,
.social-message {
  font-size: 0.84rem;
  line-height: 1.38;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 1fr 340px;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .log-panel {
    min-height: unset;
  }
}