:root {
  --bg: #f4f7f3;
  --panel: #ffffff;
  --ink: #1d2a22;
  --muted: #5f6f66;
  --accent: #1e7a4c;
  --accent-2: #e0f2e7;
  --line: #dfe5e0;
  --danger: #c62828;
  --nav-h: 58px;
  --top-h: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.fineprint { font-size: 12px; color: var(--muted); margin-top: 24px; }

/* ---------- shell ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--accent); color: #fff; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.topbar select { padding: 5px 8px; border-radius: 6px; border: 0; font-size: 13px; }

.nav { position: fixed; z-index: 20; display: flex; background: var(--panel); border-top: 1px solid var(--line); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; text-decoration: none; color: var(--muted); font-size: 11px; }
.nav a .ic { font-size: 20px; }
.nav a.active { color: var(--accent); font-weight: 600; }

main { padding-top: var(--top-h); min-height: 100%; }
.view { display: none; padding: 16px; max-width: 1100px; margin: 0 auto; }
.view.active { display: block; }

/* mobile: bottom nav */
.nav { left: 0; right: 0; bottom: 0; height: var(--nav-h); }
main { padding-bottom: var(--nav-h); }

/* desktop: side nav */
@media (min-width: 900px) {
  .nav { top: var(--top-h); bottom: 0; left: 0; width: 92px; height: auto; flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); }
  .nav a { flex: 0 0 auto; padding: 14px 4px; font-size: 12px; }
  .nav a .ic { font-size: 22px; }
  main { padding-left: 92px; padding-bottom: 0; }
}

