/* ==========================================================================
   Tree Survey Pro — application UI (screens, shell, components)
   Loaded after css/app.css. The printable report (.rp*, .rt*, #report-body)
   keeps its own styles in app.css and is intentionally untouched here.
   Layout concept: right-hand sidebar shell for home/admin, full-width
   working canvas for the editor; one forest-green brand, one survey-tape accent.
   ========================================================================== */

:root {
  /* palette — light */
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --surface-3: #e3e8e1;
  --line: #d5dcd3;
  --line-strong: #b9c4bb;
  --text: #17241d;
  --text-2: #445349;
  --text-3: #56645b;
  --primary: #1f4d3a;
  --primary-hover: #183e2e;
  --on-primary: #ffffff;
  --primary-soft: #e1ede5;
  --primary-text: #1f5a42;
  --accent: #a8561d;
  --accent-soft: #f8e8da;
  --gold: #75591b;
  --gold-soft: #f6efdc;
  --danger: #b3261e;
  --danger-soft: #fbe8e6;
  --warning: #855400;
  --warning-soft: #fdf1d6;
  --success: #1e6b45;
  --success-soft: #e0f1e7;
  --info: #1d5c94;
  --info-soft: #e2edf8;
  --focus: #c8661f;
  --overlay: rgba(14, 24, 19, .48);
  --sidebar-bg: #15241c;
  --sidebar-text: #d9e4dc;
  --sidebar-text-2: #9fb3a6;
  --sidebar-active: rgba(255, 255, 255, .1);
  --shadow-1: 0 1px 2px rgba(18, 35, 26, .06), 0 1px 1px rgba(18, 35, 26, .04);
  --shadow-2: 0 8px 28px -12px rgba(18, 35, 26, .28);
  --shadow-3: 0 24px 60px -20px rgba(18, 35, 26, .45);
  /* status colours follow the Ministry report convention */
  --st-pres: #d32f2f;
  --st-cut: #d4b100;
  --st-move: #e07a2e;
  --st-free: #0a9fd6;
  --st-none: #9aa69e;

  /* type */
  --font-ui: "IBM Plex Sans Hebrew", "Heebo", "Segoe UI", Arial, sans-serif;
  --font-display: "Frank Ruhl Libre", "David Libre", Georgia, serif;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-md: .9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.5rem;

  /* shape & space */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --sidebar-w: 248px;
  --hdr-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411; --surface: #151d19; --surface-2: #1b2520; --surface-3: #23302a;
    --line: #2b3832; --line-strong: #3b4b43;
    --text: #e5ece7; --text-2: #b8c5bd; --text-3: #94a39a;
    --primary: #4f9c76; --primary-hover: #5fae86; --on-primary: #0b1510;
    --primary-soft: #1a2d23; --primary-text: #8fd0ad;
    --accent: #e9a36d; --accent-soft: #34251a;
    --gold: #d8b871; --gold-soft: #2e2716;
    --danger: #f08a80; --danger-soft: #3a1f1d;
    --warning: #f0c165; --warning-soft: #33280f;
    --success: #79cf9f; --success-soft: #16301f;
    --info: #8ebcf0; --info-soft: #18283b;
    --focus: #f0a35e;
    --overlay: rgba(0, 0, 0, .6);
    --sidebar-bg: #0b110e; --sidebar-text: #d9e4dc; --sidebar-text-2: #8ea398; --sidebar-active: rgba(255, 255, 255, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, .6);
    --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1411; --surface: #151d19; --surface-2: #1b2520; --surface-3: #23302a;
  --line: #2b3832; --line-strong: #3b4b43;
  --text: #e5ece7; --text-2: #b8c5bd; --text-3: #94a39a;
  --primary: #4f9c76; --primary-hover: #5fae86; --on-primary: #0b1510;
  --primary-soft: #1a2d23; --primary-text: #8fd0ad;
  --accent: #e9a36d; --accent-soft: #34251a;
  --gold: #d8b871; --gold-soft: #2e2716;
  --danger: #f08a80; --danger-soft: #3a1f1d;
  --warning: #f0c165; --warning-soft: #33280f;
  --success: #79cf9f; --success-soft: #16301f;
  --info: #8ebcf0; --info-soft: #18283b;
  --focus: #f0a35e;
  --overlay: rgba(0, 0, 0, .6);
  --sidebar-bg: #0b110e; --sidebar-text: #d9e4dc; --sidebar-text-2: #8ea398; --sidebar-active: rgba(255, 255, 255, .08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* accessibility preferences (set on <html> by the accessibility menu) */
:root[data-a11y-text="1"] { font-size: 112.5%; }
:root[data-a11y-text="2"] { font-size: 125%; }
:root[data-a11y-text="3"] { font-size: 137.5%; }
:root[data-a11y-contrast="high"] {
  --text: #000; --text-2: #111; --text-3: #222; --line: #555; --line-strong: #000;
  --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --surface-3: #e6e6e6;
  --primary: #0b3d27; --primary-text: #0b3d27; --primary-soft: #dcefe3; --accent: #7a3500; --focus: #b34700;
  --sidebar-bg: #000; --sidebar-text: #fff; --sidebar-text-2: #ddd;
  color-scheme: light;
}
:root[data-a11y-links="1"] a, :root[data-a11y-links="1"] .link-btn { text-decoration: underline !important; text-underline-offset: 3px; }
:root[data-a11y-font="readable"] { --font-ui: Arial, "Helvetica Neue", sans-serif; --font-display: Arial, sans-serif; letter-spacing: .01em; }
:root[data-a11y-motion="off"] *, :root[data-a11y-motion="off"] *::before, :root[data-a11y-motion="off"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--primary-text); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; right: 8px; z-index: 10000; transform: translateY(-160%);
  background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: var(--r);
  font-weight: 600; text-decoration: none; transition: transform .15s;
}
.skip-link:focus { transform: none; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ---------- icons ---------- */
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none;
  position: relative;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); background: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: var(--fs-md); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .kbd { margin-inline-start: 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-text); font-weight: 600; cursor: pointer; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.kbd { font-family: var(--font-ui); font-size: .7rem; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2); font-weight: 600; }

