/* ==========================================================================
   AgriNudgex — scientific SaaS design system (light theme, restrained green)
   ========================================================================== */
:root {
    --ag-green-900: #143d27;
    --ag-green-700: #1f5f3b;
    --ag-green-600: #2f7d4f;
    --ag-green-500: #3f9564;
    --ag-green-100: #dcefe3;
    --ag-green-50: #f0f7f2;
    --ag-olive: #8a8a3c;
    --ag-bg: #f5f7f6;
    --ag-surface: #ffffff;
    --ag-border: #e2e8e4;
    --ag-border-strong: #cfd8d2;
    --ag-text: #1c2621;
    --ag-muted: #5f6d66;
    --ag-radius: 14px;
    --ag-radius-sm: 9px;
    --ag-shadow: 0 1px 2px rgba(20, 40, 30, .05), 0 4px 16px rgba(20, 40, 30, .04);
    --ag-sidebar-w: 264px;
    --mech-s0: #8a94a6;
    --mech-s1: #2f7d4f;
    --mech-s2: #c2861a;
    --mech-s3: #3b6db3;
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--ag-text);
    --bs-body-bg: var(--ag-bg);
    --bs-link-color: var(--ag-green-700);
    --bs-link-color-rgb: 31, 95, 59;
    --bs-link-hover-color: var(--ag-green-900);
    --bs-link-hover-color-rgb: 20, 61, 39;
    --bs-border-color: var(--ag-border);
    --bs-primary: var(--ag-green-600);
    --bs-primary-rgb: 47, 125, 79;
    --bs-focus-ring-color: rgba(47, 125, 79, .28);
}

html { font-size: 15px; }
body { background: var(--ag-bg); color: var(--ag-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -.01em; color: var(--ag-text); }
code, .font-mono, .mono { font-family: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", monospace; font-size: .86em; }
a { text-underline-offset: 2px; }
.text-muted { color: var(--ag-muted) !important; }
.small-caps { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--ag-muted); }

:focus-visible { outline: 3px solid rgba(47, 125, 79, .45); outline-offset: 2px; }
.skip-link { position: absolute; left: 1rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: 8px; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
    width: var(--ag-sidebar-w);
    background: var(--ag-surface);
    border-right: 1px solid var(--ag-border);
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; flex: 0 0 var(--ag-sidebar-w); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.25rem 1rem; }
.brand-link { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ag-text); }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
    background: linear-gradient(140deg, var(--ag-green-600), var(--ag-green-900)); color: #fff; font-size: 1.15rem;
}
.brand-name { display: block; font-weight: 750; font-size: 1.08rem; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: .74rem; color: var(--ag-muted); }

.sidebar-nav { padding: .5rem .75rem; flex: 1 1 auto; overflow-y: auto; }
.nav-item-link {
    display: flex; align-items: center; gap: .75rem; padding: .58rem .8rem; margin-bottom: 2px;
    border-radius: var(--ag-radius-sm); color: #3b4842; text-decoration: none; font-weight: 520;
    transition: background .15s, color .15s;
}
.nav-item-link i { font-size: 1.05rem; color: #7b8a82; }
.nav-item-link:hover { background: var(--ag-green-50); color: var(--ag-green-900); }
.nav-item-link.active { background: var(--ag-green-100); color: var(--ag-green-900); font-weight: 650; }
.nav-item-link.active i { color: var(--ag-green-700); }
.sidebar-footer { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid var(--ag-border); }
.synthetic-pill {
    display: inline-flex; align-items: center; gap: .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em;
    background: #fff7e6; color: #8a5a00; border: 1px solid #f3dca8; border-radius: 999px; padding: .25rem .65rem;
}

.topbar {
    display: flex; align-items: center; gap: 1rem; padding: 1.1rem 2rem;
    background: rgba(245, 247, 246, .92); backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--ag-border); position: sticky; top: 0; z-index: 1010;
}
.topbar-title { flex: 1 1 auto; min-width: 0; }
.topbar-eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ag-green-700); font-weight: 650; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.btn-icon { border: 1px solid var(--ag-border); background: #fff; border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.3rem; }

.content { padding: 1.75rem 2rem 2.5rem; flex: 1 1 auto; }
.content:focus { outline: none; }
.app-footer {
    padding: 1rem 2rem 1.5rem; font-size: .8rem; color: var(--ag-muted); border-top: 1px solid var(--ag-border);
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem;
}
.app-footer > div:first-child { max-width: 860px; }

@media (max-width: 991.98px) {
    .topbar { padding: .9rem 1rem; }
    .content { padding: 1.25rem 1rem 2rem; }
    .app-footer { padding: 1rem; }
}

/* ---------- Panels & cards ---------- */
.panel {
    background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow); margin-bottom: 1.5rem;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--ag-border);
}
.panel-header h2, .panel-header h3 { font-size: 1rem; margin: 0; }
.panel-header .panel-sub { font-size: .8rem; color: var(--ag-muted); margin-top: .15rem; }
.panel-body { padding: 1.25rem; }
.panel-footer { padding: .8rem 1.25rem; border-top: 1px solid var(--ag-border); background: #fbfcfb; border-radius: 0 0 var(--ag-radius) var(--ag-radius); font-size: .82rem; color: var(--ag-muted); }

.kpi {
    background: var(--ag-surface); border: 1px solid var(--ag-border); border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow); padding: 1.1rem 1.2rem; height: 100%; position: relative; overflow: hidden;
}
.kpi-label { font-size: .78rem; color: var(--ag-muted); font-weight: 560; display: flex; align-items: center; gap: .4rem; }
.kpi-value { font-size: 1.7rem; font-weight: 720; letter-spacing: -.02em; margin-top: .25rem; line-height: 1.15; }
.kpi-note { font-size: .76rem; color: var(--ag-muted); margin-top: .3rem; }
.kpi-icon {
    position: absolute; right: 1rem; top: 1rem; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: var(--ag-green-50); color: var(--ag-green-700); font-size: 1.05rem;
}

