:root {
  color-scheme: light;
  --bg: #eef3f1;
  --panel: #fbfdfc;
  --panel-strong: #ffffff;
  --ink: #18211f;
  --muted: #66736d;
  --line: #d8e1de;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --accent-soft: #dff4ed;
  --gold: #d49b2f;
  --red: #c44949;
  --blue: #3267a8;
  --shadow: 0 22px 70px rgba(25, 44, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(212, 155, 47, 0.13), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 450px) minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0;
}

.input-panel,
.result-panel {
  border: 1px solid rgba(216, 225, 222, 0.9);
  background: rgba(251, 253, 252, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.input-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  padding: 24px;
}

.result-panel {
  min-width: 0;
  border-radius: 8px;
  padding: 24px;
}

.brand-row,
.chart-heading,
.board-heading,
.board-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.result-label {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  margin-top: 6px;
  font-size: clamp(1.85rem, 2.5vw, 2.6rem);
}

h2 {
  margin-top: 4px;
  font-size: 1.2rem;
}

.quick-settings {
  position: relative;
  flex: 0 0 auto;
}

.preset-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.preset-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.preset-button:hover,
.primary-button:hover,
.download-button:hover {
  transform: translateY(-1px);
}

.preset-button:focus-visible,
.primary-button:focus-visible,
.download-button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.preset-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 12px;
  width: min(340px, calc(100vw - 42px));
  border: 1px solid rgba(216, 225, 222, 0.98);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(25, 44, 42, 0.16);
  padding: 14px;
}

.preset-panel[hidden] {
  display: none;
}

.preset-panel-heading {
  display: grid;
  gap: 4px;
}

.preset-panel-heading strong {
  color: var(--ink);
  font-size: 1rem;
}

.preset-panel-heading span,
.preset-status,
.preset-meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.preset-list {
  display: grid;
  gap: 8px;
}

.preset-empty {
  margin: 0;
  border: 1px dashed #d6e1dd;
  border-radius: 8px;
  background: #f7fbfa;
  color: var(--muted);
  padding: 12px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.preset-item {
  display: grid;
  gap: 10px;
  border: 1px solid #e1e9e6;
  border-radius: 8px;
  background: #fbfefd;
  padding: 10px;
}

.preset-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.preset-name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.preset-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.preset-action.primary {
  border-color: rgba(15, 118, 110, 0.22);
  background: var(--accent);
  color: #ffffff;
}

.preset-action.danger {
  color: var(--red);
}

.preset-save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.preset-save-row input {
  height: 42px;
}

.preset-status {
  min-height: 1.2em;
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.inflation-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  border: 1px solid rgba(212, 155, 47, 0.42);
  border-radius: 8px;
  background: #fff8e7;
  color: #5d4211;
  padding: 12px 14px;
  line-height: 1.45;
}

.inflation-alert.is-hidden {
  display: none;
}

.inflation-alert div {
  display: grid;
  gap: 4px;
}

.inflation-alert strong {
  font-size: 0.9rem;
}

.inflation-alert span,
.field-note,
.empty-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.alert-close {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(93, 66, 17, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #5d4211;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.alert-close:hover {
  background: #ffffff;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  transition:
    opacity 160ms ease,
    background 160ms ease;
}

legend {
  padding: 0 8px;
  color: var(--ink);
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.full-span {
  grid-column: 1 / -1;
}

.field-note,
.empty-note {
  margin: 0;
}

.dynamic-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.dynamic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  min-width: 0;
  border: 1px solid #e1e9e6;
  border-radius: 8px;
  background: #fbfefd;
  padding: 10px;
}

.child-row {
  grid-template-columns: minmax(0, 1fr);
}

.row-button,
.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  padding: 0 12px;
  font-weight: 900;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.row-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--accent-soft);
}

.scenario-toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  padding: 8px 10px;
}

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

.scenario-toggle span {
  color: var(--accent-dark);
  font-weight: 900;
}

.scenario-disabled {
  background: rgba(255, 255, 255, 0.36);
}

.scenario-disabled label:not(.scenario-toggle) {
  opacity: 0.48;
}

.scenario-sub-disabled {
  opacity: 0.48;
}

label span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #d5dfdc;
  border-radius: 8px;
  background: #fbfefd;
  color: var(--ink);
  padding: 0 12px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input:hover {
  border-color: #aebfba;
}

.suffix-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d5dfdc;
  border-radius: 8px;
  background: #fbfefd;
}