/* ---------- form fields ---------- */
.fld { display: grid; gap: 6px; min-width: 0; }
.fld > label, .fld-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fld .hint { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }
.inp, .fld input:not([type=checkbox]):not([type=radio]):not([type=file]), .fld select, .fld textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-md); transition: border-color .15s, box-shadow .15s;
}
.fld textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.inp:hover, .fld input:hover, .fld select:hover, .fld textarea:hover { border-color: var(--text-3); }
.inp:focus, .fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); outline: none; }
.inp::placeholder, .fld input::placeholder, .fld textarea::placeholder { color: var(--text-3); opacity: .85; }
.fld-err { font-size: var(--fs-xs); color: var(--danger); display: none; }
.fld-err.show, .field-err.show { display: block; }
.field-err { font-size: var(--fs-xs); color: var(--danger); display: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-4); }
.form-grid .span-all { grid-column: 1 / -1; }
.form-msg { padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; }
.form-msg.ok { background: var(--success-soft); color: var(--success); }
.form-msg.err { background: var(--danger-soft); color: var(--danger); }
.search-field { position: relative; min-width: 0; }
.search-field .ic { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-field input { padding-inline-start: 36px !important; }
.select-sm, .inp-sm { min-height: 36px !important; font-size: var(--fs-sm) !important; padding: 6px 10px !important; }
.seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; color: var(--text-2); border-inline-start: 1px solid var(--line); min-width: 38px; }
.seg button:first-child { border-inline-start: 0; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: var(--fs-sm); }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 21px; }

/* ---------- chips, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); line-height: 1.7; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.no-dot::before { display: none; }
.chip-pres::before { background: var(--st-pres); }
.chip-cut::before { background: var(--st-cut); }
.chip-move::before { background: var(--st-move); }
.chip-free::before { background: var(--st-free); }
.chip-ok { background: var(--success-soft); color: var(--success); }
.chip-warn { background: var(--warning-soft); color: var(--warning); }
.chip-bad { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-gold { background: var(--gold-soft); color: var(--gold); }
.chip-brand { background: var(--primary-soft); color: var(--primary-text); }
.count-pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; }

/* ---------- cards & panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-1); min-width: 0; }
.card-hd { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.card-hd h2, .card-hd h3 { font-size: var(--fs-lg); font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; }
.card-hd .sub { color: var(--text-3); font-size: var(--fs-sm); width: 100%; margin-top: -8px; }
.card-hd .spacer { flex: 1; }
.stack { display: grid; gap: var(--sp-4); }
.stack-lg { display: grid; gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--sp-2) 0; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--text); font-size: var(--fs-sm); }
.callout .ic { color: var(--info); margin-top: 2px; }
.callout.warn { background: var(--warning-soft); } .callout.warn .ic { color: var(--warning); }
.callout.ok { background: var(--success-soft); } .callout.ok .ic { color: var(--success); }
details.disclose { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
details.disclose > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::after { content: "▾"; margin-inline-start: auto; transition: transform .15s; }
details.disclose[open] > summary::after { transform: rotate(180deg); }
details.disclose > .disclose-body { padding: 0 14px 14px; font-size: var(--fs-sm); color: var(--text-2); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.kpi .k-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; letter-spacing: .02em; }
.kpi .k-val { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-sub { font-size: var(--fs-xs); color: var(--text-3); }
.kpi.kpi-gold .k-val { color: var(--gold); }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- screens ---------- */
.screen { display: none; }
.screen.active { display: block; }

