/* =========================================================
   EggLedger – farm.css
   Farm look on top of the Khamba stylesheet (style.css):
   warm yolk + leaf-green palette, egg-tray split visual,
   fund cards, and a few helpers the farm pages need.
   ========================================================= */
:root {
  --primary: #15803d;
  --yolk: #f59e0b;
  --yolk-soft: #fef3c7;
  --leaf: #10b981;
  --owner: #6366f1;
  --sb: #10211a;
  --danger: #dc2626;
}
[data-bs-theme=dark] { --yolk-soft: #2a2110; }

body.booting .main, body.booting .sidebar { visibility: hidden }

/* ---------- brand ---------- */
.logo, .logo-egg { background: linear-gradient(135deg, #fbbf24, #d97706) }
.store-card .logo.logo-egg { background: rgba(255, 255, 255, .14) }
.sb-link.active i { color: #fbbf24 }
.sb-lock { width: 13px !important; height: 13px !important; margin-left: auto; opacity: .45 }
.sb-badge + .sb-lock { margin-left: 6px }
body.collapsed .sb-lock { display: none }
.sb-link .sb-badge { background: rgba(251, 191, 36, .2); color: #fde68a }
.avatar.av-initials { background: var(--yolk-soft); color: #b45309; font-size: 13px }
.tb-date { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500 }
.btn-sm-x { height: 40px }
.role-tag { font-weight: 700; font-size: 11px; padding: 1px 7px; border-radius: 20px }
.role-super { background: #ede9fe; color: #6d28d9 }
.role-admin { background: #dbeafe; color: #1d4ed8 }
[data-bs-theme=dark] .role-super { background: #2a1d4a; color: #c4b5fd }
[data-bs-theme=dark] .role-admin { background: #172554; color: #93c5fd }

/* ---------- buttons ---------- */
.btn-dark-x.btn-green { background: var(--primary); border-color: var(--primary); color: #fff }
.btn-danger-x { height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--danger); background: var(--danger); color: #fff; font-weight: 600 }
.btn-danger-x:hover { opacity: .9 }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px }
.icon-btn.sm svg { width: 15px; height: 15px }
.icon-btn.danger:hover { color: var(--danger); border-color: #fecaca }
.btn-soft:disabled, .btn-dark-x:disabled { opacity: .5; cursor: not-allowed }
.confirm-ico { width: 52px; height: 52px; border-radius: 50%; background: #fee2e2; color: var(--danger); display: inline-grid; place-items: center }

/* ---------- status badges the farm adds ---------- */
.s-Part { background: #dbeafe; color: #1d4ed8 }
.s-Laying { background: #fef3c7; color: #b45309 }
.s-Growing { background: #d1fae5; color: #047857 }
.s-Retired, .s-Inactive { background: #e5e7eb; color: #374151 }
.s-Scheduled { background: #dbeafe; color: #1d4ed8 }
.s-Done { background: #d1fae5; color: #047857 }
.s-Overdue { background: #fee2e2; color: #b91c1c }
[data-bs-theme=dark] .s-Part, [data-bs-theme=dark] .s-Scheduled { background: #172554; color: #93c5fd }
[data-bs-theme=dark] .s-Laying, [data-bs-theme=dark] .s-Low { background: #2a2110; color: #fbbf24 }
[data-bs-theme=dark] .s-Growing, [data-bs-theme=dark] .s-Done, [data-bs-theme=dark] .s-Delivered { background: #0d2a20; color: #34d399 }
[data-bs-theme=dark] .s-Retired, [data-bs-theme=dark] .s-Inactive { background: #262a33; color: #cbd0d8 }
[data-bs-theme=dark] .s-Overdue, [data-bs-theme=dark] .s-Critical { background: #2c1214; color: #f87171 }

/* ---------- forms in modals ---------- */
.modal-content { border: 1px solid var(--border); border-radius: 16px; background: var(--card) }
.modal-header, .modal-footer { border-color: var(--border) }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); min-height: 40px; font-size: 14px }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 128, 61, .15) }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px }
.input-group-text { border-color: var(--border); border-radius: 10px; background: var(--bg); color: var(--muted) }

/* ---------- KPI tiles ---------- */
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px }
.kpi.k-yolk { background: #fff7e0 }
[data-bs-theme=dark] .kpi.k-yolk { background: #231c0c }

/* "Today at the coop" hero */
.coop-hero { background: linear-gradient(120deg, #10211a 0%, #1f3a2b 60%, #2f4f33 100%); color: #fff; border-radius: var(--r); padding: 24px; position: relative; overflow: hidden }
.coop-hero:after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 300px; border-radius: 50% 50% 48% 48% / 58% 58% 42% 42%; background: radial-gradient(circle at 50% 60%, rgba(251, 191, 36, .45), rgba(251, 191, 36, 0) 60%) }
.coop-hero h2 { font-size: 22px; font-weight: 700; margin: 0 }
.coop-hero p { color: #b8c7bd; margin: 4px 0 0 }
.coop-hero .hs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 20px; position: relative; z-index: 1 }
.coop-hero .hs div { background: rgba(255, 255, 255, .07); border-radius: 12px; padding: 12px 14px }
.coop-hero .hs small { color: #b8c7bd; display: block; font-size: 12px }
.coop-hero .hs b { font-size: 20px; display: block; margin-top: 2px }
.coop-hero .hs em { font-style: normal; font-size: 12px; color: #fbbf24 }
@media (max-width: 767.98px) { .coop-hero .hs { grid-template-columns: repeat(2, minmax(0, 1fr)) } }

/* laying-rate ring */
.ring { --p: 0; --c: var(--yolk); width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--hover) 0); flex-shrink: 0 }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center }
.ring b { font-size: 22px; line-height: 1 }
.ring small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px }

/* ---------- the egg tray (revenue split visual) ---------- */
.tray { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; background: #d6b98c; padding: 14px; border-radius: 14px; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .15); width: 210px; flex-shrink: 0 }
[data-bs-theme=dark] .tray { background: #5b4a32 }
.tray .egg { aspect-ratio: 4/5; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #fdf6ec; box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .2); transition: background .3s, transform .2s }
.tray .egg:hover { transform: scale(1.08) }
.tray .egg.f-expense { background: #fbbf24 }
.tray .egg.f-growth { background: #34d399 }
.tray .egg.f-owner { background: #818cf8 }
.legend-x { display: flex; flex-direction: column; gap: 10px }
.legend-x .li { display: flex; align-items: center; gap: 10px }
.legend-x .sw { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0 }
.legend-x b { margin-left: auto }

/* fund cards */
.fund-card { border-radius: var(--r); border: 1px solid var(--border); background: var(--card); padding: 18px 20px; height: 100%; position: relative; overflow: hidden }
.fund-card:before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--fc) }
.fund-card .fc-top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600 }
.fund-card .fc-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--fs); color: var(--fc) }
.fund-card .fc-bal { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 12px 0 4px }
.fund-card .fc-sub { font-size: 12px; color: var(--muted) }
.fund-card .fc-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--muted) }
.fund-card .fc-row b { color: var(--text); font-weight: 600 }
[data-bs-theme=dark] .fund-card .fc-ico { background: rgba(255, 255, 255, .06) }

/* split bar */
.split-bar { display: flex; height: 12px; border-radius: 12px; overflow: hidden; background: var(--hover) }
.split-bar i { display: block; height: 100% }

/* allocation preview inside the sale form */
.alloc-preview { border: 1px dashed var(--border); border-radius: 12px; padding: 12px 14px; background: var(--bg) }
.alloc-preview .ap-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 3px 0 }
.alloc-preview .ap-row span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted) }
.alloc-preview .ap-row span i { width: 9px; height: 9px; border-radius: 50%; display: inline-block }
.alloc-preview .ap-total { font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 6px }

/* ---------- misc ---------- */
.empty-x { text-align: center; padding: 36px 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px }
.empty-x svg { width: 34px; height: 34px; opacity: .5 }
.empty-x b { color: var(--text) }
.table-x td.num, .table-x th.num { text-align: right }
.table-x tfoot td { padding: 12px; font-weight: 700; border-top: 2px solid var(--border) }
.mono { font-variant-numeric: tabular-nums }
.muted { color: var(--muted) }
.text-up { color: #059669 } .text-down { color: var(--danger) }
.lock-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px }
.lock-note svg { width: 13px; height: 13px }
.feed-card { border: 1px solid var(--border); border-radius: var(--r); background: var(--card); padding: 18px; height: 100% }
.feed-card h6 { font-weight: 700; margin: 0 }
.feed-card .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em }
.sack { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--yolk-soft); color: #b45309 }
.gauge-line { height: 8px; border-radius: 8px; background: var(--hover); overflow: hidden; margin: 10px 0 6px }
.gauge-line i { display: block; height: 100%; border-radius: 8px }
.timeline-x { list-style: none; padding: 0; margin: 0 }
.timeline-x li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border) }
.timeline-x li:last-child { border-bottom: 0 }
.tl-date { width: 52px; text-align: center; flex-shrink: 0; border-radius: 10px; background: var(--bg); padding: 6px 0; line-height: 1.1 }
.tl-date b { display: block; font-size: 17px }
.tl-date small { font-size: 11px; color: var(--muted); text-transform: uppercase }
.perm-table td, .perm-table th { white-space: normal }
.perm-yes { color: #059669 } .perm-no { color: #9ca3af }
.chart-sm { height: 240px; position: relative }
.receipt { font-family: ui-monospace, Menlo, monospace; font-size: 13px }
.receipt .r-line { display: flex; justify-content: space-between; padding: 2px 0 }
.receipt hr { border-style: dashed }
@media print {
  .sidebar, .topbar, .footer-x, .page-head .d-flex, .no-print, .toast-container { display: none !important }
  .main { margin: 0 !important }
  body.printing-receipt > *:not(.modal) { display: none !important }
  body.printing-receipt .modal { position: static !important; display: block !important }
  body.printing-receipt .modal-footer, body.printing-receipt .btn-close { display: none !important }
  body.printing-receipt .modal-backdrop { display: none !important }
}

/* keep KPI tiles readable on phones */
.ms-card > div { min-width: 0 }
.ms-card b { overflow-wrap: anywhere }
@media (max-width: 575.98px) {
  .ms-card { flex-direction: column; align-items: flex-start; gap: 8px }
  .ms-card b { font-size: 16px }
  .kpi .val { font-size: 22px }
  .content { padding: 18px 16px }
}

/* farm name as the app's name */
.brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.15 }
.brand-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.brand-sub { font-size: 11px; font-weight: 500; color: #7d8492; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tb-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tb-name > span { overflow: hidden; text-overflow: ellipsis }
.tb-name + .tb-date { padding-left: 12px; border-left: 1px solid var(--border) }

/* loading state while the farm's data comes from the database */
body.booting::after { content: "Loading farm records…"; position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; background: var(--bg) }
.saving { opacity: .6; pointer-events: none }
