/* ==========================================================================
   Revenue Calculation POC — Stylesheet (Phase 4: mobile-first rewrite)
   Government-grade digital service aesthetic — trustworthy, clean, calm.

   Authoring approach: MOBILE-FIRST. Every base rule below targets a narrow
   phone viewport (single column, full-width fields, ≥44px tap targets).
   `min-width` media queries only ADD progressive enhancement for larger
   screens (wider containers, multi-column grids) — they never redefine the
   base layout model. There is no revived two-column sticky sidebar: the
   "summary" is the dedicated full-screen result view.

   Sections:
     1) Design tokens        6) Sticky bottom Calculate bar
     2) Base / reset         7) Accordion sections
     3) Layout & views       8) Forms & fields (shared)
     4) Header               9) Classification (step 2)
     5) Buttons              10) Parcels (step 3)
                              11) Result screen
                              12) Footer
                              13) Responsive enhancements (min-width)
                              14) Print stylesheet
                              15) Reduced motion
   ========================================================================== */

/* ----------------------------- 1) Design tokens ------------------------- */
:root {
  /* Brand palette (Nepal crimson + professional navy neutrals) */
  --brand:        #C8102E;
  --brand-dark:   #9E0B23;
  --brand-soft:   #FCE9EC;

  --ink:          #14213D;   /* headings / primary text        */
  --ink-2:        #3B475C;   /* body text                      */
  --muted:        #6B7688;   /* helper / secondary text        */
  --line:         #E6E9F0;   /* borders / dividers             */

  --bg:           #F4F6FB;   /* page background                */
  --card:         #FFFFFF;
  --card-2:       #FAFBFE;   /* subtle inner surfaces          */
  --surface:      #FFFFFF;

  --ok:           #0E9F6E;
  --ok-soft:      #E4F7EF;
  --warn:         #B45309;
  --error:        #C8102E;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .06);
  --shadow-md: 0 8px 24px -12px rgba(20, 33, 61, .18);
  --shadow-lg: 0 24px 60px -24px rgba(20, 33, 61, .28);

  --radius:    18px;
  --radius-sm: 12px;
  --radius-xs: 9px;

  --gap:       18px;
  --maxw:      760px;      /* comfortable single-column reading width */
  --maxw-wide: 960px;      /* desktop enhancement for the result screen */

  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans Devanagari",
          "Mukta", Roboto, Arial, sans-serif;

  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Sticky bottom Calculate bar — content clearance + safe-area (notch) */
  --calcbar-h: 96px;
  --tap: 44px; /* minimum comfortable touch target */
}

/* ----------------------------- 2) Base / reset -------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-2);
  background:
    radial-gradient(900px 400px at 100% -10%, rgba(200,16,46,.05), transparent 60%),
    radial-gradient(700px 400px at -10% 0%, rgba(20,33,61,.04), transparent 55%),
    var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }

/* Devanagari tends to render tall — give it a touch more breathing room */
html[lang="ne"] body { line-height: 1.7; }

button { touch-action: manipulation; }

/* Visible, consistent focus ring everywhere (accessibility requirement) */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----------------------------- 3) Layout & views ------------------------ */
.app-main {
  display: block;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px calc(var(--calcbar-h) + 16px);
}

/* Two top-level views toggled via the `hidden` attribute (render.js#setActiveView).
   Author CSS beats the UA default [hidden]{display:none}, so re-assert it
   explicitly rather than relying on cascade origin alone. */
.view[hidden] { display: none !important; }
.view--form { display: block; }
.view--result { display: block; }

.workflow { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.workflow__actions { display: flex; justify-content: center; padding: 6px 2px 4px; }
.workflow__actions .btn { width: 100%; }

/* ----------------------------- 4) Header --------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__logo { border-radius: 10px; box-shadow: var(--shadow-sm); flex: none; width: 38px; height: 38px; }
.brand__title { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.brand__subtitle { margin: 2px 0 0; font-size: .76rem; color: var(--muted); }

.lang-switch {
  display: inline-flex;
  align-self: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  flex: none;
}
.lang-switch__btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  padding: 9px 14px;
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
  white-space: nowrap;
}
.lang-switch__btn:hover { color: var(--ink); }
.lang-switch__btn.is-active {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ----------------------------- 5) Buttons -------------------------------- */
.btn {
  font: inherit; font-weight: 700; font-size: .92rem;
  border-radius: var(--radius-xs);
  padding: 11px 18px;
  min-height: var(--tap);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease),
              background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease),
              opacity .18s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) { box-shadow: var(--shadow-md); }