.hero {
    border-radius: var(--ag-radius); padding: 1.6rem 1.75rem; margin-bottom: 1.5rem; color: #f2fbf5;
    background: radial-gradient(1200px 300px at 90% -40%, rgba(255, 255, 255, .14), transparent 60%),
                linear-gradient(120deg, var(--ag-green-700), var(--ag-green-900));
    box-shadow: var(--ag-shadow);
}
.hero h2 { color: #fff; font-size: 1.35rem; }
.hero p { color: rgba(242, 251, 245, .86); max-width: 760px; }
.hero .btn-light { color: var(--ag-green-900); font-weight: 600; }
.hero .btn-outline-light { font-weight: 600; }

/* ---------- Buttons & forms ---------- */
.btn { border-radius: 10px; font-weight: 560; }
.btn-primary { --bs-btn-bg: var(--ag-green-600); --bs-btn-border-color: var(--ag-green-600); --bs-btn-hover-bg: var(--ag-green-700); --bs-btn-hover-border-color: var(--ag-green-700); --bs-btn-active-bg: var(--ag-green-900); --bs-btn-disabled-bg: var(--ag-green-500); --bs-btn-disabled-border-color: var(--ag-green-500); }
.btn-outline-primary { --bs-btn-color: var(--ag-green-700); --bs-btn-border-color: var(--ag-green-500); --bs-btn-hover-bg: var(--ag-green-600); --bs-btn-hover-border-color: var(--ag-green-600); --bs-btn-active-bg: var(--ag-green-700); }
.btn-soft { background: var(--ag-green-50); color: var(--ag-green-900); border: 1px solid var(--ag-green-100); }
.btn-soft:hover { background: var(--ag-green-100); color: var(--ag-green-900); }
.form-control, .form-select { border-radius: 9px; border-color: var(--ag-border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--ag-green-500); box-shadow: 0 0 0 .2rem rgba(47, 125, 79, .18); }
.form-check-input:checked { background-color: var(--ag-green-600); border-color: var(--ag-green-600); }
.form-label { font-weight: 560; font-size: .86rem; margin-bottom: .3rem; }
.form-text { font-size: .76rem; }
.input-group-text { background: #f6f8f7; border-color: var(--ag-border-strong); font-size: .82rem; color: var(--ag-muted); }
.field-validation-error, .text-danger { font-size: .8rem; }
.input-validation-error { border-color: #dc3545 !important; }

.form-section { padding: 1.25rem; border-bottom: 1px solid var(--ag-border); }
.form-section:last-child { border-bottom: 0; }
.form-section-title { font-weight: 650; font-size: .95rem; margin-bottom: .2rem; display: flex; align-items: center; gap: .5rem; }
.form-section-title i { color: var(--ag-green-600); }
.form-section-desc { color: var(--ag-muted); font-size: .82rem; margin-bottom: 1rem; }

.option-card {
    display: block; border: 1px solid var(--ag-border-strong); border-radius: 12px; padding: .8rem .9rem; cursor: pointer; height: 100%;
    transition: border-color .15s, background .15s, box-shadow .15s; background: #fff;
}
.option-card:hover { border-color: var(--ag-green-500); }
.option-card:has(input:checked) { border-color: var(--ag-green-600); background: var(--ag-green-50); box-shadow: inset 0 0 0 1px var(--ag-green-600); }
.option-card:has(input:disabled) { cursor: default; }
.option-card .opt-title { font-weight: 640; display: flex; align-items: center; gap: .45rem; }
.option-card .opt-desc { font-size: .78rem; color: var(--ag-muted); margin-top: .2rem; }

.preset-card { text-decoration: none; color: inherit; display: block; height: 100%; }
.preset-card .inner { border: 1px solid var(--ag-border); border-radius: 12px; padding: .9rem 1rem; background: #fff; height: 100%; transition: border-color .15s, box-shadow .15s, transform .15s; }
.preset-card:hover .inner { border-color: var(--ag-green-500); box-shadow: var(--ag-shadow); transform: translateY(-1px); }
.preset-card.active .inner { border-color: var(--ag-green-600); background: var(--ag-green-50); }
.preset-card .title { font-weight: 650; font-size: .92rem; }
.preset-card .desc { font-size: .78rem; color: var(--ag-muted); margin-top: .25rem; }

.workload-box { background: #f8faf9; border: 1px dashed var(--ag-border-strong); border-radius: 12px; padding: 1rem; font-size: .85rem; }
.workload-box .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.workload-bar { height: 6px; border-radius: 6px; background: #e7ece9; overflow: hidden; margin-top: .5rem; }
.workload-bar > span { display: block; height: 100%; background: var(--ag-green-500); transition: width .2s; }
.workload-bar.over > span { background: #c0392b; }

/* ---------- Tables ---------- */
.table-sci { margin: 0; font-size: .86rem; --bs-table-bg: transparent; }
.table-sci thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ag-muted); font-weight: 650;
    border-bottom: 1px solid var(--ag-border); background: #fafbfa; white-space: nowrap; padding: .65rem .9rem;
}
.table-sci td { padding: .65rem .9rem; vertical-align: middle; border-color: var(--ag-border); }
.table-sci tbody tr:hover { background: #fafcfb; }
.table-sci .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-sci .ci { color: var(--ag-muted); font-size: .78rem; }
.na { color: #9aa5a0; font-style: italic; }
.table-responsive { border-radius: 0 0 var(--ag-radius) var(--ag-radius); position: relative; } /* contain visually-hidden absolute labels */

/* ---------- Badges ---------- */
.status-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 650; padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-completed { background: #e3f4e9; color: #1d6b3d; }
.status-running { background: #e6efff; color: #2753a3; }
.status-running::before { animation: pulse 1.2s infinite; }
.status-queued { background: #f3f0e3; color: #7a6416; }
.status-failed { background: #fbe7e5; color: #a3322a; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.mech-badge { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; font-size: .8rem; white-space: nowrap; }
.mech-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.mech-s0 .mech-dot, .mech-dot.mech-s0 { background: var(--mech-s0); }
.mech-s1 .mech-dot, .mech-dot.mech-s1 { background: var(--mech-s1); }
.mech-s2 .mech-dot, .mech-dot.mech-s2 { background: var(--mech-s2); }
.mech-s3 .mech-dot, .mech-dot.mech-s3 { background: var(--mech-s3); }
.tag { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 6px; background: #eef2f0; color: #43514a; font-weight: 600; margin: 0 .2rem .2rem 0; }
.tag-synthetic { background: #fff7e6; color: #8a5a00; border: 1px solid #f3dca8; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 240px; }
.chart-tools { display: flex; gap: .35rem; }
.chart-tools .btn { padding: .2rem .55rem; font-size: .76rem; }
.chart-caption { font-size: .76rem; color: var(--ag-muted); margin-top: .6rem; }

/* ---------- Heatmap ---------- */
.heatmap { border-collapse: separate; border-spacing: 6px; width: 100%; }
.heatmap th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ag-muted); font-weight: 650; text-align: center; padding: .25rem; }
.heatmap th.row-head { text-align: right; padding-right: .75rem; white-space: nowrap; }
.heatmap td { border-radius: 10px; text-align: center; padding: 1rem .5rem; font-variant-numeric: tabular-nums; min-width: 110px; }
.heatmap .hm-value { font-weight: 720; font-size: 1.05rem; }
.heatmap .hm-ci { font-size: .72rem; opacity: .85; }
.heatmap td.empty { background: #f1f3f2; color: #9aa5a0; }
.heat-legend { display: flex; align-items: center; gap: .6rem; font-size: .76rem; color: var(--ag-muted); }
.heat-legend .bar { height: 10px; width: 160px; border-radius: 6px; background: linear-gradient(90deg, #f1f7f3, #2f7d4f); }

/* ---------- Progress ---------- */
.progress { height: 10px; border-radius: 999px; background: #e7ece9; }
.progress-bar { background: linear-gradient(90deg, var(--ag-green-500), var(--ag-green-700)); }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 2.75rem 1.5rem; }
.empty-state .icon { width: 58px; height: 58px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--ag-green-50); color: var(--ag-green-700); font-size: 1.6rem; margin-bottom: .9rem; }
.empty-state h3 { font-size: 1.05rem; }
.empty-state p { color: var(--ag-muted); max-width: 520px; margin: .4rem auto 1rem; font-size: .9rem; }

/* ---------- Math / methodology ---------- */
.formula {
    font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif; font-size: 1.02rem;
    background: #f8faf9; border: 1px solid var(--ag-border); border-left: 3px solid var(--ag-green-600);
    border-radius: 8px; padding: .65rem .9rem; margin: .4rem 0; overflow-x: auto; white-space: nowrap;
}
.prose { max-width: 900px; }
.prose p, .prose li { line-height: 1.65; }
.prose h2 { font-size: 1.15rem; margin-top: 1.25rem; }
.prose h3 { font-size: 1rem; margin-top: 1rem; }
.toc a { display: block; padding: .3rem .6rem; border-radius: 7px; color: #3b4842; text-decoration: none; font-size: .86rem; }
.toc a:hover { background: var(--ag-green-50); }
.callout { border-radius: 12px; padding: .9rem 1rem; font-size: .86rem; display: flex; gap: .7rem; }
.callout i { font-size: 1.1rem; }
.callout-info { background: #eef4fb; color: #22426b; border: 1px solid #d5e3f4; }
.callout-warn { background: #fff8e8; color: #6d4c00; border: 1px solid #f2e0b0; }
.callout-green { background: var(--ag-green-50); color: var(--ag-green-900); border: 1px solid var(--ag-green-100); }

.json-view { background: #0f1f17; color: #d6f0df; border-radius: 10px; padding: 1rem; font-size: .78rem; max-height: 420px; overflow: auto; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem 1.25rem; margin: 0; }
.dl-grid dt { font-size: .78rem; color: var(--ag-muted); font-weight: 600; }  /* no uppercase: it would corrupt Greek symbols (β→Β) */
.dl-grid dd { margin: .15rem 0 0; font-weight: 560; word-break: break-word; }

.loading-overlay { position: fixed; inset: 0; background: rgba(245, 247, 246, .7); display: none; place-items: center; z-index: 3000; }
.loading-overlay.show { display: grid; }
.spinner-border.text-success { color: var(--ag-green-600) !important; }

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

/* ---------- Model v2 additions ---------- */
:root { --mech-s3r: #7a4fa3; }
.mech-s3r .mech-dot, .mech-dot.mech-s3r { background: var(--mech-s3r); }
.version-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; white-space: nowrap; letter-spacing: .02em; }
.version-current { background: var(--ag-green-100); color: var(--ag-green-900); border: 1px solid #bfdcc9; }
.version-archived { background: #eef0f3; color: #4b5563; border: 1px solid #d9dde3; }
.endpoint-tag { display: inline-block; font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; background: #e8f0fb; color: #22426b; margin-left: .3rem; }
.avail-partial { color: #8a5a00; font-weight: 600; }
.avail-unavailable { color: #a3322a; font-weight: 600; }
.prcc-cell { text-align: center; font-variant-numeric: tabular-nums; border-radius: 6px; font-size: .8rem; }
.model-switch .btn-check:checked + .btn { background: var(--ag-green-600); color: #fff; border-color: var(--ag-green-600); }

/* ---------- Accounts, roles and visibility ---------- */
.nav-sep { height: 1px; background: var(--ag-border); margin: .6rem .5rem; }
.account-btn { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-wrap { max-width: 520px; margin: 0 auto; }
.auth-wrap.wide { max-width: 720px; }
.auth-card .panel-body { padding: 1.75rem; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; font-size: .86rem; margin-top: 1rem; }
.vis-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; padding: .14rem .5rem; border-radius: 999px; white-space: nowrap; letter-spacing: .02em; }
.vis-private { background: #e8f0fb; color: #22426b; border: 1px solid #d5e3f4; }
.vis-public { background: var(--ag-green-100); color: var(--ag-green-900); border: 1px solid #bfdcc9; }
.vis-demo { background: #fff7e6; color: #8a5a00; border: 1px solid #f3dca8; }
.vis-legacy { background: #eef0f3; color: #4b5563; border: 1px solid #d9dde3; }
.acct-status { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; padding: .16rem .55rem; border-radius: 999px; white-space: nowrap; }
.acct-Approved { background: #e3f4e9; color: #1d6b3d; }
.acct-ApprovalPending, .acct-EmailVerificationPending, .acct-Registered { background: #f3f0e3; color: #7a6416; }
.acct-Rejected, .acct-Suspended { background: #fbe7e5; color: #a3322a; }
.status-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.status-steps li { display: flex; gap: .7rem; align-items: flex-start; font-size: .88rem; }
.status-steps .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #eef2f0; color: var(--ag-muted); font-size: .85rem; }
.status-steps .done .dot { background: var(--ag-green-600); color: #fff; }
.status-steps .current .dot { background: #f3dca8; color: #6d4c00; }
.audit-table td { vertical-align: top; }