/* ---------- auth screens ---------- */
#screen-login.active, #screen-register.active, #screen-reset.active {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; background: var(--bg);
}
.auth-art {
  position: relative; overflow: hidden; color: #eaf3ec;
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(255,255,255,.08), transparent 60%),
    linear-gradient(165deg, #0f2219 0%, #1a3a2b 55%, #24513c 100%);
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px;
}
.auth-art .brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.auth-art h2 { font-family: var(--font-display); font-size: clamp(2rem, 3.4vw, 3rem); font-weight: 700; line-height: 1.15; margin: 0 0 14px; max-width: 14ch; text-wrap: balance; }
.auth-art p { color: #b9d2c1; max-width: 42ch; font-size: var(--fs-lg); line-height: 1.6; }
.auth-art .art-rings { position: absolute; inset-inline-end: -120px; bottom: -140px; width: 520px; height: 520px; opacity: .22; pointer-events: none; }
.auth-art .art-facts { display: flex; gap: 28px; flex-wrap: wrap; font-size: var(--fs-sm); color: #b9d2c1; position: relative; }
.auth-art .art-facts b { display: block; color: #fff; font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.auth-pane { display: grid; place-items: center; padding: 40px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.auth-box { width: min(400px, 100%); display: grid; gap: 18px; }
.auth-logo h1 { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; margin: 0; }
.auth-logo p { color: var(--text-3); margin: 4px 0 0; }
.auth-logo .ico { display: none; }
.auth-box .af { display: grid; gap: 6px; }
.auth-box .af label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.auth-box .af input { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-md); }
.auth-box .af input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); outline: none; }
.auth-err { color: var(--danger); font-size: var(--fs-sm); min-height: 1.2em; font-weight: 500; }
.auth-err:empty { display: none; }
.auth-btn { width: 100%; min-height: 48px; border: 0; border-radius: var(--r-sm); background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: var(--fs-md); cursor: pointer; transition: background .15s; }
.auth-btn:hover { background: var(--primary-hover); }
.auth-btn:disabled { opacity: .6; cursor: progress; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: var(--fs-sm); }
.auth-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-3); border-top: 1px solid var(--line); padding-top: 14px; }
.reg-done { text-align: center; display: grid; gap: 10px; justify-items: center; }
.reg-done .big { font-size: 2.6rem; }
.reg-done h3 { font-size: var(--fs-xl); margin: 0; }
.reg-done p { color: var(--text-2); }
@media (max-width: 860px) {
  #screen-login.active, #screen-register.active, #screen-reset.active { grid-template-columns: 1fr; }
  .auth-art { padding: 28px max(16px, env(safe-area-inset-right, 0px)) 28px max(16px, env(safe-area-inset-left, 0px)); min-height: 0; }
  .auth-art h2 { font-size: 1.7rem; margin-bottom: 6px; }
  .auth-art p, .auth-art .art-facts { display: none; }
  .auth-art .art-rings { width: 300px; height: 300px; bottom: -160px; }
}

/* ---------- app shell (home + admin) ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: #fff; }
.sb-brand small { display: block; font-family: var(--font-ui); font-size: .7rem; font-weight: 500; color: var(--sidebar-text-2); letter-spacing: .04em; }
.sb-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(150deg, #2f6b50, #1a3a2b); display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sb-section { font-size: .68rem; color: var(--sidebar-text-2); font-weight: 700; letter-spacing: .08em; padding: 14px 10px 4px; }
.sb-nav { display: grid; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0;
  background: none; color: var(--sidebar-text); font-size: var(--fs-sm); font-weight: 500; text-align: start; cursor: pointer; text-decoration: none;
}
.sb-item:hover { background: var(--sidebar-active); color: #fff; }
.sb-item[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 700; box-shadow: inset -3px 0 0 var(--accent); }
.sb-item .count-pill { margin-inline-start: auto; }
.sb-item .ic { opacity: .9; }
.sb-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; min-width: 0; }
.sb-user .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #2f6b50; color: #fff; font-weight: 700; flex: none; }
.sb-user .u-name { font-size: var(--fs-sm); font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user .u-mail { font-size: .7rem; color: var(--sidebar-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-credit { font-size: .68rem; color: var(--sidebar-text-2); padding: 4px 10px; line-height: 1.5; }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.main-inner { max-width: 1180px; margin-inline: auto; display: grid; gap: var(--sp-5); }
.page-hd { display: flex; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; }
.page-hd h1 { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; margin: 0; line-height: 1.2; }
.page-hd .eyebrow { font-size: var(--fs-xs); color: var(--accent); font-weight: 700; letter-spacing: .06em; margin-bottom: 4px; }
.page-hd p { color: var(--text-3); margin: 4px 0 0; }
.page-hd .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }
.view { display: none; }
.view.active { display: grid; gap: var(--sp-5); }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 900; transform: translateX(110%); transition: transform .2s; height: 100dvh; padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 800; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 700;
    background: var(--sidebar-bg); color: #fff; padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  }
  .mobile-bar .btn { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
  .mobile-bar .mb-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
  .main { padding-top: 18px; }
}

/* ---------- project list ---------- */
.list-tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.list-tools .search-field { flex: 1 1 260px; max-width: 420px; }
.proj-list { display: grid; gap: 10px; }
.proj-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: var(--shadow-1); transition: border-color .15s, box-shadow .15s, transform .15s; position: relative;
}
.proj-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.proj-card:focus-within { border-color: var(--primary); }
.proj-mark { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.proj-main { min-width: 0; display: grid; gap: 4px; }
.proj-title-btn { all: unset; cursor: pointer; font-weight: 700; font-size: var(--fs-lg); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-title-btn::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.proj-title-btn:focus-visible { outline: none; }
.proj-title-btn:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.proj-sub { color: var(--text-3); font-size: var(--fs-sm); display: flex; gap: 6px 14px; flex-wrap: wrap; }
.proj-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.proj-side { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.proj-value { text-align: end; display: grid; }
.proj-value b { font-variant-numeric: tabular-nums; font-size: var(--fs-md); }
.proj-value span { font-size: var(--fs-xs); color: var(--text-3); }
.proj-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; display: flex; width: 120px; }
.proj-bar i { display: block; height: 100%; }
@media (max-width: 640px) {
  .proj-card { grid-template-columns: auto minmax(0, 1fr); }
  .proj-side { grid-column: 1 / -1; justify-content: space-between; }
  .proj-bar { display: none; }
}
.empty-state { text-align: center; padding: 48px 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--text-3); display: grid; gap: 10px; justify-items: center; background: var(--surface); }
.empty-state .ei { font-size: 2.4rem; }
.empty-state h3 { margin: 0; color: var(--text); font-size: var(--fs-lg); }

/* status picker */
.proj-status { appearance: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 3px 12px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); cursor: pointer; }

