:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f7f9f5;
  --ink: #172027;
  --muted: #64727b;
  --line: #dfe4df;
  --blue: #2f6486;
  --blue-dark: #1f4a65;
  --green: #6f9f87;
  --amber: #d99b5f;
  --teal: #5aa6a6;
  --danger-bg: #fff0eb;
  --danger: #a4492f;
  --shadow: 0 18px 45px rgba(24, 36, 44, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(111, 159, 135, 0.16), transparent 32rem),
    linear-gradient(180deg, #fbfbf7 0, var(--bg) 38rem, #eef1ed 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 0;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(24, 36, 44, 0.08);
  backdrop-filter: blur(18px);
}

.nav-toggle {
  display: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  place-items: center;
  gap: 0.22rem;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 1rem;
  height: 2px;
  background: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--green);
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.92rem;
}

.main-nav a,
.logout-form button {
  border: 0;
  background: transparent;
  padding: 0.55rem 0.7rem;
  color: #1d2a32;
  border-radius: 6px;
  cursor: pointer;
}

.main-nav a:hover,
.logout-form button:hover {
  background: var(--surface-soft);
}

.main-nav .nav-button,
.logout-form button {
  background: var(--blue);
  color: #fff;
}

.main-nav .nav-button:hover,
.logout-form button:hover {
  background: var(--blue-dark);
}

.logout-form {
  margin: 0;
}

.message-stack,
.global-disclaimer {
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 0;
}

.flash,
.global-disclaimer,
.result-disclaimer {
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(24, 36, 44, 0.06);
}

.global-disclaimer,
.result-disclaimer {
  border-color: #eedab6;
  background: #fff8e9;
  font-weight: 650;
}

main {
  min-height: 70vh;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
  width: min(1180px, calc(100% - 2rem));
  min-height: 560px;
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5.5rem) 0 4rem;
}

.hero h1,
.page-header h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p {
  max-width: 560px;
  color: #2d3c43;
  font-size: 1.15rem;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-actions,
.button-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 750;
  cursor: pointer;
  transition: 0.16s ease;
}

.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.button.primary:hover {
  background: var(--blue-dark);
}

.button.secondary {
  background: #fff;
}

.button.secondary:hover {
  border-color: #b9c9c1;
  background: var(--surface-soft);
}

.button.full {
  width: 100%;
}

