/* Sakongrow v2 — one stylesheet for the whole app.
 *
 * Values are ported from the reference demo (Sakongrow_UI.html). What changed:
 * everything the reference expressed as an inline style="…" string is a class
 * here (SPEC_v2.md §12.1), and two latent defects the reference carried are
 * fixed rather than inherited:
 *   · --accent-light was referenced as var(--accent-light,#F4DDD4) but never
 *     defined, so the inline fallback silently carried every render. Defined.
 *   · .stamp and .pulse-dot were defined and used nowhere. Dropped.
 * .cd-track/.cd-fill were also defined-and-unused in the reference; here the
 * delivery tab actually renders the bar.
 */

:root {
  --primary: #8BBA5A;
  --primary-dark: #206532;
  --primary-darker: #4A7A2A;
  --light: #E7FBB4;
  --p50: #F4FBE8;
  --accent: #D36E49;
  --accent-dark: #B85A3A;
  --accent-light: #F4DDD4;
  --accent-bg: #FDF0EC;
  --bg: #F6F9F3;
  --fg: #1A2E1A;
  --muted: #6B7A65;
  --card: #FFF;
  --bdr: #C8D8C2;
  --paper: #EDF1EA;
  --card-tint: #DCE4D8;

  --font-sans: 'Kanit', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --fg-rgb: 26, 46, 26;
  --primary-rgb: 139, 186, 90;
  --primary-darker-rgb: 74, 122, 42;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  padding: 20px 16px 80px;
  background-image: radial-gradient(circle, rgba(var(--primary-darker-rgb), .035) .6px, transparent .6px);
  background-size: 16px 16px;
}

#app { max-width: 1200px; margin: 0 auto; }

/* ---------- form controls ---------- */

