:root {
    --ink: #273326;
    --muted: #687565;
    --green-900: #244b2c;
    --green-700: #3f7d3b;
    --green-500: #6eaa52;
    --green-100: #e7f2df;
    --cream: #fbf8ee;
    --paper: #fffdf7;
    --gold: #f1b84b;
    --gold-soft: #fff0c9;
    --line: #dfe6d9;
    --danger: #9b3838;
    --shadow: 0 16px 42px rgba(43, 70, 37, 0.10);
    --radius-lg: 20px;
    --radius-md: 13px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: radial-gradient(circle at 85% 5%, rgba(241, 184, 75, 0.13), transparent 24rem), linear-gradient(180deg, #f5f1e4 0, var(--cream) 23rem);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button, input, select { font: inherit; }
h1, h2, h3, p { margin-top: 0; }

.site-header {
    border-bottom: 1px solid rgba(50, 85, 48, 0.13);
    background: rgba(255, 253, 247, 0.78);
    backdrop-filter: blur(10px);
}

.header-inner {
    width: min(1180px, calc(100% - 40px));
    min-height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--green-900);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--green-100);
}

.header-inner p, .panel-heading p, .chart-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.page-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 60px 0 72px;
}

.intro { max-width: 700px; margin-bottom: 34px; }

.eyebrow {
    margin: 0 0 8px;
    color: var(--green-700);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin-bottom: 12px;
    color: var(--green-900);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.35rem, 6vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.intro-copy {
    max-width: 640px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
    align-items: start;
    gap: 28px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.setup-panel { padding: 26px; position: sticky; top: 22px; }

.panel-heading, .result-heading, .chart-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-heading { justify-content: flex-start; margin-bottom: 24px; }
.panel-heading h2, .result-heading h2, .chart-heading h3 { margin: 0; color: var(--green-900); letter-spacing: -0.025em; }
.panel-heading h2, .result-heading h2 { font-size: 1.45rem; }

.step-number {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--green-700);
    font-weight: 800;
}

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -8px 0 20px;
    padding: 12px 14px;
    border: 1px solid #efc3bf;
    border-radius: 10px;
    color: var(--danger);
    background: #fff2f0;
    font-size: 0.9rem;
}

.alert span {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--danger);
    font-weight: 800;
}

.optimizer-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-wide, .profession-fieldset { grid-column: 1 / -1; }
.field label, .profession-fieldset legend { color: #3d493b; font-size: 0.85rem; font-weight: 750; }

.field input, .field select {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    border: 1px solid #ccd7c7;
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
}

.field input:focus, .field select:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(110, 170, 82, 0.16); }
.field small, .check-card small { color: var(--muted); font-size: 0.73rem; }

.profession-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.profession-fieldset legend { margin-bottom: 7px; }

.check-card {
    min-width: 0;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fafbf7;
    cursor: pointer;
}

.check-card:hover { border-color: #adbea7; }
.check-card input { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--green-700); }
.check-card span { min-width: 0; display: flex; flex-direction: column; }
.check-card strong { font-size: 0.83rem; }

.primary-button {
    height: 50px;
    margin-top: 4px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    border-radius: 11px;
    color: white;
    background: var(--green-700);
    box-shadow: 0 8px 20px rgba(63, 125, 59, 0.22);
    font-weight: 800;
    cursor: pointer;
    transition: background 150ms, transform 150ms;
}

