/* Grain Marketing v2 — page styles (v2-only; v1 keeps its inline styles) */

.grain-layout { display: flex; flex: 1; overflow: hidden; height: calc(100dvh - 60px); }
.grain-left {
  width: 280px; min-width: 280px; background: white; display: flex; flex-direction: column;
  overflow-y: auto; border-right: 1px solid #E8DFD0;
}
.grain-center { flex: 1; overflow-y: auto; background: var(--bg); padding: 24px; }
.grain-loading { display: flex; align-items: center; padding: 40px 20px; }

.grain-left-header {
  padding: 13px 16px; font-family: var(--font-body); font-size: 13px; font-weight: 500;
  color: var(--accent); letter-spacing: .04em; background: var(--sidebar); flex-shrink: 0;
}
.grain-nav { padding: 6px 0; border-bottom: 1px solid #E8DFD0; }
.gm-nav-item {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 16px;
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  border-left: 3px solid transparent; transition: all .15s; cursor: pointer;
}
.gm-nav-item:hover { background: #FAF7F2; color: var(--text); }
.gm-nav-item.active { border-left-color: var(--accent); background: var(--bg); color: var(--text); font-weight: 600; }
.gm-alert-count {
  display: inline-flex; align-items: center; justify-content: center; background: var(--rust);
  color: white; border-radius: 100px; font-size: 10px; font-weight: 700; min-width: 18px;
  height: 18px; padding: 0 5px; line-height: 1;
}
.grain-left-section { padding: 12px 16px; border-bottom: 1px solid #F0EBE3; }
.gl-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.gl-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.gl-row .c { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.gl-row .v { font-family: var(--font-mono); font-size: 11px; color: var(--text); }

/* Section header + cards */
.g-section-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; gap: 14px; }
.g-section-title { font-family: var(--font-head); font-size: 22px; color: var(--text); }
.g-section-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; max-width: 720px; }
.g-card {
  background: white; border: 1px solid #A89880; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(44,24,16,.06); overflow: hidden; margin-bottom: 16px;
}
.g-card-header { background: var(--sidebar); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.g-card-title { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.g-card-body { padding: 16px; overflow-x: auto; }
.g-qn { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; border-radius: 50%; background: var(--accent); color: var(--sidebar); font-size: 11px; font-weight: 700; flex-shrink: 0; }
.g-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.g-grid2 .g-card { margin-bottom: 0; }
@media (max-width: 980px) { .g-grid2 { grid-template-columns: 1fr; } }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid3 { grid-template-columns: 1fr; } }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1280px) { .grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .grid4 { grid-template-columns: 1fr; } }

/* Buttons */
.g-btn-primary { background: var(--sidebar); color: var(--accent); border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-family: var(--font-body); font-weight: 500; cursor: pointer; transition: opacity .15s; }
.g-btn-primary:hover { opacity: .88; }
.g-btn-primary.sm { padding: 5px 12px; font-size: 12px; }
.g-btn-secondary { background: white; color: var(--text); border: 1px solid #A89880; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-family: var(--font-body); cursor: pointer; transition: background .12s; }
.g-btn-secondary:hover { background: #F5F0E8; }
.g-btn-secondary.sm { padding: 4px 11px; font-size: 12px; }

/* Tables */
.g2-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.g2-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); text-align: left; padding: 5px 8px; border-bottom: 1.5px solid var(--border); font-weight: 500; }
.g2-table td { padding: 7px 8px; border-bottom: 1px solid #F0EBE3; vertical-align: middle; }
.g2-table tr:last-child td { border-bottom: none; }
.g2-table td.n, .g2-table th.n { text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
.g2-pos { color: var(--sage); font-weight: 600; }
.g2-neg { color: var(--rust); font-weight: 600; }

/* Chips / verdicts */
.g2-chip { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 2px 10px; line-height: 1.6; }
.g2-chip.ok { background: var(--sage-bg); color: var(--sage); }
.g2-chip.warn { background: #FBF3E2; color: #8a6a1f; }
.g2-chip.bad { background: var(--rust-bg); color: var(--rust); }
.g2-chip.auto { background: #EEF2F6; color: #4a6072; font-weight: 500; }
.g2-chip.you { background: rgba(200,169,110,.18); color: #7A5C00; font-weight: 500; }
.g2-verdict { border-left: 4px solid var(--sage); background: var(--sage-bg); border-radius: 8px; padding: 9px 13px; font-size: 13px; margin-top: 12px; }
.g2-verdict.warn { border-left-color: var(--rust); background: var(--rust-bg); }
.g2-note { font-size: 11.5px; color: var(--text-muted); background: #FDFBF7; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 12px; margin-top: 12px; line-height: 1.55; }

/* Stock-in-stock strip */
.g2-stock-strip { display: flex; gap: 12px; flex-wrap: wrap; background: white; border: 1px solid #E8DFD0; border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.g2-stock-item { display: flex; flex-direction: column; gap: 2px; min-width: 110px; }
.g2-stock-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.g2-stock-val { font-family: var(--font-mono); font-size: 15px; color: var(--text); }

/* Bin cards — fill % is ALWAYS total contents across every crop year */
.g2-bin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.g2-bin-card { background: white; border: 1px solid #A89880; border-radius: 10px; box-shadow: 0 2px 8px rgba(44,24,16,.06); overflow: hidden; }
.g2-bin-head { padding: 12px 16px 4px; display: flex; justify-content: space-between; align-items: baseline; }
.g2-bin-name { font-family: var(--font-head); font-size: 16px; }
.g2-bin-cap { font-size: 11px; color: var(--text-muted); }
.g2-bin-fillwrap { padding: 0 16px 6px; }
.g2-bin-fill { height: 10px; background: #EDE7DB; border-radius: 5px; overflow: hidden; }
.g2-bin-fill div { height: 100%; background: var(--sage); border-radius: 5px; }
.g2-bin-fillmeta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.g2-bin-fillmeta .mono { font-family: var(--font-mono); color: var(--text); }
.g2-bin-card details { border-top: 1px solid #F0EBE3; }
.g2-bin-card summary { padding: 9px 16px; font-size: 12px; color: var(--text-muted); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.g2-bin-card summary::-webkit-details-marker { display: none; }
.g2-bin-card summary .g2-caret { display: inline-block; font-size: 12px; font-weight: 700; color: var(--text-muted); transition: transform .15s; }
.g2-bin-card details[open] summary .g2-caret { transform: rotate(90deg); }
.g2-lot-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.g2-lot-table th { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); text-align: left; padding: 4px 16px 4px 16px; border-bottom: 1px solid #F0EBE3; font-weight: 500; }
.g2-lot-table td { padding: 5px 16px; border-bottom: 1px solid #F7F3EB; }
.g2-lot-table td.n, .g2-lot-table th.n { text-align: right; font-family: var(--font-mono); font-size: 11.5px; }
.g2-lot-year { display: inline-block; font-size: 10px; font-weight: 700; background: rgba(200,169,110,.2); color: #7A5C00; border-radius: 4px; padding: 0 5px; margin-right: 5px; }
.g2-lot-nofield { color: var(--text-muted); font-style: italic; }

/* Position bucket bar + legend */
.g-pos-bar { height: 16px; border-radius: 8px; overflow: hidden; background: #E8DFD0; display: flex; margin: 4px 0 10px; }
.g-pos-bar div { height: 100%; min-width: 4px; }
.leg { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-muted); }
.leg span i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.c-set { background: #3D5C42; }
.c-com { background: #6a8f6f; }
.c-hedged { background: #C8A96E; }
.c-naked { background: #e0d5bf; }

/* Crop switcher pills */
.cpill { padding: 5px 16px; border-radius: 20px; border: 1.5px solid var(--border); font-size: 13px; font-weight: 500; cursor: pointer; background: white; display: inline-block; }
.cpill.on { background: var(--sidebar); color: var(--accent); border-color: var(--sidebar); }

/* Seasonal basis chart */
.bchart { display: flex; align-items: flex-end; gap: 5px; height: 110px; padding: 6px 4px 0; }
.bchart .bc { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; font-size: 9.5px; color: var(--text-muted); height: 100%; }
.bchart .bar { width: 100%; background: #d8cdb8; border-radius: 3px 3px 0 0; }
.bchart .bar.typ { background: var(--sage); }

/* Chip variants used by views */
.g2-chip.info { background: #EFEAF7; color: #5b4a8a; }

/* Info icon + tooltip (opens BELOW the icon — cards clip anything above their
   header, and first-row icons would collide with it) */
.g2-info { text-transform: none; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #A99B85; color: #fff; font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 11px; font-weight: 600; margin-left: 1px; cursor: help; position: relative; vertical-align: middle; flex-shrink: 0; line-height: 1; padding-right: 1px; }
/* Tips render in a fixed body-level layer (see main.js) so no card/table/
   modal overflow container can ever clip them. */
.g2-tipbox { position: fixed; z-index: 4000; display: none; background: #FDFBF7; color: var(--text); border: 1px solid var(--border-mid); padding: 9px 12px; border-radius: 8px; font-family: var(--font-body); font-style: normal; font-size: 11.5px; font-weight: 400; width: min(330px, 75vw); text-align: left; line-height: 1.55; box-shadow: 0 6px 20px rgba(44,24,16,.18); pointer-events: none; }
.g2-tipbox p { margin: 0; }
.g2-tipbox p + p, .g2-tipbox ul + p { margin-top: 7px; }
.g2-tipbox ul { margin: 6px 0 0; padding-left: 17px; }
.g2-tipbox li { margin: 5px 0; padding-left: 2px; }
.g2-tipbox li::marker { color: var(--accent); }
.g2-tipbox b { font-weight: 600; }
/* bottom-of-card icons open upward (the card's overflow clips downward tips there) */
/* right-side columns: open leftward so the tip stays on screen */



/* Inline add-forms (hedging / plan / basis) — same field language as modals */
.g2-inline-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 14px; align-items: end; margin-top: 12px; }
.g2-inline-form .g2-field input, .g2-inline-form .g2-field select { width: 100%; text-align: left; font-family: var(--font-body); font-size: 13px; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; background: white; color: var(--text); }
.g2-inline-form .g2-field input[type=number] { font-family: var(--font-mono); }
.g2-inline-form .g-btn-primary { height: 36px; }

/* Contract row expando chevron */
.g2-cx-toggle { background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 700; line-height: 1; color: var(--text-muted); transition: transform .15s; padding: 2px 4px; }
.g2-cx-toggle.open { transform: rotate(90deg); color: var(--text); }

/* Settings inputs */
.g2-input { font-family: var(--font-mono); font-size: 13px; padding: 5px 9px; border: 1.5px solid var(--border); border-radius: 8px; background: white; color: var(--text); width: 90px; text-align: right; }

/* Modal */
.g2-overlay { position: fixed; inset: 0; background: rgba(28,18,8,.45); z-index: 400; display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.g2-overlay.open { display: flex; }
.g2-modal { background: white; border-radius: 12px; box-shadow: 0 8px 40px rgba(44,24,16,.25); width: 100%; max-width: 560px; overflow: hidden; }
.g2-modal-head { background: var(--sidebar); color: var(--accent); padding: 12px 18px; font-size: 14px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.g2-modal-close { background: none; border: none; color: var(--accent); font-size: 18px; cursor: pointer; line-height: 1; }
.g2-modal-body { padding: 18px; }
.g2-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.g2-form-grid .full { grid-column: 1 / -1; }
.g2-field label { display: flex; align-items: center; min-height: 17px; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
/* In form cells the info icon sits flush right so icons align uniformly */
.g2-field label .g2-info-w { margin-left: auto; }
.g2-field input, .g2-field select { width: 100%; text-align: left; font-family: var(--font-body); font-size: 13px; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; background: white; color: var(--text); }
.g2-field input[type=number] { font-family: var(--font-mono); }
.g2-modal-err { color: var(--rust); font-size: 12.5px; margin-top: 10px; display: none; }
.g2-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (max-width: 700px) {
  .grain-left { display: none; }
  .grain-center { padding: 14px; }
  .g2-bin-grid { grid-template-columns: 1fr; }
}

/* left-rail v1 link */
.gl-link { font-size: 11px; color: var(--text-muted); text-decoration: none; cursor: pointer; }
.gl-link:hover { color: var(--text); }

/* collapsible g-cards (toolbox, cancelled contracts): no native triangle */
details.g-card > summary { list-style: none; }
details.g-card > summary::-webkit-details-marker { display: none; }
details.g-card > summary::before { content: '❯'; display: inline-block; color: var(--text-muted); font-size: 12px; font-weight: 700; margin-right: 7px; transition: transform .15s; }
details.g-card[open] > summary::before { transform: rotate(90deg); }

/* Standard: every dollar-entry box carries a $ inside the box */
.g2-usd { position: relative; display: inline-block; vertical-align: middle; }
.g2-field .g2-usd, .g2-form-grid .g2-usd { display: block; }
.g2-usd::before { content: '$'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--text-muted); pointer-events: none; font-family: var(--font-mono); }
.g2-usd > input { padding-left: 22px !important; }

/* Borderless inline icon buttons (edit pencils etc.) */
.g2-icon-btn { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 2px 4px; vertical-align: middle; }
.g2-icon-btn:hover { color: var(--text); }

/* Crop card bar (season flow, left→right) + threshold tick marks */
.g2-cardbar-wrap { position: relative; margin-top: 6px; }
.g2-cardbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: #F5F0E8; }
.g2-cardbar i { display: block; height: 100%; }
.g2-tick { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px dashed var(--sidebar); opacity: .65; }
.g2-tick em { position: absolute; top: 100%; left: -2px; transform: translateX(-50%); font-style: normal; font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }
details.g-card > summary.g-card-header { list-style: none; }
details.g-card > summary.g-card-header::-webkit-details-marker { display: none; }

/* Crop card sections: related lines read as one group */
.g2-cs + .g2-cs { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.g2-cs-label { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 7px; }

/* Nav tree: groups load open, remember how they were left */
.gm-nav-parent { display: flex; align-items: center; justify-content: space-between; padding: 9px 16px; border-left: 3px solid transparent; font-size: 13px; color: var(--text-muted); cursor: pointer; user-select: none; }
.gm-nav-parent:hover { color: var(--text); }
.gm-nav-chev { font-size: 11px; font-weight: 700; transition: transform .15s; }
.gm-nav-group.open .gm-nav-chev { transform: rotate(90deg); }
.gm-nav-children { display: none; }
.gm-nav-group.open .gm-nav-children { display: block; }
.gm-nav-item.sub { padding-left: 28px; font-size: 12.5px; }
.gm-bell { float: right; cursor: pointer; font-size: 14px; position: relative; text-decoration: none; }
.gm-bell .gm-alert-count { position: absolute; top: -6px; right: -8px; }
.gm-bell.on { filter: drop-shadow(0 0 2px var(--accent)); }

/* Stock strip: year groups with crop chips — scales past a couple of crops */
.g2-stock-group { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; padding-left: 16px; border-left: 1px solid var(--border-mid); }
.g2-stock-group.old .g2-stock-val { color: var(--text-muted); }
.g2-stock-year { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; align-self: flex-start; white-space: nowrap; }

/* Home whole-farm strip: 3 fixed columns, per-crop split under each number */
.g2-farm-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; background: white; border: 1px solid #E8DFD0; border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; }
.g2-fs-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.g2-fs-cell + .g2-fs-cell { border-left: 1px solid var(--border); padding-left: 20px; }
.g2-fs-sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
@media (max-width: 900px) { .g2-farm-strip { grid-template-columns: 1fr; } .g2-fs-cell + .g2-fs-cell { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 10px; } }
