/* Economy Simulator — dense modern dashboard */

.eco-page {
  padding-bottom: 1.5rem;
  max-width: 1180px;
}

/* —— Hero —— */
.eco-hero {
  padding: 1.1rem 0 0.65rem;
}
.eco-hero .eyebrow {
  margin-bottom: 0.35rem;
  padding: 0.12rem 0.5rem;
  font-size: 0.68rem;
}
.eco-hero h1 {
  margin: 0 0 0.2rem;
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  letter-spacing: -0.03em;
  font-weight: 750;
}
.eco-hero .lede.short {
  max-width: 42ch;
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.45;
  color: var(--muted);
}
.eco-hero .lede.short strong {
  color: var(--text);
  font-weight: 650;
}
.eco-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
}

/* Segmented presets */
.preset-row {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.preset-row .btn {
  border: 0;
  box-shadow: none;
  background: transparent;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}
.preset-row .btn:hover {
  background: #fff;
  color: var(--text);
  border: 0;
}
.preset-row .btn.is-active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* —— Layout —— */
.eco-layout {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  max-width: 100%;
  min-width: 0;
}
.eco-layout > * { min-width: 0; max-width: 100%; }
@media (max-width: 900px) {
  .eco-layout { grid-template-columns: minmax(0, 1fr); }
}

/* —— Control panel (form) —— */
.eco-form.compact.panel {
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 0.5rem);
  contain: layout style;
}
.eco-results.panel {
  contain: layout style;
}
@media (max-width: 900px) {
  .eco-form.compact.panel { position: static; }
}

.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--bg-2));
}
.form-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.form-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

.eco-form fieldset {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0;
  padding: 0.55rem 0.75rem 0.65rem;
  background: #fff;
}
.eco-form fieldset:last-of-type { border-bottom: 0; }

.eco-form legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 0.4rem;
  color: var(--text-2);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.eco-form legend + * {
  clear: both;
}
.eco-form legend .opt {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 0.65rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
}

.eco-form label {
  display: grid;
  gap: 0.12rem;
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.eco-form input,
.eco-form select {
  width: 100%;
  padding: 0.32rem 0.4rem;
  font-size: 0.84rem;
  font-weight: 550;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.eco-form input:hover,
.eco-form select:hover {
  background: #fff;
  border-color: var(--line-strong);
}
.eco-form input:focus,
.eco-form select:focus {
  background: #fff;
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.eco-form .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.4rem;
}
.eco-form .row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem 0.4rem;
}
.eco-form .row-4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.4rem;
}
@media (min-width: 901px) {
  .eco-form .row-4 { grid-template-columns: 1fr 1fr; }
}

.legend-check {
  display: inline-flex !important;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.7rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
  font-weight: 650 !important;
  cursor: pointer;
}
.legend-check input {
  width: auto !important;
  margin: 0;
  accent-color: var(--accent);
}

.eco-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.75rem;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
}
.eco-actions .btn.primary {
  flex: 1;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  border-radius: 9px;
}
.eco-actions .btn.compact {
  padding: 0.55rem 0.7rem;
  font-size: 0.84rem;
  border-radius: 9px;
}
.hint {
  color: var(--warn);
  font-size: 0.78rem;
  margin: 0;
  padding: 0 0.75rem 0.65rem;
  background: var(--bg-2);
}

/* —— Results dashboard —— */
.results-stack {
  display: grid;
  gap: 0.65rem;
}
.results-panel.panel {
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--bg-2));
}
.results-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.play-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.play-controls .btn.compact {
  padding: 0.32rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 7px;
}
.speed-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.speed-label select {
  width: auto;
  padding: 0.28rem 0.35rem;
  font-size: 0.78rem;
  text-transform: none;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
}

.results-body {
  padding: 0.7rem 0.85rem 0.9rem;
}

#eco-health {
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text);
  /* Instant presence — sliding toast felt jarring on first paint */
  opacity: 1;
  transform: none;
  transition: background 0.2s ease, color 0.2s ease;
}
#eco-health.show {
  opacity: 1;
  transform: none;
}
#eco-health[data-tone="ok"] {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}
#eco-health[data-tone="warn"] {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
}
#eco-health[data-tone="bad"] {
  border-color: transparent;
  background: #fef2f2;
  color: #b91c1c;
}

.step-readout {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 0.25rem 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-variant-numeric: tabular-nums;
}
.step-readout .step-label {
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.step-readout strong {
  font-size: 0.95rem;
  color: var(--text);
  min-width: 2.5rem;
}
.step-track {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}
.step-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.05s linear;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  max-width: 100%;
}
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: minmax(0, 1fr); }
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  min-width: 0;
  overflow: hidden;
}
.kpi.show {
  opacity: 1;
  transform: none;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 750;
  margin-bottom: 0.1rem;
  overflow-wrap: anywhere;
}
.kpi strong {
  display: block;
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chart-wrap {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.45rem 0.55rem;
  margin-bottom: 0.55rem;
}
.chart-wrap canvas {
  width: 100%;
  height: 200px;
  display: block;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
  padding: 0 0.15rem;
}
.chart-leg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  border-radius: 999px;
  padding: 0.28rem 0.6rem 0.28rem 0.45rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
}
.chart-leg i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}
.chart-leg.is-on {
  border-color: var(--line-strong);
  color: var(--text);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.12);
}
.chart-leg:not(.is-on) {
  opacity: 0.48;
  color: var(--muted);
}
.chart-leg:not(.is-on) i {
  background: #cbd5e1;
  box-shadow: none;
}
.chart-leg:hover {
  border-color: var(--line-strong);
}
.chart-leg:focus-visible {
  outline: 2px solid var(--accent-2-soft);
  outline-offset: 2px;
}
.chart-hint {
  margin: 0.35rem 0 0;
  padding: 0 0.15rem;
  font-size: 0.72rem;
}

