/*
 * IIRR Receipt Review. Light theme by default; dark and "follow the device" are chosen with the switch in the menu
 * (the choice sits on <html data-theme>). Fonts are served from this site. Google Sans and Tiro Telugu are under the
 * SIL Open Font Licence, see /assets/fonts.
 */
@font-face {
  font-family: "Google Sans";
  src: url("/assets/fonts/google-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+2010-2015, U+2018-201E, U+2022, U+2026, U+20B9, U+2190-2193, U+2212;
}
@font-face {
  font-family: "Tiro Telugu";
  src: url("/assets/fonts/tiro-telugu.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0C00-0C7F, U+200C-200D;
}

/* ---------- Colours ---------- */

:root {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ec;
  --surface-3: #e2eadf;
  --text: #17231b;
  --muted: #5a685f;
  --line: #d9e2d6;
  --primary: #1b7a43;
  --primary-hover: #146234;
  --primary-soft: #e3f3e8;
  --on-primary: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d4;
  --warn-line: #ecc75a;
  --info: #1f5fbf;
  --info-soft: #e8f0fd;
  --focus: #1a5fd0;
  --shadow: 0 1px 2px rgb(16 40 24 / 6%), 0 6px 20px rgb(16 40 24 / 7%);
  --shadow-lift: 0 2px 4px rgb(16 40 24 / 8%), 0 12px 32px rgb(16 40 24 / 12%);
  --radius: 14px;
  --font: "Google Sans", "Tiro Telugu", system-ui, -apple-system, "Segoe UI", "Telugu Sangam MN", "Nirmala UI", Gautami, Roboto, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1511;
  --surface: #172019;
  --surface-2: #1e2a21;
  --surface-3: #27362b;
  --text: #e7efe9;
  --muted: #a3b2a8;
  --line: #2d3b31;
  --primary: #5cc98a;
  --primary-hover: #7bd8a1;
  --primary-soft: #183825;
  --on-primary: #06210f;
  --danger: #ff9d92;
  --danger-soft: #3a1714;
  --warn: #f2c35b;
  --warn-soft: #34290c;
  --warn-line: #7d6216;
  --info: #9ec2ff;
  --info-soft: #172741;
  --focus: #8ab4ff;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-lift: 0 4px 18px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1511;
    --surface: #172019;
    --surface-2: #1e2a21;
    --surface-3: #27362b;
    --text: #e7efe9;
    --muted: #a3b2a8;
    --line: #2d3b31;
    --primary: #5cc98a;
    --primary-hover: #7bd8a1;
    --primary-soft: #183825;
    --on-primary: #06210f;
    --danger: #ff9d92;
    --danger-soft: #3a1714;
    --warn: #f2c35b;
    --warn-soft: #34290c;
    --warn-line: #7d6216;
    --info: #9ec2ff;
    --info-soft: #172741;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-lift: 0 4px 18px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (orientation: landscape) and (min-width: 106.25em) { html { font-size: 112.5%; } }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: anywhere;
}
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.te { font-family: "Tiro Telugu", var(--font); }

.h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); line-height: 1.35; font-weight: 700; }
.h2 { font-size: 1.1875rem; line-height: 1.4; font-weight: 700; }
.h3 { font-size: 1rem; line-height: 1.45; font-weight: 650; }
.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.skip { position: absolute; left: 0.5rem; top: -4rem; z-index: 50; padding: 0.75rem 1rem; background: var(--surface); color: var(--text); border: 2px solid var(--focus); border-radius: var(--radius); }
.skip:focus { top: 0.5rem; }

