:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --border: #e2e7dc;
  --text: #1c2a1f;
  --muted: #5f6f62;
  --brand: #2f7d3a;
  --brand-dark: #24612d;
  --brand-soft: #e6f2e4;
  --healthy: #3f9c4a;
  --watch: #e0a51f;
  --issue: #d5493a;
  --missing: #b8c0b3;
  --sidebar: #17301d;
  --sidebar-text: #c9dccb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 24, .06), 0 4px 14px rgba(20, 40, 24, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a12;
    --surface: #17241a;
    --border: #263829;
    --text: #e6efe6;
    --muted: #92a595;
    --brand: #4cb15a;
    --brand-dark: #3a9447;
    --brand-soft: #1d3322;
    --missing: #4a5a4c;
    --sidebar: #0a130c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1a12;
    --surface: #17241a;
    --border: #263829;
    --text: #e6efe6;
    --muted: #92a595;
    --brand: #4cb15a;
    --brand-dark: #3a9447;
    --brand-soft: #1d3322;
    --missing: #4a5a4c;
    --sidebar: #0a130c;
    --shadow: none;
  }


* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand-mark { display: grid; place-items: center; flex: none; width: 64px; height: 42px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; /* lifts the dark parts of the logo off the dark sidebar without a solid box */ filter: brightness(1.5) drop-shadow(0 0 3px rgba(255, 255, 255, .55)) drop-shadow(0 0 8px rgba(255, 255, 255, .25)); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 8px;
  color: inherit; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.active { background: var(--brand); color: #fff; }
.nav a svg { flex: none; opacity: .9; }
.nav .badge {
  margin-left: auto; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  padding: 2px 6px; border-radius: 99px; background: rgba(255, 255, 255, .1); color: #a9c3ac;
}
.nav a.active .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding: 12px 10px 0; display: grid; gap: 6px; font-size: 12px; }
.device { display: flex; align-items: center; gap: 8px; }
.device em { font-style: normal; opacity: .65; margin-left: auto; max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: #5fd06c; box-shadow: 0 0 0 3px rgba(95, 208, 108, .2); }
.dot.off { background: #7d8b7f; }

/* Top bar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title h1 { font-size: 20px; }
.topbar-title p { color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; }

.select select {
  appearance: none; font: inherit; color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235f6f62' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 32px 8px 12px; cursor: pointer;
}
.btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* Content */
.content { padding: 24px 28px 40px; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }

/* Client (read-only, no-login) view */
.client-shell { min-height: 100vh; background: var(--bg); }
.client-topbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px; background: var(--sidebar); color: var(--sidebar-text); }
.client-topbar .brand-mark img { height: 40px; width: auto; filter: brightness(1.5) drop-shadow(0 0 1px rgba(255,255,255,.5)) drop-shadow(0 0 6px rgba(255,255,255,.25)); }
.client-title { display: flex; flex-direction: column; }
.client-title .brand-name { font-weight: 700; font-size: 15px; }
.client-title .sub { color: var(--sidebar-text); opacity: .7; font-size: 12px; }
.client-content { max-width: 900px; margin: 0 auto; width: 100%; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-head h2 { font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .right { margin-left: auto; }
.card-body { padding: 14px 18px 18px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 16px 18px; display: grid; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.kpi .note { color: var(--muted); font-size: 12px; }
.kpi .note b { font-weight: 600; }
.up { color: var(--healthy); } .down { color: var(--issue); }
.kpi-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi-icon.warn { background: #fbecc8; color: #a4720a; }
.kpi-icon.bad { background: #fadcd8; color: #b03426; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kpi-icon.warn { background: #3a2e0d; color: #e6b53f; }
  :root:not([data-theme="light"]) .kpi-icon.bad { background: #3d1a16; color: #ec7a6c; }
}
:root[data-theme="dark"] .kpi-icon.warn { background: #3a2e0d; color: #e6b53f; }
  :root[data-theme="dark"] .kpi-icon.bad { background: #3d1a16; color: #ec7a6c; }


.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }

/* Map */
.map-tools { display: flex; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 12px; font-weight: 600; padding: 5px 11px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.map-wrap {
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  background: repeating-linear-gradient(45deg, #dfe8d5 0 10px, #d8e2cd 10px 20px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map-wrap { background: repeating-linear-gradient(45deg, #1a2a1d 0 10px, #182719 10px 20px); }
}
:root[data-theme="dark"] .map-wrap { background: repeating-linear-gradient(45deg, #1a2a1d 0 10px, #182719 10px 20px); }

.map-wrap svg { display: block; width: 100%; height: auto; }
.map-wrap circle { cursor: pointer; transition: r .12s; }
.map-wrap circle:hover { stroke: #fff; stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.list li:first-child { border-top: 0; padding-top: 4px; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: 12px; }
.sev { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
button.tag { border: none; cursor: pointer; font-family: inherit; }
button.tag:hover { text-decoration: underline; }
.tag.high { background: #fadcd8; color: #b03426; }
.tag.mid { background: #fbecc8; color: #8a5f06; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.high { background: #3d1a16; color: #ec7a6c; }
  :root:not([data-theme="light"]) .tag.mid { background: #3a2e0d; color: #e6b53f; }
}
:root[data-theme="dark"] .tag.high { background: #3d1a16; color: #ec7a6c; }
  :root[data-theme="dark"] .tag.mid { background: #3a2e0d; color: #e6b53f; }

.grow { flex: 1; min-width: 0; }

/* Workflow */
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.step { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: grid; gap: 6px; position: relative; background: var(--bg); }
.step .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--border); color: var(--muted); }
.step.done .num { background: var(--brand); color: #fff; }
.step.now { border-color: var(--brand); background: var(--brand-soft); }
.step.now .num { background: var(--brand); color: #fff; }
.step h3 { font-size: 14px; }
.step p { color: var(--muted); font-size: 12px; }

/* Placeholder screens */
.placeholder { padding: 40px 28px; display: grid; gap: 14px; justify-items: start; max-width: 720px; }
.placeholder ul { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 6px; }

/* Tooltip */
.tooltip {
  position: fixed; pointer-events: none; z-index: 50; opacity: 0; transition: opacity .1s;
  background: #16251a; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: 220px;
}
.tooltip.show { opacity: 1; }
.tooltip b { display: block; font-size: 13px; }

/* Responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar-actions { width: 100%; margin-left: 0; }
  .topbar-actions .btn { margin-left: auto; }
  .content { padding: 16px; }
}
@media (max-width: 480px) {
  .kpis, .flow { grid-template-columns: 1fr; }
}

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-row label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form-row select, .form-row input {
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}

/* Dropzone */
.dropzone {
  display: grid; justify-items: center; gap: 4px; text-align: center; padding: 30px 16px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 10px; color: var(--muted); background: var(--bg);
}
.dropzone strong { color: var(--text); margin-top: 6px; }
.dropzone:hover, .dropzone.over, .dropzone:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.dropzone svg { color: var(--brand); }
.file-head { display: flex; align-items: center; gap: 6px; margin: 14px 0 10px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.thumbs img, .thumbs .more { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.thumbs .more { display: grid; place-items: center; background: var(--bg); color: var(--muted); font-weight: 600; }

/* Pipeline */
.pipeline { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pipeline li { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pipeline .num { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--border); font-size: 11px; }
.pipeline li.now { color: var(--text); } .pipeline li.now .num { background: var(--watch); color: #fff; }
.pipeline li.done { color: var(--text); } .pipeline li.done .num { background: var(--brand); color: #fff; }
.progress { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .8s ease; }
.process-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.process-foot .sub { color: var(--muted); }
.process-foot .btn { margin-left: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Checklist */
.checklist li { padding: 10px 0; }
.check { display: flex; gap: 10px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.check .title, .check .meta { display: block; }

/* Table */
.table-wrap { overflow-x: auto; padding-top: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.num-col { text-align: right; }

@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } .pipeline { grid-template-columns: 1fr 1fr; } }

/* Tree count */
.map-opts { display: flex; gap: 18px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.map-opts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.map-opts input { accent-color: var(--brand); }
.count-map { max-height: 560px; overflow: auto; }
.count-map svg { display: block; max-width: none; }
.count-map .ticks text { font-size: 9px; fill: rgba(255, 255, 255, .8); }
.count-map .idlabel { font-size: 7px; fill: #fff; font-weight: 600; }
.count-map circle.sel { stroke: #fff; stroke-width: 3; }
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-weight: 500; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* AI health scan */
.scan-preview { position: relative; margin-top: 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 16 / 10; background: #000; }
.scan-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pin { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--issue); color: #fff; }
.pin.on-img { position: absolute; transform: translate(-50%, -50%); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.scan-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.scan-photos .thumb { position: relative; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.scan-photos .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-photos .thumb button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; display: grid; place-items: center; padding: 0; }
.empty-state { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { color: var(--brand); }
.empty-state strong { color: var(--text); }
.score-row { display: flex; align-items: center; gap: 16px; }
.finding .f-head { display: flex; align-items: center; gap: 12px; }
.finding .title { font-weight: 600; }
.finding .meta { color: var(--muted); font-size: 12px; }
.bar { height: 5px; border-radius: 99px; background: var(--border); margin: 12px 0; overflow: hidden; }
.bar div { height: 100%; background: var(--brand); border-radius: 99px; }
.seen { font-size: 13px; margin-bottom: 10px; }
.todo { font-size: 13px; margin-bottom: 12px; }
.todo ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; color: var(--muted); }
.warn { font-size: 12px; margin-bottom: 12px; padding: 8px 10px; border-radius: 8px; background: #fbecc8; color: #7a5305; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn { background: #3a2e0d; color: #e6b53f; } }
:root[data-theme="dark"] .warn { background: #3a2e0d; color: #e6b53f; }

.disclaimer { font-size: 12px; color: var(--muted); padding: 0 4px; }
textarea, .form-row input::placeholder { font: inherit; }

/* Microscope lab */
.cam-row { display: flex; gap: 10px; margin-bottom: 12px; }
.cam-row select { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.cam-stage { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #0b120d; border: 1px solid var(--border); }
.cam-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; padding: 20px; color: #93a696; }
.cam-empty[hidden], .cam-stage video[hidden] { display: none; }
.cam-empty svg { color: #4cb15a; }
.cam-empty strong { color: #e6efe6; }
.cam-msg { min-height: 20px; margin: 10px 0 6px; font-size: 12px; color: var(--muted); }
.scan-reticle { position: absolute; inset: 15% 30%; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 2000px rgba(0, 0, 0, .35); pointer-events: none; }
.scan-reticle.found { border-color: var(--healthy); }
.soil-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.soil-fields[hidden] { display: none; }
.soil-fields label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.soil-fields input, .soil-fields select { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; width: 100%; }
.samples { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.sample { position: relative; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg); }
.sample.on { border-color: var(--brand); }
.sample:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sample img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.sample .stype { position: absolute; left: 6px; top: 6px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 99px; background: rgba(0, 0, 0, .65); color: #fff; }
.sample .del { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; line-height: 1; }
.sample .smeta { display: block; padding: 5px 8px; font-size: 11px; color: var(--muted); }
.thumb-lg { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; }
@media (max-width: 480px) { .soil-fields { grid-template-columns: 1fr 1fr; } }

/* Treatments */
.board-tools { display: flex; align-items: center; gap: 12px; }
.board-tools .btn { margin-left: auto; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 4px; }
.col-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.col-head .count { margin-left: auto; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--border); color: var(--muted); }
.col-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 0; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.t-top { display: flex; align-items: center; gap: 8px; }
.t-top .src { margin-left: auto; font-size: 11px; color: var(--muted); }
.task h3 { font-size: 14px; line-height: 1.3; }
.t-target { font-size: 12px; color: var(--muted); }
.t-date { font-size: 12px; }
.t-date.late { color: var(--issue); font-weight: 600; }
.t-notes { font-size: 12px; color: var(--muted); font-style: italic; }
.task details { font-size: 12px; }
.task summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.task details ol { margin: 6px 0 0; padding-left: 18px; color: var(--muted); display: grid; gap: 3px; }
.task .btn-row { margin-top: 4px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); margin-left: auto; }
.btn.ghost:hover { color: var(--issue); }

dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(8, 20, 10, .55); }
dialog form { display: grid; gap: 14px; padding: 22px; }
dialog h2 { font-size: 17px; }
dialog label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
dialog input:not([type="radio"]), dialog select, dialog textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
dialog fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; margin: 0; }
dialog legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
dialog label.radio { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
dialog label.radio input { accent-color: var(--brand); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s; z-index: 60; background: #16251a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.nav .badge.num { background: var(--issue); color: #fff; font-size: 11px; }
.nav a.active .badge.num { background: #fff; color: var(--brand-dark); }

@media (max-width: 1250px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .board { grid-template-columns: 1fr; } }

/* Reports & charts */
.vz {
  --v-line: var(--brand);
  --v-good: #0ca30c; --v-neutral: #7d8a80; --v-bad: #d03b3b;
  --v-grid: #e6eae1; --v-axis: #c9cfc4; --v-tick: #6f7d72;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .vz { --v-grid: #263829; --v-axis: #3a4d3d; --v-tick: #8ea092; } }
:root[data-theme="dark"] .vz { --v-grid: #263829; --v-axis: #3a4d3d; --v-tick: #8ea092; }

.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-2.even { grid-template-columns: 1fr; } }
.vz-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.vz-grid { stroke: var(--v-grid); stroke-width: 1; }
.vz-axis { stroke: var(--v-axis); stroke-width: 1; }
.vz-tick { fill: var(--v-tick); font-size: 11px; }
.vz-label { fill: var(--text); font-size: 12px; }
.vz-val, .vz-end { fill: var(--text); font-size: 12px; font-weight: 600; }
.vz-line { fill: none; stroke: var(--v-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.vz-dot, .vz-hdot { fill: var(--v-line); stroke: var(--surface); stroke-width: 2; }
.vz-cross { stroke: var(--v-axis); stroke-width: 1; }
.vz-band, .vz-hit { fill: transparent; }
.vz-band:focus { outline: none; fill: var(--brand-soft); }
.vz-bar { fill: var(--v-line); }
.vz-seg { }
.vz-seglabel { fill: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.vz-row { outline: none; cursor: default; }
.vz-row:hover .vz-bar, .vz-row:focus .vz-bar, .vz-row:hover .vz-seg, .vz-row:focus .vz-seg { filter: brightness(1.15); }
.vz-row:focus .vz-hit { fill: var(--brand-soft); }
.vz-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.vz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.vz-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.vz-legend[hidden], .vz-chart[hidden], .vz-table[hidden] { display: none; }
.ctip { position: fixed; z-index: 70; pointer-events: none; opacity: 0; transition: opacity .1s; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); min-width: 130px; }
.ctip.show { opacity: 1; }
.ct-title { color: var(--muted); margin-bottom: 4px; }
.ct-row { display: flex; align-items: center; gap: 8px; }
.ct-row .k { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.ct-row strong { font-size: 13px; }
.ct-row span { color: var(--muted); }
.tree-pick { display: inline-grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.tree-pick input { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 200px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 64px 140px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); align-items: baseline; }
.timeline li:first-child { border-top: 0; }
.tl-date { color: var(--muted); font-size: 12px; }
.tl-kind { font-weight: 600; font-size: 12px; }
@media (max-width: 620px) { .timeline li { grid-template-columns: 56px 1fr; } .timeline li span:nth-child(3) { grid-column: 2; } }

@media print {
  .sidebar, .topbar, .no-print, .toast, .ctip { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .vz-table[hidden] { display: block !important; }
  .grid-2.even { grid-template-columns: 1fr; }
}

/* Printing a tree's QR label: hide everything else on the page, show just the label, centred. */
.print-label { display: none; }
@media print {
  body:has(.print-label) .content > *:not(.print-label) { display: none !important; }
  .print-label { display: flex !important; flex-direction: column; align-items: center; gap: 10px; margin-top: 15vh; }
  .print-code { font-size: 22px; font-weight: 700; letter-spacing: 2px; color: #000; }
}

/* Plots & map */
.plot-map svg { display: block; width: 100%; height: auto; }
.plot-map .road { fill: none; stroke: rgba(120, 130, 110, .35); stroke-width: 10; stroke-linecap: round; }
.plot-shape { fill: rgba(63, 156, 74, .16); stroke: var(--brand); stroke-width: 1.5; }
.plot-shape.has-photo { fill: transparent; stroke-width: 2.5; }
.plot { cursor: pointer; outline: none; }
.plot:hover .plot-shape, .plot:focus-visible .plot-shape { fill: rgba(63, 156, 74, .28); }
.plot.sel .plot-shape { stroke-width: 3.5; fill: rgba(63, 156, 74, .26); }
.plot-tag rect { fill: var(--surface); stroke: var(--border); }
.plot-tag text { fill: var(--text); font-size: 11px; font-weight: 600; }
.plot.sel .plot-tag rect { fill: var(--brand); stroke: var(--brand); }
.plot.sel .plot-tag text { fill: #fff; }
.plot-map .north path { fill: var(--muted); } .plot-map .north text { fill: var(--muted); font-size: 11px; font-weight: 700; }
.plot-map svg.drawing { cursor: crosshair; }
.draw-fill { fill: rgba(255, 209, 102, .28); stroke: none; }
.draw-line { fill: none; stroke: #ffd166; stroke-width: 2; stroke-dasharray: 4 3; }
.draw-pt { fill: #ffd166; stroke: #7a5a00; stroke-width: 1.5; }
.pick { cursor: pointer; }
.pick:hover td, .pick:focus-visible td { background: var(--brand-soft); }
.pick.on td { background: var(--brand-soft); font-weight: 600; }
.pick:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.meta { color: var(--muted); font-size: 12px; font-weight: 400; }
.rec-tools { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rec-tools input { flex: 1; min-width: 200px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.pager { display: flex; align-items: center; margin-top: 12px; }
.pager .btn-row { margin-left: auto; }
#plotForm { margin-top: 4px; }
#plotForm label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
#plotForm input { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }


/* Settings */
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-farm { font-size: 11px; font-weight: 500; color: var(--sidebar-text); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.brand-farm[hidden] { display: none; }
.set-form { display: grid; gap: 16px; }
.set-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.set-form input:not([type="range"]), .set-form select { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
.set-form input[type="range"] { accent-color: var(--brand); width: 100%; }
.set-form output { color: var(--text); font-weight: 700; }
.set-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.set-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.hint { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 6px; }
.cam-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.cam-list:empty { display: none; }
.rule { border: 0; border-top: 1px solid var(--border); width: 100%; margin: 0; }
.btn.danger { color: var(--issue); border-color: var(--issue); }
.btn.danger:hover { background: rgba(213, 73, 58, .1); }
.planned { list-style: none; margin: 0; padding: 0; display: grid; }
.planned li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--border); }
.planned li:first-child { border-top: 0; padding-top: 0; }
.planned span { color: var(--muted); font-size: 12px; }
@media (max-width: 480px) { .set-form .two { grid-template-columns: 1fr; } }

/* Real tree counting */
.banner { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--brand-soft); border-color: transparent; }
.banner > div { flex: 1; }
.tips { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.prev { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #000; margin-top: 4px; }
.real-map svg { cursor: crosshair; }
.real-map .pt { fill: #fff; stroke: var(--brand-dark); stroke-width: 1.5; pointer-events: none; }
.real-map .pt.man { fill: #ffd166; }
.real-map .crown-o { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 1; pointer-events: none; }
.real-map .hit { fill: transparent; cursor: pointer; }
.real-map .hit:hover { fill: rgba(255, 92, 92, .3); stroke: #ff5c5c; stroke-width: 1.5; }
.hist li { cursor: pointer; align-items: center; }
.hist li.on { background: var(--brand-soft); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.hist li:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.set-form label.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
.set-form label.chk input { width: auto; accent-color: var(--brand); }

/* AI status */
.banner code { background: rgba(0, 0, 0, .15); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.banner.off { background: #fbecc8; color: #5c4004; }
.banner.off code { background: rgba(0, 0, 0, .1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner.off { background: #3a2e0d; color: #f0d58a; } }
:root[data-theme="dark"] .banner.off { background: #3a2e0d; color: #f0d58a; }
.ai-status { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: #fbecc8; color: #5c4004; }
.ai-status.on { background: var(--brand-soft); color: var(--text); }
.ai-status code { background: rgba(0, 0, 0, .12); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-status:not(.on) { background: #3a2e0d; color: #f0d58a; } }
:root[data-theme="dark"] .ai-status:not(.on) { background: #3a2e0d; color: #f0d58a; }

/* Offline status bar (below the top bar, visible on every screen) */
.offline-bar { display: flex; align-items: center; gap: 10px; padding: 8px 24px; font-size: 13px; font-weight: 600; background: #fbecc8; color: #5c4004; }
.offline-bar.syncing { background: var(--brand-soft); color: var(--text); }
.offline-bar button { margin-left: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .offline-bar { background: #3a2e0d; color: #f0d58a; } }
:root[data-theme="dark"] .offline-bar { background: #3a2e0d; color: #f0d58a; }

/* keep toolbar buttons on one line and let the toolbar wrap instead */
.board-tools { flex-wrap: wrap; }
.seg button { white-space: nowrap; }

/* Dashboard: latest count */
.dash-map { cursor: pointer; }
.dash-map svg { display: block; width: 100%; height: auto; cursor: pointer; }
.dash-map:hover { outline: 2px solid var(--brand); }
.list li[data-review]:hover .title { color: var(--brand); }


/* Farm bar */
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.farm-pick { display: inline-flex; align-items: center; gap: 8px; }
.farm-lab { font-size: 12px; font-weight: 600; color: var(--muted); }
#farmSelect { max-width: 200px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.plot-empty { fill: var(--muted); font-size: 13px; }

/* Sign-in screen */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand img { filter: brightness(1.1); }
.auth-brand h1 { font-size: 17px; font-weight: 700; }
.auth-card h2 { font-size: 19px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 18px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.auth-form input { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; }
.auth-form button { margin-top: 4px; justify-content: center; }