/* ---------- menus ---------- */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 600; min-width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3);
  padding: 6px; display: grid; gap: 1px;
}
.menu.menu-start { inset-inline-end: auto; inset-inline-start: 0; }
.menu[hidden] { display: none; }
.menu-label { font-size: .68rem; color: var(--text-3); font-weight: 700; letter-spacing: .06em; padding: 8px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 7px; border: 0; background: none;
  font-size: var(--fs-sm); font-weight: 500; color: var(--text); cursor: pointer; text-align: start; position: relative;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .mi-sub { display: block; font-size: .72rem; color: var(--text-3); font-weight: 400; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- dialogs ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 9000; background: var(--overlay); display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  animation: fadeIn .15s ease-out;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); color: var(--text);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 24px; display: grid; gap: 16px; animation: popIn .18s ease-out;
}
.dialog.dialog-sm { width: min(420px, 100%); }
.dialog.dialog-lg { width: min(720px, 100%); }
.dialog-hd { display: flex; align-items: flex-start; gap: 12px; }
.dialog-hd h2 { font-size: var(--fs-xl); font-weight: 700; margin: 0; line-height: 1.3; }
.dialog-hd p { color: var(--text-3); margin: 4px 0 0; font-size: var(--fs-sm); }
.dialog-hd .btn-icon { margin-inline-start: auto; flex: none; }
.dialog-ft { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.dialog-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--danger-soft); color: var(--danger); }
.dialog-icon.info { background: var(--primary-soft); color: var(--primary-text); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* legacy modal markup reused for new-project & quick-capture */
.modal-overlay { position: fixed; inset: 0; z-index: 9000; background: var(--overlay); display: none; place-items: center; padding: 16px; }
.modal-overlay.open { display: grid; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 10000; bottom: max(18px, env(safe-area-inset-bottom, 0px)); inset-inline-start: max(18px, env(safe-area-inset-left, 0px)); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r);
  background: #17241d; color: #eef4f0; box-shadow: var(--shadow-3); font-size: var(--fs-sm); line-height: 1.45; animation: popIn .18s ease-out;
  border-inline-start: 4px solid var(--st-none);
}
:root[data-theme="dark"] .toast { background: #26332c; }
.toast.ok { border-inline-start-color: #4caf7d; }
.toast.err { border-inline-start-color: #ef6b5e; }
.toast.warn { border-inline-start-color: #f0b44c; }
.toast .t-msg { flex: 1; white-space: pre-line; }
.toast .t-act { background: none; border: 0; color: #f0b27f; font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.toast .t-close { background: none; border: 0; color: #a9bbb0; cursor: pointer; padding: 4px; border-radius: 6px; line-height: 0; }

/* ---------- editor ---------- */
#screen-editor.active { min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.ed-hdr {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 500; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); box-shadow: var(--shadow-1);
}
.ed-hdr-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; }
.ed-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 260px; }
.ed-crumb .proj-title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.save-indicator { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; white-space: nowrap; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); }
.save-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.save-indicator .dot.unsaved { background: var(--accent); }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tab-nav { display: flex; gap: 2px; overflow-x: auto; margin-top: 6px; scrollbar-width: none; }
.tab-nav::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; border: 0; background: none; cursor: pointer;
  color: var(--text-3); font-weight: 600; font-size: var(--fs-sm); border-bottom: 3px solid transparent; white-space: nowrap; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--accent); }
.tab .count-pill { background: var(--surface-3); color: var(--text-2); }
.tab.active .count-pill { background: var(--primary-soft); color: var(--primary-text); }
.tab-panels { padding: 22px max(16px, env(safe-area-inset-right, 0px)) 72px max(16px, env(safe-area-inset-left, 0px)); max-width: 1680px; margin-inline: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: grid; gap: var(--sp-4); }
#tab-details.active { max-width: 1100px; margin-inline: auto; width: 100%; }

/* details: text template helpers */
.tpl-btns { display: inline-flex; gap: 6px; margin-inline-start: auto; }
.dropzone {
  position: relative; display: grid; place-items: center; gap: 6px; text-align: center; min-height: 140px; padding: 16px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); color: var(--text-3); cursor: pointer;
  transition: border-color .15s, background .15s; overflow: hidden; font-size: var(--fs-sm);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone img { max-height: 150px; border-radius: 6px; }
.dropzone .dz-icon { font-size: 1.6rem; }
.img-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4); }
.agri-zone { height: 130px; }
.agri-zone img { width: 100%; height: 100%; object-fit: cover; }
.opt-group { display: flex; gap: 8px; flex-wrap: wrap; }
.opt-btn { padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; }
.opt-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* trees tab */
.tree-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree-toolbar .row-count { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.tree-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree-filters .search-field { flex: 1 1 240px; max-width: 360px; }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--r); background: var(--text); color: var(--bg); font-size: var(--fs-sm); }
.bulk-bar select { background: var(--surface); color: var(--text); border-radius: var(--r-sm); border: 0; min-height: 34px; padding: 4px 8px; }
.bulk-bar .btn { min-height: 34px; }
.bulk-bar .btn-ghost { color: var(--bg); }
.bulk-bar .btn-ghost:hover { background: rgba(127,127,127,.25); }
.mobile-tbl-hint { display: none; }
@media (max-width: 760px) { .mobile-tbl-hint { display: flex; } }
.import-alert { display: none; padding: 10px 14px; border-radius: var(--r); font-size: var(--fs-sm); font-weight: 500; }
.import-alert.ok, .import-alert.success { background: var(--success-soft); color: var(--success); }
.import-alert.err, .import-alert.error { background: var(--danger-soft); color: var(--danger); }
.formula-box { margin: 0; }
.formula-eq { display: block; direction: ltr; text-align: left; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 8px 0; color: var(--text); font-size: .82rem; }

