/* AgriWealth Scout - phone app (mobile only, one 480px column).
   Brand look taken from the AgriWealth logo: leaf greens + sun yellow, soft green surfaces, rounded shapes.
   One design system for every screen:
     tokens (:root) -> type (eyebrow / h1 / meta) -> header (.page-head, .hero, .head-card) -> surfaces (.panel, .list)
     -> buttons (.btn + primary / secondary / danger / link, sizes lg / xl, .hero-btn) -> fields -> per-screen bits. */
:root {
  --brand-900: #0b3d24; --brand-800: #0f5130; --brand-700: #146c3d; --brand-600: #18874a; --brand-500: #22a35a; --brand-400: #4cc27c;
  --brand-100: #dcf3e5; --brand-50: #eef9f2; --sun: #f2c230; --sun-50: #fff8e1;
  --bg: #f2f5f3; --surface: #ffffff; --border: #e3e9e5; --border-strong: #cdd7d1;
  --text: #0f1d16; --text-2: #34443b; --muted: #66756d; --subtle: #9aa79f;
  --danger: #d92d20; --danger-press: #b42318; --danger-50: #fef3f2; --danger-100: #fecdca;
  --warn-50: #fffaeb; --warn-100: #fedf89; --warn-ink: #93370d;
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 22px;
  --shadow: 0 1px 2px rgba(16,32,24,.05), 0 1px 3px rgba(16,32,24,.07);
  --shadow-md: 0 10px 28px -14px rgba(16,32,24,.3);
  --glow: 0 12px 24px -12px rgba(20,108,61,.85), inset 0 1px 0 rgba(255,255,255,.2);
  --grad: linear-gradient(180deg, var(--brand-500), var(--brand-700));
  --focus: 0 0 0 3px rgba(34,163,90,.3);
  --ease: cubic-bezier(.2,.7,.2,1); --col: 480px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { padding-bottom: env(safe-area-inset-bottom); min-height: 100vh; }
.hidden { display: none !important; }
.ic { width: 24px; height: 24px; flex: none; }
.ic.sm { width: 20px; height: 20px; } .ic.xs { width: 16px; height: 16px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; line-height: 1.3; }
.grow b { font-weight: 700; color: inherit; }
.grow small { font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ---------- top bar ---------- */
#topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; max-width: var(--col); margin: 0 auto;
  min-height: 58px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
#title { flex: 1; font-size: 16.5px; font-weight: 600; color: var(--text-2); letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#title b { color: var(--brand-800); font-weight: 800; }
.brand { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.brand img { width: 34px; height: 34px; display: block; }
.icon { position: relative; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border-radius: 12px; cursor: pointer;
  background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-700); }
.icon:active { background: var(--brand-100); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px;
  background: var(--sun); color: #3d2c00; font-weight: 800; font-size: 11.5px; border-radius: 10px; box-shadow: 0 0 0 2px #fff; }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  color: var(--brand-700); background: var(--brand-50); border: 1px solid var(--brand-100); }
.net::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); box-shadow: 0 0 0 3px rgba(34,163,90,.2); }
.net.off { color: var(--danger-press); background: var(--danger-50); border-color: var(--danger-100); }
.net.off::before { background: #f04438; box-shadow: 0 0 0 3px rgba(240,68,56,.18); }

/* ---------- layout & type ---------- */
.screen { padding: 16px 16px 32px; max-width: var(--col); margin: 0 auto; animation: rise .26s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
h1 { font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: -.02em; margin: 0; }
h1.h-sm { font-size: 19px; }
h3 { font-size: 12.5px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 20px 2px 10px; }
.panel h3:first-child, .panel-head h3 { margin-top: 0; }
.eyebrow { font-size: 12px; font-weight: 750; color: var(--brand-600); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.small { font-size: 14px; } .center { text-align: center; }
.hint, .note { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.note { text-align: center; margin: 12px 8px; }
.body { margin: 0 0 8px; font-size: 15px; color: var(--text-2); }
.msg { color: var(--danger); font-weight: 600; font-size: 14.5px; margin: 8px 2px; }
.msg:empty { margin: 0; }
.hint.warn { color: var(--warn-ink); background: var(--warn-50); border: 1px solid var(--warn-100); border-radius: var(--r); padding: 12px; margin: 0 0 12px; }

/* ---------- screen headers: same pattern everywhere ---------- */
.page-head { margin: 4px 2px 16px; }
.page-head .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; font-size: 13px; }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  color: var(--brand-700); background: var(--brand-50); border: 1px solid var(--brand-100); }
.tag:empty { display: none; }
.meta-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.meta-line span { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: var(--text-2);
  background: var(--brand-50); border: 1px solid var(--brand-100); }
/* home: green hero with the leaf mark */
.hero { position: relative; overflow: hidden; margin: 0 0 16px; padding: 18px 18px 16px; border-radius: var(--r-xl); color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, var(--brand-500) 0%, var(--brand-700) 45%, var(--brand-900) 100%); box-shadow: var(--shadow-md); }
.hero::after { content: ""; position: absolute; right: -26px; bottom: -34px; width: 132px; height: 132px; opacity: .14;
  background: url("logo-mark.png") center / contain no-repeat; filter: brightness(0) invert(1); pointer-events: none; }
.hero .eyebrow { color: #c9f0d9; }
.hero h1 { font-size: 23px; font-weight: 600; }
.hero h1 span { font-weight: 800; }
.hero .meta { position: relative; z-index: 1; }
.hero .tag { color: #fff; background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.22); }
.hero .meta a { color: #d7f5e3; }
/* bed: white card with a leaf-green top edge */
.head-card { margin: 0 0 14px; padding: 16px; text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-top: 5px solid var(--brand-500); border-radius: var(--r-xl); box-shadow: var(--shadow); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin: 0 0 12px; overflow: hidden; box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; margin: 0; padding: 14px 16px; border: 0; background: none;
  color: var(--text); font-size: 16px; font-weight: 400; text-align: left; cursor: pointer; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row:active { background: var(--brand-50); }
.tile { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; background: var(--brand-50); color: var(--brand-700);
  border: 1px solid var(--brand-100); }
.tile.light { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.2); color: #fff; }
.chev { color: var(--subtle); }

/* ---------- fields ---------- */
label { display: block; margin: 16px 0 0; font-size: 15px; font-weight: 650; color: var(--text-2); }
.opt { font-weight: 500; color: var(--subtle); font-size: 13px; }
input, select { font: inherit; width: 100%; min-height: 54px; padding: 13px 14px; margin-top: 6px; color: var(--text);
  background: #fff; border: 1.5px solid var(--border-strong); border-radius: var(--r); transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: var(--subtle); }
select { appearance: none; padding-right: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2366756d' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center; }
input:focus, select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; margin-top: 0; }
.row > .btn { flex: 1; margin: 0; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 50px; height: 30px; min-height: 0; margin: 0; padding: 0; position: relative;
  border: 0; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch:checked { background: var(--brand-500); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { box-shadow: var(--focus); }
.toggle { display: flex; gap: 12px; align-items: center; margin: 16px 0 0; font-weight: 600; }
.toggle input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; accent-color: var(--brand-600); }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 12px 16px;
  font-size: 16px; font-weight: 700; border-radius: var(--r); border: 1.5px solid transparent; color: var(--text); background: none;
  transition: background .15s, box-shadow .15s, transform .08s; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .list-row:focus-visible, .hot-row:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.lg { width: 100%; min-height: 58px; font-size: 17px; margin: 8px 0; border-radius: 16px; }
.btn.xl { width: 100%; min-height: 66px; font-size: 18.5px; font-weight: 800; margin: 0 0 12px; border-radius: 18px; }
.btn.block { width: 100%; }
.primary { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.primary:active { background: linear-gradient(180deg, var(--brand-600), var(--brand-800)); }
.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); }
.secondary:active { background: var(--brand-50); }
.danger { background: linear-gradient(180deg, #ea5a4e, var(--danger)); color: #fff;
  box-shadow: 0 12px 24px -12px rgba(217,45,32,.75), inset 0 1px 0 rgba(255,255,255,.2); }
.link { min-height: 44px; padding: 8px 12px; color: var(--brand-700); }
.link.muted { color: var(--muted); }
.link:active { background: var(--brand-50); }
.ok-ic { color: var(--brand-600); }
/* the main task on a screen: icon tile, title, subtitle, chevron */
.hero-btn { width: 100%; justify-content: flex-start; gap: 14px; min-height: 96px; padding: 18px; margin: 0 0 12px; border-radius: var(--r-xl); text-align: left; }
.hero-btn .grow b { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.hero-btn .grow small { color: rgba(255,255,255,.86); font-size: 14px; }
.hero-btn .chev { color: rgba(255,255,255,.8); }
.bed-nav { margin-top: 14px; }
.bed-nav .btn { margin: 0; }
.bed-nav #scan-bed { flex: 0 0 38%; }
.bed-nav #next-bed { gap: 10px; padding: 8px 14px; }
.bed-nav #next-bed .grow small { color: rgba(255,255,255,.86); }
.bed-nav #next-bed:disabled { opacity: .5; }

/* ---------- login ---------- */
#s-login { padding-top: 36px; }
.login-brand { text-align: center; margin: 0 0 24px; }
.login-logo { width: 72%; max-width: 280px; height: auto; display: block; margin: 0 auto; }
.login-sub { margin-top: 8px; font-size: 12.5px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--brand-600); }
#s-login .panel { padding: 20px; border-top: 5px solid var(--brand-500); border-radius: var(--r-xl); }
#s-login .panel h1 { font-size: 21px; margin-bottom: 2px; }
#s-login .btn.lg { margin-top: 20px; }
.tips { margin: 18px 4px 8px; padding: 0 0 0 18px; color: var(--muted); font-size: 13.5px; }
.tips li { margin: 6px 0; }
.tips li::marker { color: var(--brand-500); }

/* ---------- home ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { padding: 12px 8px; text-align: center; border-radius: var(--r); background: var(--brand-50); border: 1px solid var(--brand-100); }
.kpi b { display: block; font-size: 24px; line-height: 1.15; font-weight: 800; color: var(--brand-800); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi.is-alert { background: var(--danger-50); border-color: var(--danger-100); }
.kpi.is-alert b { color: var(--danger-press); }
.sub-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; font-size: 13px; font-weight: 750; color: var(--danger); }
.sub-head span { font-size: 12px; font-weight: 500; color: var(--muted); }
.hot-list { display: grid; gap: 8px; }
.hot-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; border-radius: var(--r);
  border: 1px solid var(--danger-100); background: var(--danger-50); color: var(--text); font-size: 15px; text-align: left; }
.hot-row b { color: var(--danger-press); }
.hot-row:active { background: var(--danger-100); }
.hot-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px rgba(217,45,32,.15); flex: none; }
.empty { margin-top: 14px; padding: 12px; border-radius: var(--r); background: var(--brand-50); color: var(--brand-700); font-size: 14px; font-weight: 600; }
.more { margin-top: 14px; font-size: 13px; color: var(--muted); }
.more summary { cursor: pointer; list-style: none; font-weight: 650; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; font-weight: 800; color: var(--brand-600); }
.more[open] summary::before { content: "\2212 "; }
.more p { margin: 6px 0 0; }
.sync { text-align: center; padding: 14px 16px 10px; font-size: 13px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.sync-actions { display: flex; justify-content: center; gap: 4px; margin: 6px 0 2px; }
.ver { font-size: 12px; color: var(--subtle); }

/* ---------- bed ---------- */
.alert { margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r); background: var(--danger-50); border: 1px solid var(--danger-100);
  border-left: 4px solid var(--danger); color: var(--danger-press); font-size: 14px; }
.alert b { display: block; font-weight: 750; }
.saved { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--brand-50); color: var(--brand-700);
  font-size: 14px; font-weight: 650; text-align: center; }
.saved:empty { display: none; }

/* ---------- scanner ---------- */
.camwrap { position: relative; width: 100%; aspect-ratio: 1/1; background: #0b1410; border-radius: var(--r-xl); overflow: hidden; margin: 0 0 12px;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.6); }
.camwrap video { width: 100%; height: 100%; object-fit: cover; }
.aim { position: absolute; inset: 18%; border-radius: 18px;
  background:
    linear-gradient(#fff, #fff) top left / 34px 4px, linear-gradient(#fff, #fff) top left / 4px 34px,
    linear-gradient(#fff, #fff) top right / 34px 4px, linear-gradient(#fff, #fff) top right / 4px 34px,
    linear-gradient(#fff, #fff) bottom left / 34px 4px, linear-gradient(#fff, #fff) bottom left / 4px 34px,
    linear-gradient(#fff, #fff) bottom right / 34px 4px, linear-gradient(#fff, #fff) bottom right / 4px 34px;
  background-repeat: no-repeat; filter: drop-shadow(0 0 6px rgba(0,0,0,.5)); }
.aim::after { content: ""; position: absolute; left: 6%; right: 6%; height: 2px; top: 50%; background: linear-gradient(90deg, transparent, var(--brand-400), transparent);
  animation: scanline 2.2s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-120px); opacity: .2; } 50% { transform: translateY(120px); opacity: 1; } }
#s-scan > .row .btn { min-height: 54px; }
details summary { cursor: pointer; font-weight: 700; font-size: 15.5px; }
#manual { margin-top: 12px; }
#manual .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
#manual .row select { min-height: 50px; }

/* ---------- record a plant ---------- */
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; margin: 0; min-height: 0; cursor: pointer; }
.tipbox { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r); background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--text-2); }
.files div { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; font-size: 14px;
  background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: var(--r-sm); }
.files button { padding: 6px 12px; border: 0; border-radius: var(--r-sm); background: var(--danger-50); color: var(--danger); font-size: 14px; font-weight: 650; }
.files .thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 9px; margin-right: 8px; vertical-align: middle; }
.seg { display: flex; gap: 4px; padding: 4px; background: #e9efeb; border-radius: 16px; }
.seg button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 6px; border: 0;
  border-radius: 12px; background: transparent; color: var(--text-2); font-size: 15px; font-weight: 650; }
.seg button.on { background: #fff; color: var(--brand-700); font-weight: 800; box-shadow: 0 2px 8px -2px rgba(16,32,24,.2); }
.capmode { margin-bottom: 8px; }
#plantbox h3 { margin-top: 20px; }
#plantbox .row { flex-wrap: wrap; }
#plantbox .row select { flex: 1 1 100%; }
.step { width: 54px; height: 54px; padding: 0; flex: none; border: 1.5px solid var(--border-strong); border-radius: var(--r); background: #fff;
  color: var(--text); font-size: 26px; }
.step:active { background: var(--brand-50); }
.delta { flex: 1; text-align: center; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.plantno { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding: 12px 16px; border-radius: var(--r);
  background: var(--brand-50); border: 1px solid var(--brand-100); font-size: 15px; font-weight: 650; color: var(--muted); }
.plantno b { font-size: 24px; color: var(--brand-700); font-variant-numeric: tabular-nums; }
.bar-actions { position: sticky; bottom: 0; z-index: 3; margin: 16px -16px 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(242,245,243,0), var(--bg) 30%); }
.bar-actions .btn { margin: 0; }
.bar-actions .secondary { flex: 0 0 34%; }

/* ---------- trap ---------- */
.counts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.counts label { margin: 0; font-size: 14px; }

/* ---------- upload queue ---------- */
#q-summary:empty { display: none; }
.qitem { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; margin: 10px 0; font-size: 14px; box-shadow: var(--shadow); }
.qitem .top { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 8px; background: #e9efeb; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand-600), var(--brand-400)); transition: width .3s; }
.ok { color: #067647; font-weight: 750; } .wait { color: #b54708; } .err { color: var(--danger); }

/* ---------- toast, results ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: max(24px, env(safe-area-inset-bottom)); max-width: calc(var(--col) - 32px); margin: 0 auto;
  padding: 15px 18px; border-radius: 16px; background: var(--brand-900); color: #fff; font-weight: 650; text-align: center;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.5); z-index: 10; animation: rise .25s var(--ease) both; }
.result { text-align: center; }
.result .ok, .result .err, .result .wait { font-size: 18px; font-weight: 800; margin-top: 4px; }

/* larger screens: keep the phone column, framed */
@media (min-width: 560px) {
  body { background: #e6ece8; }
  #topbar { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .screen { min-height: calc(100vh - 58px); background: var(--bg); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