.suffix-input:focus-within {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.suffix-input input {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.suffix-input input:focus-visible {
  outline: 0;
}

.suffix-input span {
  padding-right: 12px;
  color: var(--muted);
  font-weight: 800;
}

.status-card,
.metric-card,
.chart-card,
.insight-grid article,
.timeline-card,
.board-card {
  border: 1px solid rgba(216, 225, 222, 0.95);
  border-radius: 8px;
  background: var(--panel-strong);
}

.status-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-height: 182px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 46%),
    #ffffff;
}

.hero-result {
  margin: 8px 0 10px;
  font-size: clamp(2.35rem, 6.6vw, 5.7rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0;
}

.result-subtitle {
  max-width: 58ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.status-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-card.warning .status-badge {
  border-color: rgba(196, 73, 73, 0.24);
  background: #fae9e7;
  color: var(--red);
}

.status-card.bankrupt {
  background:
    linear-gradient(135deg, rgba(196, 73, 73, 0.12), transparent 46%),
    #ffffff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metric-card,
.insight-grid article {
  min-width: 0;
  padding: 18px;
}

.metric-card span,
.insight-grid span,
.timeline-item span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.metric-card strong,
.insight-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.08rem, 1.8vw, 1.44rem);
  line-height: 1.2;
}

.chart-card,
.timeline-card,
.board-card {
  margin-top: 16px;
  padding: 20px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 999px;
}

.dot.assets {
  background: var(--accent);
}

.dot.target {
  background: var(--gold);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 12px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.timeline-heading {
  margin-bottom: 14px;
}

.timeline-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  min-width: 0;
  border: 1px solid #e1e9e6;
  border-radius: 8px;
  background: #fbfefd;
  padding: 12px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.96rem;
  line-height: 1.25;
}

.timeline-item span {
  margin: 0;
  line-height: 1.35;
}

.timeline-item.risk {
  border-color: rgba(196, 73, 73, 0.22);
  background: #fff8f7;
}

.event-age {
  min-width: 52px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 5px 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
}

.primary-button,
.download-button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 900;
  text-decoration: none;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.primary-button:hover,
.download-button:hover {
  background: var(--accent-dark);
}

.download-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--accent-dark);
}

.download-button:hover {
  background: var(--accent-soft);
}

.board-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.board-preview-shell {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px dashed #cbd8d4;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), transparent 36%),
    linear-gradient(315deg, rgba(212, 155, 47, 0.08), transparent 32%),
    #fbfefd;
  padding: 14px;
}

.board-preview-shell img {
  display: block;
  width: min(100%, 760px);
  max-height: 720px;
  object-fit: contain;
  border: 1px solid rgba(216, 225, 222, 0.95);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(25, 44, 42, 0.12);
}

.board-preview-shell img[hidden] {
  display: none;
}

#boardStatus {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  text-align: center;
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 18px auto 0;
  color: rgba(102, 115, 109, 0.82);
  font-size: 0.78rem;
  line-height: 1.55;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer span {
  margin-right: 8px;
  font-weight: 800;
}

.site-footer a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.mobile-page-indicator {
  display: none;
}

@media (max-width: 1180px) {
  .metric-grid,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 740px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    display: flex;
    gap: 24px;
    width: 100vw;
    margin: 0;
    overflow-x: auto;
    overflow-y: visible;
    padding: 12px;
    scroll-behavior: smooth;
    scroll-padding: 12px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell::-webkit-scrollbar {
    display: none;
  }

  .input-panel,
  .result-panel {
    flex: 0 0 calc(100vw - 24px);
    width: calc(100vw - 24px);
    min-width: calc(100vw - 24px);
    padding: 16px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .input-panel {
    margin-right: 0;
  }

  .status-card,
  .chart-heading,
  .board-heading,
  .board-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-row {
    align-items: center;
  }

  .preset-panel {
    width: min(330px, calc(100vw - 48px));
  }

  .preset-save-row {
    grid-template-columns: 1fr;
  }

  fieldset,
  .dynamic-row,
  .metric-grid,
  .insight-grid,
  .timeline-list {
    grid-template-columns: 1fr;
  }

  .status-badge {
    width: fit-content;
  }

  .hero-result {
    font-size: clamp(2.15rem, 13vw, 4.2rem);
  }

  .chart-card,
  .timeline-card,
  .board-card {
    padding: 16px;
  }

  .site-footer {
    margin-bottom: 34px;
    padding-inline: 4px;
  }

  .mobile-page-indicator {
    position: fixed;
    right: 0;
    bottom: 10px;
    left: 0;
    z-index: 20;
    display: flex;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
  }

  .mobile-page-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(102, 115, 109, 0.3);
    transition:
      width 180ms ease,
      background 180ms ease;
  }

  .mobile-page-indicator span.active {
    width: 18px;
    background: rgba(15, 118, 110, 0.76);
  }
}
