/* AgriSense Research — design tokens, layout and components. */
:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --surface: #fcfcfb;
  --surface-2: #f0efe8;
  --line: #e2e0d6;
  --line-strong: #cfccbf;
  --text: #1b1d1a;
  --text-2: #50534c;
  --text-3: #7a7d74;
  --brand: #1f5f3f;
  --brand-2: #2f855a;
  --brand-soft: #e3f1e8;
  --brand-ink: #ffffff;
  --accent: #b2852d;
  --accent-soft: #f6ecd6;
  --chart-1: #2f855a;
  --good: #1d7a46; --good-soft: #e1f2e7;
  --warn: #9a6400; --warn-soft: #fbefd5;
  --bad: #b3261e; --bad-soft: #fbe3e1;
  --info: #2a5fa8; --info-soft: #e3ecf8;
  --shadow: 0 1px 2px rgba(30, 32, 25, .06), 0 4px 16px rgba(30, 32, 25, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121311; --surface: #1a1a19; --surface-2: #22231f; --line: #30322c; --line-strong: #43463e;
    --text: #efeee9; --text-2: #c3c2b7; --text-3: #8f9187;
    --brand: #4fb07f; --brand-2: #3d9a6a; --brand-soft: #1d3327; --brand-ink: #0d1a12;
    --accent: #d7b066; --accent-soft: #3a3020; --chart-1: #3d9a6a;
    --good: #6ccf95; --good-soft: #1b3324; --warn: #e6b450; --warn-soft: #3b2f17; --bad: #f08a80; --bad-soft: #3d1f1c; --info: #86b3f0; --info-soft: #1c2a3f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121311; --surface: #1a1a19; --surface-2: #22231f; --line: #30322c; --line-strong: #43463e;
  --text: #efeee9; --text-2: #c3c2b7; --text-3: #8f9187;
  --brand: #4fb07f; --brand-2: #3d9a6a; --brand-soft: #1d3327; --brand-ink: #0d1a12;
  --accent: #d7b066; --accent-soft: #3a3020; --chart-1: #3d9a6a;
  --good: #6ccf95; --good-soft: #1b3324; --warn: #e6b450; --warn-soft: #3b2f17; --bad: #f08a80; --bad-soft: #3d1f1c; --info: #86b3f0; --info-soft: #1c2a3f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; font-family: var(--font); font-weight: 650; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: .86rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Boot */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--text-2); }
.boot-mark { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--brand); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; text-decoration: none; color: var(--text); }
.brand img { width: 34px; height: 34px; }
.brand b { font-family: var(--font-display); font-size: 1.1rem; display: block; line-height: 1.1; }
.brand span { font-size: .78rem; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav .ico { width: 22px; text-align: center; }
.nav .count { margin-left: auto; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; font-size: .78rem; font-weight: 700; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; font-size: .85rem; }
.who { display: flex; gap: 10px; align-items: center; padding: 6px 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .title { font-weight: 650; }
.content { padding: 24px 28px 96px; max-width: 1240px; width: 100%; }
.menu-btn { display: none; }

.sync { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: .84rem; color: var(--text-2); cursor: pointer; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.sync.offline .dot { background: var(--text-3); }
.sync.pending .dot { background: var(--warn); }
.sync.error .dot { background: var(--bad); }
.sync.busy .dot { animation: pulse 1s infinite; }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 280px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
  .menu-btn { display: inline-flex; }
  .top { padding: 10px 16px; }
  .content { padding: 16px 16px 110px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; text-align: center; text-decoration: none; color: var(--text-3); font-size: .72rem; font-weight: 600; padding: 4px 0; }
  .bottom-nav a .ico { display: block; font-size: 1.25rem; line-height: 1.3; }
  .bottom-nav a.on { color: var(--brand); }
}

/* Cards & tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2, .card h3 { margin-bottom: .5em; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: .8rem; color: var(--text-2); font-weight: 600; }
.tile .v { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.15; margin-top: 2px; }
.tile .s { font-size: .8rem; color: var(--text-3); }
.hero { background: linear-gradient(135deg, var(--brand) 0%, #2b7a52 100%); color: #f3faf5; border-radius: 18px; padding: 24px 26px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero h1 { color: #fff; margin-bottom: .25em; }
.hero p { color: rgba(255,255,255,.85); max-width: 640px; }
:root[data-theme="dark"] .hero, :root:not([data-theme="light"]) .hero { color: #f3faf5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(135deg, #1f4d35, #255d40); } }
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #1f4d35, #255d40); }
.hero .btn { background: #fff; color: #1f5f3f; border-color: #fff; }
.hero .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; min-height: 40px; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-2); padding: 6px 10px; min-height: 34px; }
.btn.quiet:hover { background: var(--surface-2); color: var(--text); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.btn.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .86rem; }
.btn.lg { padding: 12px 22px; min-height: 48px; font-size: 1.02rem; }
.btn.block { width: 100%; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.submitted { background: var(--info-soft); color: var(--info); }
.chip.verified { background: var(--good-soft); color: var(--good); }
.chip.needs_fix { background: var(--warn-soft); color: var(--warn); }
.chip.rejected, .chip.withdrawn { background: var(--bad-soft); color: var(--bad); }
.chip.local { background: var(--accent-soft); color: var(--accent); }
.flag { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.flag.error { background: var(--bad-soft); color: var(--bad); }
.flag.info { background: var(--info-soft); color: var(--info); }
.flags { display: grid; gap: 6px; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 3px solid var(--accent); font-size: .9rem; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }

/* Forms */
.form { display: grid; gap: 16px; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; background: var(--surface); }
.fieldset > legend { font-weight: 700; padding: 0 6px; font-size: .95rem; }
.fields { display: grid; gap: 14px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
.field label, .field .lbl { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field .req { color: var(--bad); margin-left: 2px; }
.field .unit { color: var(--text-3); font-weight: 500; }
.field .help { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.field .err { font-size: .82rem; color: var(--bad); margin-top: 4px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid var(--line-strong); border-radius: 99px; cursor: pointer; font-size: .88rem; user-select: none; }
.check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.check input { accent-color: var(--brand); margin: 0; }
.consent-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.consent-item:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.consent-item input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.consent-text { font-size: .95rem; background: var(--surface-2); padding: 14px 16px; border-radius: 12px; line-height: 1.6; }
.gps { display: grid; gap: 8px; }
.gps .readout { font-family: var(--mono); font-size: .86rem; color: var(--text-2); }
.gps .mini-map { height: 220px; border-radius: 10px; border: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 13px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
@media (max-width: 900px) { .form-actions { bottom: 62px; } }

/* Type picker */
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.type-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px; cursor: pointer; font: inherit; color: inherit; }
.type-card:hover { border-color: var(--brand); }
.type-card .em { font-size: 1.6rem; }
.type-card b { display: block; margin-top: 4px; }
.type-card span { font-size: .82rem; color: var(--text-2); }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .rm { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border: 0; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.photo select { position: absolute; left: 6px; right: 6px; bottom: 6px; min-height: 30px; padding: 3px 6px; font-size: .78rem; background: rgba(255,255,255,.92); color: #111; }
.photo .tag { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; padding: 2px 7px; border-radius: 99px; }
.add-photo { display: grid; place-content: center; text-align: center; border: 2px dashed var(--line-strong); border-radius: 10px; aspect-ratio: 1; cursor: pointer; color: var(--text-2); font-size: .85rem; }
.add-photo:hover { border-color: var(--brand); color: var(--brand); }
.add-photo b { font-size: 1.8rem; display: block; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: var(--surface-2); }

/* Lists & tables */
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; }
a.item:hover { border-color: var(--brand); }
.item .code { font-family: var(--mono); font-weight: 700; font-size: .92rem; }
.item .meta { font-size: .84rem; color: var(--text-2); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.empty .em { font-size: 2rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 6px 14px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

/* Timeline */
.timeline { display: grid; gap: 0; position: relative; }
.ev { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 10px 0; position: relative; }
.ev::before { content: ""; position: absolute; left: 19px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.ev:first-child::before { top: 24px; } .ev:last-child::before { bottom: calc(100% - 24px); }
.ev .bub { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--surface); position: relative; z-index: 1; font-size: 1.1rem; }
.ev .body { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }

/* Plot card */
.plot { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.plot + .plot { margin-top: 14px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }

/* Charts — single series: one hue, thin marks, recessive axes */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 48px; gap: 10px; align-items: center; font-size: .86rem; }
.bar-row .lbl { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; border-radius: 0 4px 4px 0; position: relative; }
.bar-fill { height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.bar-row:hover .bar-fill, .bar-row:focus-within .bar-fill { filter: brightness(1.12); }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.col { flex: 1; background: var(--chart-1); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; cursor: default; }
.col:hover, .col:focus { filter: brightness(1.15); outline: none; }
.col-axis { display: flex; justify-content: space-between; font-size: .74rem; color: var(--text-3); margin-top: 4px; }
.range { position: relative; height: 22px; }
.range .track { position: absolute; top: 10px; left: 0; right: 0; height: 2px; background: var(--line); }
.range .iqr { position: absolute; top: 7px; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--chart-1) 35%, transparent); }
.range .med { position: absolute; top: 3px; width: 4px; height: 16px; border-radius: 2px; background: var(--chart-1); transform: translateX(-2px); }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 10px; font-size: .82rem; }
.tip b { display: block; font-size: .95rem; }
.map { height: 380px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }

/* Labelling */
.labeller { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .labeller { grid-template-columns: 1fr; } }
.stage { background: #0e0f0d; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 340px; max-height: 72vh; }
.stage img { max-width: 100%; max-height: 72vh; object-fit: contain; display: block; }
.label-btns { display: grid; gap: 8px; }
.label-btn { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.label-btn:hover { border-color: var(--brand); }
.label-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.label-btn kbd { font-family: var(--mono); font-size: .75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--text-2); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-2); }

/* Dialogs & toasts */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(10, 12, 9, .45); }
.dlg-head { padding: 18px 20px 6px; } .dlg-body { padding: 6px 20px 12px; overflow: auto; } .dlg-foot { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
.viewer img { width: 100%; max-height: 75vh; object-fit: contain; background: #0e0f0d; display: block; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; max-width: 380px; animation: up .2s ease; }
.toast.bad { background: var(--bad); color: #fff; } .toast.good { background: var(--good); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 900px) { .toasts { bottom: 80px; left: 16px; right: 16px; } }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(160deg, #1f5f3f, #173f2b 70%); color: #eef7f0; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 2.3rem; max-width: 520px; }
.auth-side p { color: rgba(255,255,255,.82); max-width: 520px; font-size: 1.02rem; }
.pillars { display: grid; gap: 14px; margin-top: 28px; max-width: 540px; }
.pillar { display: flex; gap: 14px; }
.pillar .em { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.1); display: grid; place-items: center; flex: none; font-size: 1.2rem; }
.pillar b { display: block; color: #fff; }
.pillar span { color: rgba(255,255,255,.75); font-size: .92rem; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .card { width: min(420px, 100%); padding: 28px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-side { padding: 32px 22px; } .auth-side h1 { font-size: 1.7rem; } .pillars { display: none; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.filters .field label { font-size: .78rem; color: var(--text-2); }
.dict-field { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 220px 1fr; gap: 12px; }
@media (max-width: 640px) { .dict-field { grid-template-columns: 1fr; } }
.codes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.codes code { background: var(--surface-2); border-radius: 5px; padding: 1px 6px; font-size: .78rem; }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; }
.leaflet-container { font: inherit; background: var(--surface-2); }
.row > select { width: auto; min-width: 180px; max-width: 100%; }

/* ── Public landing page ─────────────────────────────────────────── */
.lp { background: var(--bg); min-height: 100vh; }
.lp-wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.lp-nav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px max(24px, calc((100vw - 1120px) / 2 + 24px)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.lp-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-display); font-size: 1.15rem; }
.lp-links { display: flex; align-items: center; gap: 22px; }
.lp-links a:not(.btn) { color: var(--text-2); text-decoration: none; font-weight: 550; font-size: .93rem; }
.lp-links a:not(.btn):hover { color: var(--brand); }
.lp-hero { background: radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), linear-gradient(160deg, #1f5f3f, #163d29 75%); color: #eef7f0; padding: 88px 0 72px; }
.lp-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 700; color: #b9e2c7; margin-bottom: 14px; }
.lp-hero h1 { color: #fff; font-size: clamp(2.1rem, 5vw, 3.4rem); max-width: 760px; margin-bottom: 18px; }
.lp-lead { font-size: 1.12rem; line-height: 1.65; color: rgba(255,255,255,.86); max-width: 720px; margin-bottom: 28px; }
.lp-hero .btn { background: #fff; color: #1f5f3f; border-color: #fff; }
.lp-hero .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.lp-stats { display: flex; flex-wrap: wrap; gap: 14px 40px; margin-top: 44px; }
.lp-stats:empty { display: none; }
.lp-stats div { display: flex; flex-direction: column; }
.lp-stats b { font-family: var(--font-display); font-size: 2rem; color: #fff; line-height: 1.1; }
.lp-stats span { font-size: .86rem; color: rgba(255,255,255,.75); }
.lp-section { padding: 72px 0; }
.lp-section.alt { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lp-section h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 28px; max-width: 680px; }
.lp-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.lp-step { display: flex; flex-direction: column; gap: 12px; }
.lp-num { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-family: var(--font-display); font-size: 1.1rem; }
.lp-step h3, .lp-card h3, .lp-principle h3 { margin-bottom: 6px; }
.lp-step p, .lp-card p, .lp-principle p { color: var(--text-2); margin: 0; }
.lp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lp-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 40px; }
.lp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.lp-card ul { margin: 12px 0 0; padding-left: 18px; color: var(--text-2); font-size: .92rem; }
.lp-em { font-size: 1.6rem; margin-bottom: 8px; }
.lp-principle { display: flex; gap: 16px; }
.lp-principle .lp-em { width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--brand-soft); display: grid; place-items: center; font-size: 1.3rem; margin: 0; }
.lp-cta { padding: 64px 0; text-align: center; background: var(--brand-soft); }
.lp-cta h2 { margin: 0 auto 10px; }
.lp-cta p { color: var(--text-2); max-width: 560px; margin: 0 auto 22px; }
.lp-foot { padding: 26px 0; border-top: 1px solid var(--line); font-size: .88rem; color: var(--text-3); }
.lp-foot a { color: var(--text-2); }
.lp-foot .row { gap: 18px; }
@media (max-width: 900px) {
  .lp-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-grid, .lp-grid.two { grid-template-columns: 1fr; }
  .lp-links a:not(.btn) { display: none; }
  .lp-hero { padding: 56px 0 48px; }
  .lp-section { padding: 52px 0; }
}
@media (max-width: 560px) { .lp-steps { grid-template-columns: 1fr; } .lp-wrap { padding: 0 16px; } .lp-nav { padding: 10px 16px; } }
