:root {
  --bg: #f5f3ec;
  --card: #ffffff;
  --ink: #1d2a1f;
  --muted: #667064;
  --line: #e3e0d4;
  --green: #2f6b3a;
  --green-soft: #e3efdd;
  --amber: #a96a00;
  --amber-soft: #fbefd0;
  --blue: #1f5f8b;
  --blue-soft: #dcecf6;
  --red: #b3261e;
  --red-soft: #fbe3e0;
  --grey-soft: #eceae1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 20, .06), 0 2px 8px rgba(30, 40, 20, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a15; --card: #1d251e; --ink: #e8efe5; --muted: #99a597; --line: #2e382f;
    --green: #7fc58a; --green-soft: #1f3a25; --amber: #f0b44c; --amber-soft: #3b2f13;
    --blue: #7db8e3; --blue-soft: #16303f; --red: #ff8f86; --red-soft: #3f1c19; --grey-soft: #283029;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
section { margin-top: 1.6rem; }
p { margin: .3rem 0 .6rem; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .82rem; }
.mt { margin-top: 1rem; }
.strike { text-decoration: line-through; }
.r { text-align: right; }

/* ---- layout */
.shell { min-height: 100vh; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: 76px; }
.content { max-width: 980px; margin: 0 auto; padding: 1rem 16px 2rem; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .6rem 16px; background: var(--green); color: #fff;
  padding-top: max(.6rem, env(safe-area-inset-top));
}
.topbar .brand, .topbar .brand:hover { color: #fff; font-weight: 700; text-decoration: none; }
.topbar .btn.primary { background: #fff; color: var(--green); border-color: #fff; }
.quick { position: relative; }
.quick summary { list-style: none; cursor: pointer; }
.quick summary::-webkit-details-marker { display: none; }
.quick-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 230px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0, 0, 0, .18); padding: .4rem;
}
.quick-menu a { display: block; padding: .6rem .7rem; border-radius: 10px; color: var(--ink); }
.quick-menu a:hover { background: var(--green-soft); text-decoration: none; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 0; padding: .45rem 0 .4rem; font-size: .72rem; color: var(--muted); }
.bottom-nav a span { font-size: 1.35rem; line-height: 1.2; }
.bottom-nav a.active { color: var(--green); font-weight: 600; }
.bottom-nav a:hover { text-decoration: none; }

@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; width: 244px; flex: none; position: sticky; top: 0; height: 100vh;
    padding: 1.1rem .8rem; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto;
  }
  .sidebar .brand { font-size: 1.2rem; font-weight: 700; color: var(--green); margin: 0 .5rem 1rem; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar nav a { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: 10px; color: var(--ink); }
  .sidebar nav a:hover { background: var(--grey-soft); text-decoration: none; }
  .sidebar nav a.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
  .sidebar .ico { width: 1.4rem; text-align: center; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 0; }
  .topbar { background: var(--bg); color: var(--ink); justify-content: flex-end; padding: .8rem 24px 0; }
  .topbar .brand { display: none; }
  .topbar .btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
  .content { padding: 1rem 24px 3rem; }
}

/* ---- pieces */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .8rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.section-head h2 { margin: 0 0 .6rem; }
.crumbs { margin: 0 0 .2rem; font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
form.inline, .chips form { display: inline; margin: 0; }
.flash { background: var(--green-soft); color: var(--green); border-radius: 12px; padding: .65rem .9rem; margin-bottom: 1rem; font-weight: 500; }
.flash.error { background: var(--red-soft); color: var(--red); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
.empty .btn { margin-left: .5rem; }
.summary { color: var(--muted); margin: 0 0 .6rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem .95rem; min-height: 42px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; padding: .4rem .6rem; font: inherit; color: var(--muted); cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--red); }
.sidebar form { margin-top: 1rem; }

.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--red-soft); color: var(--red); }