.hero-panel {
  min-height: 330px;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mini-toolbar {
  height: 2rem;
  border-bottom: 1px solid var(--line);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.metric-card {
  padding: 0.8rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-card span,
.metric-list dt,
.scenario-card span,
.article-card span,
.muted {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--blue-dark);
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 0.65rem;
  height: 165px;
  padding: 1rem;
  background: linear-gradient(180deg, #fff, #f0f5ef);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mini-chart span {
  flex: 1;
  background: linear-gradient(180deg, var(--blue), var(--green));
  border-radius: 4px 4px 0 0;
}

.mini-chart span:nth-child(1) { height: 24%; }
.mini-chart span:nth-child(2) { height: 38%; }
.mini-chart span:nth-child(3) { height: 54%; }
.mini-chart span:nth-child(4) { height: 72%; }
.mini-chart span:nth-child(5) { height: 92%; }

.section,
.band,
.trust-section,
.page-shell,
.chat-shell,
.auth-shell,
.site-footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.section,
.band,
.trust-section,
.page-shell,
.chat-shell,
.auth-shell {
  padding: clamp(2rem, 5vw, 4rem) 0;
}

.section-heading,
.page-header {
  margin-bottom: 1.5rem;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.feature-card,
.article-card,
.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(24, 36, 44, 0.06);
}

.feature-card,
.article-card {
  display: block;
  padding: 1.25rem;
}

.feature-card:hover,
.article-card:hover {
  border-color: #b9c9c1;
  transform: translateY(-1px);
}

.feature-card,
.article-card,
.panel,
.button,
.form-control {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.feature-card h3,
.article-card h2,
.article-card h3 {
  margin: 0.9rem 0 0.35rem;
}

.feature-card p,
.article-card p {
  margin: 0;
  color: var(--muted);
}

.icon-tile {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  background: #e7eef5;
  color: var(--blue);
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.75rem;
}

.icon-tile.green {
  background: #e6f1ea;
  color: #3f7c5d;
}

.icon-tile.amber {
  background: #fbefd9;
  color: #9b6429;
}

.band {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 2rem;
  align-items: center;
  padding-left: clamp(1rem, 3vw, 2rem);
  padding-right: clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.58);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-strip div {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-strip span,
.stat-strip strong {
  display: block;
}

.trust-section {
  text-align: center;
}

.trust-section p {
  max-width: 720px;
  margin: 0.75rem auto 1.25rem;
}

.page-shell.narrow,
.article-detail {
  width: min(860px, calc(100% - 2rem));
}

.page-header p {
  max-width: 740px;
  color: var(--muted);
}

.page-header h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
  gap: 1.25rem;
  align-items: start;
}

.split-grid.wide-left {
  grid-template-columns: minmax(420px, 1.2fr) minmax(0, 0.8fr);
}

.panel {
  padding: 1.25rem;
}

.panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
}

.form-panel {
  display: grid;
  gap: 0.95rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

label span {
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #cfd7d2;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.form-control:focus {
  outline: 2px solid rgba(53, 101, 138, 0.22);
  border-color: var(--blue);
}

.form-control:hover {
  border-color: #b8c7c1;
}

.checkbox {
  width: 1rem;
  height: 1rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.field-error,
.form-errors {
  color: var(--danger);
}

.form-errors {
  padding: 0.75rem;
  background: var(--danger-bg);
  border: 1px solid #efc8ba;
  border-radius: 6px;
}

.results-stack {
  display: grid;
  gap: 1rem;
}

.result-hero {
  display: grid;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(47, 100, 134, 0.08), rgba(111, 159, 135, 0.1)), #fff;
}

.result-hero strong {
  display: block;
  margin: 0.2rem 0 0.5rem;
  color: var(--blue-dark);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.05;
}

.result-label,
.result-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.assumption-pills,
.category-chips,
.suggestion-chips {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}

.assumption-pills span,
.category-chips a,
.suggestion-chips button {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #344750;
  font-size: 0.82rem;
  font-weight: 750;
}

.category-chips,
.suggestion-chips {
  margin-bottom: 1rem;
}

.category-chips a.active,
.category-chips a:hover,
.suggestion-chips button:hover {
  border-color: var(--blue);
  background: #eaf1f5;
}

.suggestion-chips button {
  cursor: pointer;
}

.result-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.result-card strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--blue-dark);
  font-size: 1.35rem;
}

.interpretation-card {
  border-left: 4px solid var(--green);
}

.metric-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.metric-list div:last-child {
  border-bottom: 0;
}

.metric-list dd {
  margin: 0;
  color: #2f7c52;
  font-weight: 800;
  text-align: right;
}

.chart-panel {
  min-height: 300px;
}

.chart-panel canvas {
  width: 100%;
  min-height: 220px;
}

.wide-panel {
  margin-top: 1.25rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.muted-panel {
  background: rgba(255, 255, 255, 0.62);
}

.empty-state {
  padding: clamp(1.5rem, 4vw, 2.2rem);
  background: rgba(255, 255, 255, 0.78);
  border: 1px dashed #cbd6cf;
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(24, 36, 44, 0.04);
}

.empty-state h1,
.empty-state h2 {
  margin: 0 0 0.6rem;
}

.empty-state p {
  max-width: 620px;
  color: var(--muted);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.scenario-card {
  border-top: 3px solid var(--blue);
}

.scenario-card:nth-child(2) {
  border-top-color: var(--green);
}

.scenario-card:nth-child(3) {
  border-top-color: var(--amber);
}

.scenario-card p {
  min-height: 4.5rem;
  color: var(--muted);
}

.scenario-card strong {
  display: block;
  margin: 0.75rem 0 0.2rem;
  color: var(--blue-dark);
  font-size: 1.25rem;
}

.risk-note,
.risk-panel {
  border-color: #efc8ba;
  background: var(--danger-bg);
  color: #62311f;
}

.risk-note {
  padding: 1rem;
  border-radius: var(--radius);
  font-weight: 750;
}

.holding-rows {
  display: grid;
  gap: 0.55rem;
}

.holding-table {
  display: grid;
  gap: 0.5rem;
}

.holding-head,
.holding-row {
  display: grid;
  grid-template-columns: 1.2fr 0.95fr 0.85fr 0.85fr 0.9fr 2.4rem;
  gap: 0.55rem;
  align-items: center;
}

.holding-head {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.holding-row {
  padding: 0.35rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.holding-row .form-control {
  min-height: 2.45rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.icon-button:hover {
  border-color: #e1b8ad;
  background: var(--danger-bg);
  color: var(--danger);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.chart-grid canvas {
  min-height: 220px;
}

.chat-shell {
  width: min(920px, calc(100% - 2rem));
}

.chat-panel {
  padding: 0;
  overflow: hidden;
}

.chat-log {
  display: grid;
  gap: 0.85rem;
  min-height: 420px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 1rem;
  background: linear-gradient(180deg, #fff, #f7f8f4);
}

.chat-message {
  max-width: 82%;
  padding: 0.85rem 1rem;
  background: #edf2f5;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(24, 36, 44, 0.05);
}

.chat-message.user {
  justify-self: end;
  background: var(--blue);
  color: #fff;
}

.chat-message.assistant {
  border: 1px solid var(--line);
  background: #fff;
}

.chat-message.assistant.refused {
  background: var(--danger-bg);
}

.chat-message span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 800;
  opacity: 0.72;
}

.chat-message p {
  margin: 0;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: #fff;
}

.article-list {
  display: grid;
  gap: 1rem;
}

.article-list.compact {
  grid-template-columns: repeat(3, 1fr);
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.article-card.rich {
  min-height: 210px;
  display: flex;
  flex-direction: column;
}

.article-card.rich small {
  margin-top: auto;
  color: var(--muted);
  font-weight: 700;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

.prose {
  font-size: 1.05rem;
}

.prose p {
  margin: 0 0 1rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 0.9fr;
  gap: 1rem;
}

.dashboard-grid.secondary {
  grid-template-columns: 1fr 1fr;
  margin-top: 1rem;
}

.dashboard-card.accent {
  background: linear-gradient(135deg, rgba(47, 100, 134, 0.1), rgba(111, 159, 135, 0.12)), #fff;
}

.dashboard-card > strong,
.dashboard-card.accent strong {
  display: block;
  margin: 0.35rem 0;
  color: var(--blue-dark);
  font-size: 1.7rem;
}

.inline-link {
  display: inline-flex;
  margin-top: 0.9rem;
  color: var(--blue-dark);
  font-weight: 800;
}

.inline-link:hover {
  text-decoration: underline;
}

.simple-list {
  display: grid;
  gap: 0.7rem;
}

.simple-list div {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.simple-list.tight div {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.auth-shell {
  width: min(460px, calc(100% - 2rem));
}

.auth-panel {
  display: grid;
  gap: 1rem;
}

.auth-panel h1 {
  margin: 0;
}

.site-footer {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  color: #2e3a41;
}

.site-footer a,
.site-footer p {
  display: block;
  margin: 0.35rem 0 0;
  color: var(--muted);
}

@media (max-width: 920px) {
  .site-header,
  .split,
  .hero,
  .band,
  .split-grid,
  .split-grid.wide-left,
  .dashboard-grid,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-header,
  .split {
    display: grid;
  }

  .site-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    justify-content: start;
  }

  .card-grid,
  .scenario-grid,
  .article-list.compact,
  .article-grid,
  .result-card-grid,
  .chart-grid,
  .stat-strip {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: grid;
    margin-left: auto;
  }

  .main-nav {
    display: none;
  }

  .main-nav.open {
    display: grid;
    grid-template-columns: 1fr;
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .holding-head {
    display: none;
  }
}

@media (max-width: 560px) {
  .main-nav a,
  .logout-form button {
    padding: 0.5rem;
  }

  .hero {
    min-height: auto;
  }

  .hero h1,
  .page-header h1 {
    font-size: 2.15rem;
  }

  .mini-grid,
  .holding-row,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .metric-list div {
    display: grid;
  }

  .chat-message {
    max-width: 100%;
  }
}
