:root {
    --green: #2E5E34;
    --green-dark: #1E3F22;
    --green-soft: #eaf1ea;
    --cherry: #8C1C2B;
    --cherry-dark: #5E0F1A;
    --cherry-soft: #f7e6e8;
    --gold: #C8862B;
    --gold-soft: #f8eed9;
    --ink: #35271f;
    --muted: #8a7c74;
    --line: #ece4dc;
    --line-soft: #f3ede5;
    --bg: #f6f2ea;
    --panel: #ffffff;
    --sidebar: #f4ede0;
    --sidebar-2: #efe6d6;
    --sidebar-ink: #35271f;
    --sidebar-muted: #8a7c74;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(45,35,25,.04), 0 6px 20px rgba(45,35,25,.05);
    --shadow-sm: 0 1px 2px rgba(45,35,25,.05);
    --serif: Georgia, "Times New Roman", "Cambria", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cherry-dark); }
code { background: #efe8e4; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.page { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 244px;
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    border-right: 1px solid var(--line);
    color: var(--sidebar-ink);
    flex-shrink: 0;
    padding: 20px 16px 24px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}
.brand { padding: 6px 6px 18px; text-align: center; }
.brand-logo { width: 100%; max-width: 188px; height: auto; display: inline-block; }
.brand-tagline { color: var(--sidebar-muted); font-family: var(--serif); font-style: italic; font-size: 0.8rem; text-align: center; margin-top: 6px; letter-spacing: .2px; }
.report-tagline { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 0.92rem; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-bottom: 2px; }
.nav-group-label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--sidebar-muted); font-weight: 700;
    padding: 16px 12px 6px;
}
.nav-group:first-child .nav-group-label { padding-top: 6px; }
/* Collapsible group headers */
summary.nav-group-label { cursor: pointer; display: flex; align-items: center; gap: 6px; list-style: none; user-select: none; }
summary.nav-group-label::-webkit-details-marker { display: none; }
summary.nav-group-label::marker { content: ""; }
summary.nav-group-label:hover { color: var(--sidebar-ink); }
.nav-chevron { margin-left: auto; font-size: .62rem; opacity: .6; transition: transform .15s ease; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: rgba(140,28,43,0.08); color: var(--cherry-dark); }
.nav-item.active { background: var(--cherry); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.nav-ico { width: 20px; text-align: center; font-size: 1rem; opacity: .95; }

/* ---------- Main ---------- */
main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 32px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(140%) blur(6px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 700; font-family: var(--serif); letter-spacing: 0.3px; font-size: 1.02rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar .user { color: var(--muted); margin-right: 14px; font-size: .9rem; }
.link { color: var(--cherry-dark); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

.content { padding: 30px 32px 48px; flex: 1; max-width: 1240px; width: 100%; }
.footer { padding: 16px 32px; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.85rem; }

h1 { font-size: 1.65rem; margin: 0 0 4px; font-family: var(--serif); color: var(--green-dark); letter-spacing: .2px; }
h2 { font-size: 1.08rem; margin: 0 0 14px; }
.subtle { color: var(--muted); margin-top: 0; }
.small { font-size: 0.85rem; }

/* ---------- Page hero header ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.hero .eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); font-weight: 700; margin: 0 0 2px; }

/* ---------- KPI tiles (exec dashboard) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 16px; margin: 22px 0 4px; }
.kpi {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 18px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cherry); }
.kpi.k-cherry::before { background: var(--cherry); }
.kpi.k-gold::before { background: var(--gold); }
.kpi.k-green::before { background: var(--green); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi-ico { font-size: 1.1rem; opacity: .9; }
.kpi-val { font-size: 1.9rem; font-weight: 800; margin-top: 8px; color: var(--cherry); font-family: var(--serif); line-height: 1.05; }
.kpi.k-cherry .kpi-val { color: var(--cherry); }
.kpi.k-gold .kpi-val { color: #a56d1c; }
.kpi.k-green .kpi-val { color: var(--green-dark); }
.kpi-foot { color: var(--muted); font-size: 0.78rem; margin-top: 5px; }

/* ---------- Generic cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; border-top: 3px solid var(--green); box-shadow: var(--shadow-sm); }
.card-label { color: var(--muted); font-size: 0.85rem; }
.card-value { font-size: 1.7rem; font-weight: 800; margin-top: 6px; color: var(--cherry); font-family: var(--serif); }
.card-foot { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 20px; overflow-x: auto; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 12px; flex-wrap: wrap; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 30px 22px; color: var(--muted); }
.empty .empty-ico { font-size: 2rem; display: block; margin-bottom: 8px; opacity: .85; }
.empty .empty-title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.empty .empty-cta { margin-top: 14px; }
.empty-inline { color: var(--muted); padding: 8px 0; }

/* ---------- Getting started ---------- */
.getting-started { background: linear-gradient(135deg, #fff, #fbf6ec); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; margin-top: 22px; box-shadow: var(--shadow); }
.gs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.gs-head .gs-badge { background: var(--green-soft); color: var(--green-dark); font-weight: 700; font-size: .72rem; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }
.gs-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.gs-step { display: flex; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; color: var(--ink); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.gs-step:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--green); }
.gs-step.done { opacity: .62; }
.gs-num { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-family: var(--serif); }
.gs-step.done .gs-num { background: var(--muted); }
.gs-step-title { font-weight: 700; color: var(--green-dark); }
.gs-step-title .gs-check { color: var(--green); margin-left: 6px; }
.gs-step-desc { font-size: .84rem; color: var(--muted); margin-top: 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: none; cursor: pointer; padding: 9px 14px; font-size: 0.9rem; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--cherry-dark); border-bottom-color: var(--cherry); }

/* ---------- Tables ---------- */
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; white-space: nowrap; }
.grid thead th { color: var(--muted); font-weight: 600; border-bottom-color: var(--line); }
.grid tbody tr:hover { background: #fcfaf6; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid .num { text-align: right; }
.grid tr.total-row td { border-top: 2px solid var(--line); background: #faf7f1; }
.grid tr.total-row:hover { background: #faf7f1; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: #efe8e4; color: var(--muted); }
.g-Premium { background: var(--cherry-soft); color: #8C1C2B; }
.g-No1 { background: var(--green-soft); color: #2E5E34; }
.g-No2 { background: var(--gold-soft); color: #946012; }
.g-Cull { background: #ece6e2; color: #8a7c74; }
.m-Domestic { background: var(--green-soft); color: #2E5E34; }
.m-Export { background: var(--gold-soft); color: #946012; }
.k-Staff { background: var(--green-soft); color: #2E5E34; }
.k-Buyer { background: #e6eefb; color: #2f5fb3; }
.k-Vendor { background: var(--gold-soft); color: #946012; }
.k-Broker { background: var(--cherry-soft); color: #8C1C2B; }
.pill-live { background: var(--green-soft); color: #2E5E34; }
.pill-snapshot { background: var(--gold-soft); color: #946012; }
.g-paid { background: var(--green-soft); color: #2E5E34; }
.g-pending { background: var(--gold-soft); color: #946012; }

/* ---------- Grids / two-col ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.count-pill { display: inline-block; font-size: 0.8rem; font-weight: 800; padding: 1px 10px; border-radius: 999px; background: var(--cherry); color: #fff; vertical-align: middle; margin-left: 6px; }
.count-pill.zero { background: var(--green-soft); color: #2E5E34; }
.fulfill-panel { border-left: 4px solid var(--cherry); }
.ok { color: var(--green); font-size: 0.95rem; }

/* ---------- Bar charts ---------- */
.barchart { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.barrow { display: grid; grid-template-columns: 120px 1fr 90px; align-items: center; gap: 10px; font-size: 0.85rem; }
.barrow.wide { grid-template-columns: 100px 1fr 150px; }
.barrow .barval { white-space: nowrap; }
.barlabel { color: var(--ink); font-weight: 600; }
.bartrack { height: 12px; background: #efe7da; border-radius: 7px; overflow: hidden; }
.bartrack > span { display: block; height: 100%; border-radius: 7px; transition: width .4s ease; }
.bartrack > span.cherry { background: linear-gradient(90deg, var(--cherry), #b03142); }
.bartrack > span.green { background: linear-gradient(90deg, #2E5E34, #6E8F35 28%, #E07B2C 64%, #8C1C2B); }
.bartrack > span.gold { background: linear-gradient(90deg, var(--gold), #dda23f); }
.barval { text-align: right; color: var(--muted); font-weight: 600; }

/* ---------- Season goal ---------- */
.goal-panel { background: linear-gradient(180deg, #ffffff, #fbf7ee); }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.goal-head h2 { margin: 0; }
.goal-amt { font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--cherry); }
.goal-amt .goal-of { font-size: 15px; color: var(--muted); font-weight: 600; }
.goal-bar { height: 16px; background: #efe7da; border-radius: 9px; overflow: hidden; margin: 12px 0 8px; }
.goal-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--cherry), #b03142); border-radius: 9px; transition: width .4s ease; }
.goal-foot { font-size: 13px; color: var(--muted); }

/* ---------- SVG gauges ---------- */
.chart-panel { text-align: center; }
.chart-panel h2 { text-align: left; }
.gauge-wrap { display: flex; justify-content: center; }
.gauge { width: 100%; max-width: 260px; height: auto; }
.gauge-val { font-family: var(--serif); font-size: 26px; font-weight: 700; fill: var(--cherry); }
.gauge-sub { font-size: 11px; fill: var(--muted); }
.chart-foot { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; text-align: center; }
.chart-legend { display: flex; justify-content: center; gap: 18px; font-size: 0.85rem; color: var(--ink); margin-top: 4px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* ---------- Company page ---------- */
.company-name { font-family: var(--serif); font-size: 1.7rem; color: var(--green-dark); margin: 0 0 2px; }
.company-legal { color: var(--cherry); font-weight: 600; margin: 0 0 12px; }
.company-about { color: var(--ink); line-height: 1.55; margin: 0; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.contact-list li:last-child { border-bottom: none; }
.ci { width: 22px; text-align: center; flex: 0 0 22px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.team-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); box-shadow: var(--shadow-sm); }
.team-top { display: flex; align-items: center; gap: 12px; }
.team-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-family: var(--serif); }
.team-name { font-weight: 700; color: var(--ink); }
.team-role { font-size: 0.82rem; color: var(--muted); }
.team-top .badge { margin-left: auto; }
.team-meta { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line-soft); font-size: 0.85rem; color: var(--ink); }
.team-meta li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.team-actions { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); text-align: right; }

/* ---------- Store overview + product cards ---------- */
.overview { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .overview { grid-template-columns: 1fr; } }
.cards.mini { margin: 0; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.cards.mini .card { padding: 12px 14px; }
.cards.mini .card-value { font-size: 1.4rem; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 6px; }
.prod-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.prod-img { aspect-ratio: 4 / 3; background: #f4eee6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-img img { width: 100%; height: 100%; object-fit: cover; }
.prod-noimg { font-size: 2.4rem; }
.prod-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.prod-title { font-weight: 700; font-family: var(--serif); color: var(--green-dark); }
.var-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.prod-price { font-weight: 800; color: var(--cherry); font-size: 1.05rem; }
.prod-price .perlb { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.prod-stockline { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--ink); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; background: var(--cherry); color: #fff; border: none; border-radius: 9px; padding: 9px 16px; font-size: 0.9rem; font-weight: 700; cursor: pointer; text-decoration: none; transition: background .12s ease, transform .06s ease; }
.btn:hover { background: var(--cherry-dark); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--cherry-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--cherry-soft); }
.btn.cherry { background: var(--cherry); }
.btn.cherry:hover { background: var(--cherry-dark); }
.btn.danger { background: var(--cherry); }
.btn.danger:hover { background: var(--cherry-dark); }
.btn.sm { padding: 6px 11px; font-size: .82rem; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.text, select, input.text { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; background: #fff; color: var(--ink); width: 100%; }
.text:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
textarea.text { min-height: 84px; resize: vertical; font-family: inherit; }
.upload-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.note { color: var(--green); margin-top: 12px; }
.error { color: var(--cherry-dark); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .row2, .row3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-size: 0.9rem; }
.kv dd { margin: 0; }
.placeholder { padding: 26px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
.addform { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 18px; background: #fbf8f3; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-size: 0.9rem; color: var(--ink); }
.link-btn { background: none; border: none; cursor: pointer; font-weight: 600; font-size: 0.84rem; padding: 0 6px; color: var(--green-dark); }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--cherry-dark); }
.acts { white-space: nowrap; text-align: right; }
.danger-zone { border-color: #e8c9ce; background: linear-gradient(180deg, #fff, #fdf4f5); }
.danger-zone h2 { color: var(--cherry-dark); }

/* ---------- Alerts ---------- */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.92rem; }
.alert-list li:last-child { border-bottom: none; }
.alert-list .badge { margin-right: 6px; }

/* ---------- Trend charts ---------- */
.trend { width: 100%; height: auto; display: block; }
.trend-x { font-size: 10px; fill: var(--muted); }
.trend-v { font-size: 10px; fill: var(--ink); font-weight: 700; }

/* ---------- Packout line badges ---------- */
.line-algoma { background: var(--green-soft); color: var(--green-dark); }
.line-sandhu { background: #e6eefb; color: #2f5fb3; }
.line-karma { background: var(--gold-soft); color: #946012; }

/* ---------- Packout cards ---------- */
.packout-card { padding: 18px 22px 20px; }
.po-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.po-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.po-ref { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--green-dark); }
.po-variety { color: var(--muted); font-weight: 600; font-size: .9rem; }
.po-actions { display: flex; align-items: center; gap: 12px; }
.po-date { color: var(--muted); font-size: .85rem; }
.po-stats { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 14px 0 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.po-stat { display: flex; flex-direction: column; }
.po-stat-v { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.po-stat-v.good { color: var(--green); }
.po-stat-v.warn { color: var(--cherry); }
.po-stat-l { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.po-notes { margin: 14px 0 0; font-size: .9rem; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.cull-row td { color: var(--muted); }
.cull-badge { background: var(--gold-soft); color: #946012; margin-left: 6px; }

/* ---------- Packout add/edit form ---------- */
.addform-panel { background: linear-gradient(180deg, #fff, #fbf8f3); border-color: var(--green); }
.calc-note { padding: 8px 10px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.lines-editor { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.lines-editor h3 { font-size: .98rem; }
table.compact-form td { padding: 4px 5px; white-space: nowrap; }
table.compact-form input.text { padding: 6px 8px; min-width: 78px; }
table.compact-form input.text.num { text-align: right; min-width: 68px; }

/* ---------- Report ---------- */
.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 34px 38px; margin-top: 20px; box-shadow: var(--shadow-sm); max-width: 960px; }
.report-letterhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 3px solid var(--green); padding-bottom: 16px; flex-wrap: wrap; }
.report-brand-wrap { display: flex; flex-direction: column; gap: 6px; }
.report-brand { background: #faf6ee; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; display: inline-flex; align-items: center; align-self: flex-start; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.report-logo { height: 58px; width: auto; display: block; }
.report-company { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; color: var(--green-dark); line-height: 1.1; }
.report-legal { color: var(--muted); font-size: .9rem; }
.report-meta { text-align: right; }
.report-eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); font-weight: 700; }
.report-year { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.report-gen { color: var(--muted); font-size: .8rem; margin-top: 2px; }

.report-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 22px 0 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.report-kpis .rk { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-right: 1px solid var(--line-soft); }
.report-kpis .rk:last-child { border-right: none; }
.rk-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.rk-val { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; color: var(--ink); }
@media (max-width: 720px) { .report-kpis { grid-template-columns: repeat(3, 1fr); } .report-kpis .rk:nth-child(3) { border-right: none; } }

.report-money { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
.report-money .rm { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #faf7f1; }
.report-money .rm-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.report-money .rm-val { font-family: var(--serif); font-size: 1.25rem; font-weight: 800; color: var(--green-dark); }
.report-money .rm-net { background: var(--green-soft); border-color: var(--green); }
@media (max-width: 720px) { .report-money { grid-template-columns: repeat(2, 1fr); } }

.report-h { font-family: var(--serif); font-size: 1.05rem; color: var(--green-dark); margin: 26px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.report-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

/* ---------- Print ---------- */
@page { margin: 0; }  /* removes the browser's auto header/footer (URL, date, page title) */
.print-letterhead { display: none; }  /* only shown when printing */
@media print {
    .sidebar, .topbar, .footer, .no-print { display: none !important; }
    .page { display: block; }
    .content { padding: 12mm; max-width: none; }
    body:has(.report) .content { padding: 0; }  /* the Season Report manages its own margins */

    /* Branded letterhead on every printed page */
    .print-letterhead { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--green); }
    body:has(.report) .print-letterhead { display: none; }  /* the report has its own letterhead */
    .print-lh-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; color: var(--green-dark); line-height: 1.1; }

    .report { border: none; box-shadow: none; margin: 0; padding: 16mm 14mm; max-width: none; border-radius: 0; }
    .report-money .rm, .report-kpis, .report table { break-inside: avoid; }
    .report-h { break-after: avoid; }
    .grid tbody tr, .kpi, .panel, .qc-check, .packout-card { break-inside: avoid; }
    body { background: #fff; font-size: 11.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a[href]:after { content: ""; }
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    background: #f6e1e4; color: #8C1C2B;
    bottom: 0; display: none; left: 0; position: fixed;
    width: 100%; padding: 10px 16px; box-shadow: 0 -1px 4px rgba(0,0,0,0.1);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 8px; }

/* ---------- Mobile menu toggle (hidden on desktop) ---------- */
.nav-toggle { display: none; }
.nav-burger { display: none; }
.nav-backdrop { display: none; }

/* ---------- Responsive: slide-in sidebar on phones ---------- */
@media (max-width: 760px) {
    .page { display: block; }

    /* Hamburger button in the top bar */
    .nav-burger {
        display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
        width: 40px; height: 36px; padding: 8px 9px; margin-right: 4px;
        border: 1px solid var(--line); border-radius: 9px; background: #fff;
        cursor: pointer; flex: 0 0 auto;
    }
    .nav-burger span { display: block; height: 2px; border-radius: 2px; background: var(--green-dark); transition: transform .2s ease, opacity .2s ease; }

    .topbar { padding: 10px 14px; gap: 12px; }
    .topbar-title { font-size: .95rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Off-canvas sidebar */
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 60;
        width: 264px; max-width: 84vw; height: 100vh; height: 100dvh;
        padding: 18px 14px 24px;
        transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); }

    /* Dark backdrop behind the open menu; tap to close */
    .nav-toggle:checked ~ .nav-backdrop {
        display: block; position: fixed; inset: 0; z-index: 55;
        background: rgba(0,0,0,.45);
    }

    /* Turn the burger into an X when open */
    .nav-toggle:checked ~ main .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .nav-toggle:checked ~ main .nav-burger span:nth-child(2) { opacity: 0; }
    .nav-toggle:checked ~ main .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

    .nav { flex-direction: column; gap: 2px; }
    .nav-item { padding: 11px 12px; font-size: .96rem; }

    .content { padding: 20px 16px 40px; }
    h1 { font-size: 1.4rem; }
    .hero .filters { width: 100%; }
    .hero .filters .btn { flex: 1; justify-content: center; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 8px; }
}

/* ---------- New-page helpers (Sales / Orchards / Photos) ---------- */
.kpi.k-blue::before { background: #3f6296; }
.kpi.k-blue .kpi-val { color: #3f6296; }
.row1 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: #e8eef7; color: #3f6296; }
.checkbox-field { justify-content: flex-end; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; }
.grid tr.muted-row td { color: var(--muted); }

/* Inline net $/lb editor on the Packing Lines cards */
.rate-inline-wrap { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.rate-inline { width: 84px; padding: 5px 8px; text-align: right; font-weight: 700; color: var(--ink); }
.rate-saved { color: var(--green); font-weight: 700; font-size: .8rem; }

/* Analytics recommendation callout */
.rec-callout { background: var(--green-soft); border-radius: 10px; padding: 14px 16px; font-size: 1.02rem; line-height: 1.5; color: var(--ink); }

/* KPI season-over-season delta */
.delta { display: inline-block; margin-left: 4px; font-weight: 700; font-size: 0.72rem; white-space: nowrap; }
.delta-up { color: var(--green); }
.delta-down { color: var(--cherry); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.photo-card { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.photo-card img { width: 100%; height: 160px; object-fit: cover; display: block; background: #f3efe9; }
.photo-card figcaption { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 0.78rem; }
.photo-card .photo-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.photo-card figcaption .link-btn { padding: 0; }

/* Full-screen photo viewer (tap image to open, Back / tap-outside to close) */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; gap: 12px; }
.lightbox img { max-width: 100%; max-height: 82vh; object-fit: contain; border-radius: 8px; }
.lightbox-caption { color: rgba(255,255,255,.85); font-size: .85rem; text-align: center; max-width: 90%; overflow-wrap: anywhere; }
.lightbox-back { position: fixed; top: 14px; left: 14px; z-index: 101; background: rgba(255,255,255,.95); color: var(--ink); border: none; border-radius: 9px; padding: 11px 18px; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.lightbox-back:hover { background: #fff; }

/* QC check cards + photo strip */
.qc-check { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; background: var(--panel); box-shadow: var(--shadow-sm); }
.qc-check:last-child { margin-bottom: 0; }
.qc-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.qc-thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.qc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; background: #f3efe9; }
.qc-thumb .link-btn { position: absolute; top: 2px; right: 4px; background: rgba(255,255,255,.9); border-radius: 6px; padding: 0 5px; line-height: 1.4; }
.qc-addphoto { position: relative; overflow: hidden; cursor: pointer; }

/* ---------- Agent (Ruby) — floating avatar & chat panel ---------- */
.agent { position: fixed; right: 22px; bottom: 22px; z-index: 900; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }

.agent-fab {
    width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    background: var(--sidebar); overflow: hidden;
    box-shadow: 0 4px 10px rgba(45,35,25,.18), 0 10px 28px rgba(45,35,25,.20);
    transition: transform .16s ease, box-shadow .16s ease;
}
.agent-fab img { display: block; width: 56px; height: 56px; border-radius: 50%; }
.agent-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 14px rgba(45,35,25,.22), 0 14px 34px rgba(45,35,25,.24); }
.agent-fab:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.agent-fab.on { box-shadow: 0 0 0 3px var(--cherry), 0 8px 22px rgba(45,35,25,.24); }

.agent-panel {
    width: 380px; max-width: calc(100vw - 44px);
    height: 540px; max-height: calc(100vh - 132px);
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 2px 6px rgba(45,35,25,.06), 0 18px 48px rgba(45,35,25,.20);
}

.agent-head { display: flex; align-items: center; gap: 11px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, #fbf7ee); }
.agent-face { border-radius: 50%; flex-shrink: 0; }
.agent-id { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.agent-id strong { font-size: .95rem; color: var(--green-dark); }
.agent-id span { font-size: .72rem; color: var(--muted); }
.agent-clear { border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .7rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; cursor: pointer; }
.agent-clear:hover { color: var(--cherry); border-color: #e8c9ce; }
.agent-x { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.agent-x:hover { color: var(--cherry); }

.agent-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column-reverse; gap: 10px; padding: 16px; }

.agent-msg { max-width: 88%; padding: 10px 13px; border-radius: 13px; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.agent-msg.me { align-self: flex-end; background: var(--cherry); color: #fff; border-bottom-right-radius: 4px; }
.agent-msg.bot { align-self: flex-start; background: var(--green-soft); color: var(--ink); border: 1px solid #dbe6d6; border-bottom-left-radius: 4px; }

.agent-typing { display: inline-flex; gap: 4px; align-items: center; height: 1.1em; }
.agent-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); opacity: .35; animation: agentBlink 1.1s infinite ease-in-out; }
.agent-typing i:nth-child(2) { animation-delay: .18s; }
.agent-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes agentBlink { 0%, 80%, 100% { opacity: .28; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-2px); } }

.agent-intro { padding: 2px 2px 6px; }
.agent-greet { font-family: var(--serif); font-size: 1.12rem; color: var(--green-dark); margin: 0 0 6px; }
.agent-sub { font-size: .82rem; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.agent-chips { display: flex; flex-direction: column; gap: 7px; }
.agent-chip { text-align: left; font-size: .82rem; color: var(--cherry-dark); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.agent-chip:hover { background: var(--cherry-soft); border-color: #e8c9ce; }

.agent-warn { font-size: .74rem; color: #8a5a20; background: var(--gold-soft); border-top: 1px solid #eadfc4; padding: 8px 14px; }
.agent-warn code { background: #fff; }

.agent-form { display: flex; gap: 8px; padding: 11px 12px; border-top: 1px solid var(--line); background: #fff; }
.agent-form input { flex: 1; min-width: 0; font: inherit; font-size: .88rem; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fdfbf7; color: var(--ink); }
.agent-form input:focus { outline: none; border-color: var(--green); background: #fff; }
.agent-form input:disabled { opacity: .6; }
.agent-send { border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: .85rem; color: #fff; background: var(--cherry); cursor: pointer; }
.agent-send:hover:not(:disabled) { background: var(--cherry-dark); }
.agent-send:disabled { background: #d9cfc6; cursor: default; }

@media (max-width: 640px) {
    .agent { right: 14px; bottom: 14px; }
    .agent-panel { width: calc(100vw - 28px); height: calc(100vh - 110px); }
}
