:root {
  --charcoal: #525252;
  --charcoal-dark: #3f4244;
  --nav-blue: #c8d7f0;
  --gold: #d2a714;
  --green: #5fb50f;
  --green-dark: #2d7c32;
  --green-soft: #edf7e7;
  --orange: #cc7b18;
  --orange-soft: #fff3de;
  --red: #bd4e46;
  --blue: #2d8cc4;
  --ink: #20272b;
  --muted: #667178;
  --line: #d9dfe2;
  --surface: #ffffff;
  --background: #eef1f2;
  --shadow: 0 10px 28px rgba(42, 50, 54, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, #f5f7f8 0, #e9edef 100%); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, [role="radio"]:focus-visible { outline: 3px solid rgba(45, 140, 196, .35); outline-offset: 2px; }

.noscript { padding: 1rem; background: #8b2222; color: white; text-align: center; font-weight: 700; }
.app-shell { width: min(1240px, calc(100% - 28px)); margin: 24px auto 40px; background: var(--surface); border: 1px solid #c7cdcf; box-shadow: var(--shadow); }

.brand-bar { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 9px 16px; background: var(--charcoal); color: white; border-top: 3px solid var(--gold); border-bottom: 2px solid var(--gold); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 3px solid var(--gold); color: var(--gold); border-radius: 50%; font-size: 23px; font-weight: 900; transform: rotate(-16deg); }
.brand-copy { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.brand-copy strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand-copy span { font-size: .78rem; color: #eef0f1; }
.icon-button { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.65); color: white; background: transparent; font-weight: 800; }
.icon-button:hover { background: rgba(255,255,255,.12); }

.primary-nav { display: flex; gap: 0; padding-left: 16px; background: var(--nav-blue); border-bottom: 2px solid var(--gold); }
.nav-tab { min-width: 132px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 11px 16px; border: 0; border-left: 1px solid rgba(82,82,82,.18); background: transparent; color: #171c20; font-weight: 650; }
.nav-tab:last-child { border-right: 1px solid rgba(82,82,82,.18); }
.nav-tab.active { background: rgba(255,255,255,.78); box-shadow: inset 0 -3px 0 var(--gold); }
.nav-tab:hover { background: rgba(255,255,255,.48); }
.nav-icon { font-size: 1.3rem; line-height: 1; }

.session-bar { min-height: 48px; padding: 6px 14px; display: flex; align-items: center; justify-content: space-between; background: var(--charcoal-dark); color: white; }
.session-user { display: flex; align-items: center; gap: 9px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; background: white; color: #9b8616; border: 2px solid var(--gold); }
.session-actions { display: flex; gap: 8px; }
.text-button { border: 1px solid rgba(255,255,255,.32); background: rgba(255,255,255,.06); color: white; padding: 7px 11px; border-radius: 5px; }
.text-button:hover { background: rgba(255,255,255,.15); }

main { background: #f0f2f3; }
.view { display: none; padding: 22px; }
.view.active { display: block; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.55rem, 2.5vw, 2.25rem); line-height: 1.15; }
h2 { font-size: 1.08rem; }
.eyebrow { margin-bottom: 7px; color: var(--green-dark); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.small-note, .explanation-note { color: var(--muted); font-size: .82rem; line-height: 1.5; }

.intro-panel, .dashboard-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 20px 22px; background: white; border: 1px solid var(--line); }
.intro-panel p:not(.eyebrow), .dashboard-header p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); max-width: 760px; line-height: 1.5; }
.progress-block { min-width: 270px; }
.progress-copy { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: .83rem; margin-bottom: 6px; }
.progress-copy strong { color: var(--green-dark); }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e3e7e9; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #8bc747, var(--green)); transition: width .25s ease; }

.assessment-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.scale-legend { align-self: start; position: sticky; top: 12px; padding: 18px; background: white; border: 1px solid var(--line); }
.scale-legend h2 { margin-bottom: 8px; }
.scale-legend p { color: var(--muted); line-height: 1.45; }
.scale-legend ol { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 12px; }
.scale-legend li { display: grid; grid-template-columns: 13px 20px 1fr; align-items: center; gap: 7px; font-size: .87rem; }
.scale-dot { width: 11px; height: 11px; border-radius: 50%; }
.scale-dot.v1 { background: #aa473f; }.scale-dot.v3 { background: #d17c34; }.scale-dot.v5 { background: #d5b446; }.scale-dot.v7 { background: #85ae46; }.scale-dot.v9 { background: #3b8c46; }

.criteria-accordion { display: grid; gap: 9px; }
.criteria-group { background: white; border: 1px solid var(--line); }
.group-toggle { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; background: #fff; text-align: left; }
.group-toggle:hover { background: #f7f9f9; }
.group-code { min-width: 36px; height: 28px; display: grid; place-items: center; background: #e4eedf; color: var(--green-dark); font-weight: 800; border-radius: 4px; }
.group-toggle strong { font-size: .98rem; }
.group-status { margin-left: auto; color: var(--muted); font-size: .78rem; }
.chevron { color: var(--charcoal); transition: transform .2s ease; }
.criteria-group.open .chevron { transform: rotate(180deg); }
.group-content { display: none; border-top: 1px solid var(--line); }
.criteria-group.open .group-content { display: block; }
.question-card { padding: 17px 18px 19px; border-bottom: 1px solid #e7ebed; }
.question-card:last-child { border-bottom: 0; }
.question-header { display: grid; grid-template-columns: 47px 1fr; gap: 12px; align-items: start; }
.question-code { display: inline-grid; place-items: center; height: 28px; border: 1px solid #aab5ba; background: #f4f6f7; color: #425058; font-size: .78rem; font-weight: 800; }
.question-title { margin: 0 0 4px; font-size: 1rem; }
.question-text { margin: 0; line-height: 1.45; }
.help-text { margin: 9px 0 0 59px; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.scale-options { margin: 15px 0 0 59px; display: grid; grid-template-columns: repeat(5, minmax(112px, 1fr)); gap: 8px; }
.scale-option { min-height: 72px; padding: 10px 8px; display: flex; flex-direction: column; justify-content: center; gap: 3px; border: 1px solid #cbd2d5; background: white; border-radius: 6px; text-align: center; color: #414a4f; }
.scale-option strong { font-size: 1rem; }
.scale-option span { font-size: .72rem; line-height: 1.25; }
.scale-option:hover { transform: translateY(-1px); border-color: #8b989e; box-shadow: 0 5px 13px rgba(51,65,71,.08); }
.scale-option.selected { border-color: var(--green-dark); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green-dark); color: #1f5b28; }
.scale-option[data-value="1"].selected { border-color: #a74740; background: #fff0ef; color: #8b2e29; }
.scale-option[data-value="3"].selected { border-color: #c76d29; background: #fff4ea; color: #934712; }
.scale-option[data-value="5"].selected { border-color: #b18d1d; background: #fff9df; color: #745c0e; }

.sticky-action { position: sticky; bottom: 0; z-index: 5; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; border: 1px solid #bcc7ca; background: rgba(255,255,255,.96); box-shadow: 0 -8px 22px rgba(48,57,61,.09); backdrop-filter: blur(8px); }
.sticky-action div { display: flex; flex-direction: column; gap: 3px; }
.sticky-action span { color: var(--muted); font-size: .78rem; }
.primary-button, .secondary-button { border-radius: 5px; padding: 11px 16px; font-weight: 750; }
.primary-button { border: 1px solid #2c6d31; color: white; background: linear-gradient(#69b934, #4f9e22); }
.primary-button:hover:not(:disabled) { background: linear-gradient(#75c542, #59a82a); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { border: 1px solid #aab5ba; color: #344047; background: #fff; }
.secondary-button:hover { background: #f1f4f5; }

.dashboard-header { align-items: center; margin-bottom: 16px; }
.model-badge { white-space: nowrap; border: 1px solid #b7c0c4; background: #f5f7f8; padding: 9px 12px; border-radius: 4px; color: var(--muted); font-size: .82rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 16px; }
.dashboard-side { display: grid; gap: 16px; }
.panel { background: white; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(49,57,60,.04); }
.panel-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-heading.compact { min-height: 46px; justify-content: center; text-align: center; }
.panel-heading h2 { margin: 0; text-transform: uppercase; letter-spacing: .025em; font-size: .98rem; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.metric-hint { color: var(--muted); font-size: .75rem; }

.bar-chart { min-height: 390px; padding: 24px 18px 16px; display: flex; align-items: flex-end; gap: clamp(5px, 1vw, 13px); border-top: 8px solid #f5f6f6; background-image: linear-gradient(to top, #edf0f1 1px, transparent 1px); background-size: 100% 20%; }
.bar-item { flex: 1 1 0; min-width: 0; height: 340px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.bar-value { font-size: .72rem; font-weight: 800; color: #4b565c; }
.bar-column { position: relative; width: min(40px, 76%); min-height: 3px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #2aa9d5, #157db2); box-shadow: inset 0 0 0 1px rgba(0,0,0,.10); transition: height .5s ease; }
.bar-item:first-child .bar-column { background: linear-gradient(180deg, #3fc945, #1ca331); }
.bar-rank { position: absolute; top: -27px; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--charcoal); color: white; font-size: .7rem; font-weight: 800; }
.bar-item:first-child .bar-rank { background: var(--green-dark); }
.bar-emoji { font-size: 1.25rem; line-height: 1; }
.bar-label { width: 100%; min-height: 34px; font-size: .68rem; text-align: center; line-height: 1.15; word-break: normal; }

.ranking-list { margin: 0; padding: 13px 17px 17px 46px; min-height: 222px; display: grid; gap: 8px; }
.ranking-list li { padding: 7px 9px; background: #f5f6f6; border-left: 4px solid #aeb6ba; font-weight: 700; }
.ranking-list li:first-child { background: #eff8e9; border-left-color: var(--green); color: #23672c; }
.ranking-list small { float: right; color: var(--muted); font-weight: 650; }

.robustness-content { min-height: 157px; padding: 16px; display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 16px; background: #fbfcfc; }
.gauge { --value: 0; position: relative; width: 108px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--value) * 1%), #e2e6e7 0); display: grid; place-items: center; }
.gauge::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: white; }
.gauge-center { position: relative; z-index: 1; display: grid; text-align: center; }
.gauge-center strong { font-size: 1.42rem; color: var(--green-dark); }
.gauge-center span { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.robustness-content p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }

.dashboard-secondary { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; margin-top: 16px; }
.factor-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 17px; }
.factor-columns h3 { font-size: .86rem; text-transform: uppercase; letter-spacing: .03em; }
.positive-title { color: var(--green-dark); }.attention-title { color: #9d5b14; }
.factor-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.factor-list li { padding: 9px 10px; border: 1px solid #e0e4e5; background: #f8fafa; font-size: .82rem; line-height: 1.35; }
.factor-list li strong { display: block; margin-bottom: 2px; }
.explanation-note { margin: 0 17px 16px; }
.top-three-cards { padding: 17px; display: grid; gap: 10px; }
.top-card { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 11px; padding: 10px; border: 1px solid #dbe0e2; background: #fafbfb; }
.top-card .crop-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: #edf3e9; font-size: 1.45rem; }
.top-card strong { display: block; }
.top-card span { color: var(--muted); font-size: .75rem; }
.top-card .probability { color: var(--green-dark); font-size: 1.05rem; font-weight: 850; }

.crop-grid-panel { margin-top: 16px; }
.crop-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; padding: 16px; }
.crop-card { position: relative; min-height: 158px; padding: 15px 12px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1px solid #d8dfe1; background: linear-gradient(#fff, #f7f9f9); }
.crop-card.winner { border-color: #70ab43; box-shadow: inset 0 0 0 2px #85c05a; background: linear-gradient(#f9fff5, #eef8e8); }
.crop-rank-badge { position: absolute; left: 8px; top: 8px; min-width: 27px; height: 27px; padding: 0 6px; display: grid; place-items: center; border-radius: 14px; background: #555f64; color: white; font-size: .74rem; font-weight: 850; }
.crop-card.winner .crop-rank-badge { background: var(--green-dark); }
.crop-card .large-emoji { font-size: 2.05rem; line-height: 1; margin-bottom: 8px; }
.crop-card h3 { margin: 0 0 8px; font-size: .95rem; }
.crop-metrics { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.crop-metrics div { padding: 6px 4px; background: rgba(226,231,233,.7); }
.crop-metrics strong { display: block; font-size: .9rem; }
.crop-metrics span { color: var(--muted); font-size: .61rem; text-transform: uppercase; letter-spacing: .04em; }
.dashboard-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 10px; }

.methodology-page { max-width: 1080px; margin: 0 auto; }
.methodology-page > h1 { margin-bottom: 20px; }
.methodology-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.method-card { position: relative; padding: 20px 16px 16px; background: white; border: 1px solid var(--line); }
.step-number { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 50%; background: var(--gold); color: #fff; font-weight: 900; }
.method-card h2 { margin-bottom: 8px; }
.method-card p { margin: 0; color: var(--muted); font-size: .83rem; line-height: 1.48; }
.formula-panel, .criteria-dictionary-panel { margin-top: 16px; background: white; border: 1px solid var(--line); padding: 18px; }
.formula-panel ul { margin-bottom: 0; padding-left: 20px; line-height: 1.55; }
.formula-panel li + li { margin-top: 6px; }
.formula-panel code { background: #eef1f2; padding: 2px 5px; }
.criteria-dictionary-panel { padding: 0; }
.dictionary-table-wrap { overflow: auto; }
.dictionary-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.dictionary-table th, .dictionary-table td { padding: 10px; border-bottom: 1px solid #e2e6e7; text-align: left; vertical-align: top; }
.dictionary-table th { position: sticky; top: 0; background: #eef2f3; z-index: 1; }
.dictionary-table td:first-child { font-weight: 850; color: var(--green-dark); }
.disclaimer { margin-top: 16px; padding: 15px 17px; background: #fff7e8; border: 1px solid #e5c279; }
.disclaimer p { margin: 4px 0 0; line-height: 1.48; }

.dialog-card { position: relative; max-width: 540px; padding: 26px; border: 0; }
dialog { border: 0; padding: 0; box-shadow: 0 18px 70px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(26,32,35,.62); }
.dialog-close { position: absolute; right: 11px; top: 8px; border: 0; background: transparent; font-size: 1.7rem; color: var(--muted); }
.dialog-card p { color: var(--muted); line-height: 1.5; }

@media (max-width: 980px) {
  .assessment-layout { grid-template-columns: 1fr; }
  .scale-legend { position: static; }
  .scale-legend ol { grid-template-columns: repeat(5, 1fr); }
  .scale-legend li { grid-template-columns: 13px 18px 1fr; }
  .dashboard-grid, .dashboard-secondary { grid-template-columns: 1fr; }
  .crop-grid { grid-template-columns: repeat(3, 1fr); }
  .methodology-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .app-shell { width: 100%; margin: 0; border-left: 0; border-right: 0; }
  .brand-copy span { display: none; }
  .primary-nav { padding-left: 0; }
  .nav-tab { min-width: 0; flex: 1; padding: 10px 7px; font-size: .78rem; }
  .session-bar { align-items: flex-start; gap: 8px; }
  .session-actions { flex-wrap: wrap; justify-content: flex-end; }
  .view { padding: 12px; }
  .intro-panel, .dashboard-header { align-items: stretch; flex-direction: column; padding: 16px; }
  .progress-block { min-width: 0; width: 100%; }
  .scale-legend ol { grid-template-columns: 1fr; }
  .scale-options { margin-left: 0; grid-template-columns: 1fr; }
  .scale-option { min-height: 54px; flex-direction: row; align-items: center; justify-content: flex-start; text-align: left; padding: 9px 12px; }
  .scale-option strong { min-width: 22px; }
  .help-text { margin-left: 0; }
  .question-header { grid-template-columns: 40px 1fr; }
  .sticky-action { align-items: stretch; flex-direction: column; }
  .sticky-action .primary-button { width: 100%; }
  .bar-chart { min-height: 330px; padding-left: 7px; padding-right: 7px; gap: 3px; }
  .bar-item { height: 285px; }
  .bar-label { font-size: .58rem; transform: rotate(-52deg); transform-origin: center top; min-height: 70px; padding-top: 4px; }
  .factor-columns { grid-template-columns: 1fr; }
  .crop-grid { grid-template-columns: repeat(2, 1fr); }
  .methodology-grid { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading .secondary-button { width: 100%; }
}

@media print {
  body { background: white; }
  .app-shell { width: 100%; margin: 0; border: 0; box-shadow: none; }
  .primary-nav, .session-bar, #assessmentView, #methodologyView, .dashboard-actions, #printButton { display: none !important; }
  main, .view { background: white; padding: 0; }
  #dashboardView { display: block !important; }
  .panel, .dashboard-header { break-inside: avoid; box-shadow: none; }
  .bar-chart { min-height: 320px; }
}