.btn--primary:disabled {
  background: #cfd4de;
  color: #8b93a3;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--dashed {
  width: 100%;
  background: transparent;
  border: 1.5px dashed var(--brand);
  color: var(--brand);
}
.btn--dashed:hover:not(:disabled) { background: var(--brand-soft); }
.btn--dashed:disabled { opacity: .45; cursor: not-allowed; }
.btn--dashed span[aria-hidden] { font-size: 1.15rem; line-height: 1; }

.btn--ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn--ghost:hover { border-color: var(--error); color: var(--error); background: var(--brand-soft); }

/* ----------------------------- 6) Sticky bottom Calculate bar ------------ */
/* Fixed to the thumb zone; only visible in the form view (render.js hides
   it via the `hidden` attribute when the result view is active). */
.calc-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px -16px rgba(20, 33, 61, .35);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
}
.calc-bar[hidden] { display: none !important; }

/* Inner wrapper constrains the content to the same column width as the form so
   the button lines up with the fields (not floating at the viewport edge). */
.calc-bar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-bar__status {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0 2px;
}
.calc-bar[data-status="updating"] .calc-bar__status,
.calc-bar[data-status="error"] .calc-bar__status {
  display: flex;
}
.calc-bar__status-text { display: inline-flex; align-items: center; gap: 6px; }
.calc-bar[data-status="updating"] .calc-bar__status-text::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 999px;
  background: var(--brand);
  animation: calcPulse 1.1s ease-in-out infinite;
  flex: none;
}
@keyframes calcPulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50%      { opacity: 1;   transform: scale(1); }
}
.calc-bar[data-status="error"] .calc-bar__status-text {
  color: var(--error);
}
.calc-bar[data-status="error"] .calc-bar__status-text::before {
  content: "⚠";
}

