/* ==========================================================================
   AgriTrader — manila-and-green design system.
   Keep Pioneer's speed; throw away its ugliness. Bespoke CSS (no build step)
   so the entry screen renders correctly the moment `rails server` boots.
   ========================================================================== */

:root {
  --manila:      #f6efdd;
  --manila-2:    #efe6cd;
  --paper:       #fffdf7;
  --ink:         #22301b;
  --ink-soft:    #58634a;
  --line:        #ddd0a8;
  --line-strong: #b9a876;

  --green:       #1b5e20;
  --green-600:   #2e7d32;
  --green-100:   #e4efe1;
  --saffron:     #e0810f;
  --saffron-100: #fbeacd;
  --red:         #b3261e;
  --red-100:     #f7e0de;

  --radius: 10px;
  --shadow:    0 1px 2px rgba(34,48,27,.06), 0 8px 24px rgba(34,48,27,.08);
  --shadow-sm: 0 1px 2px rgba(34,48,27,.06), 0 1px 1px rgba(34,48,27,.05);
  --mono: "SF Mono", "DejaVu Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: system-ui, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --serif: Georgia, "Noto Serif Devanagari", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, #fbf6e8 0%, transparent 60%),
    var(--manila);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------- Top bar --------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .55rem 1.1rem;
  background: linear-gradient(180deg, var(--green) 0%, #164a1a 100%);
  color: #f3f7ef; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: baseline; gap: .55rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-weight: 800; font-size: 1.15rem; background: var(--saffron);
  color: #3a2400; width: 1.7rem; height: 1.7rem; border-radius: 8px;
  display: inline-grid; place-items: center; transform: translateY(3px);
}
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: .2px; }
.brand-tag  { font-size: .75rem; color: #cfe3c9; }
.topnav { display: flex; align-items: center; gap: .35rem; }
.navlink { color: #eaf3e6; padding: .35rem .7rem; border-radius: 8px; font-size: .9rem;
  background: transparent; border: 0; cursor: pointer; font-family: inherit; line-height: 1.4; }
.navlink:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.locale-toggle { margin-left: .4rem; display: inline-flex; gap: 2px; background: rgba(0,0,0,.18); border-radius: 8px; padding: 2px; }
.locale-toggle a { color: #d9e7d3; padding: .2rem .5rem; border-radius: 6px; font-size: .8rem; }
.locale-toggle a.on { background: var(--saffron); color: #3a2400; font-weight: 700; }
.locale-toggle a:hover { text-decoration: none; }

/* ------- App shell: left sidebar + slim top bar (trader layout) ---------- */
/* NOTE: .topbar/.brand/.navlink/.locale-toggle above are still used as-is by
   the admin layout (short 2-link nav, not congested) — this block only adds
   the sidebar shell for the trader-facing app, scoping color overrides under
   .topbar-slim so the admin topbar's dark-background styling is untouched. */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 220px; flex: none; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--green) 0%, #164a1a 100%);
  color: #f3f7ef; box-shadow: var(--shadow);
}
.sidebar-brand { display: flex; align-items: center; gap: .55rem; color: #fff; padding: 1rem .9rem .9rem; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand .brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; }
.sidebar-brand .brand-tag { font-size: .68rem; color: #cfe3c9; }

.sidebar-nav { display: flex; flex-direction: column; gap: .1rem; padding: .3rem .7rem 1rem; }
.sidebar-group {
  margin: .8rem 0 .2rem; padding: 0 .6rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: #a9c4a1;
}
.sidebar-link {
  display: block; color: #eaf3e6; padding: .5rem .6rem; border-radius: 8px;
  font-size: .92rem; text-decoration: none; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.sidebar-link.active { background: rgba(255,255,255,.14); border-left-color: var(--saffron); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding: .8rem .9rem 1rem; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar-foot .firm { font-size: .8rem; font-weight: 600; color: #eaf3e6; }
.sidebar-foot .fy { font-size: .68rem; color: #9fbd95; margin-top: .1rem; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-slim {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1.1rem; background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar-spacer { flex: 1; }
.sidebar-toggle {
  display: none; background: none; border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 1.05rem; line-height: 1; padding: .3rem .55rem; cursor: pointer; color: var(--ink);
}
.topbar-slim .locale-toggle { background: var(--manila-2); }
.topbar-slim .locale-toggle a { color: var(--ink-soft); }
.topbar-slim .locale-toggle a.on { background: var(--saffron); color: #3a2400; }
.topbar-slim .navuser { color: var(--ink-soft); }
.topbar-slim .navlink { color: var(--ink); }
.topbar-slim .navlink:hover { background: var(--manila-2); }
.topbar-slim .firm-select { background: var(--manila-2); color: var(--ink); border: 1px solid var(--line-strong); }
.topbar-slim .firm-select option { color: var(--ink); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: 240px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-toggle { display: inline-flex; align-items: center; }
}

@media print {
  .app-shell { display: block; }
  .sidebar, .topbar-slim, .sidebar-backdrop { display: none !important; }
}

/* ------- Page shell ------------------------------------------------------ */
.page { max-width: 1120px; margin: 1.4rem auto; padding: 0 1rem; }
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .92rem; }
.flash.notice { background: var(--green-100); color: var(--green); border: 1px solid #bcd7b4; }
.flash.alert  { background: var(--red-100);   color: var(--red);   border: 1px solid #e6b8b4; }

/* ------- Purchi card ----------------------------------------------------- */
.purchi { display: grid; grid-template-columns: 1fr 340px; gap: 1.1rem; align-items: start; }
@media (max-width: 860px) { .purchi { grid-template-columns: 1fr; } }
/* Entry-form column stacks the fast-entry card above a glanceable recent-
   activity card, so a short form doesn't leave a bare void on tall screens. */
.purchi-col { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.card-head h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1rem; color: var(--green); }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.1rem; border-bottom: 1px dashed var(--line-strong);
  background: linear-gradient(180deg, var(--paper), var(--manila-2));
}
.card-head h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--green); }
.card-head .sub { font-size: .78rem; color: var(--ink-soft); letter-spacing: .3px; text-transform: uppercase; }
.card-head .doc-no { font-family: var(--mono); font-size: .9rem; color: var(--ink-soft); }
.card-body { padding: 1.1rem; }

/* ------- Field grid ------------------------------------------------------ */
.grid { display: grid; gap: .75rem 1rem; }
.grid.cols-3 { grid-template-columns: 2fr 1.4fr 1fr; }
.grid.cols-4 { grid-template-columns: 2fr 1.2fr 1fr 0.75fr; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .grid.cols-3, .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field label { font-size: .72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select {
  width: 100%; min-width: 0; max-width: 100%;
  font-family: var(--sans); font-size: .98rem; color: var(--ink);
  padding: .5rem .6rem; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fffef9; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(46,125,50,.14);
}
.field .num { font-family: var(--mono); text-align: right; }
/* Checkboxes/radios must not be stretched by the full-width input rule above. */
.field input[type="checkbox"], .field input[type="radio"] {
  width: auto; min-width: 0; max-width: none; flex: none;
  margin: 0 .4rem 0 0; padding: 0; vertical-align: -2px;
  accent-color: var(--green);
}
/* A checkbox sitting next to its own label reads as one inline row. */
.field label:has(> input[type="checkbox"]),
.field label:has(> input[type="radio"]) {
  display: inline-flex; align-items: center;
  text-transform: none; font-weight: 400; font-size: .95rem; color: var(--ink);
}

/* ------- Line-item table ------------------------------------------------- */
.lines { width: 100%; border-collapse: collapse; margin-top: .3rem; }
.lines th {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .4px; font-weight: 700;
  color: var(--ink); background: var(--manila-2); text-align: right; padding: .5rem .5rem;
  border-bottom: 1px solid var(--line-strong);
}
.lines th.l, .lines td.l { text-align: left; }
.lines td { padding: .42rem .4rem; border-bottom: 1px solid var(--line); }
.lines tbody tr:nth-child(even) { background: rgba(239, 230, 205, .35); }
.lines tbody tr:hover { background: var(--green-100); }
.lines input, .lines select {
  width: 100%; font-family: var(--mono); text-align: right; font-size: .92rem;
  padding: .38rem .45rem; border: 1px solid transparent; border-radius: 6px;
  background: transparent;
}
.lines td.l input, .lines td.l select { text-align: left; font-family: var(--sans); }
.lines input:focus, .lines select:focus {
  outline: none; background: #fffef9; border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(46,125,50,.12);
}
.lines .computed { font-family: var(--mono); text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.lines .rm {
  border: none; background: none; color: var(--red); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: .2rem .4rem; border-radius: 6px;
}
.lines .rm:hover { background: var(--red-100); }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  font-family: var(--sans); font-size: .9rem; font-weight: 600;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent;
}
.btn-ghost { background: var(--green-100); color: var(--green); border-color: #bcd7b4; margin-top: .6rem; }
.btn-ghost:hover { background: #d7e8d1; }
.btn-primary { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--green-600); }
.btn-saffron { background: var(--saffron); color: #3a2400; }
.btn-sm { padding: .28rem .6rem; font-size: .8rem; margin-top: 0; }
.btn-row { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; }
/* Understated action — for a btn-row's purely-navigational links (Dashboard,
   "All X") that shouldn't visually compete with the row's real action(s). */
.btn-quiet {
  background: none; border-color: transparent; color: var(--ink-soft);
  font-weight: 500; padding: .5rem .3rem; margin-top: 0;
}
.btn-quiet:hover { color: var(--ink); text-decoration: underline; background: none; }

/* ------- Status pills (direction / mode) ---------------------------------- */
.pill { display: inline-flex; align-items: center; font-size: .72rem; font-weight: 600; padding: .16rem .55rem; border-radius: 999px; line-height: 1.4; }
.pill-in  { background: var(--green-100); color: var(--green-600); }
.pill-out { background: var(--saffron-100); color: #8a5108; }
.pill-mode { background: var(--manila-2); color: var(--ink-soft); font-weight: 500; }
.pill-error { background: var(--red-100); color: var(--red); }
.doc-badge {
  display: inline-flex; align-items: center; font-size: .72rem; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase; padding: .18rem .55rem;
  border-radius: 999px; background: var(--manila-2); color: var(--ink-soft);
}
.doc-badge.pill-in    { background: var(--green-100);  color: var(--green-600); }
.doc-badge.pill-error { background: var(--red-100);     color: var(--red); }

.stock-negative { color: var(--red); }
.stock-negative .v { color: var(--red); }
.stock-flag {
  display: inline-block; padding: .12rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}
.stock-flag--negative { background: var(--red-100); color: var(--red); }
/* Section sub-navs (reports / masters) get breathing room below them. */
.subnav-row { margin-bottom: .9rem; }
.subnav-row + .period-bar { margin-top: 0; }   /* don't double the gap when a filter bar follows */

.report-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .6rem; margin-bottom: .9rem;
}
.report-toolbar .subnav-row { margin-bottom: 0; flex: 1 1 auto; }
.report-export-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; flex-shrink: 0;
}

.report-search-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
  margin-bottom: .85rem; padding: .55rem .65rem;
  background: var(--manila-2); border: 1px solid var(--line); border-radius: 8px;
}
.report-search-bar input[type="search"] {
  flex: 1 1 200px; min-width: 180px; max-width: 360px;
  padding: .35rem .55rem; border: 1px solid var(--line-strong); border-radius: 7px;
  font: inherit; background: var(--paper);
}
.report-search-count { font-size: .78rem; color: var(--ink-soft); }
.report-search-hint { font-size: .72rem; color: var(--ink-soft); margin-left: auto; }
.report-search-hint kbd {
  padding: .05rem .3rem; border: 1px solid var(--line-strong); border-radius: 4px;
  font-size: .68rem; background: var(--paper);
}
.report-search-empty {
  margin: -.5rem 0 .75rem; padding: .55rem .7rem;
  font-size: .85rem; color: var(--ink-soft);
  background: var(--manila-2); border-radius: 7px;
}

/* ------- Settlement panel (the receipt) ---------------------------------- */
.settle { position: sticky; top: 1rem; }
.settle .card-head h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; color: var(--green); }
.settle .doc-badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 999px; background: var(--saffron-100); color: #8a5108;
}
.settle-rows { padding: .4rem 1.1rem 0; }
.srow { display: flex; align-items: baseline; justify-content: space-between; padding: .32rem 0; font-size: .9rem; }
.srow .k { color: var(--ink-soft); }
.srow .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.srow.sub .k { padding-left: .6rem; font-size: .85rem; }
.srow.sub .v { color: var(--red); }
.srow.head { border-top: 1px dashed var(--line-strong); margin-top: .3rem; padding-top: .5rem; font-weight: 600; color: var(--ink); }
.settle .net {
  margin: .6rem 1.1rem 1.1rem; padding: .8rem 1rem; border-radius: 10px;
  background: linear-gradient(180deg, var(--green-100), #d7e8d1);
  border: 1px solid #b5d0ad; display: flex; align-items: baseline; justify-content: space-between;
}
.settle .net .k { font-weight: 700; color: var(--green); }
.settle .net .v { font-family: var(--mono); font-size: 1.45rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.keys-hint { font-size: .72rem; color: var(--ink-soft); padding: 0 1.1rem 1rem; }

.expense-lines input, .expense-lines select { width: 100%; }
.expense-editor__remove { text-align: right; white-space: nowrap; }

.expense-toggle { gap: .15rem; }
.expense-customize-link {
  align-self: flex-start; padding: 0; border: none; background: none;
  font-size: .72rem; color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}
.expense-customize-link:hover { color: var(--green); }

/* Lives in the right-hand column next to the settlement panel, not inline
   in the entry form — it edits the numbers shown there, so it belongs
   beside them. */
.expense-drawer {
  padding: .9rem 1rem 1.1rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.expense-drawer__head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  margin-bottom: .35rem;
}
.expense-drawer__title { font-size: .78rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .35px; }
.expense-drawer__note {
  margin: 0 0 .65rem; font-size: .78rem; line-height: 1.4; color: var(--ink-soft);
}
.expense-drawer__actions { margin-top: .5rem; }

/* A <details> reuses .expense-drawer's card look; <summary> is its own
   toggle, no JS needed. */
.transport-drawer__summary {
  cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .35px; list-style: none;
}
.transport-drawer__summary::-webkit-details-marker { display: none; }
.transport-drawer__section-title {
  margin: .9rem 0 .4rem; font-size: .78rem; font-weight: 600; color: var(--green);
  border-top: 1px dashed var(--line); padding-top: .7rem;
}
details.expense-drawer[open] .transport-drawer__summary { margin-bottom: .35rem; }

/* ------- Charge master (edit + list) ------------------------------------- */
.charge-form-card { max-width: 42rem; }
.charge-form { display: flex; flex-direction: column; gap: 1.25rem; }
.charge-form__section { display: flex; flex-direction: column; gap: .65rem; }
.charge-form__section--compact { padding-top: .25rem; border-top: 1px dashed var(--line); }
.charge-form__heading {
  margin: 0; font-family: var(--serif); font-size: .95rem; font-weight: 700; color: var(--green);
}
.charge-form__hint {
  margin: 0; font-size: .82rem; line-height: 1.45; color: var(--ink-soft);
}
.charge-form__default-rate { max-width: 10rem; }
.charge-form__active {
  display: flex; align-items: center; gap: .45rem;
  margin-top: .45rem; font-weight: 400; text-transform: none; font-size: .95rem; color: var(--ink);
}

.charge-modes { display: flex; flex-direction: column; gap: .75rem; }
.charge-modes__group {
  display: flex; flex-direction: column; gap: .5rem;
  padding: .75rem; border: 1px solid var(--line); border-radius: 12px; background: #fffef9;
}
.charge-modes__group.is-disabled { opacity: .45; pointer-events: none; }
.charge-modes__group-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-soft);
}
.charge-modes__or {
  align-self: center; font-size: .72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase;
}

.charge-mode-row {
  display: grid; grid-template-columns: auto 1fr 7rem; align-items: center; gap: .75rem;
  padding: .55rem .65rem; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
.charge-mode-row.is-on {
  border-color: var(--green-600); box-shadow: 0 0 0 2px rgba(46, 125, 50, .12);
}
.charge-mode-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; cursor: pointer; }
.charge-mode-row__name { display: flex; flex-direction: column; gap: .1rem; min-width: 0; cursor: pointer; }
.charge-mode-row__name strong { font-size: .92rem; color: var(--ink); }
.charge-mode-row__sub { font-size: .72rem; color: var(--ink-soft); line-height: 1.3; }
.charge-mode-row__rate {
  width: 100%; font-family: var(--mono); text-align: right;
  padding: .35rem .45rem; font-size: .9rem;
}
.charge-mode-row__rate:disabled { background: var(--manila-2); color: var(--ink-soft); cursor: not-allowed; }

.charge-badges { display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.charge-badge {
  display: inline-block; padding: .12rem .45rem; border-radius: 999px;
  font-size: .68rem; font-weight: 600; letter-spacing: .2px;
  background: var(--green-100); color: var(--green); border: 1px solid #bcd7b4;
}

@media (max-width: 640px) {
  .charge-mode-row { grid-template-columns: auto 1fr; }
  .charge-mode-row__rate { grid-column: 2; }
}

/* ------- Farmer typeahead ------------------------------------------------ */
.typeahead { position: relative; }
.typeahead-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; max-height: 240px; overflow-y: auto;
}
.typeahead-list button {
  display: flex; width: 100%; justify-content: space-between; gap: 1rem;
  padding: .5rem .7rem; border: none; background: none; cursor: pointer; text-align: left;
  font-size: .9rem; color: var(--ink);
}
.typeahead-list button:hover, .typeahead-list button.active { background: var(--green-100); }
.typeahead-list .muted { color: var(--ink-soft); font-size: .8rem; }
.typeahead-empty { padding: .5rem .7rem; color: var(--ink-soft); font-size: .85rem; }

/* ------- Dashboard ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }
.stat .value { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; color: var(--green); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.stat.warn .value { color: var(--saffron); }
.stat .unit { font-size: .8rem; color: var(--ink-soft); }
.section-title { margin: 1.4rem 0 .7rem; color: var(--green); font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }

/* ------- Report period bar ----------------------------------------------- */
.period-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  margin: .9rem 0 1rem; padding: .6rem .8rem;
  background: var(--manila-2, #f3f6ec); border: 1px solid var(--line); border-radius: 10px;
}
.period-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; margin: 0; }
/* The action buttons (Apply/Filter/Clear) sit apart from the fields, with a divider. */
.filter-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-left: 1rem; margin-left: .2rem; border-left: 1px solid var(--line); }
@media (max-width: 640px) { .filter-actions { border-left: 0; padding-left: 0; } }
.period-lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); display: flex; align-items: center; gap: .4rem; }
.period-lbl input[type="date"] {
  font-family: var(--sans); font-size: .9rem; color: var(--ink);
  padding: .32rem .45rem; border: 1px solid var(--line-strong); border-radius: 7px; background: #fffef9;
}
.period-lbl select {
  width: auto; font-family: var(--sans); font-size: .9rem; color: var(--ink);
  padding: .32rem .45rem; border: 1px solid var(--line-strong); border-radius: 7px; background: #fffef9;
}
.pager { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-top: 1rem; }
.pager-info { font-size: .85rem; color: var(--ink-soft); }
.pager-off { opacity: .4; pointer-events: none; }
.viewall { display: inline-block; margin-top: .25rem; font-size: .8rem; color: var(--green); text-decoration: none; }
.viewall:hover { text-decoration: underline; }
.period-caption { margin-left: auto; font-size: .9rem; color: var(--ink-soft); }
.period-caption strong { color: var(--ink); }
.tag-fy { display: inline-block; margin-left: .5rem; font-size: .72rem; padding: 1px 8px; border-radius: 10px; background: var(--green-100, #e4efe1); color: var(--green); border: 1px solid var(--line); }

/* ------- Print (patti) --------------------------------------------------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .page { margin: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #000; }
  .purchi { grid-template-columns: 1fr; }
}

/* ------- Auth / admin ---------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 380px; }
.navuser { color: #cfe3c9; font-size: .82rem; padding: 0 .5rem; }
.topnav form { display: inline; margin: 0; }
.lines form { display: inline; margin: 0; }
.linklike { border: none; background: none; color: var(--green-600); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.firm-switch { display: inline; margin: 0; }
.firm-select {
  background: rgba(0,0,0,.2); color: #eaf3e6; border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px; padding: .3rem .5rem; font-size: .82rem; max-width: 180px;
}
.firm-select option { color: #1a2116; }
.brand-logo { align-self: center; display: block; }
.auth-logo { display: block; margin: .2rem auto 0; height: auto; max-width: 100%; }

/* ------- PWA install banner ---------------------------------------------- */
.hidden { display: none !important; }
.pwa-install-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  z-index: 1060;
  padding: 0.85rem 1rem;
  background: var(--green);
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(27, 94, 32, 0.35);
}
.pwa-install-banner:not(.hidden) { display: flex; }
/* Clear the sidebar at desktop widths instead of floating over its footer. */
@media (min-width: 901px) {
  .app-shell ~ .pwa-install-banner { left: max(236px, calc(220px + env(safe-area-inset-left, 0px))); }
}
.pwa-install-banner__copy strong { display: block; font-size: 0.95rem; }
.pwa-install-banner__subtitle { font-size: 0.8rem; color: #d7e8d1; margin-top: 0.15rem; }
.pwa-install-banner__actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.btn-install {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  background: var(--saffron);
  color: #3a2400;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.pwa-install-banner__dismiss {
  border: none;
  background: transparent;
  color: #eaf3e6;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
@media print {
  .pwa-install-banner { display: none !important; }
}

/* ------- Keyboard shortcuts ------------------------------------------------ */
kbd, .kbd {
  display: inline-block; min-width: 1.4em; padding: .1rem .4rem; margin: 0 1px;
  font-family: var(--mono); font-size: .74rem; text-align: center; line-height: 1.5;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 5px;
}
.sidebar-foot .hint { font-size: .68rem; color: #9fbd95; margin-top: .35rem; }
.sidebar-foot .hint kbd { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.28); color: #eaf3e6; }

.shortcuts-backdrop {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start;
  justify-content: center; padding: 8vh 1rem; background: rgba(20,26,15,.45);
}
/* The `hidden` attribute alone loses to the class rule above (author styles
   beat the UA stylesheet's [hidden]{display:none} at equal specificity) —
   this is what actually makes toggling `hidden` hide the modal again. */
.shortcuts-backdrop[hidden] { display: none; }
.shortcuts-modal {
  width: 100%; max-width: 720px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem 1.3rem;
}
.shortcuts-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.shortcuts-modal-head h2 { margin: 0; font-family: var(--serif); font-size: 1.2rem; color: var(--green); }
.shortcuts-modal-head .linklike { font-size: 1.3rem; text-decoration: none; color: var(--ink-soft); }
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.2rem; }
@media (max-width: 640px) { .shortcuts-grid { grid-template-columns: 1fr; } }
.shortcuts-grid h3 {
  margin: 0 0 .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft);
}
.shortcuts-grid section + section, .shortcuts-grid h3 + h3 { margin-top: .9rem; }
.shortcuts-grid dl { margin: 0; }
.shortcuts-grid dl > div { display: flex; align-items: baseline; gap: .6rem; padding: .2rem 0; }
.shortcuts-grid dt { flex: none; white-space: nowrap; }
.shortcuts-grid dd { margin: 0; font-size: .86rem; color: var(--ink); }
.shortcuts-grid dd .muted { color: var(--ink-soft); font-size: .78rem; }

/* ------- Cheque printing --------------------------------------------------- */
.cheque-leaf {
  position: relative; margin: 1.4rem auto; background: var(--paper);
  border: 1px dashed var(--line-strong); box-shadow: var(--shadow-sm);
}
.cheque-field {
  position: absolute; font-family: var(--mono); font-size: 3.5mm; color: var(--ink);
  white-space: nowrap; line-height: 1.3;
}
.cheque-words { white-space: normal; }
/* RBI/CTS-2010 reference zones — screen-only calibration guides, never printed. */
.cheque-micr-band {
  position: absolute; left: 0; right: 0; bottom: 0; height: 13mm;
  background: repeating-linear-gradient(45deg, rgba(179,38,30,.08), rgba(179,38,30,.08) 4px, transparent 4px, transparent 8px);
  border-top: 1px dotted var(--red);
}
.cheque-micr-band::after {
  content: "MICR band — leave clear"; position: absolute; left: 4mm; top: 1mm;
  font-size: .62rem; color: var(--red); text-transform: uppercase; letter-spacing: .3px;
}
.cheque-amount-box {
  position: absolute; border: 1px dotted var(--green-600); border-radius: 2px;
}
@media print {
  .cheque-leaf { border: none; box-shadow: none; margin: 0; background: none; }
  .cheque-micr-band, .cheque-amount-box { display: none; }
}