/* tree table re-skin (structure and classes unchanged) */
.tbl-outer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; max-height: calc(100dvh - 250px); box-shadow: var(--shadow-1); }
table.tree-tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .8rem; }
table.tree-tbl thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .72rem; line-height: 1.3;
  padding: 9px 6px; border-bottom: 1px solid var(--line-strong); text-align: center; vertical-align: bottom; white-space: nowrap;
}
table.tree-tbl tbody td { padding: 4px 4px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); vertical-align: middle; }
table.tree-tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
table.tree-tbl tbody tr:hover td { background: var(--primary-soft); }
table.tree-tbl tbody tr.row-selected td { background: var(--accent-soft); }
table.tree-tbl tbody tr.row-warn td:nth-child(2) { box-shadow: inset 3px 0 0 var(--warning); }
table.tree-tbl input[type=number], table.tree-tbl input[type=text], table.tree-tbl select {
  width: 100%; min-height: 32px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font-size: .8rem;
}
table.tree-tbl input[type=number] { font-variant-numeric: tabular-nums; text-align: center; }
table.tree-tbl input:hover, table.tree-tbl select:hover { border-color: var(--line-strong); background: var(--surface); }
table.tree-tbl input:focus, table.tree-tbl select:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); outline: none; }
table.tree-tbl input.f-warn { border-color: var(--warning); background: var(--warning-soft); }
table.tree-tbl .cc { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
table.tree-tbl .cc.value-cell { background: var(--gold-soft) !important; }
table.tree-tbl .value-cell input { color: var(--gold) !important; font-weight: 700; }
.del-row-btn { width: 30px; height: 30px; border-radius: 6px; border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: .9rem; }
.del-row-btn:hover { background: var(--danger-soft); color: var(--danger); }
.row-open-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; border: 0; background: none; color: var(--text-3); cursor: pointer; vertical-align: middle; }
.row-open-btn:hover { background: var(--primary-soft); color: var(--primary-text); }
.row-idx { color: var(--text-3); font-size: .7rem; font-variant-numeric: tabular-nums; }
.tbl-addfooter td { padding: 10px !important; background: var(--surface) !important; border-bottom: 0 !important; }
.sp-drop { background: var(--surface) !important; border: 1px solid var(--line) !important; box-shadow: var(--shadow-3) !important; border-radius: var(--r) !important; color: var(--text); }
.sp-drop div { color: var(--text); border-bottom-color: var(--line) !important; }
.sp-drop div.sp-active, .sp-drop div:hover { background: var(--primary-soft) !important; }
.sp-drop div span.sp-latin { color: var(--text-3) !important; }
.autocomplete-list { background: var(--surface) !important; border: 1px solid var(--line) !important; box-shadow: var(--shadow-3) !important; border-radius: var(--r) !important; color: var(--text); }
.autocomplete-list div { color: var(--text); border-bottom-color: var(--line) !important; }
.autocomplete-list div:hover, .autocomplete-list div:focus { background: var(--primary-soft) !important; }

/* tree side panel */
.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 850; animation: fadeIn .15s; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(420px, 100vw); z-index: 860; background: var(--surface);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slideIn .18s ease-out;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }
.drawer-hd { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-hd h2 { font-size: var(--fs-lg); margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: grid; gap: 14px; align-content: start; }
.drawer-ft { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.score-seg { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.score-seg button { border: 0; background: var(--surface); padding: 8px 0; font-weight: 600; cursor: pointer; border-inline-start: 1px solid var(--line); font-variant-numeric: tabular-nums; color: var(--text-2); }
.score-seg button:first-child { border-inline-start: 0; }
.score-seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.calc-box { border: 1px dashed var(--primary); border-radius: var(--r); padding: 12px 14px; background: var(--primary-soft); display: grid; gap: 6px; font-size: var(--fs-sm); }
.calc-box .cb-formula { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; color: var(--text-2); line-height: 1.7; word-break: break-word; }
.calc-box .cb-val { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.warn-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.warn-list li { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); padding: 8px 10px; border-radius: 8px; background: var(--warning-soft); color: var(--text); }
.warn-list li .ic { color: var(--warning); margin-top: 2px; }

/* analysis + images re-skin */
.stat-card { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-lg) !important; box-shadow: var(--shadow-1) !important; }
.stat-card .sn { color: var(--text) !important; font-variant-numeric: tabular-nums; }
.stat-card .sl { color: var(--text-3) !important; }
.at-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; }
.at th { background: var(--surface-2) !important; color: var(--text-2) !important; }
.at td { color: var(--text); border-color: var(--line) !important; }
.at tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)) !important; }
.at tfoot td { background: var(--surface-3) !important; color: var(--text) !important; }
.scard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-1); }
.scard-title { font-size: var(--fs-lg); font-weight: 700; color: var(--text); border: 0; padding: 0; margin: 0 0 var(--sp-4); display: flex; align-items: center; gap: 10px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.img-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; position: relative; }
.img-card-lbl input { background: var(--surface); color: var(--text); border-color: var(--line); }
.add-img-btn { border: 1.5px dashed var(--line-strong) !important; background: var(--surface-2) !important; color: var(--text-3) !important; border-radius: var(--r) !important; position: relative; }
.add-img-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.img-del { opacity: 1 !important; }