.calc-bar__retry {
  display: none;
  flex: none;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: 999px;
  padding: 5px 13px;
  min-height: 32px;
  cursor: pointer;
}
.calc-bar__retry:hover { background: #fff; }
.calc-bar[data-status="error"] .calc-bar__retry { display: inline-flex; align-items: center; }

.calc-bar__inner #calculateBtn { width: 100%; }

/* ----------------------------- 7) Accordion sections --------------------- */
.accordion-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion-section[open] { box-shadow: var(--shadow-md); }

.accordion-section__header {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 14px 16px;
  min-height: var(--tap);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.accordion-section__header::-webkit-details-marker,
.accordion-section__header::marker { display: none; content: ""; }
.accordion-section__header:hover { background: var(--card-2); }

.step-badge {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}
.accordion-section__title {
  flex: 1 1 130px;
  min-width: 0;
  font-size: .98rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-chip {
  flex: none;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  background: #eef1f6;
  padding: 4px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.section-chip.is-complete {
  color: var(--ok);
  background: var(--ok-soft);
}
.accordion-section__chev {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform .2s var(--ease);
}
.accordion-section[open] .accordion-section__chev { transform: rotate(180deg); }

.accordion-section__body {
  padding: 0 16px 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.card__hint { margin: 0 0 14px; font-size: .85rem; color: var(--muted); }

/* ----------------------------- 8) Forms & fields (shared) ---------------- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: .84rem; font-weight: 600; color: var(--ink); }

/* Two fields sharing one row (e.g. area unit + registration number) even on
   narrow mobile widths, where .field-grid itself is still single-column. */
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 359px) { .field-row-2 { grid-template-columns: 1fr; } }

/* Label row with a live per-field score badge (parcel / criterion fields) */
.field__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field__score {
  flex: none;
  font-size: .72rem; font-weight: 700;
  color: var(--brand-dark); background: var(--brand-soft);
  padding: 2px 9px; border-radius: 999px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.field__score.is-empty { color: var(--muted); background: #eef1f6; }

.field__input, .select {
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 11px 13px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  appearance: none;
}
.field__input::placeholder { color: #9aa3b2; }
.field__input:hover, .select:hover { border-color: #c9cfdb; }
.field__input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(200, 16, 46, .12);
}
.field__input:disabled, .select:disabled {
  background-color: #f1f3f8;
  color: #9aa3b2;
  cursor: not-allowed;
}

/* Custom dropdown chevron */
.select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7688' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

.field__hint {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}
.field__matched:empty { display: none; }
.field__matched {
  color: var(--accent, #1f6feb);
  font-weight: 600;
}
.field__error {
  font-size: .8rem;
  color: var(--error);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.field__error[hidden] { display: none; }
.field__error::before { content: "⚠"; flex: none; }
.field__input.is-invalid, .select.is-invalid {
  border-color: var(--error);
  background: #fff5f6;
}

/* Searchable select (District) — looks like a .select, filters as you type. */
.combobox { position: relative; }
.combobox__input {
  /* the chevron comes from the shared .select rule; keep a text caret while
     typing rather than the select's pointer cursor. */
  cursor: text;
}
.combobox.is-open .combobox__input {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.combobox__list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0; right: 0;
  margin: 0;
  padding: 5px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-md);
  -webkit-overflow-scrolling: touch;
}
.combobox__list[hidden] { display: none; }
.combobox__option {
  padding: 10px 12px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  border-radius: calc(var(--radius-xs) - 3px);
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
}
.combobox__option:hover,
.combobox__option.is-active { background: var(--brand-soft); }
.combobox__option[aria-selected="true"] {
  font-weight: 700;
  color: var(--brand);
}
.combobox__empty {
  padding: 12px;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
}

/* Registration-number composite input (prefix + 4 digits) */
.field--span-2 { grid-column: 1 / -1; }
.reg-input { display: flex; align-items: stretch; }
.reg-input__prefix {
  display: inline-flex; align-items: center;
  padding: 0 12px;
  font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink-2, var(--ink)); background: var(--brand-soft);
  border: 1px solid var(--line); border-right: none;
  border-radius: 10px 0 0 10px; white-space: nowrap;
}
.reg-input__digits { border-radius: 0 10px 10px 0; letter-spacing: .2em; }

/* Read-only field (auto-filled parcel classification) */
.readonly-field {
  width: 100%;
  font-size: .96rem; font-weight: 700; color: var(--ink);
  background: repeating-linear-gradient(-45deg, #f3f6fb, #f3f6fb 10px, #eef2f8 10px, #eef2f8 20px);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-xs);
  padding: 11px 13px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: var(--tap);
}
.readonly-field__score {
  font-size: .74rem; font-weight: 700; color: var(--brand-dark);
  background: var(--brand-soft); padding: 2px 9px; border-radius: 999px;
}
.kv__pending, .cls-live__pending, .readonly-field__pending { color: var(--muted); font-weight: 600; font-style: italic; }

/* ---------------- 9) Land Holder Classification (step 2) ---------------- */
.cls-live {
  position: static;
  background: linear-gradient(135deg, #1b2a4a 0%, #24365c 100%);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.cls-live__main { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cls-live__stat { display: flex; flex-direction: column; gap: 1px; }
.cls-live__label { font-size: .64rem; opacity: .72; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.cls-live__value { font-size: 1.3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cls-live__class {
  font-size: .95rem; font-weight: 800;
  background: rgba(255,255,255,.16);
  padding: 2px 11px; border-radius: 999px; display: inline-block; width: fit-content;
}
.cls-live__pending { font-size: .84rem; opacity: .85; font-weight: 600; }
.cls-live__progress { flex: 1 1 130px; min-width: 120px; }
.cls-live__bar { height: 5px; margin-top: 5px; background: rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; }
.cls-live__bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #ff8fa3, var(--brand));
  border-radius: 999px; transition: width .35s var(--ease);
}
.cls-live__progress-text { font-size: .68rem; opacity: .82; font-variant-numeric: tabular-nums; }

/* Criteria grid */
.criteria-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.criterion {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  padding: 14px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.criterion--full { grid-column: 1 / -1; }
.criterion__error { margin-top: 6px; }
.criterion.is-invalid { border-color: var(--error); }
.criterion__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.criterion__label { font-size: .88rem; font-weight: 700; color: var(--ink); line-height: 1.35; }
.criterion__optional {
  font-size: .64rem; font-weight: 600; color: var(--muted);
  background: #eef1f6; padding: 1px 8px; border-radius: 999px;
  margin-left: 6px; vertical-align: middle; white-space: nowrap;
}
.criterion__score {
  flex: none;
  font-size: .72rem; font-weight: 700;
  color: var(--brand-dark); background: var(--brand-soft);
  padding: 3px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.criterion__score.is-empty { color: var(--muted); background: #eef1f6; }
.criterion__body { display: flex; flex-direction: column; gap: 10px; }

/* Land type as segmented buttons (touch-friendly pills) */
.landtype { display: flex; gap: 8px; flex-wrap: wrap; }
.landtype__opt {
  flex: 1 1 100px;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: var(--radius-xs);
  padding: 10px 10px;
  font-size: .88rem; font-weight: 600; color: var(--ink-2);
  cursor: pointer; text-align: center;
  transition: all .18s var(--ease);
}
.landtype__opt:hover:not(:disabled) { border-color: #c9cfdb; }
.landtype__opt.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.landtype__opt:disabled { opacity: .45; cursor: not-allowed; }

/* ----------------------------- 10) Parcels (step 3) ----------------------- */
.parcels { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.parcels__empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

.parcel-group {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface);
}
.parcel-group__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.parcel-group__title { font-size: .96rem; font-weight: 700; color: var(--ink); }
.parcel-group__usage,
.parcel-total {
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--brand-dark); background: var(--brand-soft);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.parcel-total { display: block; text-align: center; margin-bottom: 14px; }
.parcel-group__usage.is-over,
.parcel-total.is-over { color: #fff; background: var(--error); }

.parcel {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  padding: 16px;
  position: relative;
  animation: parcelIn .35s var(--ease);
}
.parcel.is-removing { animation: parcelOut .3s var(--ease) forwards; }

@keyframes parcelIn {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes parcelOut {
  from { opacity: 1; transform: none; max-height: 800px; }
  to   { opacity: 0; transform: translateY(-8px) scale(.98); max-height: 0;
         margin: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
}

.parcel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.parcel__title { display: flex; align-items: center; gap: 9px; font-size: .96rem; font-weight: 700; color: var(--ink); }
.parcel__index {
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: .78rem; font-weight: 700;
  flex: none;
}

.parcel__remove {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit; font-size: .8rem; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .18s var(--ease);
}
.parcel__remove:hover { color: var(--error); border-color: var(--brand); background: var(--brand-soft); }

.parcel__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.parcel__span-2 { grid-column: 1 / -1; }

/* Compound local-unit area entry (e.g. Ropani + Aana + Paisa + Daam) */
.area-units-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
}
.area-units-row__item { display: flex; flex-direction: column; gap: 4px; }
.area-units-row__label { font-size: .78rem; font-weight: 600; color: var(--muted); }

/* Valuation-rate entry: one number + its unit dropdown, side by side */
.rate-row { display: flex; gap: 8px; align-items: stretch; }
.rate-row .field__input { flex: 1 1 auto; min-width: 0; }
.rate-row__unit { flex: 0 0 auto; width: auto; min-width: 120px; }

/* Parcel footer: score + revenue / validation note */
.parcel__foot {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}
.parcel__score { display: flex; align-items: baseline; gap: 8px; }
.parcel__score-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.parcel__score-value {
  font-size: 1.35rem; font-weight: 800; color: var(--brand);
  font-variant-numeric: tabular-nums;
  transition: color .2s var(--ease);
}
.parcel__score--revenue { text-align: right; align-items: flex-end; }
.parcel__score--revenue .parcel__score-value { font-size: 1.05rem; color: var(--ink); }
.parcel__note {
  font-size: .8rem; font-weight: 600; color: var(--warn);
  display: inline-flex; align-items: center; gap: 6px;
}
.parcel__note::before { content: "ℹ"; }

/* Grand totals block under all parcel groups */
.parcels-grand-totals {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

/* ----------------------------- 11) Result screen -------------------------- */
#view-result { padding-top: 4px; }

.result__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.result__actions .btn { padding: 9px 14px; font-size: .84rem; min-height: 40px; }
.result__actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

.summary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.summary__banner {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 20px 18px 22px;
}
.summary__banner-label { font-size: .8rem; opacity: .85; font-weight: 600; margin: 0 0 6px; }
.summary__amount {
  font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin: 0;
  word-break: break-word;
}
.summary__words { font-size: .84rem; opacity: .92; margin: 8px 0 0; font-style: italic; }

.summary__body { padding: 18px 18px 20px; }
.summary__section-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin: 0 0 10px;
}
.summary__section + .summary__section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: .89rem; padding: 4px 0; }
.kv__k { color: var(--muted); }
.kv__v { color: var(--ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.kv__v.total { color: var(--brand); font-size: 1.02rem; }

.summary__parcel {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.summary__parcel-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; color: var(--ink); font-size: .9rem; margin-bottom: 8px;
  gap: 8px; flex-wrap: wrap;
}
.summary__parcel-head .pscore { color: var(--brand); }
.summary__parcel .kv { font-size: .82rem; padding: 2px 0; }
.summary__parcel-rev {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: .86rem; font-weight: 700; color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.summary__totals { background: var(--card-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.summary__empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 12px 0; }

/* ----------------------------- 12) Footer -------------------------------- */
.app-footer {
  max-width: var(--maxw);
  margin: 8px auto 0;
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  border-top: 1px solid var(--line);
}

/* ============================================================================
   13) RESPONSIVE ENHANCEMENTS — progressive, min-width only.
   Base rules above are the mobile truth; these widen containers and turn on
   multi-column grids once there's room, without reviving a sticky sidebar.
   ========================================================================== */

/* --- Tablet: ~600px and up --- */
@media (min-width: 640px) {
  .app-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
  }
  .lang-switch { align-self: auto; }
  .brand__title { font-size: 1.15rem; }
  .brand__subtitle { font-size: .82rem; }

  .app-main { padding: 28px 24px calc(var(--calcbar-h) + 20px); }
  .app-footer { padding: 24px; }

  .accordion-section__header { padding: 16px 22px; }
  .accordion-section__body { padding: 0 22px 22px; padding-top: 18px; }
  .step-badge { width: 32px; height: 32px; font-size: .95rem; }
  .accordion-section__title { font-size: 1.05rem; }

  .field-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
  .field--span-2 { grid-column: 1 / -1; }

  .criteria-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

  .parcel__grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

  .workflow__actions { justify-content: flex-end; }
  .workflow__actions .btn { width: auto; }

  /* The classification live card can safely stick under the header once the
     header height is stable across a wider viewport. */
  .cls-live { position: sticky; top: 74px; z-index: 5; }

  /* Calculate bar becomes a comfortable row instead of a stacked column. The
     button is pinned to the right via margin-auto on the status, so it stays
     put whether or not the status text is visible (no left/right jump). */
  .calc-bar { padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); }
  .calc-bar__inner {
    flex-direction: row;
    align-items: center;
    padding: 0 24px;
  }
  .calc-bar__status { flex: 0 1 auto; margin-right: auto; }
  .calc-bar__inner #calculateBtn { width: auto; min-width: 220px; }
  :root { --calcbar-h: 76px; }

  .summary__banner { padding: 26px 28px 28px; }
  .summary__amount { font-size: 2rem; }
  .summary__body { padding: 22px 28px 26px; }
  .result__actions .btn { padding: 11px 18px; font-size: .9rem; }
}

/* --- Desktop: ~1024px and up --- */
@media (min-width: 1024px) {
  .app-main, .app-header__inner, .app-footer { max-width: var(--maxw); }

  /* The result screen gets a little more breathing room than the form —
     widen the shared .app-main container only while the result view is the
     visible child (progressive enhancement; falls back to --maxw in
     browsers without :has() support, which is still a perfectly fine
     single-column layout). */
  .app-main:has(#view-result:not([hidden])) { max-width: var(--maxw-wide); }

  .summary__body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }
  .summary__body > .summary__section { margin-top: 0 !important; padding-top: 0 !important; border-top: none !important; }
  /* Banner + parcels list + totals span the full width; applicant info and
     class result sit side-by-side as an enhancement, not a sidebar. */
  .summary__body > .summary__section:nth-of-type(1),
  .summary__body > .summary__section:nth-of-type(4),
  .summary__body > .summary__section:nth-of-type(5) {
    grid-column: 1 / -1;
  }
  .summary__body > .summary__section:not(:first-child) {
    padding-top: 18px;
  }
  .summary__body > .summary__section:nth-of-type(1) { padding-top: 0; }
}

/* ============================================================================
   14) PRINT STYLESHEET — clean, paper-friendly result output only.
   ========================================================================== */
@media print {
  @page { size: A4; margin: 12mm 14mm; }

  .app-header,
  .app-footer,
  .calc-bar,
  #calc-bar,
  .lang-switch,
  #view-form,
  .result__actions {
    display: none !important;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11px;
    line-height: 1.3;
  }

  .app-main { max-width: none; padding: 0; margin: 0; }

  .summary {
    box-shadow: none !important;
    border: 1px solid #000;
    border-radius: 0;
  }
  .summary__banner {
    background: none !important;
    color: #000 !important;
    border-bottom: 2px solid #000;
    padding: 0 0 8px;
    margin-bottom: 8px;
  }
  .summary__banner-label { font-size: .74rem; }
  .summary__amount { font-size: 1.3rem; }
  .summary__words { opacity: 1; color: #000 !important; font-size: .78rem; margin-top: 4px; }

  /* Use the page's full width: applicant info + classification result sit
     side by side (same pairing the on-screen desktop layout already uses),
     everything else spans both columns — a report reads top-to-bottom, not
     as two independent columns, so only that one pair is worth pairing up. */
  .summary__body {
    padding: 0;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
  }
  .summary__body > .summary__section {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
  }
  .summary__body > .summary__section:nth-of-type(1),
  .summary__body > .summary__section:nth-of-type(4),
  .summary__body > .summary__section:nth-of-type(5) {
    grid-column: 1 / -1;
  }
  .summary__section + .summary__section { margin-top: 6px; }
  .summary__section-title { font-size: .68rem; margin-bottom: 4px; }

  .kv { padding: 1px 0; font-size: .78rem; gap: 8px; }

  /* Each parcel's own field list also runs 2-up, so a 10-field parcel takes
     roughly half the vertical space a single column would. */
  .summary__parcel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    padding: 6px 9px;
    margin-bottom: 6px;
    break-inside: avoid;
    page-break-inside: avoid;
    background: #fff !important;
    border-color: #999 !important;
  }
  .summary__parcel-head,
  .summary__parcel-rev {
    grid-column: 1 / -1;
  }
  .summary__parcel-head { font-size: .82rem; margin-bottom: 3px; }
  .summary__parcel .kv { font-size: .74rem; padding: 0; }
  .summary__parcel-rev { margin-top: 3px; padding-top: 3px; font-size: .78rem; }

  .summary__totals { padding: 8px 10px; }

  .criterion,
  .parcel {
    break-inside: avoid;
    page-break-inside: avoid;
    background: #fff !important;
    border-color: #999 !important;
  }

  .kv__v.total, .parcel__score-value, .summary__amount { color: #000 !important; }
  a[href]::after { content: none !important; }
}

/* ----------------------------- 15) Reduced motion ------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
