/* KITE Agro — Farm Record Book (assets/js/farm-record-book.js) */
.frb-section{padding:28px 0 40px}
.frb-wrap{max-width:980px}
#frbApp{background:#fff;border:1px solid var(--border);border-radius:20px;box-shadow:0 10px 30px -18px rgba(42,29,12,.4);overflow:hidden}
.frb-start{text-align:center;padding:34px 22px 30px}
.frb-start-ic{font-size:46px;line-height:1}
.frb-start h2{margin:10px 0 8px;font-size:clamp(21px,3vw,26px)}
.frb-start p{max-width:560px;margin:0 auto 14px;color:var(--ink-soft);line-height:1.6}
.frb-crops{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin:0 0 20px}
.frb-crops span{background:var(--cream-deep);border-radius:999px;padding:6px 14px;font-weight:600;font-size:14px}
.frb-big{min-height:50px;font-size:16px;padding:12px 22px;justify-content:center}

.frb-tabs{display:flex;gap:4px;padding:8px;background:var(--cream-deep);overflow-x:auto;scrollbar-width:none}
.frb-tabs::-webkit-scrollbar{display:none}
.frb-tab{flex:1 0 auto;border:0;background:transparent;font:inherit;font-weight:700;font-size:14px;padding:11px 14px;border-radius:12px;color:var(--ink-soft);cursor:pointer;white-space:nowrap;min-height:44px}
.frb-tab.on{background:#fff;color:var(--rust-deep);box-shadow:0 2px 6px rgba(42,29,12,.12)}
.frb-panel{padding:20px 22px 24px}
.frb-h{font-size:17px;margin:20px 0 10px}
.frb-h:first-child{margin-top:0}
.frb-empty{padding:20px 0;color:var(--ink-soft);text-align:center}
.frb-hint{font-size:13.5px;color:var(--ink-soft);line-height:1.55}
.frb-sub{font-size:12.5px;color:var(--ink-soft);margin:10px 0 4px}
.frb-inline{display:inline-flex;align-items:center;gap:8px;font-weight:600;font-size:14px}
.frb-inline select,.frb-filters select{font:inherit;font-size:15px;padding:8px 10px;border:1px solid var(--border);border-radius:10px;background:var(--cream);min-height:42px}
.neg{color:#B42318}.pos{color:#1A7F43}

.frb-remind{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:#FFF4E0;border:1px solid #F2C77A;border-radius:14px;padding:12px 14px;margin-bottom:14px}
.frb-remind > span{font-size:26px}
.frb-remind > div{flex:1 1 220px;min-width:0}
.frb-remind b{display:block}
.frb-remind small{display:block;color:var(--ink-soft);font-size:13px;line-height:1.5;margin-top:2px}
.frb-totals{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:14px 0 4px}
.frb-totals div{background:var(--cream-deep);border-radius:14px;padding:12px 14px}
.frb-totals span{display:block;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.3px;color:var(--ink-soft)}
.frb-totals b{display:block;font-size:clamp(17px,2.4vw,22px);margin-top:2px;white-space:nowrap}
.frb-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:12px}
.frb-card{border:1px solid var(--border);border-radius:16px;padding:14px 16px;border-top:5px solid #8a4b12}
.frb-card.frb-crop-coconut{border-top-color:#1B6B3A}.frb-card.frb-crop-turmeric{border-top-color:#D4A017}.frb-card.frb-crop-other{border-top-color:#6B5D48}
.frb-card.frb-crop-banana{border-top-color:#CA8A04}.frb-card.frb-crop-pepper{border-top-color:#1F2937}.frb-card.frb-crop-nutmeg{border-top-color:#92400E}.frb-card.frb-crop-cocoa{border-top-color:#7C2D12}.frb-card.frb-crop-coffee{border-top-color:#57301A}.frb-card.frb-crop-mango{border-top-color:#EA580C}.frb-card.frb-crop-jackfruit{border-top-color:#65A30D}.frb-card.frb-crop-sugarcane{border-top-color:#0E7490}
.frb-card h3{margin:0 0 8px;font-size:17px}
.frb-card h3 small{font-size:12.5px;font-weight:500;color:var(--ink-soft)}
.frb-card dl{margin:0;display:grid;gap:6px}
.frb-card dl div{display:flex;justify-content:space-between;gap:10px;align-items:baseline}
.frb-card dt{font-size:13.5px;color:var(--ink-soft)}
.frb-card dd{margin:0;font-weight:700;text-align:right}
.frb-card dd small{display:block;font-size:11.5px;font-weight:500;color:var(--ink-soft)}
.frb-harv{margin:0;padding-left:18px;font-size:13.5px;line-height:1.6}
.frb-table-wrap{overflow-x:auto}
.frb-table{width:100%;border-collapse:collapse;font-size:14px}
.frb-table th,.frb-table td{padding:8px 10px;border-bottom:1px solid var(--border);text-align:right;white-space:nowrap}
.frb-table th:first-child,.frb-table td:first-child{text-align:left}
.frb-table th{font-size:12px;text-transform:uppercase;letter-spacing:.3px;color:var(--ink-soft)}

.frb-types{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin-bottom:6px}
.frb-type{display:flex;align-items:center;gap:8px;min-width:0;overflow-wrap:break-word;border:1.5px solid var(--border);background:var(--cream);border-radius:12px;padding:10px 12px;font:inherit;font-size:14px;font-weight:600;color:var(--ink);cursor:pointer;text-align:left;min-height:48px;line-height:1.3}
.frb-type span{font-size:20px}
.frb-type.on{border-color:var(--rust);background:var(--gold-pale)}
.frb-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
.frb-field label{display:block;font-size:12.5px;font-weight:700;color:var(--ink-soft);margin-bottom:5px}
.frb-field input,.frb-field select,.frb-field textarea{width:100%;font:inherit;font-size:16px;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:var(--cream);min-height:46px;box-sizing:border-box}
.frb-field textarea{min-height:64px;resize:vertical}
.frb-wide{grid-column:1/-1}
.frb-calc{font-weight:700;margin:12px 0 0;min-height:1.2em;color:var(--rust-deep)}
.frb-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:14px}
.frb-toast{font-weight:700;color:#1A7F43}
.frb-plotform{margin-top:14px;padding-top:14px;border-top:1px dashed var(--border)}

.frb-filters{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}
.frb-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.frb-item{display:grid;grid-template-columns:auto 1fr auto;gap:4px 12px;align-items:center;border:1px solid var(--border);border-radius:14px;padding:10px 12px}
.frb-item-ic{font-size:22px;grid-row:span 2}
.frb-item-main{min-width:0;font-size:14.5px;line-height:1.4}
.frb-item-main small{display:block;color:var(--ink-soft);font-size:12.5px;overflow-wrap:anywhere}
.frb-item-amt{text-align:right;font-size:14.5px;white-space:nowrap}
.frb-item-amt b{display:block}
.frb-item-btns{grid-column:2/-1;display:flex;gap:6px;justify-content:flex-end}
.frb-item-btns button{font:inherit;font-size:13px;padding:6px 12px;border-radius:8px;border:1px solid var(--border);background:var(--cream);cursor:pointer;min-height:36px}

.frb-files{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:10px}
.frb-backup{margin-top:18px;padding:14px 16px;border-radius:14px;background:var(--cream-deep);font-size:14px;line-height:1.55}
.frb-backup p{margin:0 0 6px}
.frb-file{cursor:pointer}

/* ── Online save ─────────────────────────────────────────────────────── */
.frb-cloud{display:block;width:100%;margin:0 0 10px;padding:8px 14px;border:0;border-radius:12px;font:600 13px/1.45 'Inter',system-ui,sans-serif;text-align:left;cursor:pointer;background:#E8F5EC;color:#14532D}
/* Two lines reserved while online: "Saving online…" (1 line) and "Saved online · number · last saved" (2 lines on a phone) swap after every save, and the height change pushed the whole book up/down (CLS). */
.frb-cloud:not(.off){display:flex;align-items:center;min-height:calc(2.9em + 16px)}
.frb-cloud.off{background:#F1EEE7;color:#4A3F34}
.frb-cloud.warn{background:#FFF4E0;color:#8A4B12}
.frb-start-cloud{max-width:560px;margin:16px auto 0;font-size:13.5px;line-height:1.6;color:var(--ink-soft)}
.frb-start-cloud a{color:var(--rust)}
.frb-linkbtn{border:0;background:none;padding:0;font:inherit;font-weight:700;color:var(--rust);text-decoration:underline;cursor:pointer}
.frb-cloudcard{border:1px solid #BFE3CB;background:#F3FBF5;border-radius:16px;padding:14px 16px;margin:4px 0 18px}
.frb-cloudcard.off{border-color:var(--border);background:#FBF8F2}
.frb-cloudcard h3{margin:0 0 6px;font-size:17px}
.frb-cloudcard p{margin:0 0 8px;font-size:14px;line-height:1.6}
.frb-cloudnum{display:grid;gap:6px;margin:6px 0 10px}
.frb-cloudnum[hidden]{display:none}
.frb-cloudnum span{display:flex;gap:8px;flex-wrap:wrap}
.frb-cloudnum input{flex:1 1 200px;min-height:44px;padding:8px 12px;border:1px solid var(--border);border-radius:10px;font:inherit;font-size:16px}
.frb-err{color:#B42318;font-size:13px}

/* ── Harvest: sold right away · stock ─────────────────────────────── */
.frb-soldnow{margin:4px 0 12px;padding:12px 14px;border:1px dashed #9BD3AE;border-radius:14px;background:#F3FBF5}
.frb-check{display:flex;gap:10px;align-items:flex-start;cursor:pointer}
.frb-check input{width:22px;height:22px;margin:1px 0 0;flex:none;accent-color:#1B6B3A}
.frb-check b{display:block;font-size:15px}
.frb-check small{display:block;font-size:12.5px;color:var(--ink-soft);line-height:1.45}
#frbSoldBox{margin-top:10px}
#frbSoldBox[hidden]{display:none}
.frb-harv li{display:flex;flex-direction:column;gap:1px;margin-bottom:5px}
.frb-harv li small{font-size:12.5px;color:var(--ink-soft)}
.frb-harv .frb-stock{color:#1B6B3A}

/* ── Charts ──────────────────────────────────────────────────────────── */
.frb-charts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:6px 0 8px}
.frb-chartbox{background:#fff;border:1px solid var(--border);border-radius:18px;padding:14px 16px 12px;box-shadow:0 8px 22px -18px rgba(42,29,12,.45)}
.frb-chartwide{grid-column:1/-1}
.frb-chartbox h4{margin:0 0 8px;font-size:15px;color:var(--ink)}
.frb-chart{display:block;width:100%;height:auto}
.frb-chart text{font:11px 'Inter',system-ui,sans-serif;fill:#6B5D4C}
.frb-chart .g{stroke:#EFE5D2;stroke-width:1}
.frb-chart .z{stroke:#CDBB98;stroke-width:1.2}
.frb-chart rect.exp{fill:url(#frbGExp)}
.frb-chart rect.inc{fill:url(#frbGInc)}
.frb-chart .pl{fill:none;stroke:#7C3AED;stroke-width:2.4;stroke-linejoin:round;stroke-linecap:round}
.frb-chart .pd{fill:#7C3AED;stroke:#fff;stroke-width:2}
.frb-chart .pd.n{fill:#B42318}
.frb-key{display:flex;flex-wrap:wrap;gap:6px 16px;margin:8px 0 0;font-size:12.5px;color:var(--ink-soft)}
.frb-key span{display:inline-flex;align-items:center;gap:6px}
.frb-key i{width:12px;height:12px;border-radius:4px;display:inline-block}
.frb-key i.exp{background:linear-gradient(#F97316,#C2410C)}
.frb-key i.inc{background:linear-gradient(#4ADE80,#15803D)}
.frb-key i.pl{height:3px;border-radius:2px;background:#7C3AED}
.frb-ringwrap{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.frb-ring{width:150px;height:150px;flex:none}
.frb-ring circle{fill:none;stroke-width:22}
.frb-ring circle.bg{stroke:#F1EBDD}
.frb-ring .t1{font:700 17px 'Inter',system-ui,sans-serif;fill:var(--ink)}
.frb-ring .t2{font:600 10.5px 'Inter',system-ui,sans-serif;fill:#6B5D4C;text-transform:uppercase;letter-spacing:.4px}
.frb-legend{list-style:none;margin:0;padding:0;display:grid;gap:6px;flex:1 1 180px;min-width:0}
.frb-legend li{display:grid;grid-template-columns:12px minmax(0,1fr) auto;align-items:center;gap:8px;font-size:13px}
.frb-legend i{width:12px;height:12px;border-radius:50%}
.frb-legend b{text-align:right;white-space:nowrap;font-size:13.5px}
.frb-legend small{display:block;font-size:11px;font-weight:500;color:var(--ink-soft)}
.frb-cp{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px;padding:9px 10px;border-radius:14px;background:var(--cream-deep);margin-bottom:8px}
.frb-cp-ic{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#fff;font-size:21px}
.frb-cp-main{display:grid;gap:5px;min-width:0}
.frb-cp-main b{font-size:14px}
.frb-cp-bars{display:grid;gap:3px}
.frb-cp-bars i{display:block;height:7px;border-radius:4px;min-width:2px}
.frb-cp-bars i.exp{background:linear-gradient(90deg,#F97316,#C2410C)}
.frb-cp-bars i.inc{background:linear-gradient(90deg,#4ADE80,#15803D)}
.frb-cp-p{font-size:14.5px;white-space:nowrap}
@media (max-width:700px){ .frb-charts{grid-template-columns:1fr} }
@media (max-width:420px){ .frb-ring{width:130px;height:130px} }

@media (max-width:560px){
  /* all five tabs visible: wrap onto two rows instead of hiding some off to the side */
  .frb-tabs{flex-wrap:wrap;overflow:visible}
  .frb-tab{flex:1 1 30%;padding:10px 6px;font-size:13.5px;white-space:normal;line-height:1.25}
  .frb-types{grid-template-columns:1fr 1fr}
  .frb-type{font-size:13px;gap:6px;padding:8px 10px}
  .frb-type span{font-size:17px}
  .frb-panel{padding:16px 14px 20px}
  .frb-totals{grid-template-columns:1fr}
  .frb-totals div{display:flex;justify-content:space-between;align-items:baseline}
  .frb-grid{grid-template-columns:1fr 1fr}
  .frb-grid .frb-field:has(textarea),.frb-grid .frb-field:has(input[type="date"]){grid-column:1/-1}
}
@media (max-width:360px){ .frb-grid{grid-template-columns:1fr} }

/* ── Print: only the print area, with KITE Agro header/footer on every page ── */
#frbPrintArea{display:none}
@media print{
  body.frb-printing > *:not(#frbPrintArea){display:none !important}
  body.frb-printing #frbPrintArea{display:block}
  @page{size:A4;margin:12mm}
  .frbp-page{page-break-after:always;font-family:'Noto Sans Tamil','Inter',Arial,sans-serif;color:#000}
  .frbp-page:last-child{page-break-after:auto}
  .frbp-head{display:flex;align-items:center;gap:10px;border-bottom:2px solid #1B6B3A;padding-bottom:6px;margin-bottom:10px}
  .frbp-head img{width:40px;height:40px;object-fit:contain}
  .frbp-head b{display:block;font-size:16px;color:#1B6B3A}
  .frbp-head span{display:block;font-size:9.5px;color:#444}
  .frbp-site{margin-left:auto;font-weight:700;font-size:12px;color:#1B6B3A}
  .frbp-page h1{font-size:18px;margin:6px 0 8px}
  .frbp-page h2{font-size:14px;margin:12px 0 6px}
  .frbp-meta,.frbp-note{font-size:10.5px;color:#444}
  .frbp-t{width:100%;border-collapse:collapse;font-size:10.5px}
  .frbp-t th,.frbp-t td{border:1px solid #999;padding:4px 6px;text-align:left;vertical-align:top}
  .frbp-t th{background:#E8F3EC}
  .frbp-blank td{height:26px}
  .frbp-form th{width:32%}
  .frbp-form td{height:24px}
  .frbp-t thead{display:table-header-group}
  .frbp-foot{margin-top:10px;border-top:1px solid #1B6B3A;padding-top:5px;font-size:9.5px;color:#222;text-align:center;line-height:1.5}
}

/* ── Easy entry: crop buttons, tap-choices, suggestions, quick "add again" ── */
.frb-cropbar{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;margin:2px 0 14px}
@media (max-width:900px){ .frb-cropbar{grid-template-columns:repeat(4,minmax(0,1fr))} }
.frb-crop{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:58px;border:1.5px solid var(--border);border-radius:14px;background:var(--cream);font:inherit;font-size:13px;font-weight:700;color:var(--ink);cursor:pointer;padding:6px 4px;text-align:center;line-height:1.2}
.frb-crop span{font-size:22px}
.frb-crop.on{border-color:#1B6B3A;background:#E6F6EC;box-shadow:0 0 0 2px #1B6B3A inset}
.frb-lab{display:block;font-size:12.5px;font-weight:700;color:var(--ink-soft);margin-bottom:6px}
.frb-chips{display:flex;flex-wrap:wrap;gap:6px}
.frb-chip{border:1.5px solid var(--border);background:#fff;border-radius:999px;padding:8px 14px;font:inherit;font-size:14px;font-weight:600;color:var(--ink);cursor:pointer;min-height:40px;line-height:1.2}
.frb-chip.on{background:#1B6B3A;border-color:#1B6B3A;color:#fff}
.frb-sugg{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.frb-chip-s{font-size:13px;padding:6px 12px;min-height:34px;background:var(--cream)}
.frb-quick{margin-bottom:12px;padding:10px 12px;border:1px dashed #9BD3AE;border-radius:14px;background:#F2FBF5}
.frb-again{background:#fff;border-color:#9BD3AE;font-size:13.5px}
.frb-opt{margin-top:12px;border:1px solid var(--border);border-radius:12px;padding:0 12px}
.frb-opt summary{cursor:pointer;font-weight:700;font-size:14px;padding:12px 0;color:var(--ink-soft)}
.frb-opt[open] summary{border-bottom:1px dashed var(--border);margin-bottom:12px}
.frb-opt .frb-grid{padding-bottom:12px}
.frb-save{min-height:50px;font-size:16px;padding:12px 28px}
@media (max-width:560px){
  .frb-cropbar{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .frb-crop{min-height:50px;font-size:12px;line-height:1.2;padding:4px 3px}
  .frb-crop span{font-size:19px}
  .frb-save{flex:1 1 100%}
}

/* Phones: the 9 record types as a compact 3 × 3 grid of icon tiles (words stay whole) */
@media (max-width:560px){
  .frb-types{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .frb-type{flex-direction:column;justify-content:center;text-align:center;gap:3px;font-size:12px;line-height:1.25;padding:8px 4px;min-height:74px;overflow-wrap:normal;word-break:normal}
  .frb-type span{font-size:22px}
}
@media (max-width:380px){ .frb-type{font-size:11px;padding:8px 2px} }

/* Empty book: a friendly welcome with the two first steps as big buttons */
.frb-welcome{text-align:center;padding:10px 4px 6px}
.frb-welcome h3{margin:0 0 6px;font-size:20px}
.frb-welcome > p{margin:0 0 14px;color:var(--ink-soft)}
.frb-welcome-btns{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.frb-welcome-btns .btn{flex:0 1 300px}
.frb-welcome-steps{text-align:left;max-width:560px;margin:18px auto 0;padding-left:20px;line-height:1.7;color:var(--ink-soft);font-size:14.5px}
@media (max-width:560px){ .frb-welcome-btns .btn{flex:1 1 100%} }
