/* =====================================================================
   Farmreview - design system
   Mobile-first, minimal, high contrast for outdoor (sunlight) use.
   ===================================================================== */

:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e8e8e3;
  --border: #e2e2dc;
  --border-strong: #c9c9c1;
  --text: #15181b;
  --text-2: #50565c;
  --text-3: #80868b;
  --accent: #1f5f4a;
  --accent-strong: #174a39;
  --accent-soft: #e4eee9;
  --accent-ink: #ffffff;
  --good: #1d7148;      --good-soft: #e3f1e8;
  --warning: #9a5b00;   --warning-soft: #fbefd9;
  --critical: #b3261e;  --critical-soft: #f9e3e0;
  --info: #2459a8;      --info-soft: #e4ecf8;
  --muted-soft: #efefeb;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 27, .04), 0 4px 16px rgba(20, 24, 27, .06);
  --shadow-lg: 0 8px 40px rgba(20, 24, 27, .18);
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
h4 { font-size: .9375rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
small, .small { font-size: .8125rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.icon { width: 20px; height: 20px; flex: none; }
.icon-sm .icon, .icon.icon-sm { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { flex: 1; min-width: 0; padding: 0 8px; }
.topbar__title h1 { font-size: 1.0625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title .sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 650; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .8125rem; font-weight: 700; letter-spacing: .02em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--text);
  display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 0; cursor: pointer;
}
.sync-pill .icon { width: 16px; height: 16px; }
.sync-pill[data-state="offline"] { background: var(--warning-soft); color: var(--warning); }
.sync-pill[data-state="pending"] { background: var(--info-soft); color: var(--info); }
.sync-pill[data-state="error"] { background: var(--critical-soft); color: var(--critical); }
.sync-pill[data-state="online"] .label { display: none; }

.page {
  padding: 16px 16px calc(var(--bottomnav-h) + 32px + env(safe-area-inset-bottom));
  max-width: 1120px; margin: 0 auto;
}
.page > * + * { margin-top: 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .meta { color: var(--text-2); font-size: .875rem; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; font-size: .6875rem; font-weight: 600; color: var(--text-3); background: none; border: 0; cursor: pointer;
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav .icon { width: 22px; height: 22px; }
.bottomnav [aria-current="page"] { color: var(--accent); }

.sidebar { display: none; }

@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px;
  }
  .sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 650; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
  .sidebar nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px;
    color: var(--text-2); font-size: .9375rem; font-weight: 550;
  }
  .sidebar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .sidebar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
  .sidebar .nav-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 12px 6px; font-weight: 650; }
  .sidebar__user { border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; font-size: .875rem; }
  .shell { margin-left: var(--sidebar-w); }
  .bottomnav, .topbar .menu-btn { display: none; }
  .page { padding: 24px 32px 64px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: .75rem; font-weight: 700; flex: none; }

/* ---------- Bottom sheet (mobile "More" menu, dialogs) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 20, .38); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .18s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(102%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 4px auto 12px; }
.sheet.is-open { transform: none; }
.sheet.is-open + .sheet-backdrop, .sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet nav a { display: flex; align-items: center; gap: 14px; padding: 13px 12px; color: var(--text); border-radius: 10px; font-weight: 550; }
.sheet nav a:hover { background: var(--surface-2); text-decoration: none; }
.sheet nav a .icon { color: var(--text-2); }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: 50%; width: min(520px, 92vw); border-radius: 16px; transform: translate(-50%, 60%); opacity: 0; pointer-events: none; transition: transform .2s, opacity .2s; }
  .sheet::before { display: none; }
  .sheet.is-open { transform: translate(-50%, 50%); opacity: 1; pointer-events: auto; }
}

/* ---------- Cards & lists ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card__head h2, .card__head h3 { font-size: 1rem; }
.card__head .actions { display: flex; gap: 8px; align-items: center; }
.card__body { padding: 16px; }
.card__body > * + * { margin-top: 12px; }
.card__body.form-grid > *, .card__body.photos > * { margin-top: 0; }
.card__foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card--flush .card__body { padding: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.section-title h2 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); min-height: 56px; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item > .badge, .list-item > form { flex: none; }
.list-item__meta { font-size: .8125rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.list-item__aside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; font-size: .8125rem; color: var(--text-2); }
.list-item .chev { color: var(--text-3); width: 18px; height: 18px; }
.list-item__lead { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: none; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.kpi__label { font-size: .75rem; color: var(--text-2); font-weight: 550; }
.kpi__value { font-size: 1.5rem; font-weight: 650; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.kpi__value small { font-size: .8125rem; font-weight: 550; color: var(--text-2); letter-spacing: 0; }
.kpi__sub { font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.kpi--alert .kpi__value { color: var(--critical); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9375rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--critical); border-color: #e7b8b3; }
.btn--danger:hover { background: var(--critical-soft); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: .8125rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row--end { justify-content: flex-end; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid currentColor; border-color: var(--text-3) transparent var(--text-3) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn--primary.is-busy::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); z-index: 25;
  height: 52px; padding: 0 20px 0 16px; border-radius: 26px; border: 0; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 650; box-shadow: var(--shadow-lg);
}
.fab:hover { text-decoration: none; background: var(--accent-strong); }
@media (min-width: 1024px) { .fab { bottom: 24px; right: 32px; } }

/* sticky action bar at the bottom of long forms */
.form-actions {
  position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); z-index: 20;
  margin: 16px -16px 0; padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  background: rgba(245, 245, 242, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--border);
}
.form-actions .btn { flex: 1 1 auto; }
@media (min-width: 1024px) { .form-actions { bottom: 0; margin: 24px 0 0; border-radius: var(--radius); border: 1px solid var(--border); } .form-actions .btn { flex: 0 0 auto; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid .span-all { grid-column: 1 / -1; }
}
.form-grid--2c { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: .8125rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: .75rem; color: var(--text-3); }
.field-error { font-size: .8125rem; color: var(--critical); margin: 0; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; appearance: none; -webkit-appearance: none;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2350565c' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid, .is-invalid .input { border-color: var(--critical); }
.input--num { font-variant-numeric: tabular-nums; }
.input-unit { position: relative; }
.input-unit .input { padding-right: 56px; }
.input-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: .8125rem; color: var(--text-3); pointer-events: none; }
.input--sm { min-height: 38px; padding: 6px 10px; font-size: .9375rem; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: .9375rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.checks { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .checks--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.missing { color: var(--warning); font-size: .75rem; font-weight: 600; }

/* segmented status control (audit checklist) */
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 4px; border-radius: 8px;
  font-size: .75rem; font-weight: 650; color: var(--text-2); cursor: pointer; text-align: center; line-height: 1.15; user-select: none;
}
.seg input:focus-visible + label { outline: 2px solid var(--accent); }
.seg input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.seg input[value="satisfactory"]:checked + label { background: var(--good); color: #fff; }
.seg input[value="attention"]:checked + label { background: #c47a00; color: #fff; }
.seg input[value="critical"]:checked + label { background: var(--critical); color: #fff; }
.seg--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* chips (filters, objective pickers) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .875rem; font-weight: 600; cursor: pointer;
}
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip[aria-pressed="true"], .chip.is-active, .chip:has(input:checked) { background: var(--text); border-color: var(--text); color: #fff; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips--scroll::-webkit-scrollbar { display: none; }

/* stepper (+ / -) for fast counting */
.stepper { display: grid; grid-template-columns: 44px minmax(48px, 1fr) 44px; align-items: center; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { height: 44px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.25rem; cursor: pointer; display: grid; place-items: center; }
.stepper button:active { background: var(--surface-3); }
.stepper input { border: 0; text-align: center; font: inherit; font-weight: 650; font-size: 1.0625rem; height: 44px; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; background: transparent; }
.stepper input:focus { outline: none; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border);
  margin: 0 -16px; padding: 0 16px; position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 15; background: var(--bg);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  flex: none; padding: 12px 12px 10px; font: inherit; font-size: .875rem; font-weight: 600; color: var(--text-2);
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
@media (min-width: 1024px) { .tabs { margin: 0; padding: 0; } }
.tabpanel[hidden] { display: none; }

/* ---------- Badges, alerts, empty states ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .6875rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; background: var(--muted-soft); color: var(--text-2); }
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-critical { background: var(--critical-soft); color: var(--critical); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-accent { background: var(--accent-soft); color: var(--accent-strong); }
.tone-muted { background: var(--muted-soft); color: var(--text-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-3); }
.dot.tone-good { background: var(--good); } .dot.tone-warning { background: #c47a00; } .dot.tone-critical { background: var(--critical); }
.dot.tone-info { background: var(--info); }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: .875rem; background: var(--info-soft); color: #18406f; border: 1px solid #cfdcf1; }
.alert .icon { width: 18px; height: 18px; margin-top: 1px; }
.alert--warning { background: var(--warning-soft); color: #6a3f00; border-color: #f0dbb2; }
.alert--error { background: var(--critical-soft); color: #7d1a14; border-color: #efc4be; }
.alert--success { background: var(--good-soft); color: #145234; border-color: #c4e2cf; }
.alert--demo { background: #fff6cc; color: #5c4a00; border-color: #eedc8a; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.empty { text-align: center; padding: 32px 16px; color: var(--text-2); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--text-3); }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* flash toast */
.toast-stack { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + 8px + env(safe-area-inset-top)); z-index: 80; width: min(560px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 14px; border-radius: 10px; background: var(--text); color: #fff; font-size: .875rem; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease-out; }
.toast--error { background: var(--critical); }
.toast--warning { background: #7a4a00; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .8; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table tr.is-group td { background: var(--surface-2); font-weight: 650; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.table tr.is-muted td { color: var(--text-3); }
.table--compact th, .table--compact td { padding: 6px 10px; }
.table input.input, .table select.input { min-height: 38px; padding: 6px 8px; font-size: .9375rem; }
.table input.input--num { min-width: 78px; text-align: right; }
.table select.input { min-width: 92px; padding-right: 28px; background-position: right 6px center; }
.table input.input::placeholder { color: var(--text-3); font-style: italic; }
.diff-up { color: var(--good); }
.diff-down { color: var(--critical); }
.diff-neutral { color: var(--text-2); }
.na { color: var(--text-3); font-style: italic; font-size: .8125rem; }

/* ---------- Accordion ---------- */
details.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.acc + details.acc { margin-top: 10px; }
details.acc > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 12px; min-height: 56px; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .acc__title { flex: 1; font-weight: 650; }
details.acc > summary .acc__meta { font-size: .75rem; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
details.acc > summary .icon.toggle { transition: transform .15s; color: var(--text-3); }
details.acc[open] > summary .icon.toggle { transform: rotate(180deg); }
details.acc[open] > summary { border-bottom: 1px solid var(--border); }
.acc__body { padding: 4px 16px 16px; }

/* audit checklist item */
.audit-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: 0; }
.audit-item__label { font-weight: 600; font-size: .9375rem; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.audit-item__more { margin-top: 8px; }
.audit-item__more > summary { font-size: .8125rem; color: var(--accent); font-weight: 600; cursor: pointer; list-style: none; display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.audit-item__more > summary::-webkit-details-marker { display: none; }
.audit-item__more[open] > summary { margin-bottom: 8px; }
.audit-item.has-data .audit-item__more > summary::after { content: "•"; color: var(--accent); }

/* photo grid */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.photos figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: .6875rem; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.file-drop { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--text-2); font-size: .875rem; }
.file-drop:hover { border-color: var(--accent); color: var(--accent); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.file-preview span { font-size: .75rem; color: var(--text-2); background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: #ebebe6; stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .lbl { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .75rem; color: var(--text-2); margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: #fff; font-size: .75rem; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; display: none; }
.chart-empty { padding: 28px 12px; text-align: center; color: var(--text-3); font-size: .875rem; }
.chart-table summary { font-size: .75rem; color: var(--text-3); cursor: pointer; margin-top: 6px; }
.chart .chart-lg { display: none; }
@media (min-width: 720px) { .chart .chart-sm { display: none; } .chart .chart-lg { display: block; } }
@media print { .chart .chart-sm { display: none !important; } .chart .chart-lg { display: block !important; } }

/* ---------- Misc ---------- */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.row { display: flex; gap: 12px; align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2--wide-left { grid-template-columns: 2fr 1fr; } }
.dl { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 12px; margin: 0; font-size: .9375rem; }
.dl dt { color: var(--text-2); font-size: .8125rem; padding-top: 1px; }
.dl dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.text-block { font-size: .9375rem; }
.text-block ul { padding-left: 20px; margin: 0 0 .75rem; }
.mono { font-family: var(--mono); font-size: .8125rem; }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: .75rem; background: var(--surface-2); padding: 12px; border-radius: 8px; max-height: 360px; overflow: auto; }
.pill-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--critical); color: #fff; font-size: .6875rem; font-weight: 700; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.bar-inline { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.bar-inline span { display: block; height: 100%; }
.confidence { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; }
.hide-mobile { display: none; }
@media (min-width: 720px) { .hide-mobile { display: initial; } .hide-desktop { display: none !important; } }
.only-print { display: none; }
.demo-ribbon { background: #fff6cc; color: #5c4a00; text-align: center; font-size: .75rem; font-weight: 700; padding: 4px; letter-spacing: .04em; }

/* ---------- Guest (login / install) ---------- */
.guest { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.guest__card { width: min(420px, 100%); }
.guest__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; justify-content: center; }
.guest__brand .brand-mark { width: 40px; height: 40px; font-size: 1rem; border-radius: 10px; }
.guest__lang { display: flex; justify-content: center; margin-top: 20px; }

/* ---------- Language switch ---------- */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.lang-switch button {
  min-width: 44px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font: inherit; font-size: .8125rem; font-weight: 650; letter-spacing: .02em; cursor: pointer;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar__lang { padding: 12px 8px 0; }
.sheet__lang { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; color: var(--text-2); font-weight: 550; }

/* AI editor */
.ai-section { border-left: 3px solid var(--border); padding-left: 14px; }
.ai-section.is-generating { border-left-color: var(--accent); }
.ai-section.has-warnings { border-left-color: #c47a00; }
.untraced { background: var(--warning-soft); border-radius: 8px; padding: 8px 10px; font-size: .8125rem; color: #6a3f00; }

/* report block editor */
.block-item { display: flex; gap: 10px; align-items: flex-start; }
.block-item__tools { display: flex; flex-direction: column; gap: 2px; }
.block-item__tools .icon-btn { width: 32px; height: 32px; }

@media print {
  .topbar, .bottomnav, .sidebar, .fab, .form-actions, .no-print, .toast-stack { display: none !important; }
  .shell { margin: 0 !important; }
  .page { padding: 0 !important; }
  body { background: #fff; }
}