/* ---------- report bar (report body itself unchanged) ---------- */
#screen-report.active { background: #e9ece6; min-height: 100vh; }
.report-bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 500; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #15241c; color: #fff; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.report-bar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.28); }
.report-bar .btn:hover { background: rgba(255,255,255,.1); }
.report-bar .btn-gold { background: #b08a3a; border-color: #b08a3a; }
.report-bar .rb-title { flex: 1; font-weight: 600; font-size: var(--fs-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* phone: wide report tables scroll inside the page instead of widening it */
@media screen and (max-width: 900px) { #screen-report .rp { overflow-x: auto; } #screen-report .ps-sum-values { overflow-x: auto; } }

/* ---------- admin ---------- */
.adm-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; box-shadow: var(--shadow-1); }
.adm-tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.adm-tbl th { text-align: start; font-size: var(--fs-xs); color: var(--text-3); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; letter-spacing: .02em; }
.adm-tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.adm-tbl tr:last-child td { border-bottom: 0; }
.adm-tbl tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.adm-tbl .u-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.adm-tbl .u-cell .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; flex: none; }
.adm-tbl .u-cell b { display: block; }
.adm-tbl .u-cell small { color: var(--text-3); }
.adm-tbl td.empty { text-align: center; color: var(--text-3); padding: 28px; }
.exp-meter { display: grid; gap: 4px; min-width: 130px; }
.exp-meter .bar { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.exp-meter .bar i { display: block; height: 100%; background: var(--success); }
.exp-meter.warn .bar i { background: var(--warning); }
.exp-meter.bad .bar i { background: var(--danger); }
.exp-meter small { color: var(--text-3); font-size: .72rem; }

/* settings layout */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); align-items: start; }
.storage-meter { height: 10px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.storage-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--gold)); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* command palette */
.cmdk { width: min(620px, 100%); padding: 0; gap: 0; align-self: start; margin-top: 10vh; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.cmdk-input input { flex: 1; border: 0; background: none; font-size: var(--fs-lg); outline: none; min-width: 0; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: 6px; display: grid; gap: 1px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 0; background: none; width: 100%; text-align: start; font-size: var(--fs-sm); color: var(--text); }
.cmdk-item[aria-selected="true"] { background: var(--primary-soft); }
.cmdk-item .ci-sub { color: var(--text-3); font-size: .74rem; margin-inline-start: auto; }
.cmdk-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.cmdk-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .72rem; color: var(--text-3); flex-wrap: wrap; }

/* preflight check */
.check-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-sm); }
.check-list li.ok .ic { color: var(--success); }
.check-list li.warn .ic { color: var(--warning); }
.check-list li.bad .ic { color: var(--danger); }
.check-list li .cl-body { flex: 1; min-width: 0; }
.check-list li .cl-body small { display: block; color: var(--text-3); margin-top: 2px; }
.score-ring { width: 76px; height: 76px; flex: none; }

/* accessibility statement */
.prose { max-width: 70ch; line-height: 1.75; color: var(--text-2); }
.prose h3 { color: var(--text); font-size: var(--fs-lg); margin: 18px 0 6px; }
.prose ul { padding-inline-start: 20px; }

/* print: hide app chrome */
@media print {
  .toasts, .dialog-backdrop, .drawer, .drawer-backdrop, .skip-link { display: none !important; }
}

/* ── Legacy neutralizers: app.css still styles the report and some JS-built
   blocks with fixed light colors; these keep every screen on the theme tokens. ── */