.eco-block {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}
.eco-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.flow-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr 3.2rem;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.28rem;
  font-size: 0.78rem;
}
.flow-row span:first-child { color: var(--muted); font-weight: 600; }
.flow-row span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 700;
}
.flow-track {
  height: 6px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}
.flow-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  max-width: 100%;
  transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.flow-fill.in { background: var(--accent); }
.flow-fill.out { background: #dc2626; }
.flow-fill.gacha { background: var(--accent-2); }

.eco-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.eco-table th,
.eco-table td {
  padding: 0.28rem 0.3rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
}
.eco-table th:first-child,
.eco-table td:first-child { text-align: left; }
.eco-table th {
  color: var(--muted);
  font-weight: 750;
  background: transparent;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom-color: var(--line-strong);
}
.eco-table tbody tr:last-child td { border-bottom: 0; }

.inv-chip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.2rem 0.6rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-2);
  margin-bottom: 0.28rem;
  font-size: 0.8rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.inv-chip.show {
  opacity: 1;
  transform: none;
}
.inv-chip strong { color: var(--text); font-weight: 700; }
.inv-chip span { color: var(--muted); }

.note {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.limit-note {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.limit-note strong { color: var(--text); font-weight: 700; }

/* Export email gate (CSV + chart PNG) */
.gate.panel {
  padding: 0.9rem 1rem 1rem;
  max-width: 100%;
  min-width: 0;
}
.gate h2 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}
.gate .gate-lede {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  line-height: 1.45;
}
.gate label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 550;
  margin-bottom: 0.5rem;
  min-width: 0;
}
.gate input[type="email"],
.gate input[type="text"],
.gate textarea {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.gate textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.4;
}
.gate .check {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.8rem;
  line-height: 1.35;
}
.gate .check input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.gate .fine {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
}
.gate .ok {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
  color: var(--accent);
  font-weight: 650;
}
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.export-actions .btn {
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
}
.gate-status {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.gate.is-unlocked h2 { margin-bottom: 0.35rem; }

.compact-cta {
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
}
.compact-cta h2 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}
.compact-cta p {
  font-size: 0.85rem;
}
.compact-cta .btn-row { margin-top: 0.55rem; }
.compact-cta .btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  #eco-health,
  .kpi,
  .inv-chip,
  .flow-fill {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .step-fill { transition: none !important; }
}

/* —— Tablet + phone —— */
@media (max-width: 900px) {
  .eco-form input,
  .eco-form select {
    font-size: 16px;
    min-height: 44px;
  }
  .preset-row .btn {
    min-height: 44px;
    padding: 0.45rem 0.65rem;
  }
  .eco-actions .btn.primary,
  .eco-actions .btn.compact {
    min-height: 44px;
  }
  .play-controls .btn.compact {
    min-height: 44px;
    padding: 0.4rem 0.7rem;
  }
  .compact-cta .btn {
    min-height: 44px;
  }
}

/* —— Mobile —— */
@media (max-width: 640px) {
  .eco-page {
    padding-bottom: 1.25rem;
    width: min(1180px, calc(100% - 1.25rem));
  }
  .eco-hero {
    padding: 1rem 0 0.55rem;
  }
  .eco-hero h1 {
    font-size: clamp(1.3rem, 6vw, 1.55rem);
  }
  .eco-hero .lede.short {
    max-width: none;
    font-size: 0.9rem;
  }
  .eco-hero-top {
    flex-direction: column;
    align-items: stretch;
  }
  .preset-row {
    display: flex;
    width: 100%;
  }
  .preset-row .btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
    font-size: 0.78rem;
    padding: 0.45rem 0.4rem;
  }

  .eco-form.compact.panel {
    border-radius: 12px;
  }
  .eco-form input,
  .eco-form select {
    font-size: 16px;
    min-height: 44px;
  }

  /* 3-up currency row is too tight on phones */
  .eco-form .row-3 {
    grid-template-columns: 1fr 1fr;
  }
  .eco-form .row-3 > :first-child {
    grid-column: 1 / -1;
  }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .kpi strong {
    font-size: 0.88rem;
    word-break: break-word;
  }

  .step-readout {
    grid-template-columns: auto auto 1fr;
    gap: 0.25rem 0.4rem;
  }

  .results-head {
    flex-direction: column;
    align-items: stretch;
  }
  .play-controls {
    flex-wrap: wrap;
  }

  .compact-cta .btn-row {
    flex-direction: column;
  }
  .compact-cta .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  .kpi-row { grid-template-columns: 1fr; }
  .preset-row {
    flex-wrap: wrap;
  }
  .preset-row .btn {
    flex: 1 1 45%;
  }
  .eco-form .row-2,
  .eco-form .row-3,
  .eco-form .row-4 {
    grid-template-columns: 1fr;
  }
  .eco-form .row-3 > :first-child {
    grid-column: auto;
  }
}