.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.125rem;
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.pill:hover { background: var(--surface-2); border-color: var(--muted); }
.pill:active { transform: scale(0.98); }
.pill--primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.pill--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.pill--soft { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.pill--soft:hover { background: var(--surface-3); border-color: transparent; }
.pill--danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.pill--sm { min-height: 2.25rem; padding: 0.3rem 0.875rem; font-size: 0.875rem; }
.pill--block { width: 100%; }
.pill[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.pill[aria-current="page"], .pill[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.pill .count { padding: 0 0.45rem; font-size: 0.8125rem; border-radius: 999px; background: var(--surface-3); color: var(--text); }
.pill[aria-current="page"] .count { background: rgb(255 255 255 / 25%); color: inherit; }
.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pills--scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: thin; }

/* Small status labels (not buttons). */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; font-size: 0.8125rem; font-weight: 650; line-height: 1.5; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge--ok { background: var(--primary-soft); color: var(--primary); }
.badge--bad { background: var(--danger-soft); color: var(--danger); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge .icon { width: 1em; height: 1em; }

/* ---------- Signed-in layout ---------- */

.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.625rem; color: var(--text); text-decoration: none; }
.brand__mark { width: 2.25rem; height: 2.25rem; color: var(--primary); }
.brand__name { font-size: 1.0625rem; font-weight: 750; line-height: 1.15; }
.brand__tag { font-size: 0.75rem; color: var(--muted); }
.nav { order: 3; flex-basis: 100%; display: flex; gap: 0.375rem; overflow-x: auto; padding-bottom: 0.125rem; }
.nav .pill { border-color: transparent; background: transparent; }
.nav .pill:hover { background: var(--surface-2); }
.nav .pill[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.side__tools { margin-inline-start: auto; display: flex; align-items: center; gap: 0.5rem; }
.who { display: none; }
.theme-switch { display: inline-flex; padding: 0.2rem; gap: 0.15rem; background: var(--surface-2); border-radius: 999px; }
.theme-switch a { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; color: var(--muted); border-radius: 999px; }
.theme-switch a:hover { color: var(--text); }
.theme-switch a[aria-current="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.main { width: 100%; max-width: 92rem; margin-inline: auto; padding: clamp(1rem, 2.5vw, 2.25rem) clamp(1rem, 2.5vw, 2.25rem) 3rem; }

@media (min-width: 64em) {
  .shell { grid-template-rows: 1fr; grid-template-columns: 16.5rem minmax(0, 1fr); }
  .side {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 1.25rem;
    padding: 1.5rem 1rem;
    border-bottom: 0;
    border-inline-end: 1px solid var(--line);
  }
  .nav { order: 0; flex-direction: column; overflow: visible; }
  .nav .pill { justify-content: flex-start; width: 100%; min-height: 3rem; }
  .side__tools { margin: auto 0 0; flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .who { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem; border-radius: var(--radius); background: var(--surface-2); }
  .theme-switch { align-self: flex-start; }
}

.avatar { display: inline-grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 999px; }
.avatar--lg { width: 3.5rem; height: 3.5rem; font-size: 1.25rem; }

/* ---------- Page pieces ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head > div { display: grid; gap: 0.375rem; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; }

.card { padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.25); box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card, .stack > * + * { margin-top: 1.25rem; }
.card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.card__head .h2 { display: flex; align-items: center; gap: 0.5rem; }
.card--flat { box-shadow: none; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 16rem)), 1fr)); }
.split { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); align-items: start; }

.flash { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 1.25rem; padding: 0.875rem 1.125rem; font-weight: 600; border-radius: var(--radius); }
.flash--ok { color: var(--primary); background: var(--primary-soft); }
.flash--error { color: var(--danger); background: var(--danger-soft); }
.flash--warn { color: var(--warn); background: var(--warn-soft); }

.empty { display: grid; justify-items: center; gap: 0.75rem; padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty .icon { width: 3rem; height: 3rem; color: var(--primary); }

/* ---------- Overview ---------- */

.stat { position: relative; display: grid; gap: 0.25rem; padding: 1.125rem 1.25rem; color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.25); box-shadow: var(--shadow); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat__icon { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.stat__n { font-size: 2.25rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__l { font-weight: 650; }
.stat__s { font-size: 0.875rem; color: var(--muted); }
.stat--hero { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.stat--hero .stat__s { color: inherit; opacity: 0.85; }
.stat--hero .stat__icon { background: rgb(255 255 255 / 18%); color: inherit; }

.signal { display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 1rem; color: var(--text); text-decoration: none; background: var(--surface-2); border-radius: var(--radius); transition: background-color 0.12s ease; }
.signal:hover { background: var(--surface-3); }
.signal__n { min-width: 2.75rem; padding: 0.25rem 0.5rem; font-size: 1.25rem; font-weight: 750; text-align: center; border-radius: 999px; background: var(--surface); }
.signal--bad .signal__n { color: var(--danger); }
.signal--warn .signal__n { color: var(--warn); }
.signal__t { display: grid; }
.signal__t span { font-size: 0.8125rem; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 9rem; border-bottom: 1px solid var(--line); }
.bars__bar { flex: 1 1 0; min-width: 0; height: 0; background: var(--primary); border-radius: 4px 4px 0 0; opacity: 0.85; }
.bars__bar:hover { opacity: 1; }
.bars__axis { display: flex; justify-content: space-between; margin-top: 0.375rem; font-size: 0.8125rem; color: var(--muted); }

.problem { display: flex; gap: 0.875rem; align-items: center; padding: 0.625rem; color: var(--text); text-decoration: none; border-radius: var(--radius); transition: background-color 0.12s ease; }
.problem:hover { background: var(--surface-2); }
.problem__img { width: 3.5rem; height: 3.5rem; flex: none; object-fit: cover; border-radius: 12px; background: var(--surface-3); }
.problem__body { flex: 1; min-width: 0; display: grid; }
.problem__nums { display: flex; gap: 0.375rem; flex-wrap: wrap; justify-content: flex-end; }
.meter { height: 0.375rem; margin-top: 0.375rem; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 999px; width: 0; }

/* ---------- Receipt cards ---------- */

.toolbar { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filters .field-pill { display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2.75rem; padding: 0 0.375rem 0 0.875rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; }
.filters .field-pill .icon { color: var(--muted); }
.filters input, .filters select { min-height: 2.5rem; padding: 0 0.5rem; font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 999px; }
.filters input[type="search"] { width: min(18rem, 60vw); }
.filters input:focus, .filters select:focus { outline: none; }
.filters .field-pill:focus-within { border-color: var(--focus); }

.rcard { display: grid; grid-template-rows: auto 1fr; color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.25); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.rcard__media { position: relative; aspect-ratio: 16 / 10; background: var(--surface-3); }
.rcard__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rcard__noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.rcard__noimg .icon { width: 2.5rem; height: 2.5rem; opacity: 0.5; }
.rcard__status { position: absolute; top: 0.625rem; left: 0.625rem; }
.rcard__status .badge { box-shadow: var(--shadow); background: var(--surface); }
.rcard__status .badge--ok { background: var(--primary-soft); }
.rcard__status .badge--bad { background: var(--danger-soft); }
.rcard__crop { position: absolute; bottom: 0.625rem; left: 0.625rem; display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.2rem 0.65rem 0.2rem 0.2rem; font-size: 0.8125rem; font-weight: 650; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); }
.rcard__crop img, .rcard__crop .dot { width: 1.5rem; height: 1.5rem; border-radius: 999px; object-fit: cover; background: var(--primary-soft); }
.rcard__body { display: grid; gap: 0.5rem; align-content: start; padding: 0.875rem 1rem 1rem; }
.rcard__title { font-size: 1.125rem; font-weight: 700; line-height: 1.35; }
.rcard__sub { font-size: 0.875rem; color: var(--muted); }
.rcard__meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.875rem; font-size: 0.8125rem; color: var(--muted); }
.rcard__meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.rcard__meta .icon { width: 1rem; height: 1rem; }
.rcard__signs { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.pager { display: flex; justify-content: center; align-items: center; gap: 0.75rem; margin-top: 1.75rem; }

/* ---------- One receipt ---------- */

.review { display: grid; gap: 1.25rem; }
@media (min-width: 75em) {
  .review { grid-template-columns: minmax(0, 1fr) 27rem; align-items: start; }
  .review__side { position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); overflow-y: auto; border-radius: calc(var(--radius) * 1.25); }
}

.hero { display: grid; gap: 1.25rem; }
@media (min-width: 48em) { .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
.gallery { display: grid; gap: 0.5rem; }
.gallery__main { position: relative; display: block; width: 100%; padding: 0; aspect-ratio: 4 / 3; background: var(--surface-3); border: 0; border-radius: var(--radius); overflow: hidden; cursor: zoom-in; }
.gallery__main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery__zoom { position: absolute; right: 0.625rem; bottom: 0.625rem; }
.gallery__thumbs { display: flex; gap: 0.5rem; }
.gallery__thumbs button { width: 4.5rem; height: 3.5rem; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--surface-3); cursor: pointer; }
.gallery__thumbs button[aria-pressed="true"] { border-color: var(--primary); }
.gallery__thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { display: grid; place-items: center; gap: 0.5rem; aspect-ratio: 4 / 3; color: var(--muted); background: var(--surface-2); border-radius: var(--radius); text-align: center; }
.noimg .icon { width: 2.5rem; height: 2.5rem; opacity: 0.6; }

.hero__info { display: grid; gap: 1rem; align-content: start; }
.hero__title { display: grid; gap: 0.125rem; }
.hero__title .te { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 700; line-height: 1.35; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.875rem 0.25rem 0.25rem; background: var(--surface-2); border-radius: 999px; font-weight: 600; font-size: 0.9375rem; }
.chip img, .chip .dot { width: 2rem; height: 2rem; border-radius: 999px; object-fit: cover; background: var(--surface-3); }
.chip .dot { display: grid; place-items: center; color: var(--primary); }
.chip .dot .icon { width: 1.1rem; height: 1.1rem; }
.chip small { display: block; font-size: 0.75rem; font-weight: 500; color: var(--muted); line-height: 1.2; }
.chip span { line-height: 1.25; }

.symptoms { padding: 0.875rem 1rem; background: var(--surface-2); border-radius: var(--radius); }

.treat { display: grid; gap: 0.875rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.treat__card { display: grid; grid-template-columns: auto 1fr; gap: 0.875rem; padding: 1rem; background: var(--surface-2); border-radius: var(--radius); }
.treat__img { width: 4rem; height: 4rem; object-fit: cover; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.treat__body { display: grid; gap: 0.375rem; min-width: 0; }
.treat__name { font-weight: 700; line-height: 1.3; }
.treat__dose { display: inline-flex; align-items: center; gap: 0.375rem; justify-self: start; padding: 0.25rem 0.75rem; font-weight: 700; color: var(--primary); background: var(--surface); border-radius: 999px; }
.treat__how { font-size: 0.875rem; color: var(--muted); }
.treat__card--ad { background: var(--info-soft); }
.treat__card--ad .treat__dose { color: var(--info); }

.compare { display: grid; gap: 0.5rem; }
.compare__row { display: grid; grid-template-columns: minmax(6rem, auto) 1fr auto; gap: 0.75rem; align-items: center; padding: 0.625rem 0.875rem; background: var(--surface-2); border-radius: 12px; }
.compare__row .muted { font-size: 0.8125rem; }

.farmer { display: flex; gap: 1rem; align-items: center; }
.facts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.fact { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.35rem 0.875rem; font-size: 0.9375rem; background: var(--surface-2); border-radius: 999px; }
.fact .icon { width: 1.05rem; height: 1.05rem; color: var(--muted); }
.fields { display: grid; gap: 0.625rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); margin-top: 1rem; }
.field-card { padding: 0.875rem 1rem; background: var(--surface-2); border-radius: var(--radius); }
.field-card__crop { font-weight: 700; }
.timeline { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* Review form */
.review__side .card { border: 2px solid var(--primary); }
.form { display: grid; gap: 1.125rem; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend, .label { display: block; margin-bottom: 0.5rem; font-weight: 650; }
.hint { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.field-error { margin-top: 0.375rem; font-size: 0.875rem; font-weight: 650; color: var(--danger); }
.input { width: 100%; min-height: 3rem; padding: 0.7rem 0.95rem; font: inherit; font-size: max(1rem, 16px); color: var(--text); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; }
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; line-height: 1.55; }
select.input { padding-inline-end: 2rem; }

/* Big "correct / discrepancy" choice. The radio stays in the page for keyboards and screen readers. */
.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.verdict { position: relative; }
.verdict input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.verdict span { display: grid; justify-items: center; gap: 0.375rem; padding: 1rem 0.5rem; text-align: center; font-weight: 700; background: var(--surface-2); border: 2px solid transparent; border-radius: var(--radius); transition: background-color 0.12s ease, border-color 0.12s ease; }
.verdict span .icon { width: 1.75rem; height: 1.75rem; }
.verdict:hover span { border-color: var(--line); }
.verdict input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.verdict--ok input:checked + span { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); }
.verdict--bad input:checked + span { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

/* Tickable option cards (what is wrong, send by). */
.options { display: grid; gap: 0.5rem; }
.options--row { display: flex; flex-wrap: wrap; }
.option { position: relative; display: block; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option > span { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 0.875rem; background: var(--surface-2); border: 2px solid transparent; border-radius: 12px; transition: border-color 0.12s ease, background-color 0.12s ease; }
.option > span::before { content: ""; flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.1rem; border: 2px solid var(--muted); border-radius: 6px; background: var(--surface); }
.option strong { display: block; }
.option input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.option input:checked + span::before { border-color: var(--primary); background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 80% no-repeat; }
.option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.option input:disabled + span { opacity: 0.5; cursor: not-allowed; }
.options--row .option > span { padding: 0.5rem 1rem 0.5rem 0.75rem; border-radius: 999px; align-items: center; }
.options--row .option > span::before { margin-top: 0; border-radius: 999px; }

/* On/off switch for "alert this farmer". */
.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.875rem 1rem; font-weight: 700; background: var(--surface-2); border-radius: var(--radius); cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch__track { position: relative; flex: none; width: 3.25rem; height: 1.875rem; background: var(--surface-3); border-radius: 999px; transition: background-color 0.15s ease; }
.switch__track::after { content: ""; position: absolute; top: 0.1875rem; left: 0.1875rem; width: 1.5rem; height: 1.5rem; background: #fff; border-radius: 999px; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); transition: transform 0.15s ease; }
.switch input:checked ~ .switch__track { background: var(--primary); }
.switch input:checked ~ .switch__track::after { transform: translateX(1.375rem); }
.switch input:focus-visible ~ .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }

.panel-in { display: grid; gap: 1rem; padding: 1rem; background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.counter { justify-self: end; font-size: 0.8125rem; color: var(--muted); }
.actions { display: grid; gap: 0.5rem; }
[hidden] { display: none !important; }

/* Lightbox */
.lightbox { padding: 0; max-width: min(96vw, 70rem); max-height: 92vh; background: transparent; border: 0; }
.lightbox::backdrop { background: rgb(0 0 0 / 82%); }
.lightbox img { display: block; max-width: 100%; max-height: 86vh; margin: auto; border-radius: var(--radius); }
.lightbox form { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }

/* ---------- Alerts, corrections, people ---------- */

.acard { display: grid; gap: 0.875rem; padding: 1.125rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.25); box-shadow: var(--shadow); }
.acard__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.acard__head .grow { flex: 1; min-width: 12rem; display: grid; }
.acard__msg { padding: 0.75rem 1rem; font-size: 1.0625rem; background: var(--surface-2); border-inline-start: 4px solid var(--primary); border-radius: 12px; }
.acard__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.channel { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.75rem; font-size: 0.875rem; font-weight: 650; border-radius: 999px; background: var(--surface-2); }
.channel .icon { width: 1rem; height: 1rem; }
.channel--ok { background: var(--primary-soft); color: var(--primary); }
.channel--bad { background: var(--danger-soft); color: var(--danger); }
.channel--wait { background: var(--warn-soft); color: var(--warn); }
.channel small { font-weight: 500; opacity: 0.85; }
.inline { display: inline; }

.ccard__cols { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.ccard__box { padding: 0.875rem 1rem; border-radius: 12px; background: var(--surface-2); }
.ccard__box--bad { background: var(--danger-soft); }
.ccard__box--ok { background: var(--primary-soft); }
details.drawer { border-radius: var(--radius); background: var(--surface-2); }
details.drawer > summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.875rem 1rem; font-weight: 700; cursor: pointer; list-style: none; border-radius: var(--radius); }
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
details.drawer[open] > summary::after { content: "▴"; }
details.drawer > .form { padding: 0 1rem 1rem; }

.person { display: grid; gap: 0.875rem; }
.person__top { display: flex; gap: 0.875rem; align-items: center; }
.person__nums { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.linkbox { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.linkbox .input { flex: 1; }

.tablelike { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.tablelike th { text-align: start; font-size: 0.8125rem; color: var(--muted); padding: 0.5rem; border-bottom: 1px solid var(--line); }
.tablelike td { padding: 0.5rem; border-bottom: 1px solid var(--line); }

/* ---------- Sign-in pages ---------- */

.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem; background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 55%), var(--bg); }
.auth__panel { width: 100%; max-width: 28rem; padding: clamp(1.5rem, 4vw, 2.25rem); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lift); }
.auth__brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.auth__brand .brand__mark { width: 3rem; height: 3rem; }
.auth .form { margin-top: 1.25rem; }
.auth__foot { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--muted); }
.input-group { position: relative; }
.input-toggle { position: absolute; top: 0.375rem; bottom: 0.375rem; right: 0.375rem; padding: 0 0.875rem; font: inherit; font-size: 0.875rem; font-weight: 650; color: var(--primary); background: var(--surface-2); border: 0; border-radius: 999px; cursor: pointer; }
.input--has-toggle { padding-right: 5.5rem; }

/* ---------- Farmer's alert page ---------- */

.farmer-page { display: grid; place-items: start center; padding: 1rem; font-size: 1.125rem; }
.farmer-page__card { width: 100%; max-width: 36rem; display: grid; gap: 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.farmer-page__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--primary); }
.farmer-page__logo { height: 2.5rem; width: auto; border-radius: 6px; }
.farmer-page__tag { font-weight: 700; color: var(--primary); text-align: end; }
.farmer-page__hello { font-weight: 700; font-size: 1.25rem; }
.farmer-page__msg { padding: 1rem; font-size: 1.25rem; line-height: 1.75; background: var(--primary-soft); border-inline-start: 5px solid var(--primary); border-radius: 14px; }
.farmer-page__msg--en { font-size: 1rem; background: var(--surface-2); border-color: var(--line); }

/* ---------- Preferences ---------- */

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (forced-colors: active) {
  .pill, .card, .rcard, .badge, .option > span, .verdict span, .input, .switch__track { border: 2px solid CanvasText; }
  .bars__bar { background: CanvasText; }
}
@media print {
  .side, .review__side, .toolbar, .skip { display: none; }
  body { background: #fff; color: #000; }
}

.field { display: grid; gap: 0.25rem; }
.field .label { margin-bottom: 0.25rem; }
.gap-top { margin-top: 1rem; }
.grid--stats { --min: 13rem; }
.grid--wide { --min: 17rem; }
.gap-top-lg { margin-top: 1.25rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.grow-input { flex: 1 1 14rem; width: auto; min-height: 2.75rem; }
.farmer-page__from { font-weight: 600; }
.review, .hero { grid-template-columns: minmax(0, 1fr); }
.review__main, .review__side, .hero > * { min-width: 0; }
.signal__n { white-space: nowrap; flex: none; }
.chip { max-width: 100%; }
@media (min-width: 48em) { .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
@media (min-width: 75em) { .review { grid-template-columns: minmax(0, 1fr) 27rem; } }
.gap-bottom { margin-bottom: 1.25rem; }
.shell { grid-template-columns: minmax(0, 1fr); }
.side { min-width: 0; }
@media (min-width: 64em) { .shell { grid-template-columns: 16.5rem minmax(0, 1fr); } }

/* ---------- Dropdowns (Alpine) ---------- */

[x-cloak] { display: none !important; }
.dd { position: relative; }
.dd[data-ready] .dd__native { display: none; }
.dd__button { gap: 0.5rem; padding-inline-end: 0.75rem; font: inherit; color: var(--text); cursor: pointer; }
.dd__button:hover { border-color: var(--muted); }
.dd__button[aria-expanded="true"] { border-color: var(--focus); }
.dd__button--set { color: var(--primary); background: var(--primary-soft); border-color: transparent; font-weight: 650; }
.dd__button--set .icon { color: var(--primary); }
.dd__label { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd__chev { width: 1rem; height: 1rem; color: var(--muted); transition: transform 0.15s ease; }
.dd__button[aria-expanded="true"] .dd__chev { transform: rotate(180deg); }
.dd__menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.375rem);
  left: 0;
  min-width: max(100%, 15rem);
  max-width: min(22rem, 92vw);
  padding: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
}
.dd__search { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; padding: 0 0.75rem; background: var(--surface-2); border-radius: 999px; }
.dd__search .icon { color: var(--muted); width: 1rem; height: 1rem; }
.dd__search input { flex: 1; min-width: 0; min-height: 2.5rem; font: inherit; color: var(--text); background: transparent; border: 0; outline: none; }
.dd__list { max-height: 18rem; margin: 0; padding: 0; list-style: none; overflow-y: auto; outline: none; }
.dd__option { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.875rem; border-radius: 10px; cursor: pointer; }
.dd__option.is-active { background: var(--surface-2); }
.dd__option.is-selected { color: var(--primary); font-weight: 650; }
.dd__tick { width: 1rem; height: 1rem; visibility: hidden; }
.dd__option.is-selected .dd__tick { visibility: visible; }
.dd__empty { padding: 0.75rem 0.875rem; color: var(--muted); font-size: 0.875rem; }

/* ---------- Date range (flatpickr), styled to match ---------- */

.daterange { cursor: pointer; }
.daterange__input { width: 13.5rem; cursor: pointer; }
.daterange__input::placeholder { color: var(--text); }
.flatpickr-calendar { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift); font-family: var(--font); padding: 0.375rem; width: auto; }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after { display: none; }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year { color: var(--text); fill: var(--text); background: transparent; font-weight: 700; }
.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month { background: var(--surface); }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { color: var(--muted); fill: var(--muted); border-radius: 999px; }
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--primary); }
span.flatpickr-weekday { color: var(--muted); font-weight: 650; background: transparent; }
.flatpickr-day { color: var(--text); border-radius: 999px; border-color: transparent; }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--surface-2); border-color: var(--surface-2); }
.flatpickr-day.today { border-color: var(--primary); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover { color: var(--muted); opacity: 0.45; background: transparent; }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange, .flatpickr-day.selected:hover, .flatpickr-day.startRange:hover, .flatpickr-day.endRange:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.flatpickr-day.inRange, .flatpickr-day.inRange:hover { background: var(--primary-soft); border-color: var(--primary-soft); box-shadow: -5px 0 0 var(--primary-soft), 5px 0 0 var(--primary-soft); color: var(--text); }
.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)), .flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)), .flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)) { box-shadow: -10px 0 0 var(--primary); }
.fp-presets { display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0.625rem 0.375rem 0.25rem; border-top: 1px solid var(--line); margin-top: 0.375rem; max-width: 19rem; }