#screen-home, #screen-admin { background: var(--bg); }
.auth-box { background: var(--surface); color: var(--text); }
.auth-logo h1 { color: var(--text); }
.auth-logo p, .auth-links, .auth-links span { color: var(--text-3); }
.af label { color: var(--text-2); }
.tab-nav { background: var(--surface); border-bottom-color: var(--line); }
table.tree-tbl .cc { background: var(--surface-2) !important; color: var(--text-2); }
table.tree-tbl .cc.value-cell { background: var(--gold-soft) !important; }
.tbl-addfooter td { background: var(--surface) !important; border-top-color: var(--line-strong) !important; }
.stat-card .sv { opacity: 1; color: var(--text-3) !important; }
.at td { border-bottom-color: var(--line); color: var(--text); }
.at tr:nth-child(even) td { background: var(--surface-2); }
.at tfoot td { background: var(--primary-soft); }
.at-wrap, .tbl-outer { border-color: var(--line); }
.formula-box { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.formula-box strong, .formula-box .formula-eq { color: var(--primary-text); }
.formula-box .formula-eq { background: var(--surface); }
.img-card { background: var(--surface-2); border-color: var(--line); }
.img-card-lbl input { color: var(--text-2); }
.add-img-btn { border-color: var(--line-strong); color: var(--text-3); }
.autocomplete-list, .sp-drop { background: var(--surface); border-color: var(--primary); }
.autocomplete-list div, .sp-drop div { border-bottom-color: var(--line); color: var(--text); }
.autocomplete-list div:hover, .sp-drop div:hover, .sp-drop div.sp-active { background: var(--primary-soft); }
.sp-drop div span.sp-latin { color: var(--text-3); }
.field label { color: var(--text-2); }
.field input, .field select, .field textarea { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.main-inner > *, .view > * { min-width: 0; }
[tabindex="-1"]:focus { outline: none; }
.adm-table-wrap, .tbl-outer, .at-wrap { position: relative; }
/* account menu: spans the sidebar footer so it never sticks out of the sidebar */
.sb-foot { position: relative; }
.sb-foot .menu-wrap { position: static; }
#acct-menu { inset-inline: 0; min-width: 0; }
/* species list floats above the table (positioned from JS) */
.sp-drop { z-index: 1200; border: 1px solid var(--line-strong) !important; border-radius: var(--r) !important; box-shadow: var(--shadow-3); overflow-y: auto; padding: 4px; }
.sp-drop div { padding: 9px 12px !important; font-size: .9rem !important; border-radius: var(--r-sm); border-bottom: 0 !important; white-space: normal !important; }
.sp-drop div span.sp-latin { font-size: .78rem !important; font-style: italic; }

/* version history + trash rows */
.ver-list { max-height: min(60vh, 520px); overflow-y: auto; }
.ver-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ver-row > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ver-row small { font-size: var(--fs-xs); }

/* =====================================================================
   Field-work layer (js/10-field.js)
   ===================================================================== */
/* status colours (rows, cards, legend) */
:root { --st-cut: var(--danger); --st-pres: var(--success); --st-move: #b8730a; --st-none: var(--line-strong); }
.tree-tbl tbody tr[data-st] td:first-child { box-shadow: inset -5px 0 0 var(--st-none); }
.tree-tbl tbody tr[data-st="cut"] td:first-child { box-shadow: inset -5px 0 0 var(--st-cut); }
.tree-tbl tbody tr[data-st="pres"] td:first-child { box-shadow: inset -5px 0 0 var(--st-pres); }
.tree-tbl tbody tr[data-st="move"] td:first-child { box-shadow: inset -5px 0 0 var(--st-move); }
.tv-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 10px; }
.tv-switch { display: none; }
.st-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); }
.st-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.st-legend .st-cut { background: var(--st-cut); } .st-legend .st-pres { background: var(--st-pres); } .st-legend .st-move { background: var(--st-move); } .st-legend .st-none { background: var(--st-none); }

