/* Farmer's Ally: friendly full-width layout, collapsible menu, dividers (v21) */
:root { --topbar-h: 64px; --sidebar-w: 268px; --gutter: clamp(10px, 1.4vw, 20px); }

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; display: flex; flex-direction: column; }
img, svg, video { max-width: 100%; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 16px; border-radius: 12px; background: var(--forest-900); color: #fff; font-weight: 800; text-decoration: none; }
.skip-link:focus { top: 10px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 14px;
  background: rgba(253, 252, 248, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar .brand { min-width: 0; gap: 10px; }
.topbar .brand-logo { width: 44px; height: 44px; }
.topbar .brand-copy strong { font-size: 1.02rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }

.menu-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 16px 0 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--forest-800);
  font: inherit; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.menu-toggle:hover { background: var(--leaf-50); }
.menu-toggle:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.burger { width: 20px; display: grid; gap: 4px; }
.burger i { display: block; height: 2.5px; border-radius: 3px; background: currentColor; transition: transform .2s ease, opacity .2s ease; }
body[data-nav="open"] .burger i:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
body[data-nav="open"] .burger i:nth-child(2) { opacity: 0; }
body[data-nav="open"] .burger i:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.avatar { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-100); color: var(--warning); font-weight: 900; border: 2px solid var(--gold-500); }
.user-chip { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip-text { display: grid; line-height: 1.2; min-width: 0; }
.user-chip-text strong, .side-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--forest-900); }
.user-chip-text small, .side-user-text small { color: var(--ink-500); font-weight: 700; }
.user-chip-text strong { max-width: 190px; }

/* ---------- Page shell ---------- */
.layout { flex: 1; width: 100%; display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.content { flex: 1 1 auto; min-width: 0; min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; }
.layout .container { width: 100%; max-width: none; margin: 0; padding: clamp(18px, 2.8vw, 36px) var(--gutter) 48px; flex: 1; }

/* ---------- Side menu ---------- */
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column;
  padding: 18px 14px; overflow-y: auto;
  background: var(--white); border-right: 1px solid var(--line);
}
body[data-nav="closed"] .sidebar { display: none; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-title { margin: 8px 10px 4px; color: var(--ink-500); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 10px 14px;
  border-radius: 14px; color: var(--ink-700);
  font-weight: 750; text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.side-link:hover { background: var(--leaf-50); color: var(--forest-800); transform: translateX(2px); }
.side-link:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 1px; }
.side-link.active { background: var(--leaf-100); color: var(--forest-900); box-shadow: inset 4px 0 0 var(--forest-700); }
.side-icon { width: 28px; flex: 0 0 28px; text-align: center; font-size: 1.2rem; }
.side-label { flex: 1; }
.side-link .nav-badge { margin-left: auto; }
.side-divider { height: 1px; margin: 12px 4px; border: 0; background: var(--line); }
.side-foot { margin-top: auto; padding-top: 6px; position: sticky; bottom: -18px; padding-bottom: 18px; background: var(--white); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; text-decoration: none; min-width: 0; }
a.side-user:hover { background: var(--leaf-50); }
.side-user-text { display: grid; line-height: 1.25; min-width: 0; }
.side-logout { margin: 10px 0 0; }
.side-logout .button { justify-content: center; }
.side-close { display: none; }
.scrim { display: none; }

/* Small screens: the menu slides over the page */
@media (max-width: 999px) {
  .sidebar {
    position: fixed; z-index: 90; top: 0; left: 0; bottom: 0;
    width: min(86vw, 310px); height: auto;
    padding-top: 14px; box-shadow: var(--shadow-md);
    transform: translateX(-104%); visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  body[data-nav="closed"] .sidebar { display: flex; }
  body[data-nav="open"] .sidebar { transform: none; visibility: visible; transition: transform .25s ease; }
  body[data-nav="open"] .scrim { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(18, 50, 38, .45); }
  body[data-nav="open"] { overflow: hidden; }
  .side-close { display: inline-flex; align-self: flex-end; margin-bottom: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--forest-800); font: inherit; font-weight: 800; cursor: pointer; }
  .user-chip-text, .brand-copy small { display: none; }
}
@media (max-width: 560px) {
  .menu-toggle-text { display: none; }
  .menu-toggle { padding: 0 13px; }
  .topbar .brand-copy strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right .button { padding-inline: 12px; }
  .topbar-right .button.secondary { display: none; }
}

/* ---------- Dividers on every page ---------- */
.divider { height: 1px; margin: 0; border: 0; background: var(--line); }
.footer-divider { margin: 0 var(--gutter); }
.pagehead { padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pagehead.compact { padding-bottom: 14px; }
.section-heading { padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.section-block { margin-top: 34px; padding-top: 28px; border-top: 1px solid var(--line); }
footer { padding: 18px var(--gutter) 26px; }
.footer-inner { width: 100%; padding-top: 0; border-top: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }

/* ---------- Friendly look ---------- */
body { font-size: 16px; line-height: 1.55; }
.panel, .card, .stat, .form-card { border-radius: 20px; }
.card, .stat { transition: transform .18s ease, box-shadow .18s ease; }
.card:hover, .stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.button { border-radius: 14px; min-height: 46px; }
.button.small { min-height: 40px; }
input, select, textarea { border-radius: 12px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .button:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.cards, .stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)) !important; }
.tablewrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tip-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; margin: 0 0 22px; padding: 16px 20px; border-radius: 18px; border: 1px solid var(--gold-500); background: var(--gold-100); }
.tip-card p { margin: 0; color: var(--ink-900); }
.tip-card strong { color: var(--warning); }
.hero { margin-top: 0; }