.bar { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; margin: .55rem 0 .2rem; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: .6rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; color: var(--ink); display: block; }
.stat:hover { text-decoration: none; border-color: var(--green); }
.stat b { display: block; font-size: 1.45rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.alert b { color: var(--red); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* list rows */
.item { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; align-items: start; }
.item.slim { padding: .65rem .9rem; }
.item-main { min-width: 0; }
.item-title { font-weight: 650; font-size: 1.02rem; color: var(--ink); overflow-wrap: anywhere; }
a.item-title { color: var(--ink); }
.item-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.amount { font-size: 1.05rem; }
.item-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
.item-actions form { margin: 0; }
a.item { color: inherit; }
a.item:hover { text-decoration: none; border-color: var(--green); }
.meta { display: flex; flex-wrap: wrap; gap: .1rem .8rem; font-size: .85rem; color: var(--muted); margin-top: .15rem; }
.meta a { font-weight: 600; }
.chip {
  display: inline-block; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--green); text-decoration: none; }
.chip.danger { color: var(--red); }
.overdue { border-color: var(--red); }

.item:has(> form > .tick) { grid-template-columns: auto 1fr auto; }
.item:has(> form > .tick) .item-actions { grid-column: 2 / -1; }
.milestone { grid-template-columns: auto 1fr auto; align-items: center; }
.milestone .item-actions { grid-column: auto; }
.milestone.done .item-title { text-decoration: line-through; color: var(--muted); }
.tick {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--green); background: transparent; color: #fff;
  font-size: 1rem; line-height: 1; cursor: pointer; padding: 0;
}
.milestone.done .tick { background: var(--green); }
.tick:hover { background: var(--green-soft); }