/* tree cards (phones) */
.tree-cards { display: none; flex-direction: column; gap: 8px; }
.tcard { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--st-none); border-radius: var(--r); padding: 11px 12px; min-height: 64px; }
.tcard:active { background: var(--surface-2); }
.tcard.st-cut { border-inline-start-color: var(--st-cut); } .tcard.st-pres { border-inline-start-color: var(--st-pres); } .tcard.st-move { border-inline-start-color: var(--st-move); }
.tc-num { min-width: 40px; height: 40px; padding: 0 4px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.tc-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tc-sp { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-meta { font-size: 12.5px; color: var(--text-3); }
.tc-side { display: grid; gap: 4px; justify-items: end; }
.tc-chip { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tc-chip.st-cut { background: var(--danger-soft); color: var(--danger); } .tc-chip.st-pres { background: var(--success-soft); color: var(--success); } .tc-chip.st-move { background: var(--warning-soft); color: var(--warning); }
.tc-val { font-size: 12.5px; font-weight: 700; color: var(--gold); }

/* bottom bar + compact header (phones) */
.ed-bottombar, .ed-actions-m { display: none; }
.ed-bottombar { position: fixed; inset: auto 0 0 0; z-index: 400; gap: 8px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08);
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.bb-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; padding: 6px 4px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 700; position: relative; }
.bb-btn .ic { width: 22px; height: 22px; }
.bb-primary { flex: 1.4; background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-size: 14px; }
.bb-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.ed-actions-m { gap: 6px; align-items: center; margin-inline-start: auto; }

@media (max-width: 760px) {
  body.tv-cards .tree-cards { display: flex; }
  body.tv-cards #tab-trees .tbl-outer, body.tv-cards #tab-trees .mobile-tbl-hint, body.tv-cards #tab-trees .st-legend { display: none; }
  .tv-switch { display: inline-grid; }
  #tab-trees .tree-toolbar > .btn-primary, #tab-trees .tree-toolbar > label.btn { display: none; }
  #tab-trees .mobile-tbl-hint { display: none !important; }
  #screen-editor[data-tab="trees"] .ed-bottombar { display: flex; }
  #screen-editor[data-tab="trees"] #tab-trees { padding-bottom: 96px; }
  .ed-actions { display: none; }
  .ed-actions-m { display: flex; }
  .ed-crumb .save-indicator #save-text { display: none; }
}

/* new tree: values copied from the previous tree */
.prefilled { background: var(--success-soft) !important; border-color: var(--success) !important; }
.prefill-note { margin: 0 0 10px; font-size: var(--fs-xs); font-weight: 600; color: var(--primary-text); background: var(--primary-soft); border-radius: var(--r-sm); padding: 7px 10px; }
.sun-btn[aria-pressed="true"] { background: #ffd84d; color: #000; border-color: #000; }

/* sun mode: maximum contrast, bigger targets */
body.sun { --bg: #ffffff; --surface: #ffffff; --surface-2: #f0f0f0; --text: #000000; --text-2: #000000; --text-3: #1a1a1a; --line: #000000; --line-strong: #000000; color-scheme: light; }
body.sun .drawer input, body.sun .drawer select, body.sun .drawer textarea { border: 2px solid #000 !important; font-size: 18px !important; min-height: 50px; color: #000 !important; font-weight: 600; background: #fff !important; }
body.sun .drawer .score-seg button, body.sun .drawer .opt-btn { min-height: 52px; font-size: 18px; border: 2px solid #000 !important; font-weight: 800; color: #000; }
body.sun .drawer .score-seg button[aria-pressed="true"], body.sun .drawer .opt-btn[aria-pressed="true"] { background: #000 !important; color: #fff !important; }
body.sun .drawer label, body.sun .drawer .fld-label { color: #000 !important; font-weight: 800; font-size: 15px; }
body.sun .tcard { border-width: 2px; border-color: #000; } body.sun .tc-meta { color: #000; font-weight: 600; }

/* continue where you stopped */
.resume-card { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg, #1f4d3a, #2c6a50); color: #fff; border-radius: var(--r-lg); padding: 16px 20px; margin-bottom: 16px; box-shadow: 0 8px 24px rgba(31,77,58,.22); }
.resume-card[hidden] { display: none; }
.rc-ic { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.15); display: grid; place-items: center; flex: none; }
.rc-ic .ic { width: 24px; height: 24px; color: #fff; }
.rc-txt { display: grid; gap: 2px; min-width: 0; flex: 1; }
.rc-txt b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-txt small { color: #d6eadf; font-size: 13px; }
.resume-card .btn { background: #fff; color: #1f4d3a; border-color: #fff; font-weight: 800; }
@media (max-width: 520px) { .resume-card { flex-wrap: wrap; } .resume-card .btn { width: 100%; justify-content: center; } }

/* dictation */
.dict-wrap { position: relative; }
.dict-wrap textarea, .dict-wrap input { padding-inline-end: 52px; }
.dict-btn { position: absolute; inset-inline-end: 6px; bottom: 6px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--primary); display: grid; place-items: center; cursor: pointer; }
.dict-btn svg { width: 20px; height: 20px; }
.dict-btn.on { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: 0 0 0 6px var(--danger-soft); }
.dict-status { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--danger); }
.dict-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: dictPulse 1s infinite; }
@keyframes dictPulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .dict-status i { animation: none; } }

/* admin: filter chips + quick actions */
.fchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.fchip { flex: none; display: flex; gap: 6px; align-items: center; font: inherit; font-size: var(--fs-sm); font-weight: 700; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.fchip b { background: var(--surface-2); border-radius: 99px; padding: 0 7px; font-size: var(--fs-xs); }
.fchip.warn b { background: var(--warning-soft); color: var(--warning); } .fchip.bad b { background: var(--danger-soft); color: var(--danger); }
.fchip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.fchip[aria-pressed="true"] b { background: rgba(255,255,255,.22); color: inherit; }
.u-quick { display: none; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.qa { font: inherit; font-size: var(--fs-xs); font-weight: 700; padding: 7px 12px; min-height: 36px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.qa.ok { background: var(--success-soft); color: var(--success); border-color: transparent; } .qa.bad { color: var(--danger); }
@media (max-width: 760px) { .u-quick { display: flex; } }

/* an open ⋯ menu must sit above the next card (cards are positioned and can create stacking contexts) */
.proj-card:has(.menu:not([hidden])), .proj-card:focus-within { z-index: 30; }
.proj-card:hover { transform: none; }

/* ── tree map (11-map.js) ── */
.map-card .card-hd { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-tools, .map-export { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.map-place { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.map-place select { min-height: 36px; border-radius: 8px; max-width: 100%; }
.tree-map { height: min(62vh, 560px); min-height: 320px; border-radius: 10px; overflow: hidden; background: #2b2f2c; direction: ltr; }
.map-help { font-size: .8rem; margin: 6px 0; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-inline-end: 5px; vertical-align: -1px; }
.tpin-wrap { background: none; border: 0; }
.tpin { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; color: #fff; font: 700 12px/1 Heebo, Arial, sans-serif; box-shadow: 0 1px 5px rgba(0,0,0,.5); }
.tpin.focus { outline: 3px solid #ffd54f; outline-offset: 2px; }
.loc-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.loc-row #tp-loc-nav { display: contents; }
.rpage-treemap img { width: 100%; max-height: 80vh; object-fit: contain; border: 1px solid #ddd; border-radius: 6px; }

/* remember me */
.remember-me { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; margin: 2px 0 4px; }
.remember-me input { width: 18px; height: 18px; accent-color: var(--brand, #2d6a4f); }
.tp-photo { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--r); background: var(--surface-2); margin-bottom: 12px; }
#tp-loc-txt { font-weight: 600; }
@media (max-width: 760px) {
  #screen-editor[data-tab="map"] .ed-bottombar { display: flex; }
  #screen-editor[data-tab="map"] #tab-map { padding-bottom: 96px; }
  #tab-map { padding-inline: 8px; }
  #tab-map .map-card { padding: 12px; }
}
#map-edit-btn[aria-pressed="true"] { background: #ffd84d; color: #000; border-color: #000; }
.tree-map.editing .tpin { outline: 2px dashed #ffd84d; outline-offset: 3px; }
/* keep the map's own layers (zoom buttons…) under the tree card and dialogs */
.tree-map { position: relative; z-index: 0; isolation: isolate; }
/* phone: messages at the top, so they never cover the buttons at the bottom */
@media (max-width: 760px) {
  .toasts { bottom: auto; top: max(10px, env(safe-area-inset-top, 0px)); inset-inline-start: 16px; }
}
