/* AgroLive v2 UI kit: reusable components + app shell. Load after /assets/v2/map.css (base glass tokens:
 * colors, .card, .btn, .chip, .tag, .sheet, .toast). All kit classes are prefixed k- so they never collide. */

/* ---------- app shell: phone bottom nav, desktop side nav ---------- */
.k-nav { position: fixed; z-index: 35; background: rgba(7, 11, 20, .9); -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px); }
.k-nav ul { list-style: none; margin: 0; padding: 0; display: flex; }
.k-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; min-width: 44px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .01em; border-radius: 12px; transition: color .15s var(--ease), background .15s var(--ease); }
.k-nav a:hover { color: var(--text); }
.k-nav a[aria-current="page"] { color: var(--cyanText); }
.k-nav a[aria-current="page"] .ico { filter: drop-shadow(0 0 6px rgba(34, 211, 238, .6)); }
.k-nav .ico { width: 22px; height: 22px; }
.k-nav .k-navBrand { display: none; }
body.k-hasNav { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
body.k-hasNav .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (max-width: 1023px) {
  .k-nav { left: 0; right: 0; bottom: 0; border-top: 1px solid var(--line); padding: 4px max(6px, env(safe-area-inset-left)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right)); }
  .k-nav li { flex: 1 1 0; min-width: 0; }
  .k-nav a { padding: 4px 2px; }
}
@media (min-width: 1024px) {
  body.k-hasNav { padding-bottom: 0; padding-left: 92px; }
  body.k-hasNav .toast { bottom: 24px; }
  .k-nav { top: 0; bottom: 0; left: 0; width: 92px; border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 12px; }
  .k-nav ul { flex-direction: column; gap: 4px; }
  .k-nav a { min-height: 64px; }
  .k-nav a:hover { background: var(--glass); }
  .k-nav a[aria-current="page"] { background: var(--cyanSoft); }
  .k-nav .k-navBrand { display: grid; place-items: center; min-height: 44px; }
  .k-chipbar { -webkit-mask-image: none; mask-image: none; padding-right: 2px; }
}