/* ---------- Log in and Create account ---------- */
.auth-layout { width: 100%; max-width: 1100px; }
.reg-wrap { width: 100%; max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: clamp(16px, 2.5vw, 32px); align-items: start; }
.reg-aside, .reg-card { min-width: 0; }
.reg-aside { position: sticky; top: calc(var(--topbar-h) + 24px); min-height: 0; }
.reg-card { margin: 0; max-width: none; }
.reg-card h1 { margin-bottom: 4px; }
.auth-aside .eyebrow, .auth-aside .kicker { color: var(--gold-100); gap: 14px; }
.auth-aside .eyebrow::before, .auth-aside .kicker::before { margin-left: 5px; flex: none; }
.reg-form { align-items: start; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; margin-top: 18px; }
.reg-form .span-2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-top: 6px; color: var(--forest-800); font-size: .8rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 !important; color: var(--forest-800); font-weight: 750; }
.field input, .field select { width: 100%; margin: 0; box-sizing: border-box; }
.field .hint { color: var(--ink-500); font-size: .82rem; font-weight: 500; }
.field .optional { color: var(--ink-500); font-weight: 500; }
.field[hidden], [data-trader-only][hidden] { display: none !important; }
.role-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.role-card { position: relative; display: block; margin: 0 !important; }
.role-card input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.role-body { display: flex; align-items: flex-start; gap: 12px; height: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--white); transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.role-body .role-emoji { font-size: 1.6rem; line-height: 1; }
.role-body strong { display: block; color: var(--forest-900); }
.role-body small { display: block; color: var(--ink-500); font-weight: 500; }
.role-card:hover .role-body { border-color: var(--leaf-500); }
.role-card input:checked + .role-body { border-color: var(--forest-700); background: var(--leaf-50); box-shadow: 0 0 0 4px var(--leaf-100); }
.role-card input:focus-visible + .role-body { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.pw-rules { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 10px; margin: -6px 0 0; padding: 0; list-style: none; }
.pw-rules li { padding: 5px 12px; border-radius: 999px; background: var(--cream-100); border: 1px solid var(--line); color: var(--ink-500); font-size: .85rem; font-weight: 700; }
.pw-rules li::before { content: "○ "; }
.pw-rules li.ok { background: var(--leaf-100); border-color: var(--leaf-500); color: var(--forest-800); }
.pw-rules li.ok::before { content: "✓ "; }
.reg-submit { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.reg-submit .button { justify-content: center; min-height: 52px; font-size: 1.05rem; }
.reg-note { margin: 0; color: var(--ink-500); font-size: .88rem; text-align: center; }
.reg-note a, .reg-card .form-footer a { color: var(--forest-700); font-weight: 800; }
.reg-card .form-footer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 899px) {
  .reg-wrap { grid-template-columns: minmax(0, 1fr); }
  .reg-aside { position: relative; top: auto; }
  .reg-aside .auth-benefits { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
}
@media (max-width: 620px) {
  .reg-form { grid-template-columns: 1fr; }
  .role-choice { grid-template-columns: 1fr; }
  .auth-aside { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .side-link, .card, .stat, .burger i { transition: none !important; }
}