/* ---------- components ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:disabled { background: #a8b8ae; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.ghost { background: var(--accent-2); color: var(--accent); }
.btn.danger { background: var(--danger); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); margin-top: 10px; }
select, input[type=text], input[type=search], input[type=number], input[type=tel], textarea { width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; font-family: inherit; }
select:disabled { background: #f3f3f3; color: #999; }
input[type=range] { width: 100%; }
textarea { min-height: 70px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.radio { display: flex; gap: 12px; font-size: 13px; flex-wrap: wrap; }
.radio label { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--ink); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.list .item .meta { color: var(--muted); font-size: 12px; }
.list .item.empty { color: var(--muted); justify-content: center; }
.chip { display: inline-block; padding: 3px 8px; margin: 2px; border-radius: 999px; background: var(--accent-2); color: var(--accent); font-size: 12px; cursor: pointer; border: 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #eef; color: #335; }
.tag.sell { background: #e3f6ea; color: #1e7a4c; }
.tag.buy { background: #fff3e0; color: #b26a00; }
.tag.rent { background: #e8eaf6; color: #303f9f; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%) translateY(20px); background: #1d2a22; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* ---------- home ---------- */
.hero { background: linear-gradient(135deg, #1e7a4c, #2f9c66); color: #fff; border-radius: 16px; padding: 22px 20px; margin-bottom: 16px; }
.hero h1 { color: #fff; font-size: 24px; }
.hero p { margin: 6px 0 14px; font-size: 14px; opacity: .95; max-width: 640px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .btn { background: #fff; color: var(--accent); }
.hero .btn.ghost { background: rgba(255,255,255,.18); color: #fff; }
.features .feat { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.features .feat b { color: var(--accent); }
.features .feat span { font-size: 13px; color: var(--muted); }

/* ---------- map view ---------- */
.view-map.active { display: grid; grid-template-rows: 50vh 1fr; padding: 0; max-width: none; height: calc(100vh - var(--top-h) - var(--nav-h)); }
.view-map .map-wrap { position: relative; order: -1; }
.view-map .panel { overflow-y: auto; padding: 10px 14px 20px; background: var(--panel); border-top: 1px solid var(--line); }
@media (min-width: 900px) {
  .view-map.active { grid-template-rows: none; grid-template-columns: 360px 1fr; height: calc(100vh - var(--top-h)); }
  .view-map .map-wrap { order: 0; }
  .view-map .panel { border-top: 0; border-right: 1px solid var(--line); }
}
#map { width: 100%; height: 100%; background: #e9eee9; }
#map.dark { background: #000; }
.map-fabs { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.map-fabs button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); font-size: 18px; cursor: pointer; }
.map-fabs button.on { background: var(--accent); }
.measure-box { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.95); padding: 6px 10px; border-radius: 8px; font-size: 13px; z-index: 5; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.panel-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.panel-tabs button { flex: 1; padding: 7px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 13px; cursor: pointer; }
.panel-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.status { font-size: 12px; color: var(--muted); min-height: 16px; margin-top: 10px; }
.attrib { font-size: 11px; color: var(--muted); margin-top: 6px; }
.plot-info { margin-top: 10px; font-size: 13px; line-height: 1.5; }
.plot-info h2 { font-size: 17px; margin: 0 0 4px; }
.plot-info .k { color: var(--muted); }
.plot-info ol { padding-left: 18px; margin: 4px 0; }
.plot-info .actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.units { border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.units td { padding: 2px 10px 2px 0; }
.units td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.measure-result { font-size: 13px; margin-top: 6px; line-height: 1.5; }
.recent h3 { font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

/* ---------- docs ---------- */
.doc h3 { margin: 0 0 4px; font-size: 15px; }
.doc .desc { font-size: 13px; color: var(--muted); }
.doc ol { padding-left: 18px; font-size: 13px; margin: 8px 0; }
.doc .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- listings ---------- */
.filters { margin: 8px 0 12px; }
.filters input { flex: 1; min-width: 180px; }
.filters select { width: auto; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.listing h3 { margin: 4px 0; font-size: 15px; }
.listing .price { font-weight: 700; color: var(--accent); }
.listing .meta { font-size: 12px; color: var(--muted); }
.listing p { font-size: 13px; margin: 6px 0; white-space: pre-wrap; }

/* ---------- status ---------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: #bbb; }
.dot.ok { background: #2e7d32; }
.dot.down { background: #c62828; }

/* ---------- settings / native ---------- */
.icon-link { font-size: 20px; text-decoration: none; padding: 4px; }
.native #installBtn { display: none !important; }
[data-view="settings"] .card { margin-bottom: 12px; }
[data-view="settings"] .card label { margin-top: 0; }

/* ---------- bundled Hindi font ---------- */
@font-face { font-family: 'Noto Sans Devanagari'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/fonts/noto-sans-devanagari-2.woff2) format('woff2'); unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09; }
@font-face { font-family: 'Noto Sans Devanagari'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/fonts/noto-sans-devanagari-1.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans Devanagari'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/fonts/noto-sans-devanagari-3.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
html, body { font-family: 'Noto Sans Devanagari', system-ui, "Segoe UI", Roboto, sans-serif; }

/* ---------- किसान modules ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.chip.on { background: var(--accent); color: #fff; }
.tips { padding-left: 18px; margin: 6px 0; font-size: 13px; line-height: 1.5; }
.wx-now { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.wx-ic { font-size: 48px; }
.wx-temp { font-size: 28px; font-weight: 700; }
.wx-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.wx-day { text-align: center; font-size: 13px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; }
.wx-day-name { font-weight: 600; }
.wx-day-ic { font-size: 26px; }
.wx .card { margin-top: 10px; }
.item.mandi .price-col { text-align: right; min-width: 90px; }
.item.mandi .price { font-weight: 700; color: var(--accent); font-size: 16px; }
.units.big { width: 100%; font-size: 14px; margin: 10px 0; }
.units.big td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.big-out { font-size: 18px; margin: 12px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.guide-card { text-align: left; cursor: pointer; padding: 0; overflow: hidden; display: flex; flex-direction: column; font: inherit; color: inherit; }
.guide-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.guide-card > div { padding: 10px 12px; }
.guide-card h3 { margin: 4px 0; font-size: 15px; }
.guide-noimg { height: 90px; display: flex; align-items: center; justify-content: center; font-size: 40px; background: var(--accent-2); }
.guide-detail { margin-top: 14px; }
.guide-detail h2 { margin: 4px 0; font-size: 19px; }
.guide-detail h3 { font-size: 14px; margin: 12px 0 4px; color: var(--accent); }
.guide-detail ul { padding-left: 18px; margin: 4px 0; font-size: 14px; line-height: 1.55; }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin: 8px 0; }
.gallery figure { margin: 0; flex: 0 0 auto; width: 220px; }
.gallery img { width: 220px; height: 160px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.gallery figcaption { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; }
.overlay[hidden] { display: none; }
.overlay img { max-width: 100%; max-height: 75vh; object-fit: contain; border-radius: 6px; }
.overlay-top { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; color: #fff; font-size: 14px; }
.overlay-cap { color: #ddd; font-size: 12px; margin-top: 8px; text-align: center; }
.overlay-cap a { color: #9be7b8; }
.overlay-nav { position: absolute; bottom: 14px; display: flex; gap: 20px; }
.overlay-nav .btn { font-size: 20px; padding: 6px 18px; }
@media (max-width: 480px) {
  .brand span { display: none; }
  .topbar select { max-width: 130px; }
}

/* ---------- map: panel toggle + full screen ---------- */
.view-map.panel-hidden .panel { display: none; }
.view-map.active.panel-hidden { grid-template-rows: 1fr; }
@media (min-width: 900px) { .view-map.active.panel-hidden { grid-template-columns: 1fr; } }
body.map-full .topbar, body.map-full .nav { display: none; }
body.map-full main { padding: 0; }
body.map-full .view-map.active { position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 40; grid-template-rows: 50vh 1fr; }
body.map-full .view-map.active.panel-hidden { grid-template-rows: 1fr; grid-template-columns: 1fr; }
@media (min-width: 900px) { body.map-full .view-map.active { grid-template-rows: none; grid-template-columns: 360px 1fr; } }

/* ---------- phone safe areas (status bar / navigation bar, edge-to-edge) ---------- */
:root { --sat: env(safe-area-inset-top, var(--safe-area-inset-top, 0px)); --sab: env(safe-area-inset-bottom, var(--safe-area-inset-bottom, 0px)); }
.topbar { padding-top: var(--sat); height: calc(var(--top-h) + var(--sat)); }
main { padding-top: calc(var(--top-h) + var(--sat)); padding-bottom: calc(var(--nav-h) + var(--sab)); }
.nav { padding-bottom: var(--sab); height: calc(var(--nav-h) + var(--sab)); }
.view-map.active { height: calc(100vh - var(--top-h) - var(--sat) - var(--nav-h) - var(--sab)); height: calc(100dvh - var(--top-h) - var(--sat) - var(--nav-h) - var(--sab)); }
#toast { bottom: calc(var(--nav-h) + var(--sab) + 16px); }
@media (min-width: 900px) {
  .nav { top: calc(var(--top-h) + var(--sat)); height: auto; padding-bottom: 0; }
  main { padding-bottom: 0; }
  .view-map.active { height: calc(100vh - var(--top-h) - var(--sat)); height: calc(100dvh - var(--top-h) - var(--sat)); }
}
body.map-full .map-fabs { top: calc(10px + var(--sat)); }
body.map-full .ol-zoom { top: calc(.5em + var(--sat)); }
body.map-full .view-map .panel { padding-bottom: calc(20px + var(--sab)); }
.overlay { padding-top: calc(12px + var(--sat)); padding-bottom: calc(12px + var(--sab)); }
.panel-tabs .panel-hide { flex: 0 0 auto; width: 38px; padding: 7px 0; font-size: 15px; color: var(--accent); background: var(--accent-2); border-color: var(--accent-2); }
.panel-tabs .panel-hide:hover { background: var(--accent); color: #fff; }

/* ---------- अपना नक्शा (draw / नाप) ---------- */
.btn.small.on, .map-fabs button.on { background: var(--accent); color: #fff; }
.draw-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.draw-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; cursor: pointer; background: #fff; }
.draw-item.on { border-color: var(--accent); background: var(--accent-2); }
.draw-item .di-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draw-item .di-val { color: var(--muted); font-size: 12px; white-space: nowrap; }
.draw-item .di-btn { border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--muted); padding: 2px 4px; }
.draw-item .di-btn:hover { color: var(--danger); }
label.btn { cursor: pointer; }