.primary-button:hover { background: #326b35; transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }

.empty-state {
    min-height: 535px;
    padding: 64px clamp(30px, 7vw, 76px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px dashed #bac8b4;
    border-radius: var(--radius-lg);
    text-align: center;
    background: rgba(255, 253, 247, 0.55);
}

.empty-illustration { margin-bottom: 22px; display: flex; align-items: end; gap: 6px; font-size: 2.4rem; }
.empty-illustration span:nth-child(2) { font-size: 3.8rem; }
.empty-state h2 { margin-bottom: 10px; color: var(--green-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; }
.empty-state > p { max-width: 500px; color: var(--muted); }
.empty-state ol { margin: 12px 0 0; padding: 0; display: flex; gap: 18px; list-style: none; color: var(--muted); font-size: 0.8rem; }
.empty-state li { display: flex; align-items: center; gap: 6px; }
.empty-state li span { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; color: var(--green-700); background: var(--green-100); font-weight: 800; }

.results { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.result-heading { min-height: 70px; }
.crop-badge { padding: 7px 12px; border: 1px solid #cbdabc; border-radius: 999px; color: var(--green-900); background: var(--green-100); font-size: 0.8rem; font-weight: 750; }

.recommendation-card {
    padding: 28px clamp(18px, 4vw, 34px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 22px;
    border-radius: var(--radius-lg);
    color: white;
    background: radial-gradient(circle at 100% 0, rgba(255, 255, 255, 0.12), transparent 15rem), linear-gradient(135deg, #2d6637, var(--green-900));
    box-shadow: 0 18px 38px rgba(36, 75, 44, 0.2);
}

.allocation { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 14px; }
.allocation-count { min-width: 2.1ch; text-align: right; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.4rem, 5vw, 3.5rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.allocation-label { color: rgba(255, 255, 255, 0.76); font-size: 0.78rem; line-height: 1.35; }
.allocation-label strong { color: white; font-size: 0.9rem; }
.plus { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--gold-soft); background: rgba(255, 255, 255, 0.11); font-size: 1.3rem; }
.result-note { margin: -5px 2px 0; color: var(--muted); font-size: 0.8rem; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric { padding: 19px; display: grid; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); }
.metric > span { margin-bottom: 5px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.metric strong { color: var(--green-900); font-size: 1.45rem; line-height: 1.2; }
.metric small { color: var(--muted); font-size: 0.72rem; }
.metric-primary { border-color: #d8c382; background: var(--gold-soft); }
.metric .gain { color: var(--green-700); }

.strategy-panel { padding: 22px 20px 16px; box-shadow: none; }
.chart-heading { margin-bottom: 18px; }
.chart-heading h3 { font-size: 1.05rem; }
.chart-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.73rem; white-space: nowrap; }
.chart-legend span { width: 18px; height: 3px; border-radius: 3px; background: var(--green-700); }
.chart-wrap { position: relative; width: 100%; }
#strategy-chart { width: 100%; display: block; touch-action: pan-y; }

.chart-tooltip {
    position: absolute;
    width: max-content;
    max-width: 230px;
    padding: 8px 10px;
    transform: translateX(-50%);
    border-radius: 8px;
    color: white;
    background: rgba(36, 50, 36, 0.94);
    pointer-events: none;
    font-size: 0.7rem;
    text-align: center;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.16);
}

.chart-tooltip strong, .chart-tooltip span { display: block; }
.chart-tooltip span { color: #dbead6; }
.axis-labels { margin: -8px 14px 0 66px; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.68rem; }

.table-panel { overflow: hidden; box-shadow: none; }
.table-panel summary { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; list-style: none; }
.table-panel summary::-webkit-details-marker { display: none; }
.table-panel summary span:first-child { display: grid; }
.table-panel summary strong { color: var(--green-900); font-size: 0.92rem; }
.table-panel summary small { color: var(--muted); }
.summary-icon { font-size: 1.4rem; transition: transform 150ms; }
.table-panel[open] .summary-icon { transform: rotate(45deg); }
.table-scroll { max-height: 430px; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 11px 15px; border-bottom: 1px solid #edf0e9; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f6f8f2; font-size: 0.68rem; letter-spacing: 0.03em; text-transform: uppercase; }
.best-row { color: var(--green-900); background: var(--green-100); font-weight: 750; }
.best-tag { margin-left: 5px; padding: 2px 5px; border-radius: 4px; color: white; background: var(--green-700); font-size: 0.58rem; text-transform: uppercase; }

footer { padding: 24px 20px; border-top: 1px solid rgba(50, 85, 48, 0.11); color: var(--muted); text-align: center; font-size: 0.75rem; }
footer p { margin: 0; }

@media (max-width: 900px) {
    .workspace { grid-template-columns: 1fr; }
    .setup-panel { position: static; }
    .empty-state { min-height: 380px; }
}

@media (max-width: 600px) {
    .header-inner, .page-shell { width: min(100% - 28px, 1180px); }
    .header-inner p { display: none; }
    .page-shell { padding: 38px 0 54px; }
    .intro { margin-bottom: 25px; }
    .setup-panel { padding: 20px; }
    .optimizer-form, .profession-fieldset, .metric-grid { grid-template-columns: 1fr; }
    .recommendation-card { grid-template-columns: 1fr; gap: 13px; }
    .plus { margin: -3px 0; }
    .result-heading { align-items: flex-end; }
    .crop-badge { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chart-heading p, .chart-legend { display: none; }
    .axis-labels { margin-left: 58px; }
    .empty-state ol { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