/* crops */
.grid-cards { display: grid; grid-template-columns: 1fr; gap: .7rem; }
@media (min-width: 640px) { .grid-cards { grid-template-columns: repeat(2, 1fr); } }
.crop { display: block; color: var(--ink); }
.crop:hover { text-decoration: none; border-color: var(--green); }
.crop-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.two-col { display: grid; gap: 0 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1rem; }
.facts.flat { padding: .6rem 0 0; }
@media (min-width: 700px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.facts span { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.facts b { font-weight: 600; }
.note p { margin: .2rem 0; white-space: pre-wrap; }
.card + .card, .facts + .note { margin-top: .6rem; }

/* suggestions */
.sugg { border-left: 5px solid var(--blue); }
.sugg.high { border-left-color: var(--red); }
.sugg.medium { border-left-color: var(--amber); }
.sugg-head { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.sugg p { margin: .35rem 0; }

/* forms */
.form .grid { display: grid; gap: .9rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form .grid { grid-template-columns: 1fr 1fr; } .field.full { grid-column: 1 / -1; } }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field .req { color: var(--red); }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea, input[type=file] {
  width: 100%; padding: .6rem .7rem; min-height: 44px; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible, .tick:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 1px;
}
.field .help { color: var(--muted); font-size: .8rem; display: block; margin-top: .2rem; }
.field .err { color: var(--red); font-size: .85rem; font-weight: 600; }
.has-error input, .has-error select { border-color: var(--red); }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
label.check input { width: 22px; height: 22px; accent-color: var(--green); }
.actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.filters input[type=search] { flex: 1 1 180px; width: auto; }
.filters select { flex: 1 1 160px; width: auto; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 1.6rem; }
.login-card .field { text-align: left; margin: 1rem 0; }
.login-logo { font-size: 3rem; }

/* tiles on the menu page */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; color: var(--ink); font-weight: 600; display: flex; flex-direction: column; gap: .3rem; }
.tile .big { font-size: 1.8rem; }
.tile:hover { text-decoration: none; border-color: var(--green); }

/* timers */
.clock { font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.clock.big { font-size: 1.9rem; color: var(--green); }
.clock.over { color: var(--red); }
.running { border-color: var(--green); }
.stop-form { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; }
.stop-form input { flex: 1 1 200px; width: auto; }

/* files */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; margin-bottom: .8rem; }
.file { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.file img { width: 100%; height: 110px; object-fit: cover; display: block; }
.file .pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 110px; font-size: 2rem; padding: .4rem; text-align: center; }
.file .pdf span { font-size: .72rem; word-break: break-all; line-height: 1.2; }
.file figcaption { display: flex; justify-content: space-between; align-items: center; gap: .3rem; font-size: .78rem; padding: .3rem .5rem; color: var(--muted); }
.file figcaption form { margin: 0; }
.upload { display: flex; flex-wrap: wrap; gap: .5rem; }
.upload input[type=file] { flex: 2 1 220px; width: auto; }
.upload input[type=text] { flex: 1 1 160px; width: auto; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
th.r, td.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
td.neg { color: var(--red); }
tr.sub td { color: var(--muted); }

/* ---- language switch */
.top-actions { display: flex; align-items: center; gap: .5rem; }
.lang-btn {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 .85rem; border-radius: 11px; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .55); color: #fff; background: transparent;
}
.lang-btn:hover { text-decoration: none; background: rgba(255, 255, 255, .15); }
.side-foot { margin-top: 1rem; display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }
.side-foot form { margin: 0; }
.side-foot .lang-btn { color: var(--green); border-color: var(--line); margin-left: .35rem; }
.login-lang { position: fixed; top: 12px; right: 16px; }
.login-lang .lang-btn { color: var(--green); border-color: var(--line); background: var(--card); }
@media (min-width: 900px) { .top-actions .lang-btn { display: none; } }

/* Tamil script needs a little more line height and a Tamil-capable font stack */
html[lang="ta"] body {
  line-height: 1.65;
  font-family: system-ui, -apple-system, "Noto Sans Tamil", "Latha", "Nirmala UI", "Tamil Sangam MN", "Segoe UI", Roboto, sans-serif;
}
html[lang="ta"] .badge, html[lang="ta"] .chip, html[lang="ta"] .btn { line-height: 1.4; }
html[lang="ta"] .facts span, html[lang="ta"] th { text-transform: none; letter-spacing: 0; }
.topbar .brand { font-size: .95rem; line-height: 1.25; }
.top-actions .btn, .lang-btn { white-space: nowrap; }

/* ---- bell, weather, articles, notifications */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 42px; min-height: 42px; font-size: 1.25rem; color: inherit; border-radius: 11px; }
.bell:hover { text-decoration: none; background: rgba(127, 127, 127, .15); }
.bell b { position: absolute; top: 2px; right: 0; min-width: 18px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
.notif.unread { border-left: 5px solid var(--green); }
.now { display: grid; gap: .8rem; }
.now-main { display: flex; align-items: center; gap: .9rem; }
.big { font-size: 2.2rem; line-height: 1; }
.temp { font-size: 1.8rem; }
.days { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 700px) { .days { grid-template-columns: repeat(4, 1fr); } }
.day { display: flex; flex-direction: column; gap: .15rem; align-items: center; text-align: center; padding: .7rem .5rem; }
.day.wet { border-color: var(--blue); background: var(--blue-soft); }
.rainbars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 1rem; }
.rb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.rb i { display: block; width: 100%; background: var(--blue); border-radius: 4px 4px 0 0; }
.rb small { font-size: .65rem; color: var(--muted); }
.article-card strong { display: block; margin: .4rem 0 .2rem; }
.article-card p { margin: 0; }
.prose { max-width: 720px; }
.prose h1 { margin: .4rem 0; }
.prose h2 { margin-top: 1.6rem; }
.prose .lead { font-size: 1.1rem; color: var(--muted); }
.prose table { margin: 1rem 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; display: block; overflow-x: auto; }
.prose li { margin: .25rem 0; }
.prose a { text-decoration: underline; }
ul.plain { padding-left: 1.1rem; }
.setup-card { border-left: 5px solid var(--amber); }
.prose table { display: table; width: 100%; border-collapse: collapse; overflow: hidden; }
.prose th, .prose td { white-space: normal; padding: .55rem .7rem; vertical-align: top; }
.prose th:last-child, .prose td:last-child { text-align: right; white-space: nowrap; }

input[type=email], input[type=url], input[type=tel] {
  width: 100%; padding: .6rem .7rem; min-height: 44px; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
input[type=email]:focus, input[type=url]:focus, input[type=tel]:focus { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 1px; }

/* ---- brand: light logo, FARM with 9th Direction underneath */
.brand { display: inline-flex; align-items: center; gap: .6rem; min-width: 0; }
.brand img { display: block; flex: none; width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; white-space: nowrap; }
.brand-text b { font-size: 1.15rem; letter-spacing: .3em; line-height: 1.1; }
.brand-text small { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; line-height: 1.1; color: #ecd08f; }
/* desktop: the sidebar starts with a full-width green band (same green as the phone top bar) */
@media (min-width: 900px) {
  .sidebar .brand { display: flex; margin: -1.1rem -.8rem 1rem; padding: .95rem 1.1rem; background: var(--green); color: #fff; font-size: 1rem; }
  .sidebar .brand:hover { text-decoration: none; }
}

/* phones: compact top-bar controls so the whole brand stays on one line */
@media (max-width: 420px) {
  .topbar { padding-left: 12px; padding-right: 12px; gap: .3rem; }
  .brand { gap: .45rem; }
  .brand img { width: 32px; height: 32px; }
  .brand-text b { font-size: 1rem; letter-spacing: .24em; }
  .brand-text small { font-size: .55rem; letter-spacing: .1em; }
  .top-actions { gap: .25rem; }
  .bell { min-width: 34px; }
  .top-actions .lang-btn { padding: .3rem .5rem; font-size: .8rem; }
  .quick summary { font-size: 0; width: 38px; height: 38px; min-height: 0; padding: 0; display: flex; align-items: center; justify-content: center; }
  .quick summary::before { content: "+"; font-size: 1.5rem; line-height: 1; }
}