/* ---------- page head (module pages) ---------- */
.k-page { max-width: 1280px; margin: 0 auto; padding: 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.k-title { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.k-crumb { font-size: 12px; color: var(--faint); }

/* ---------- filter chip bar (multi-select) ---------- */
.k-chipbar { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 2px 18px 4px 2px; margin: 0 -2px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.k-chipbar::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) {
  .k-chipbar { -webkit-mask-image: none; mask-image: none; padding-right: 2px; }
}
.k-chipLabel { flex: none; align-self: center; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding-right: 2px; }
.k-chip { flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); color: var(--muted); font-weight: 650; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.k-chip:hover { border-color: rgba(255,255,255,.26); color: var(--text); }
.k-chip[aria-pressed="true"] { background: var(--cyanSoft); border-color: rgba(34, 211, 238, .55); color: #dffbff; box-shadow: 0 0 0 1px rgba(34,211,238,.12) inset; }
.k-chip[aria-pressed="true"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px rgba(34,211,238,.9); }
.k-chip small { font-size: 10.5px; font-weight: 600; color: var(--faint); }
.k-chip.k-chipAction { color: var(--cyanText); border-style: dashed; }
.k-chip.k-chipAction[aria-pressed="true"]::before { display: none; }
.k-chipSep { flex: none; width: 1px; align-self: stretch; margin: 8px 2px; background: var(--line2); }
.k-chip .k-sw { width: 10px; height: 10px; border-radius: 3px; flex: none; opacity: .45; }
.k-chip[aria-pressed="true"] .k-sw { opacity: 1; box-shadow: 0 0 8px rgba(34,211,238,.6); }
.k-chip.k-hasSw[aria-pressed="true"]::before { display: none; }

/* ---------- search box ---------- */
.k-search { position: relative; display: flex; align-items: center; }
.k-search .ico { position: absolute; left: 13px; color: var(--faint); pointer-events: none; }
.k-search input { width: 100%; min-height: 46px; padding: 0 44px 0 42px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(255,255,255,.05); color: var(--text); font: 500 16px/1.2 var(--font); outline: none; transition: border-color .15s var(--ease), background .15s var(--ease); }
.k-search input::placeholder { color: var(--faint); }
.k-search input:focus { border-color: rgba(34,211,238,.6); background: rgba(34,211,238,.06); }
.k-search input::-webkit-search-cancel-button { display: none; }
.k-searchClear { position: absolute; right: 1px; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 12px; display: grid; place-items: center; }

/* ---------- totals bar ---------- */
.k-totals { display: grid; gap: 10px; }
.k-totalMain { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.k-totalMain b { font-size: 32px; font-weight: 770; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.05; color: #f3fbff; text-shadow: 0 0 24px rgba(34,211,238,.25); }
.k-totalMain .unit { font-size: 15px; color: var(--muted); font-weight: 650; }
.k-totalMain .k-totalLabel { font-size: 12px; color: var(--muted); font-weight: 650; flex-basis: 100%; letter-spacing: .08em; text-transform: uppercase; }
.k-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.k-stat { min-width: 0; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.k-stat dt { font-size: 11.5px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.k-stat dd { margin: 3px 0 0; font-size: 16px; font-weight: 740; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.k-stat.off { opacity: .45; }
.k-stat .k-sw { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.k-dcs { display: flex; flex-wrap: wrap; gap: 6px; }
.k-dc { display: inline-flex; gap: 6px; align-items: baseline; padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--line); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.k-dc b { font-weight: 750; color: var(--text); }
.k-dc span { color: var(--muted); }
.sw-floor { background: linear-gradient(90deg, #22d3ee, #5eead4); }
.sw-water { background: linear-gradient(90deg, #6366f1, #818cf8); }
.sw-chile { background: repeating-linear-gradient(135deg, rgba(148,163,184,.75) 0 3px, rgba(148,163,184,.4) 3px 6px); }

/* ---------- info tip ---------- */
.k-tipBtn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -14px -12px; border: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; }
.k-tipBtn .infoDot { pointer-events: none; }
.k-tipText { margin: 6px 0 0; padding: 9px 11px; border-radius: 12px; background: rgba(34, 211, 238, .06); border: 1px dashed rgba(34, 211, 238, .32); font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---------- sortable list rows ---------- */
.k-listHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.k-seg { display: inline-flex; padding: 2px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); }
.k-seg button { min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 650; font-size: 13px; cursor: pointer; }
.k-seg button[aria-pressed="true"] { background: var(--cyanSoft); color: #dffbff; }
.k-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.k-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; width: 100%; min-height: 56px; padding: 11px 12px; text-align: left; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease); }
.k-row:hover { border-color: rgba(34,211,238,.35); background: rgba(34,211,238,.045); }
.k-rowTitle { min-width: 0; font-weight: 650; font-size: 14px; line-height: 1.3; }
.k-rowTitle code { font: 700 12.5px var(--mono); color: var(--cyanText); margin-right: 6px; }
.k-rowVal { font-weight: 760; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.k-rowVal small { display: block; font-size: 11px; color: var(--faint); font-weight: 600; }
.k-rowMeta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.k-pill { display: inline-flex; gap: 4px; align-items: baseline; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-pill b { color: var(--text); font-weight: 700; }
.k-pill.warn { color: var(--amber); border-color: rgba(251,191,36,.4); }
.k-pill.bad { color: var(--rose); border-color: rgba(251,113,133,.4); }
.k-pill.muted { color: var(--faint); }
.k-bar { grid-column: 1 / -1; display: flex; height: 5px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.05); gap: 1px; }
.k-bar i { display: block; height: 100%; }

/* ---------- detail sheet content ---------- */
.k-sheetHead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.k-sheetHead h2 { margin: 0; font-size: 18px; font-weight: 750; line-height: 1.25; }
.k-sheetHead p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.k-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.k-table th, .k-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.k-table th:first-child, .k-table td:first-child { text-align: left; }
.k-table thead th { font-size: 10.5px; color: var(--faint); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.k-table tfoot td { font-weight: 750; border-bottom: 0; }
.k-tableWrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.k-h3 { margin: 16px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.k-ship { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.k-ship li { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 13px; }
.k-ship .eta { font-weight: 750; color: var(--cyanText); font-variant-numeric: tabular-nums; }
.k-ship .lb { font-weight: 700; font-variant-numeric: tabular-nums; }
.k-ship small { display: block; color: var(--faint); font-size: 11.5px; }

/* ---------- empty / loading / placeholder ---------- */
.k-empty { text-align: center; padding: 28px 16px; border-radius: 16px; border: 1px dashed var(--line2); color: var(--muted); }
.k-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.k-skel { height: 64px; border-radius: 14px; background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.07), rgba(255,255,255,.03)); background-size: 200% 100%; animation: k-shimmer 1.2s linear infinite; }
@keyframes k-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.k-soon { max-width: 640px; margin: 24px auto; text-align: left; }
.k-soon h1 { margin: 6px 0 8px; font-size: 24px; letter-spacing: -.02em; }
.k-soon p { color: var(--muted); line-height: 1.55; }
.k-soon ul { padding-left: 18px; color: var(--muted); line-height: 1.6; }
.k-fallback { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; color: var(--faint); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.k-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.k-tile { display: flex; flex-direction: column; gap: 4px; min-height: 88px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.k-tile:hover { border-color: rgba(34,211,238,.35); }
.k-tile b { font-size: 15px; }
.k-tile span { font-size: 12.5px; color: var(--muted); }
.k-tile em { font-style: normal; font-size: 11px; color: var(--faint); margin-top: auto; }

/* ---------- dashboard pages: Accounts, Follow-ups, More ---------- */
.k-dashboardPage { display: grid; gap: 12px; }
.k-dashHero { display: grid; gap: 14px; }
.k-dashHero h2 { margin: 4px 0 6px; font-size: 24px; line-height: 1.12; letter-spacing: -.02em; }
.k-dashHero p { margin: 0; color: var(--muted); line-height: 1.5; }
.k-dashStats { align-content: start; }
.k-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.k-standardList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.k-standardList span { min-height: 44px; display: flex; align-items: center; padding: 9px 11px; border-radius: 12px; border: 1px solid rgba(34,211,238,.25); background: rgba(34,211,238,.06); color: #dffbff; font-weight: 650; font-size: 12.5px; }
.k-dashboardTiles .k-tile { min-height: 112px; }
.k-tilePrimary { border-color: rgba(34,211,238,.32); background: rgba(34,211,238,.055); }
.k-plainRows { list-style: none; padding: 0; margin: 8px 0 0; border-top: 1px solid var(--line); }
.k-plainRows li { min-height: 48px; display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.k-sheetActions { margin-top: 12px; }
@media (min-width: 820px) {
  .k-dashHero { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); align-items: center; }
  .k-standardList { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- highlighted figure row + tip row (Available now (net), stage notes) ---------- */
.availRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(34,211,238,.28); background: rgba(34,211,238,.06); font-size: 13px; font-weight: 650; color: var(--muted); }
.availRow > span { display: inline-flex; align-items: center; gap: 10px; }
.availRow b { font-size: 18px; color: #e8fbff; font-variant-numeric: tabular-nums; }
.stageNote { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; min-height: 20px; }
.stageNote > span { display: inline-flex; align-items: center; gap: 10px; }

/* As-of stamp (top of inventory pages): one date + AM/PM, readable at a glance */
.k-stamp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; font-size: 15px; line-height: 1.3; color: var(--text); }
.k-stamp b { font-weight: 750; letter-spacing: -.01em; }
.k-stamp .k-cycle { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px; border-radius: 999px; border: 1px solid rgba(34,211,238,.45); background: rgba(34,211,238,.10); color: #cffafe; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.k-stamp:empty { display: none; }
.k-titleStack { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.k-titleStack .k-title { margin: 0; line-height: 1.15; }
.k-stamp.k-stampTop { margin: 2px 0 0; gap: 6px; font-size: 12.5px; flex-wrap: nowrap; white-space: nowrap; }
.k-stamp.k-stampTop b { font-weight: 650; color: var(--muted); }
.k-stamp.k-stampTop .k-cycle { min-height: 18px; padding: 0 7px; font-size: 11px; }
.k-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