.sg-input {
  border: 1px solid var(--primary);
  background: var(--bg);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 19px;
  padding: 9px 12px;
  color: var(--fg);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.sg-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15);
}
.sg-input.is-missing { background: #FBE4DD; border-color: var(--accent); }
.sg-input-paper { background: var(--paper); }
.sg-input-auto { width: auto; min-width: 120px; }

.sg-input-mono {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sg-input-mono[type="number"] { -moz-appearance: textfield; }
.sg-input-mono[type="number"]::-webkit-outer-spin-button,
.sg-input-mono[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.sg-input-text {
  border: none;
  background: transparent;
  font-weight: 500;
  font-size: 19px;
  color: var(--fg);
  padding: 4px 2px;
  border-radius: 4px;
  width: 100%;
  font-family: var(--font-sans);
}
.sg-input-text:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.sg-fielderr { color: var(--accent-dark); font-size: 13px; margin-top: 3px; }

/* ---------- buttons ---------- */

.sg-btn {
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: 8px;
  font-weight: 500;
  font-size: 18px;
  padding: 9px 16px;
  transition: all .15s;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sg-btn:active { transform: translateY(1px); }
.sg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sg-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.sg-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.sg-btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.sg-btn-ghost { background: #fff; color: var(--primary-dark); border-color: var(--primary); }
.sg-btn-ghost:hover:not(:disabled) { background: var(--light); }
.sg-btn-subtle { background: #fff; color: var(--muted); border: 2px solid var(--bdr); font-weight: 400; }
.sg-btn-subtle:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); }
.sg-btn-danger { background: #fff; color: var(--accent); border: 1px solid var(--accent-light); font-weight: 400; }
.sg-btn-danger:hover:not(:disabled) { background: var(--accent-bg); }
.sg-btn-accent { background: var(--accent); color: #fff; border-color: var(--accent-dark); }
.sg-btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.sg-btn-sm { font-size: 15px; padding: 5px 11px; }
.sg-btn-icon { padding: 7px 10px; }

/* ---------- cards & layout ---------- */

.sg-card {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 14px;
  padding: 18px 20px 20px;
  box-shadow: 0 1px 4px rgba(var(--fg-rgb), .04);
}
.sg-card-plain { border: 1px solid var(--bdr); }
.sg-card + .sg-card { margin-top: 20px; }

.sg-h2 {
  font-weight: 600;
  font-size: 22px;
  color: var(--primary-darker);
  margin: 0 0 3px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sg-sub { font-size: 17px; color: var(--muted); margin-bottom: 14px; }
.sg-note { font-size: 16px; color: var(--accent-dark); font-weight: 500; }

.sg-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sg-row-top { align-items: flex-start; }
.sg-row-between { justify-content: space-between; }
.sg-grow { flex: 1; min-width: 160px; }
.sg-stack { display: flex; flex-direction: column; gap: 12px; }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.sg-divider { border-top: 1px solid var(--bdr); margin-top: 14px; padding-top: 14px; }
.sg-spacer { flex: 1; }

.sg-muted { color: var(--muted); }
.sg-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sg-strong { font-weight: 600; }
.sg-right { text-align: right; }
.sg-center { text-align: center; }

.sg-empty {
  color: var(--muted);
  font-size: 18px;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--bdr);
  border-radius: 10px;
}

/* ---------- tables ---------- */

.sg-tablewrap { overflow-x: auto; }
.sg-table { border-collapse: collapse; width: 100%; font-size: 18px; }
.sg-th {
  text-align: left;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 500;
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--bdr);
  white-space: nowrap;
}
.sg-td { padding: 7px 6px; border-bottom: 1px solid var(--paper); vertical-align: middle; }
.sg-td-mono {
  padding: 7px 6px;
  border-bottom: 1px solid var(--paper);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sg-tr-total { border-top: 2px solid var(--primary); }
.sg-tr-total .sg-td, .sg-tr-total .sg-td-mono { font-weight: 700; color: var(--primary-darker); }
.sg-tr-ready .sg-td, .sg-tr-ready .sg-td-mono { font-weight: 700; color: var(--accent); }

/* ---------- tabs ---------- */

.sg-tabs {
  display: flex;
  flex-wrap: nowrap;
  border: 2px solid var(--primary);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}
.sg-tab {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 22px;
  padding: 14px 20px;
  cursor: pointer;
  border-left: 2px solid var(--primary);
  transition: all .15s;
  background: #fff;
  color: var(--primary-dark);
  flex: 1;
  min-width: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.sg-tab:first-child { border-left: none; }
.sg-tab:hover:not(.active) { background: var(--light); }
.sg-tab.active { background: var(--primary); color: #fff; }
.sg-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- chips & checks ---------- */

.sg-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--bdr);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 17px;
  cursor: pointer;
  user-select: none;
  margin: 3px 6px 3px 0;
  transition: all .15s;
  background: #fff;
}
.sg-chip.on { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.sg-chip:not(.on):hover { border-color: var(--primary); color: var(--primary-dark); }

.sg-crop-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--bdr);
  border-radius: 999px;
  padding: 9px 18px 9px 9px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  transition: .15s;
  color: var(--fg);
}
.sg-crop-check:hover { border-color: var(--primary); }
.sg-crop-check.on { border-color: var(--primary); background: #DFF6C0; color: var(--primary-darker); }
.sg-crop-box {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--bdr);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  color: #fff;
  transition: .15s;
  background: #fff;
}
.sg-crop-check:hover .sg-crop-box { border-color: var(--primary); }
.sg-crop-check.on .sg-crop-box { background: var(--primary); border-color: var(--primary); }

/* ---------- farm cards (เกษตรกร) ---------- */

.sg-farm-card {
  border: 1px solid var(--bdr);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 20px;
  background: #fff;
}
.sg-farm-card:last-child { margin-bottom: 0; }
.sg-farm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.sg-farm-name { font-weight: 600; font-size: 20px; color: var(--primary-darker); flex: 1; min-width: 120px; }
.sg-croplabel { font-size: 17px; color: var(--muted); margin-bottom: 6px; }
.sg-croplist { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sg-btn-pill { border-radius: 20px; }
.sg-btn-icononly { padding: 4px 8px; font-size: 16px; }

/* Rename toggles between a muted "edit me" affordance and a green confirm. */
.sg-btn-rename { background: #FBE4DD; color: var(--accent-dark); border-color: #F0C4B6; padding: 4px 10px; font-size: 15px; }
.sg-btn-rename:hover:not(:disabled) { background: var(--accent-bg); }
.sg-btn-rename.is-editing { background: var(--primary); color: #fff; border-color: var(--primary); }
.sg-btn-rename.is-editing:hover { background: var(--primary-dark); }

/* ---------- badges & pills ---------- */

.sg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.sg-badge-ok { background: var(--light); color: var(--primary-darker); }
.sg-badge-warn { background: var(--accent-light); color: var(--accent-dark); }
.sg-badge-muted { background: var(--paper); color: var(--muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 17px;
  font-weight: 500;
  transition: all .2s;
}
.status-pill.done { background: var(--light); color: var(--primary-darker); border: 1px solid var(--primary); }
.status-pill.waiting { background: var(--bg); color: var(--muted); border: 1px solid var(--bdr); }
.status-pill.cancelled { background: var(--accent-bg); color: var(--accent-dark); border: 1px solid var(--accent-light); }

/* ---------- harvest ticket ---------- */

.ticket-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  position: relative;
  padding: 20px;
  transition: box-shadow .2s, transform .2s;
}
.ticket-card:hover { box-shadow: 0 6px 24px rgba(var(--fg-rgb), .08); transform: translateY(-2px); }
.ticket-card::before {
  content: '';
  position: absolute;
  top: 0; left: 18px; right: 18px;
  border-top: 2px dashed var(--bdr);
}
.sg-ticket-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dotted var(--card-tint);
  font-family: var(--font-mono);
  font-size: 18px;
}

/* ---------- delivery tracker ---------- */

.tracker { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.tracker .count { display: flex; align-items: baseline; gap: 8px; }
.tracker .count .big {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 40px;
  color: var(--primary-darker);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tracker .count .of { font-family: var(--font-mono); font-size: 22px; color: var(--muted); }
.tracker .count .lbl { font-size: 16px; color: var(--muted); margin-left: 2px; }
.tracker .barwrap { flex: 1; min-width: 200px; }
.tracker .barmeta { display: flex; justify-content: space-between; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.tracker .barmeta .kg { font-family: var(--font-mono); color: var(--fg); }

.cd-track {
  height: 12px;
  background: var(--paper);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--bdr);
}
.cd-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 99px;
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

.cd-farm {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-left: 4px solid transparent;
  border-radius: 12px;
  padding: 15px 18px 16px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.cd-farm:hover { box-shadow: 0 4px 16px rgba(var(--fg-rgb), .06); }
.cd-farm.is-received { border-left-color: var(--primary); background: var(--p50); }
.cd-top { display: flex; align-items: flex-start; gap: 14px; }
.cd-check { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.cd-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.cd-box {
  width: 30px; height: 30px;
  border: 2px solid var(--bdr);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  color: #fff;
  font-size: 15px;
  transition: all .18s;
}
.cd-box i { opacity: 0; transform: scale(.5); transition: all .18s; }
.cd-check input:checked + .cd-box { background: var(--primary); border-color: var(--primary-dark); }
.cd-check input:checked + .cd-box i { opacity: 1; transform: scale(1); }
.cd-check input:focus-visible + .cd-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.cd-name { font-weight: 600; font-size: 22px; color: var(--fg); cursor: pointer; }
.cd-when { font-size: 15px; color: var(--primary-dark); margin-top: 2px; }
.cd-items { margin: 12px 0 0; padding: 0 0 0 44px; list-style: none; }
.cd-total { display: flex; justify-content: space-between; font-weight: 600; font-size: 20px; padding: 8px 0 0 44px; margin-top: 2px; }
.cd-total .kg { font-family: var(--font-mono); color: var(--accent); }
.cd-short { text-decoration: line-through; color: var(--muted); }

/* ---------- header & account menu ---------- */

.sg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.sg-brand { font-weight: 700; font-size: 26px; color: var(--primary-dark); display: flex; align-items: center; gap: 9px; }
.sg-brand small { font-size: 15px; font-weight: 400; color: var(--muted); }

.sg-menu { position: relative; }
.sg-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--bdr);
  border-radius: 12px;
  box-shadow: 0 10px 34px rgba(var(--fg-rgb), .12);
  overflow: hidden;
  z-index: 40;
}
.sg-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  background: #fff;
  border: none;
  border-bottom: 1px solid var(--paper);
  font-family: var(--font-sans);
  font-size: 17px;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}
.sg-menu-item:last-child { border-bottom: none; }
.sg-menu-item:hover { background: var(--p50); }
.sg-menu-item i { width: 18px; color: var(--primary-dark); }
.sg-menu-head { padding: 13px 15px; background: var(--paper); border-bottom: 1px solid var(--bdr); }
.sg-menu-head b { display: block; font-size: 18px; }
.sg-menu-head span { font-size: 14px; color: var(--muted); }

/* ---------- notification bell ---------- */

.sg-bell { position: relative; }
.sg-bell-dot {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.sg-notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, calc(100vw - 32px));
  max-height: 60vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--bdr);
  border-radius: 12px;
  box-shadow: 0 10px 34px rgba(var(--fg-rgb), .12);
  z-index: 40;
}
.sg-notif {
  padding: 12px 15px;
  border-bottom: 1px solid var(--paper);
  display: flex;
  gap: 10px;
}
.sg-notif:last-child { border-bottom: none; }
.sg-notif.is-unread { background: var(--p50); }
.sg-notif-body b { display: block; font-size: 17px; }
.sg-notif-body p { font-size: 15px; color: var(--muted); line-height: 1.45; }
.sg-notif-body time { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- countdown ---------- */

.sg-countdown {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--primary-dark);
}
.sg-countdown.is-urgent { color: var(--accent-dark); }
.sg-countdown.is-past { color: var(--muted); }
.sg-countdown small { font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--muted); }

/* ---------- feedback ---------- */

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp .3s ease-out both; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
.spinner-dark { border-color: rgba(var(--primary-darker-rgb), .25); border-top-color: var(--primary-dark); }

#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary-darker);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 19px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
  max-width: 90vw;
  box-shadow: 0 4px 20px rgba(var(--primary-darker-rgb), .3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.is-error { background: var(--accent-dark); box-shadow: 0 4px 20px rgba(184, 90, 58, .3); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(var(--fg-rgb), .2);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(var(--fg-rgb), .2);
  transform: scale(.95);
  transition: transform .2s;
}
.modal-overlay.open .modal-box { transform: scale(1); }
.modal-box h3 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.modal-box p { font-size: 17px; color: var(--muted); line-height: 1.55; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- login ---------- */

.sg-login { max-width: 420px; margin: 8vh auto 0; }
.sg-login .sg-card { padding: 28px; }
.sg-login-title { font-size: 26px; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.sg-login-sub { font-size: 17px; color: var(--muted); margin-bottom: 22px; }
.sg-login-field { margin-bottom: 14px; }
.sg-login-field label { display: block; font-size: 16px; color: var(--muted); margin-bottom: 5px; }

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .sg-grid { grid-template-columns: 1fr; }
  .sg-tab { font-size: 16px; padding: 10px 8px; }
}
@media (max-width: 640px) {
  .sg-tabs { flex-wrap: wrap; }
  .sg-tab { flex: 1 1 45%; min-width: 110px; }
}
@media (max-width: 480px) {
  body { padding: 12px 10px 70px; }
  .sg-card { padding: 14px 14px 16px; }
  .sg-tab { font-size: 15px; padding: 10px 6px; flex: 1 1 100%; }
  .cd-items, .cd-total { padding-left: 0; }
  .cd-name { font-size: 20px; }
  .tracker .count .big { font-size: 32px; }
}

/* ================================================================
   FARMER VIEW — ported verbatim from the reference demo.
   Deliberately its own palette with hardcoded colours rather than the
   admin variables: it is a phone-first app shell (Inventory Tracker
   template), not a page of the admin dashboard, and mixing the two
   token sets is what would make it drift.

   จานสี: พื้น #F6F4EC / กรอบนอก #EDEAE0 / เขียวหลัก #206532 / เขียวอ่อน #E6F0E0
          ตัวอักษร #1E2A1B / รอง #5B6455 / จาง #8A8575 / เส้น #DDD6C4
          ร่าง #FBEDD2+#E8C77E / แดง #C0311D / แท็บที่เลือก #DCEAC9
   ================================================================ */
body.fv-mode{padding:0;background:#EDEAE0;background-image:none;height:100vh;height:100dvh;overflow:hidden}
body.fv-mode #app{max-width:none;margin:0;height:100%}
body.fv-mode #toast{bottom:88px;background:#206532;border-radius:24px;box-shadow:0 8px 26px rgba(20,24,18,.28)}
.fv-shell{position:relative;height:100%;max-width:460px;margin:0 auto;background:#F6F4EC;display:flex;flex-direction:column;overflow:hidden;font-family:'Kanit',sans-serif;color:#1E2A1B;box-shadow:0 0 44px rgba(20,24,18,.10)}
.fv-scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}
.fv-shell button{font-family:'Kanit',sans-serif}

.fv-head{flex-shrink:0;background:#FFF;border-bottom:1px solid #DDD6C4;padding:18px 24px 16px}
.fv-brandrow{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.fv-brand{font-size:18px;font-weight:700;color:#206532;line-height:1.25}
.fv-sub{font-size:13px;color:#5B6455;margin-top:1px}
.fv-logout{width:38px;height:38px;flex-shrink:0;border-radius:50%;border:1px solid #DDD6C4;background:#F6F4EC;color:#5B6455;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:.15s}
.fv-logout:hover{border-color:#206532;color:#206532;background:#E6F0E0}
/* ชื่อสวน — Kanit/subhead */
.fv-farm{
  font-family:'Kanit';
  font-style:normal;
  font-weight:600;
  font-size:22px;
  line-height:22px;
  color:#6B9A3A;
  margin-top:6px;
}
.fv-date{font-size:14px;color:#5B6455;margin-top:10px}
.fv-title{font-size:22px;font-weight:700;color:#1E2A1B;margin-top:2px}

.fv-body{padding:18px 20px 4px}
.fv-seclabel{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:0 4px;margin-bottom:12px}
.fv-seclabel b{font-size:15px;font-weight:400;color:#5B6455}
.fv-seclabel span{font-size:13px;color:#8A8575;text-align:right}
.fv-empty{background:#FFF;border:1.5px solid #DDD6C4;border-radius:20px;padding:30px 22px;text-align:center;color:#5B6455;font-size:16px;line-height:1.65}

.fv-alert{background:#FFF;border:2px solid #C0311D;border-radius:20px;padding:16px 18px;margin-bottom:12px}
.fv-alert-h{display:flex;align-items:center;gap:6px;font-size:14px;font-weight:600;color:#C0311D;margin-bottom:6px}
.fv-alert-t{font-size:17px;color:#1E2A1B;line-height:1.45;margin-bottom:12px}
.fv-alert-b{display:flex;gap:10px}
.fv-alert-b button{flex:1;height:46px;border-radius:23px;font-size:17px;font-weight:600;cursor:pointer}
.fv-btn-solid{background:#206532;color:#fff;border:none}
.fv-btn-out{background:#FFF;color:#5B6455;border:1.5px solid #DDD6C4}

.fv-list{display:flex;flex-direction:column;gap:12px}
.fv-row{background:#FFF;border:1.5px solid #DDD6C4;border-radius:20px;overflow:hidden;transition:border-color .18s,background .18s}
.fv-row.is-draft{background:#FBEDD2;border:2px solid #E8C77E}
.fv-row.is-sent{background:#E6F0E0;border:2px solid #206532}
.fv-row.is-open{background:#FFF;border:2px solid #206532}
.fv-rowbtn{width:100%;box-sizing:border-box;display:flex;align-items:center;gap:12px;padding:14px 16px;min-height:60px;background:transparent;border:none;cursor:pointer;text-align:left;color:inherit}
.fv-ico{width:36px;height:36px;border-radius:50%;background:#F6F4EC;display:flex;align-items:center;justify-content:center;flex-shrink:0;color:#1E2A1B}
.fv-name{font-size:17px;font-weight:600;color:#1E2A1B}
.fv-row.is-draft .fv-ico{background:#FFF;color:#92660A}
.fv-row.is-draft .fv-name{color:#92660A}
.fv-row.is-sent .fv-ico{background:#FFF;color:#206532}
.fv-row.is-sent .fv-name{color:#206532}
.fv-row.is-open .fv-ico{background:#F6F4EC;color:#206532}
.fv-row.is-open .fv-name{color:#206532}
.fv-grow{flex:1}
.fv-plus{width:32px;height:32px;border-radius:50%;border:1.5px solid #206532;color:#206532;display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:700;line-height:1;flex-shrink:0}
.fv-pencil{flex-shrink:0}

.fv-panel{padding:0 16px 18px}
.fv-hr{height:1px;background:#EAF2E4;margin-bottom:14px}
.fv-qlabel{font-size:15px;color:#5B6455;margin-bottom:12px}
.fv-qlabel em{font-style:normal;font-weight:600;color:#206532}
.fv-step{display:flex;align-items:center;justify-content:space-between;gap:14px}
.fv-circ{width:52px;height:52px;border-radius:50%;flex-shrink:0;cursor:pointer;font-weight:700;line-height:1;transition:.15s}
.fv-minus{border:2px solid #DDD6C4;background:#FFF;color:#C9C4B4;font-size:28px}
.fv-minus.on{border-color:#206532;color:#206532}
.fv-plusbig{border:none;background:#206532;color:#fff;font-size:26px}
.fv-plusbig:hover{background:#24552F}
.fv-num{font-size:40px;font-weight:700;color:#1E2A1B;line-height:1;font-variant-numeric:tabular-nums}
.fv-unit{font-size:14px;color:#5B6455;margin-top:2px}
.fv-chips{display:flex;gap:8px;margin-top:16px}
.fv-chip{flex:1;height:46px;border-radius:23px;cursor:pointer;font-size:16px;font-weight:600;border:1px solid #DDD6C4;background:#F6F4EC;color:#5B6455;transition:.15s}
.fv-chip.on{border:2px solid #206532;background:#E6F0E0;color:#206532}
.fv-ok{width:100%;height:52px;font-size:20px;font-weight:700;border-radius:26px;border:none;margin-top:16px;cursor:pointer;background:#206532;color:#fff}
.fv-ok:hover:not([disabled]){background:#24552F}
.fv-ok[disabled]{background:#DDD6C4;color:#8A8575;cursor:not-allowed}
.fv-del{width:100%;height:44px;margin-top:10px;border-radius:22px;border:1px solid #EBD5CF;background:#FFF;color:#C0311D;font-size:16px;font-weight:600;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:7px}
.fv-del:hover{background:#FDF1EE}

.fv-submitwrap{padding:16px 20px 28px}
.fv-submit{width:100%;height:56px;font-size:22px;font-weight:700;border-radius:28px;border:none;display:flex;align-items:center;justify-content:center;gap:10px;cursor:pointer;background:#206532;color:#fff}
.fv-submit:hover:not([disabled]){background:#24552F}
.fv-submit[disabled]{background:#DDD6C4;color:#8A8575;cursor:not-allowed}

.fv-nav{flex-shrink:0;height:68px;background:#FFF;border-top:1px solid #DDD6C4;display:flex}
.fv-navbtn{flex:1;height:100%;border:none;background:transparent;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:15px;font-weight:600;cursor:pointer;color:#8A8575}
.fv-navbtn.on{background:#DCEAC9;color:#206532}

.fv-hist{padding:20px;display:flex;flex-direction:column;gap:22px}
.fv-bal{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;background:#E6F0E0;border:2.5px solid #206532;border-radius:26px;padding:20px 22px}
.fv-bal-name{font-size:19px;font-weight:700;color:#206532}
.fv-bal-qty{font-size:32px;font-weight:700;color:#206532;margin-top:2px;line-height:1.1;font-variant-numeric:tabular-nums}
.fv-bal-meta{text-align:right;font-size:14px;color:#5B6455;flex-shrink:0}
.fv-bal-exp{font-size:15px;font-weight:700;color:#C0311D;margin-top:4px}
.fv-months{display:flex;flex-direction:column;gap:10px;margin-top:10px}
.fv-monthbtn{width:100%;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;background:#FFF;border:1.5px solid #DDD6C4;border-radius:16px;padding:14px 18px;cursor:pointer;font-size:17px;font-weight:600;color:#1E2A1B}
.fv-monthbtn:hover{border-color:#206532}
.fv-entries{display:flex;flex-direction:column;gap:18px;padding:18px 6px 4px}
.fv-entry{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.fv-e-date{font-size:14px;color:#5B6455}
.fv-e-date b{color:#1E2A1B;font-weight:600}
.fv-e-delta{display:flex;align-items:center;gap:4px;font-size:23px;font-weight:700;margin-top:2px;font-variant-numeric:tabular-nums}
.fv-in{color:#206532}
.fv-out{color:#C0311D}
.fv-e-right{text-align:right;flex-shrink:0}
.fv-e-exp{font-size:14px;font-weight:700;color:#C0311D}
.fv-e-rem{font-size:16px;color:#1E2A1B;margin-top:2px}

.fv-overlay{position:absolute;inset:0;z-index:30;background:rgba(20,24,18,0.55);display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;animation:fadeUp .18s ease-out both}
.fv-modal{background:#FFF;border-radius:24px;padding:24px;width:100%;max-width:340px;box-sizing:border-box;box-shadow:0 20px 50px rgba(0,0,0,0.3)}
.fv-modal h3{font-size:20px;font-weight:700;color:#1E2A1B;margin:0 0 16px}
.fv-lines{background:#E6F0E0;border-radius:14px;padding:16px;margin-bottom:20px;display:flex;flex-direction:column;gap:10px}
.fv-lines div{font-size:18px;font-weight:600;color:#1E2A1B}
.fv-mbtns{display:flex;gap:12px}
.fv-mbtns button{flex:1;height:52px;font-size:20px;font-weight:600;border-radius:26px;cursor:pointer}
.fv-cancel{color:#5B6455;background:#F6F4EC;border:1px solid #DDD6C4}
.fv-send{color:#fff;background:#206532;border:none;font-weight:700}
.fv-send:hover{background:#24552F}
.fv-succ{background:#FFF;border-radius:24px;padding:36px 28px;width:100%;max-width:320px;box-sizing:border-box;text-align:center;box-shadow:0 20px 50px rgba(0,0,0,0.3)}
.fv-succ-ico{width:76px;height:76px;border-radius:50%;background:#206532;display:flex;align-items:center;justify-content:center;margin:0 auto}
.fv-succ h3{font-size:22px;font-weight:700;color:#1E2A1B;margin:18px 0 0}
.fv-succ-lines{display:flex;flex-direction:column;gap:4px;margin-top:10px;font-size:17px;font-weight:600;color:#1E2A1B}
.fv-succ-time{font-size:15px;color:#5B6455;margin-top:8px}
.fv-succ-hint{font-size:14px;color:#8A8575;margin-top:10px}
.fv-succ .fv-again{width:100%;height:56px;font-size:22px;font-weight:700;color:#fff;background:#206532;border:none;border-radius:28px;margin-top:22px;cursor:pointer}
.fv-succ .fv-again:hover{background:#24552F}

@media(max-width:420px){
  .fv-head{padding:16px 18px 14px}
  .fv-body{padding:16px 14px 4px}
  .fv-submitwrap{padding:14px 14px 24px}
  .fv-hist{padding:16px 14px}
  .fv-num{font-size:36px}
  .fv-bal{padding:18px 18px;border-radius:22px}
  .fv-bal-qty{font-size:28px}
  .fv-e-delta{font-size:21px}
}
@media(prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;transition-duration:.01ms!important}}
