:root {
  /* Zonneblom CI manual colours. Change them here only. Orange is the dominant colour. */
  --color-primary: #ED7E32;
  --color-accent: #FBBA05;
  --color-light-yellow: #F5E717;
  --color-red: #E93E3A;
  /* the CI gradient (graphic device): light yellow through yellow and orange to red */
  --gradient: linear-gradient(90deg, #FFF33B 0%, var(--color-accent) 30%, var(--color-primary) 68%, var(--color-red) 100%);
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --color-text: #000000;
  --color-bg: #ffffff;
  /* Greys are black at lower strength; tints are the logo colours mixed with white */
  --color-text-2: rgb(0 0 0 / 60%);
  --color-border: rgb(0 0 0 / 15%);
  --color-border-strong: rgb(0 0 0 / 28%);
  --color-surface: rgb(0 0 0 / 3%);
  --color-surface-2: rgb(0 0 0 / 6%);
  --color-hover: color-mix(in srgb, var(--color-accent) 20%, transparent);
  --color-selected: color-mix(in srgb, var(--color-accent) 38%, transparent);
  --color-accent-soft: color-mix(in srgb, var(--color-accent) 30%, var(--color-bg));
  --color-primary-soft: color-mix(in srgb, var(--color-primary) 14%, var(--color-bg));
  /* older names used across the stylesheet */
  --bg: var(--color-bg); --surface: var(--color-bg); --ink: var(--color-text); --muted: var(--color-text-2); --line: var(--color-border);
  --brand: var(--color-primary); --brand-yellow: var(--color-accent); --brand-soft: var(--color-primary-soft); --link: var(--color-primary);
  --danger: var(--color-text); --ok: var(--color-text); --radius: 8px;
  font-family: var(--font);
}
/* end of palette */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--link); }
code { font-size: .85em; background: var(--color-surface-2); padding: .1em .35em; border-radius: 4px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.5rem; background: var(--color-bg); color: var(--ink); flex-wrap: wrap; border-bottom: 4px solid var(--brand); border-image: linear-gradient(90deg, var(--brand-yellow), var(--brand)) 1; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.brand small { font-weight: 400; color: var(--muted); margin-left: .2rem; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--ink); font-weight: 700; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-label { font-weight: 500; color: var(--muted); padding-left: .7rem; border-left: 1px solid var(--line); }
.login-logo { display: block; max-width: 220px; max-height: 80px; margin: 0 auto 1rem; }
.topnav { display: flex; align-items: center; gap: 1.2rem; }
.topnav a, .linklike { color: var(--ink); text-decoration: none; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.topnav a:hover, .linklike:hover { color: var(--link); text-decoration: underline; }
.inline { display: inline; }

/* Style guide rule 4: every staff page fills the window. The top bar stays; the content area
   below it scrolls on its own, so the page itself never scrolls. */
.container { padding: 12px 16px 24px; }
body.site-ops, body.site-prj { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.site-ops .container, .site-prj .container { flex: 1; min-height: 0; width: 100%; overflow: auto; }
.site-ops .footer, .site-prj .footer { display: none; }
/* Projects site: use the whole window width (the top bar already spans it) */
h1 { font-size: 1.6rem; margin: .2rem 0 .4rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
.mt0 { margin-top: 0; }
.h-icon { margin-right: .2rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0 0 .25rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.tile { display: flex; flex-direction: column; gap: .35rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 6px 18px rgb(0 0 0 / 6%); }
.tile-icon { font-size: 1.8rem; }
.tile-name { font-weight: 600; font-size: 1.05rem; }
.tile-desc { color: var(--muted); font-size: .9rem; }
.tile-admin { background: var(--color-accent-soft); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.empty { text-align: center; padding: 3rem 1.5rem; margin-top: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .9rem; }
.kv { margin-right: 1rem; white-space: nowrap; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0 1.5rem; }
.tabs a { padding: .55rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--color-surface); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.center { text-align: center; }
.row-off td { opacity: .55; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; background: var(--color-surface-2); color: var(--muted); }
.badge-admin { background: var(--color-accent-soft); color: var(--color-primary); }
.badge-off { background: var(--color-primary-soft); color: var(--danger); }
.tick { color: var(--ok); font-weight: 700; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar p { margin: 0; }
form.stack { display: grid; gap: 1rem; max-width: 560px; }
.align-start { align-self: start; }
label { display: grid; gap: .3rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], select { font: inherit; padding: .55rem .7rem; border: 1px solid var(--color-border-strong); border-radius: 8px; background: var(--color-bg); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; display: grid; gap: .4rem; }
legend { font-weight: 600; padding: 0 .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--color-bg); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand); border-color: var(--brand); color: var(--ink); }
.btn-secondary { background: var(--color-bg); color: var(--ink); }
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: 12px; border-left: 4px solid var(--color-accent); }
.flash-error { border-left-color: var(--color-primary); }
.flash-success { background: var(--color-accent-soft); color: var(--color-text); }
.flash-error { background: var(--color-primary-soft); color: var(--color-text); }
.errors { background: var(--color-primary-soft); color: var(--color-text); padding: .75rem 1rem .75rem 2rem; border-radius: 8px; margin: 0 0 1rem; }

.login-wrap { min-height: 65vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; }
.login-card form.stack { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Pre-planning ---------- */
.pl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.pl-desc { margin: 0; }
.pl-tabs { display: flex; gap: .15rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 1rem 0 1.25rem; scrollbar-width: thin; }
.pl-tabs a { padding: .5rem .8rem; white-space: nowrap; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .92rem; }
.pl-tabs a:hover { color: var(--ink); }
.pl-tabs a.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.stack-col { display: grid; gap: 1.5rem; align-content: start; }
.btn-danger { background: var(--color-bg); border-color: var(--color-text); color: var(--color-text); }
.btn-danger:hover { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-text); }
.danger-zone { border-color: var(--color-primary); }
table.nums td.n, table.nums th:not(:first-child) { text-align: right; }

/* formula bar + grid */
.fbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; padding: .5rem .75rem; min-height: 52px; }
.fbar-addr { font: 600 .9rem ui-monospace, Consolas, monospace; min-width: 4.5rem; padding: .3rem .5rem; background: var(--color-surface-2); border-radius: 6px; text-align: center; }
.fbar-body { flex: 1; display: flex; align-items: center; gap: .75rem; min-width: 0; flex-wrap: wrap; }
.fbar-formula { white-space: pre-wrap; font-size: .82rem; max-height: 8.5rem; overflow: auto; flex: 1 1 420px; background: var(--color-surface); padding: .35rem .5rem; border-radius: 6px; }
.fbar-value { font-weight: 600; white-space: nowrap; }
.fbar-input { flex: 0 1 360px; font: inherit; padding: .4rem .6rem; border: 1px solid var(--color-border-strong); border-radius: 8px; }
.fbar-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.fbar-status { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.fbar-status.ok { color: var(--ok); }
.fbar-status.err { color: var(--danger); white-space: normal; }
.grid-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--line); border-top: 0; background: var(--color-bg); margin-bottom: .75rem; }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; border: 0; font-size: .82rem; background: var(--color-bg); }
table.sheet col.rn { width: 46px; }
table.sheet th { position: sticky; top: 0; z-index: 2; background: var(--color-surface-2); color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .75rem; text-align: center; padding: .2rem; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
table.sheet tbody th { position: sticky; left: 0; z-index: 1; top: auto; }
table.sheet thead th.corner { left: 0; z-index: 3; }
table.sheet td { padding: .2rem .4rem; border-right: 1px solid var(--color-surface-2); border-bottom: 1px solid var(--color-surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 1.6rem; cursor: cell; vertical-align: middle; }
table.sheet td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td.f { background: var(--color-surface); color: var(--color-text); }
table.sheet td.i { background: var(--color-bg); color: var(--color-text); font-weight: 500; }
table.sheet td.t { background: var(--color-bg); color: var(--ink); }
table.sheet td.h { background: var(--color-accent-soft); font-weight: 600; color: var(--ink); }
table.sheet td.b { font-weight: 700; }
table.sheet td.dd::after { content: ' ▾'; color: var(--muted); font-size: .7rem; }
table.sheet td.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
table.sheet td.chg { animation: chg 1.6s ease-out; }
@keyframes chg { from { background: var(--color-accent-soft); } to { } }

/* charts (palette: reference categorical slots 1-3) */
.viz-root { --series-1: var(--color-primary); --series-2: var(--color-accent); --series-3: var(--color-text); --grid: var(--color-border); --tick: var(--color-text-2); }
.chart-card { margin-top: 1.25rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.zero { stroke: var(--color-border-strong); }
.chart .tick { fill: var(--tick); font-size: 11px; }
.chart .mark.series-1, .chart .dot.series-1 { fill: var(--series-1); }
.chart .mark.series-2 { fill: var(--series-2); }
.chart .mark.series-3 { fill: var(--series-3); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .line.series-1 { stroke: var(--series-1); }
.chart .dot { opacity: 0; stroke: var(--color-bg); stroke-width: 2; }
.chart .hitbox { fill: transparent; }
.chart g.hit.on .hitbox, .chart g.hit:focus .hitbox { fill: rgb(0 0 0 / 4%); }
.chart g.hit.on .dot, .chart g.hit:focus .dot { opacity: 1; }
.chart g.hit:focus { outline: none; }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.legend .key, .tip-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: .4rem; vertical-align: middle; }
.key.series-1, .tip-key.series-1 { background: var(--color-primary); }
.key.series-2, .tip-key.series-2 { background: var(--color-accent); }
.key.series-3, .tip-key.series-3 { background: var(--color-text); }
.chart-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--color-bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / 12%); padding: .5rem .7rem; font-size: .82rem; min-width: 180px; }
.tip-title { font-weight: 600; margin-bottom: .25rem; color: var(--muted); }
.tip-row { display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--muted); }

/* full-screen sheet workspace */
.pl-work-bar { display: flex; align-items: flex-end; gap: .75rem; }
.pl-work-bar .pl-tabs { flex: 1; min-width: 0; margin: 1rem 0 .75rem; }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }
.fs-btn { margin-bottom: .75rem; white-space: nowrap; flex: none; }
.fs-icon { font-size: 1rem; line-height: 1; }
#pl-sheet.loading { opacity: .5; pointer-events: none; transition: opacity .15s; }
.pl-work.is-full { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; padding: .5rem 1rem 1rem; }
.pl-work.is-full .pl-tabs { margin: .25rem 0 .5rem; }
.pl-work.is-full .fs-btn { margin-bottom: .5rem; }
.pl-work.is-full #pl-sheet { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pl-work.is-full .grid-wrap { flex: 1; max-height: none; margin-bottom: 0; }
.pl-work:fullscreen { background: var(--bg); }
body.pl-fullscreen { overflow: hidden; }

/* sheet tabs: horizontal scrolling only (no vertical scrollbar) */
.pl-tabs { overflow-y: hidden; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
.pl-tabs a { margin-bottom: 0; }

/* Top bar: project name after the site label */
.brand-wrap { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-project { font-weight: 600; color: var(--ink); text-decoration: none; padding-left: .7rem; border-left: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.brand-project:hover { color: var(--link); }
.brand-rename { color: var(--muted); text-decoration: none; font-size: .9rem; margin-left: -.35rem; }
.brand-rename:hover { color: var(--link); }

/* Project section tabs: one row under the top bar */
.pl-sections { display: flex; align-items: center; gap: .15rem; border-bottom: 1px solid var(--line); margin: -12px -16px 12px; padding: 0 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.pl-sections a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; text-decoration: none; color: var(--muted);
  white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.pl-sections a:hover { color: var(--ink); }
.pl-sections a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
.pl-sections a.pl-sections-end { margin-left: auto; border-bottom: 1px solid var(--ink); margin-bottom: .3rem; color: var(--ink); }
.pl-main { min-width: 0; }
.pl-main > .pl-tabs:first-child { margin-top: 0; }

/* Pre-planning, Layout section: map + layer panel */
.lay [hidden] { display: none !important; }
.lay-live { position: absolute; left: 50%; top: .75rem; transform: translateX(-50%); z-index: 500; background: rgb(0 0 0 / 85%); color: var(--color-bg);
  padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
.lay-status.is-error { background: var(--color-primary-soft); color: var(--danger); border-color: var(--color-primary); }
.lay-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.lay-card-head h2 { margin-bottom: 0; }
.stack-tight { display: grid; gap: .6rem; }
.lay textarea { font: inherit; padding: .5rem .7rem; border: 1px solid var(--color-border-strong); border-radius: 8px; width: 100%; resize: vertical; }
.lay-obj-measure { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.lay-btns { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lay-grow { flex: 1 1 100%; }
.lay-layer-form { display: flex; gap: .4rem; align-items: center; margin-bottom: .6rem; }
.lay-layer-form input[type=text] { padding: .35rem .55rem; min-width: 0; }
.lay-layer-form input[type=color] { width: 2.2rem; height: 2rem; padding: 0; border: 1px solid var(--color-border-strong); border-radius: 6px; background: var(--color-bg); flex: none; cursor: pointer; }
.lay-icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: .1rem .35rem; border-radius: 6px; }
.lay-icon-btn:hover, .lay-icon-btn[aria-expanded=true] { background: color-mix(in srgb, var(--color-primary) 14%, transparent); color: var(--ink); }
.lay-options { margin: .5rem 0 .25rem 1.4rem; padding: .6rem; background: var(--bg); border-radius: 8px; }
.lay-layer-head .lay-toggle { flex: none; }
.lay-name-grow { flex: 1; min-width: 0; font-weight: 600; }
.lay-feature.is-selected { background: color-mix(in srgb, var(--color-primary) 18%, transparent); font-weight: 600; }
.lay-card { padding: 1rem; }
.lay-card h2 { font-size: 1.05rem; }
.lay-layers, .lay-features { list-style: none; margin: 0; padding: 0; }
.lay-layer + .lay-layer { border-top: 1px solid var(--line); margin-top: .5rem; padding-top: .5rem; }
.lay-layer-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.lay-toggle { display: flex; align-items: center; gap: .5rem; font-weight: 600; cursor: pointer; min-width: 0; margin: 0; }
.lay-toggle input { margin: 0; width: auto; }
.lay-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgb(0 0 0 / 25%); }
.lay-features { margin: .25rem 0 0 1.4rem; }
.lay-feature { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .45rem; width: 100%; text-align: left;
  background: none; border: 0; padding: .3rem .4rem; border-radius: 6px; cursor: pointer; font: inherit; color: var(--ink); }
.lay-feature:hover { background: color-mix(in srgb, var(--color-primary) 10%, transparent); }
.lay-fname { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-measure { grid-column: 2; }
.lay-kind { width: 10px; height: 10px; margin-top: .4rem; border: 2px solid var(--muted); }
.lay-kind-point { border-radius: 50%; }
.lay-kind-line { height: 0; border-width: 2px 0 0; margin-top: .65rem; width: 12px; }
.lay-kind-area { border-radius: 2px; }
.lay-pop strong { display: block; font-size: .95rem; }
.lay-pop-meta { color: var(--muted); font-size: .8rem; margin-bottom: .35rem; }
.lay-pop dl { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; margin: 0; font-size: .85rem; }
.lay-pop dt { color: var(--muted); }
.lay-pop dd { margin: 0; font-variant-numeric: tabular-nums; }
.lay-pop p { margin: .4rem 0 0; font-size: .85rem; }

/* Pre-planning: object catalogue */
.cat-card { margin-bottom: 1.25rem; }
.cat-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cat-head h2 { margin-bottom: 0; display: flex; align-items: center; gap: .5rem; }
.cat-head .lay-swatch { width: 14px; height: 14px; }
.cat-actions { display: flex; align-items: center; gap: .75rem; }
.cat-edit summary { cursor: pointer; color: var(--muted); }
.cat-edit[open] { flex-basis: 100%; }
.cat-edit form { margin: .5rem 0 0; }
.cat-norate { display: inline-block; font-size: .75rem; padding: 0 .4rem; border-radius: 4px; background: var(--color-accent-soft); color: var(--color-primary); }
.cat-editor { display: grid; gap: 1.25rem; }
.cat-grid { display: grid; grid-template-columns: 2fr 1.3fr 1.3fr 1fr; gap: 1rem; }
.cat-color { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.cat-color input[type=color] { width: 2.6rem; height: 2.3rem; padding: 0; border: 1px solid var(--color-border-strong); border-radius: 6px; background: var(--color-bg); cursor: pointer; }
.cat-editor textarea { font: inherit; padding: .5rem .7rem; border: 1px solid var(--color-border-strong); border-radius: 8px; width: 100%; resize: vertical; }
.cat-rows { margin-bottom: .75rem; }
.cat-rows td { vertical-align: middle; padding: .3rem .35rem; }
.cat-rows input[type=text], .cat-rows input[type=number], .cat-rows select { padding: .35rem .5rem; font-size: .9rem; min-width: 5rem; }
.cat-rows input[type=number] { font: inherit; font-size: .9rem; border: 1px solid var(--color-border-strong); border-radius: 8px; width: 100%; }
.cat-rows input:disabled { background: var(--bg); color: var(--muted); }
.cat-narrow { width: 7rem; }
.cat-formula { min-width: 14rem; }
.cat-example { color: var(--muted); max-width: 16rem; white-space: normal; }
.cat-example.is-error { color: var(--danger); }
.cat-row-btns { white-space: nowrap; width: 1%; }
.mono, .cat-help code, .cat-vars code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; }
.cat-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .25rem 1rem; }
.cat-save { display: flex; gap: .75rem; }
.cat-delete { margin-top: 1.5rem; max-width: 480px; }
@media (max-width: 800px) { .cat-grid { grid-template-columns: 1fr; } }

/* Pre-planning, Layout: drawing ribbon above the map */
.rib-tabs { display: flex; gap: .1rem; overflow-x: auto; padding: .35rem .5rem 0; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.rib-tab { display: flex; align-items: center; gap: .4rem; white-space: nowrap; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .35rem .7rem; font: inherit; font-size: .88rem; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.rib-tab:hover { color: var(--ink); }
.rib-tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
.rib-tab .lay-swatch { width: 10px; height: 10px; }
.rib-body { display: flex; align-items: center; gap: .75rem; padding: .45rem .5rem; }
.rib-tools { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; flex: 1; min-width: 0; }
.rib-tool { display: inline-flex; align-items: center; gap: .4rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .65rem; font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer; white-space: nowrap; }
.rib-tool:hover { border-color: var(--brand); }
.rib-tool.is-active { background: var(--brand); border-color: var(--brand); color: var(--ink); }
.rib-tool .lay-swatch { width: 10px; height: 10px; }
.rib-icon { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; opacity: .75; flex: none; }
.rib-icon-point { border-radius: 50%; width: 9px; height: 9px; }
.rib-icon-line { height: 0; border-width: 2px 0 0; transform: rotate(-30deg); }
.rib-icon-area { border-radius: 2px 6px 2px 4px; }
.rib-icon-rect { border-radius: 1px; height: 9px; width: 14px; }
.rib-icon-circle, .rib-icon-pivot { border-radius: 50%; }
.rib-icon-pivot { border-style: dashed; }
.rib-more { margin-left: .25rem; }
.rib-filter { display: flex; align-items: center; gap: .4rem; color: var(--muted); margin: 0; white-space: nowrap; font-weight: 400; }
.rib-filter select { padding: .3rem .5rem; width: auto; max-width: 14rem; }

/* Layout: selected object panel */
.obj-type { margin: -.4rem 0 .6rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.obj-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.obj-settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.obj-settings:empty { display: none; }
.obj-settings label, .obj-two label { font-size: .88rem; }
.obj-settings input, .obj-settings select { padding: .35rem .5rem; }
.obj-settings input[type=number] { font: inherit; border: 1px solid var(--color-border-strong); border-radius: 8px; width: 100%; }
.obj-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .2rem 0 .3rem; }
.obj-dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; margin: 0; font-size: .9rem; }
.obj-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.obj-costs { width: 100%; border-collapse: collapse; font-size: .85rem; }
.obj-costs th { font-size: .75rem; color: var(--muted); font-weight: 600; text-align: left; padding: .2rem .25rem; border-bottom: 1px solid var(--line); }
.obj-costs td { padding: .25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.obj-costs .n { text-align: right; font-variant-numeric: tabular-nums; }
.obj-costs tfoot td { font-weight: 600; border-bottom: 0; }
.obj-rate { width: 5.5rem; font: inherit; font-size: .85rem; padding: .2rem .35rem; border: 1px solid var(--color-border-strong); border-radius: 6px; text-align: right; }
.obj-rate.is-override { border-color: var(--color-primary); background: var(--color-accent-soft); }
.lay-layer-meta { margin: .1rem 0 0 1.4rem; }
.lay-feature.is-filtered { opacity: .45; }
.lay-badge { display: inline-block; font-size: .7rem; padding: 0 .35rem; border-radius: 4px; margin-right: .3rem; }
.lay-badge-existing { background: var(--color-surface-2); color: var(--muted); }
.lay-badge-option { background: var(--color-primary-soft); color: var(--color-text); }

/* Layout: phases */
.phase-list { list-style: none; margin: 0; padding: 0; }
.phase-item { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; padding: .4rem 0; }
.phase-item + .phase-item { border-top: 1px solid var(--line); }
.phase-btns { display: flex; gap: .6rem; }
.linklike.danger { color: var(--danger); }
.phase-form { display: grid; gap: .5rem; margin-bottom: .6rem; padding: .6rem; background: var(--bg); border-radius: 8px; }
.phase-form input[type=text] { padding: .35rem .55rem; }
.phase-dates { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.phase-dates input { font: inherit; padding: .3rem .4rem; border: 1px solid var(--color-border-strong); border-radius: 8px; width: 100%; }
@media (max-width: 700px) { .rib-body { flex-wrap: wrap; } }
.lay select, .lay input[type=text], .lay input[type=number] { min-width: 0; max-width: 100%; }
.obj-costs { table-layout: fixed; }
.obj-costs th:nth-child(1), .obj-costs td:nth-child(1) { width: auto; overflow-wrap: anywhere; }
.obj-costs th:nth-child(2) { width: 22%; } .obj-costs th:nth-child(3) { width: 26%; } .obj-costs th:nth-child(4) { width: 24%; }
.obj-rate { width: 100%; }

/* Admin -> Branding */
.logo-preview { margin: .5rem 0 .75rem; }
.logo-preview img { width: 100%; max-height: 120px; object-fit: contain; padding: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--color-bg); }


/* ---- Layout page: fills the window below the section tabs ----
   left panel | object ribbon (top) + map (rest). The page itself doesn't scroll; the panel does. */
body:has(.lay) { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body:has(.lay) .container { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
body:has(.lay) .pl-main { flex: 1; min-height: 0; display: flex; }
body:has(.lay) .footer { display: none; }
.lay { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stack-tight { display: grid; gap: .5rem; }
.rib { grid-column: 2; border-bottom: 1px solid var(--line); background: var(--surface); }
.lay-map-box { grid-column: 2; position: relative; min-height: 0; }
.lay-map { position: absolute; inset: 0; background: var(--color-text); }
.lay-hint { position: absolute; left: .75rem; bottom: 1.6rem; z-index: 500; max-width: min(520px, 70%); margin: 0; padding: .4rem .7rem;
  background: rgb(0 0 0 / 80%); color: var(--color-bg); font-size: .82rem; border-radius: 8px; pointer-events: none; }
.lay-status { position: absolute; right: .75rem; bottom: 1.6rem; z-index: 1100; max-width: 360px; box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
  padding: .5rem .8rem; border-radius: 8px; background: var(--color-accent-soft); color: var(--ok); font-size: .88rem; border: 1px solid var(--color-accent); }
.lay-map.is-placing-home { cursor: crosshair; }

/* active layer */
.lay-layer.is-active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); border-radius: 6px; }
.lay-layer { padding: .3rem .3rem .3rem .45rem; }
.lay-layer-head { cursor: pointer; }
.lay-active-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--link); }
#lay-active-note { margin-bottom: .4rem; }
.rib-tools.is-locked .rib-tool { opacity: .45; }

/* project home marker */
.lay-home-icon { font-size: 1.2rem; color: var(--link); }
.lay-home-marker { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--brand); border: 2px solid var(--color-bg); box-shadow: 0 2px 6px rgb(0 0 0 / 45%); }
.lay-home-marker span { transform: rotate(45deg); font-size: 16px; line-height: 1; color: var(--ink); font-weight: 700; }

/* floating object editor (right-click an object) */
.lay-float { position: absolute; z-index: 1000; width: 340px; max-height: calc(100% - 1.5rem); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / 30%); }
.lay-float-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .5rem .5rem .8rem;
  border-bottom: 1px solid var(--line); cursor: move; user-select: none; background: var(--bg); border-radius: 10px 10px 0 0;
  border-top: 3px solid var(--brand); }
.lay-float-head h2 { font-size: .98rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-float-body { overflow-y: auto; padding: .7rem .8rem .8rem; scrollbar-width: thin; }
.lay-float-body .obj-type { margin: 0 0 .5rem; }

@media (max-width: 800px) {
  body:has(.lay) { height: auto; overflow: visible; }
  .lay { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; }
  .lay-side { grid-row: 3; border-right: 0; border-top: 1px solid var(--line); }
  .rib, .lay-map-box { grid-column: 1; }
  .lay-float { width: calc(100% - 1rem); }
}

/* Style guide: Layout page */
.offscreen { position: fixed; left: -200px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* Rule 4: full screen. No outer margins, panels touch on one thin line, only panels scroll. */
body:has(.lay) { background: var(--color-bg); color: var(--color-text); }
body:has(.lay) .pl-sections { margin: 0; }
body:has(.lay) .pl-sections a { color: var(--color-text-2); }
body:has(.lay) .pl-sections a.active { color: var(--color-text); border-bottom-color: var(--color-primary); }
.lay { position: relative; grid-template-columns: var(--side-w, 300px) minmax(0, 1fr); border: 0; border-radius: 0; background: var(--color-bg); }
.lay.is-side-hidden { grid-template-columns: 0 minmax(0, 1fr); }
.lay.is-side-hidden .lay-side, .lay.is-side-hidden .lay-resize { display: none; }
.lay.is-resizing { cursor: col-resize; user-select: none; }
.lay-side { grid-row: 1 / 3; overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--color-border); background: var(--color-bg); padding: 4px 0; scrollbar-width: thin; }
.lay-resize { position: absolute; top: 0; bottom: 0; left: calc(var(--side-w, 300px) - 3px); width: 7px; cursor: col-resize; z-index: 700; }
.lay-resize:hover, .lay.is-resizing .lay-resize { background: color-mix(in srgb, var(--color-primary) 45%, transparent); }

/* Rule 1: the side panel is one tree */
.tree { font-size: .88rem; color: var(--color-text); user-select: none; }
.tree-row { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 calc(5px + var(--lvl, 0) * 16px);
  border-left: 3px solid transparent; white-space: nowrap; cursor: default; }
.tree-row:hover { background: var(--color-hover); }
.tree-row.is-selected { background: var(--color-selected); border-left-color: var(--color-primary); }
.tree-head { font-weight: 600; cursor: pointer; }
.tree-layer { cursor: pointer; }
.tree-layer.is-active .tree-label { font-weight: 600; }
.tree-twisty { width: 14px; flex: none; background: none; border: 0; padding: 0; color: var(--color-text-2); font-size: .72rem; line-height: 1; text-align: center; }
button.tree-twisty { cursor: pointer; }
.tree-icon { width: 16px; flex: none; text-align: center; color: var(--color-text-2); }
.tree-icon.lay-kind { width: 10px; height: 10px; margin: 0 3px; }
.tree-icon.lay-kind-line { height: 0; width: 12px; margin: 0 2px; }
.tree-row .lay-swatch { width: 11px; height: 11px; }
.tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tree-meta { color: var(--color-text-2); font-size: .76rem; font-variant-numeric: tabular-nums; flex: none; }
.tree-tag { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-primary); flex: none; }
.tree-info { color: var(--color-text-2); font-size: .8rem; font-weight: 400; cursor: help; }
.tree-check { margin: 0; width: 13px; height: 13px; flex: none; accent-color: var(--color-primary); cursor: pointer; }
.tree-actions { display: none; gap: 1px; flex: none; }
.tree-row:hover .tree-actions, .tree-row:focus-within .tree-actions { display: flex; }
.tree-row:hover .tree-meta { display: none; }
.tree-head:hover .tree-meta { display: inline; }
.tree-act { width: 22px; height: 22px; border: 0; border-radius: 4px; background: none; color: var(--color-text); font: inherit; font-size: .9rem; line-height: 1; padding: 0; cursor: pointer; }
.tree-act:hover { background: var(--color-selected); }
.tree-row.is-filtered .tree-label, .tree-row.is-filtered .tree-icon { opacity: .45; }
.tree-empty { color: var(--color-text-2); font-style: italic; }
.tree-empty:hover { background: none; }
.tree-editing input { flex: 1; min-width: 0; height: 22px; font: inherit; padding: 0 6px; border: 1px solid var(--color-primary); border-radius: 4px; outline: none; }
.tree-form { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px 8px 6px calc(27px + var(--lvl, 0) * 16px); background: var(--color-hover); }
.tree-form input { font: inherit; font-size: .8rem; padding: 2px 5px; border: 1px solid var(--color-border); border-radius: 4px; min-width: 0; background: var(--color-bg); }
.tree-form input[name=name] { grid-column: 1 / -1; }
.tree-form-btns { grid-column: 1 / -1; display: flex; gap: 2px; }
.lay-badge { background: var(--color-hover); color: var(--color-text-2); }
.lay-badge-option { background: var(--color-hover); color: var(--color-text); }

/* right-click / ⋯ menu */
.ctx-menu { position: fixed; z-index: 3000; min-width: 180px; padding: 4px 0; background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 6px; box-shadow: 0 6px 18px rgb(0 0 0 / 18%); font-size: .86rem; }
.ctx-menu[hidden] { display: none; }
.ctx-item { position: relative; display: block; width: 100%; padding: 5px 14px 5px 26px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.ctx-item:hover { background: var(--color-hover); }
.ctx-item.is-checked::before { content: "\2713"; position: absolute; left: 9px; }
.ctx-sep { height: 1px; margin: 4px 0; background: var(--color-border); }
.ctx-heading { padding: 4px 14px 2px; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-2); }

/* toolbar above the map */
.lay .rib { background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.lay .rib-tabs { padding: 0 8px; border-bottom: 1px solid var(--color-border); overflow-y: hidden; }
.lay .rib-tab { color: var(--color-text-2); }
.lay .rib-tab.is-active { color: var(--color-text); border-bottom-color: var(--color-primary); }
.lay .rib-body { padding: 4px 8px; gap: 8px; }
.lay .rib-tool, .rib-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .55rem; border: 1px solid var(--color-border); border-radius: 6px;
  background: var(--color-bg); color: var(--color-text); font: inherit; font-size: .86rem; white-space: nowrap; cursor: pointer; }
.lay .rib-tool:hover, .rib-btn:hover { background: var(--color-hover); border-color: var(--color-primary); }
.lay .rib-tool.is-active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text); }
.rib-btn[aria-pressed=true] { border-color: var(--color-text-2); }
.lay .rib-more { color: var(--color-text-2); }
.lay .rib-filter { color: var(--color-text-2); }

/* map messages and the floating editor */
.lay .lay-status { background: var(--color-text); color: var(--color-bg); border: 0; }
.lay .lay-status.is-error { background: var(--color-text); color: var(--color-bg); box-shadow: inset 4px 0 0 var(--color-primary), 0 6px 20px rgb(0 0 0 / 20%); }
.lay .lay-float { border-color: var(--color-border); color: var(--color-text); }
.lay .lay-float-head { background: var(--color-bg); border-bottom-color: var(--color-border); border-top-color: var(--color-primary); }
.lay .btn-danger { background: var(--color-bg); border-color: var(--color-text); color: var(--color-text); }
.lay .btn-danger:hover { background: var(--color-hover); border-color: var(--color-primary); color: var(--color-text); }

/* ---- Style guide rule 3: tables (table.grid) ----
   Sticky header, click a header to sort, numbers right-aligned with units in the header,
   cells edited in place, selected row = orange bar + yellow tint. */
.table-wrap:has(> table.grid) { max-height: calc(100vh - 190px); overflow: auto; border: 1px solid var(--color-border); }
.table-wrap > table.grid { border: 0; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: .9rem; }
table.grid th, table.grid td { padding: .35rem .6rem; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
table.grid th:last-child, table.grid td:last-child { border-right: 0; } /* vertical lines between columns, not on the outer edge */
table.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--color-bg); box-shadow: inset 0 -1px 0 var(--color-border-strong); white-space: nowrap; }
table.grid th.is-sortable { cursor: pointer; user-select: none; }
table.grid th.is-sortable:hover { background: var(--color-hover); }
table.grid th.is-sortable::after { content: ""; display: inline-block; width: 1em; color: var(--color-text-2); }
table.grid th[aria-sort=ascending]::after { content: "\2191"; }
table.grid th[aria-sort=descending]::after { content: "\2193"; }
table.grid td.n, table.grid th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover td { background: var(--color-hover); }
table.grid tr.is-selected td { background: var(--color-selected); }
table.grid tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }
table.grid tr.row-off td { opacity: 1; color: var(--color-text-2); }
table.grid tfoot td { border-bottom: 0; background: var(--color-bg); }
/* inputs inside cells look like text until you click them */
table.grid td input[type=text], table.grid td select, table.grid td input[type=number] {
  width: 100%; min-width: 6rem; padding: .2rem .35rem; border: 1px solid transparent; border-radius: 4px; background: transparent; font: inherit; color: inherit; }
table.grid td input[type=text]:hover, table.grid td select:hover { border-color: var(--color-border); }
table.grid td input[type=text]:focus, table.grid td select:focus { border-color: var(--color-primary); background: var(--color-bg); outline: none; }
table.grid td input[type=color] { width: 2rem; height: 1.6rem; padding: 0; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-bg); cursor: pointer; }
table.grid td input[type=checkbox] { accent-color: var(--color-primary); width: 15px; height: 15px; cursor: pointer; }
[data-save].is-saving { opacity: .6; }
[data-save].is-saved { box-shadow: inset 0 -2px 0 var(--color-accent); }
[data-save].is-error { border-color: var(--color-primary) !important; background: var(--color-primary-soft) !important; }
.grid-add td { padding-top: .5rem; }
.grid-add form { display: flex; gap: .4rem; align-items: center; }
.grid-add input[type=text] { flex: 1; min-width: 10rem; padding: .3rem .5rem; border: 1px dashed var(--color-border-strong); border-radius: 4px; font: inherit; }
.grid-actions { white-space: nowrap; text-align: right; }

/* small saved / error message */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 4000; padding: .45rem .8rem; border-radius: 6px; background: var(--color-text); color: var(--color-bg); font-size: .88rem; box-shadow: 0 6px 18px rgb(0 0 0 / 20%); }
.toast.is-error { box-shadow: inset 4px 0 0 var(--color-primary), 0 6px 18px rgb(0 0 0 / 20%); }
.toast[hidden] { display: none; }

/* ⓘ: a longer explanation in a tooltip (style guide rule 2) */
.info { display: inline-block; margin-left: .3rem; color: var(--color-text-2); font-size: .85em; font-weight: 400; cursor: help; vertical-align: baseline; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }

/* eye button in the tree (show / hide on the map) */
.tree-eye { display: grid; place-items: center; width: 20px; height: 20px; flex: none; padding: 0; border: 0; border-radius: 4px;
  background: none; color: var(--color-text); cursor: pointer; }
.tree-eye:hover { background: var(--color-selected); }
.tree-eye.is-off { color: var(--color-text-2); }
.tree-row.is-hidden .tree-label, .tree-row.is-hidden .tree-meta, .tree-row.is-hidden .tree-icon { color: var(--color-text-2); }

/* object editor: the line a point is connected to */
.lay-obj-link { margin: 0; }
.lay-obj-link .linklike { color: var(--color-primary); text-decoration: underline; }

/* object editor: colour picker with a reset link */
.obj-colour { display: flex; align-items: center; gap: .5rem; }
.obj-colour input[type=color] { width: 2.4rem; height: 2rem; padding: 0; border: 1px solid var(--color-border-strong); border-radius: 6px; background: var(--color-bg); cursor: pointer; }

/* selection box: left-to-right = solid (completely inside), right-to-left = dashed (touching) */
.sel-box { position: absolute; z-index: 650; pointer-events: none; border: 1.5px solid var(--color-text);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent); }
.sel-box.is-crossing { border-style: dashed; background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
/* left-drag selects, so the map shows a normal pointer; Space held = pan */
.lay-map.leaflet-grab { cursor: default; }
.lay-map.is-panning, .lay-map.is-panning .leaflet-interactive { cursor: grab; }
.lay-map.leaflet-dragging { cursor: grabbing; }
.obj-group-types { font-weight: 600; }

/* Zonneblom CI manual (20 Nov 2026): Poppins; headings in Extra Bold capitals; the yellow-orange-red
   gradient is the graphic device (top bar edge, active tab); black blocks for contrast. */
:root { --link: color-mix(in srgb, var(--color-primary) 72%, var(--color-text)); }
.topbar { border-bottom: 5px solid transparent; border-image: var(--gradient) 1; }
h1, h2, h3 { font-weight: 800; letter-spacing: .01em; }
h1 { text-transform: uppercase; }
.brand-label, .brand-project { font-weight: 600; }
th { font-weight: 600; letter-spacing: .06em; }
.btn { font-weight: 600; border-radius: 6px; }
.pl-sections a.active, .tabs a.active, .pl-tabs a.active, .rib-tab.is-active { border-bottom: 3px solid transparent; border-image: var(--gradient) 1; }
.tile:hover { border-color: var(--color-primary); }
.tile-admin { background: var(--color-text); color: var(--color-bg); border-color: var(--color-text); }
.tile-admin .muted, .tile-admin p { color: rgb(255 255 255 / 75%); }

/* Layout map tools (undo/redo, select, measure, array, offset, zoom, find) */
.lay .rib-tab-tools.is-on { color: var(--color-text); font-weight: 600; }
.rib-caret { font-size: .75em; opacity: .7; }
.lay-tool { left: 56px; top: 12px; width: 240px; }
.lay-map.is-tool, .lay-map.is-tool .leaflet-interactive { cursor: crosshair; }
.lay-find { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1100; width: min(380px, 80%);
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / 20%); padding: 6px; }
.lay-find[hidden] { display: none; }
.lay-find input { width: 100%; }
.lay-find-results { max-height: 300px; overflow-y: auto; }
.lay-find-hit { display: flex; justify-content: space-between; gap: .5rem; width: 100%; padding: 5px 8px; background: none; border: 0; border-radius: 6px; font: inherit; text-align: left; cursor: pointer; color: var(--color-text); }
.lay-find-hit:hover, .lay-find-hit:first-child { background: var(--color-hover); }
.lay-find-meta { color: var(--color-text-2); font-size: .8rem; white-space: nowrap; }
.lay-find-none { margin: 6px 8px; }
.tree-lock { background: none; border: 0; padding: 0 2px; cursor: pointer; font-size: .8rem; }

/* ---- Cash Flow Projection section (recommendations §2): side tree | content ----
   Fills the window like the Layout page; the tree and the content scroll on their own. */
body:has(.pj) .container { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
body:has(.pj) .pl-sections { margin: 0; }
body:has(.pj) .pl-main { flex: 1; min-height: 0; display: flex; }
.pj { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.pj-tree { overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--color-border); padding: 4px 0; scrollbar-width: thin; }
.pj-tree a.tree-row { color: var(--color-text); text-decoration: none; }
.pj-tree .tree-head { cursor: pointer; }
.pj-node[hidden] { display: none; }
.pj-main { min-width: 0; min-height: 0; overflow: auto; padding: 12px 16px 24px; }
.pj-main > .pl-work { min-height: 100%; }
.pl-work-name { flex: 1; font-weight: 600; margin: 0 0 .75rem; align-self: center; }

/* content pages: Assumptions groups side by side when there is room */
.pj-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px 24px; align-items: start; }
.pj-cols h2, .pj-page > section > h2 { font-size: 1rem; margin-bottom: .4rem; }
table.pj-params { width: 100%; }
table.pj-params td.n input, table.pj-params td.n select { text-align: right; min-width: 7rem; }
/* three-column parameter tables (setting | value | unit): a narrow unit column */
table.pj-params th:nth-child(3):last-child, table.pj-params td:nth-child(3):last-child { width: 7rem; }
table.pj-ha { width: auto; }
table.pj-ha th:nth-child(3), table.pj-ha td:nth-child(3) { width: auto; }
.pj-calc { color: var(--color-text-2); padding: 0 .4rem; cursor: help; }

/* Projection: toolbar + one table that fills the rest */
.pj-fill { height: 100%; display: flex; flex-direction: column; }
.pj-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pj-seg { display: inline-flex; border: 1px solid var(--color-border); border-radius: 6px; overflow: hidden; }
.pj-seg a { padding: .22rem .7rem; font-size: .86rem; color: var(--color-text-2); text-decoration: none; }
.pj-seg a + a { border-left: 1px solid var(--color-border); }
.pj-seg a:hover { background: var(--color-hover); color: var(--color-text); }
.pj-seg a.is-active { background: var(--color-primary); color: var(--color-text); font-weight: 600; }
.pj-check { font-size: .86rem; cursor: help; white-space: nowrap; }
.pj-check.is-bad { font-weight: 600; box-shadow: inset 0 -2px 0 var(--color-primary); }
.pj-unit { margin-left: auto; }
.pj-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--color-border); }
table.pj-table { border-collapse: separate; border-spacing: 0; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.pj-table th, table.pj-table td { padding: .25rem .6rem; border-bottom: 1px solid var(--color-surface-2); white-space: nowrap; }
table.pj-table th { text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--color-text); }
table.pj-table td.n, table.pj-table th.n { text-align: right; min-width: 5.5rem; }
table.pj-table thead th { position: sticky; top: 0; z-index: 2; background: var(--color-bg); box-shadow: inset 0 -1px 0 var(--color-border-strong); font-weight: 600; }
table.pj-table thead th.pj-partial { color: var(--color-text-2); cursor: help; }
/* frozen first column */
table.pj-table .pj-first { position: sticky; left: 0; z-index: 1; background: var(--color-bg); text-align: left; font-weight: 400;
  min-width: 260px; box-shadow: inset -1px 0 0 var(--color-border); }
table.pj-table thead .pj-first { z-index: 3; font-weight: 600; color: var(--color-text-2); }
table.pj-table tr.pj-item .pj-first { padding-left: 2rem; }
table.pj-table tr.pj-group th, table.pj-table tr.pj-group td { font-weight: 700; border-top: 1px solid var(--color-border); }
table.pj-table tr.pj-group th { cursor: pointer; }
table.pj-table tr.pj-group .tree-twisty { margin-right: .35rem; }
table.pj-table tr.pj-net th, table.pj-table tr.pj-net td { font-weight: 700; border-top: 2px solid var(--color-text); }
table.pj-table tr.pj-bal th, table.pj-table tr.pj-bal td { color: var(--color-text-2); }
table.pj-table tr.pj-close th, table.pj-table tr.pj-close td { color: var(--color-text); font-weight: 700; border-bottom: 3px double var(--color-text); }
table.pj-table tbody tr:hover td, table.pj-table tbody tr:hover th { background: var(--color-hover); }
table.pj-table tbody tr:hover .pj-first { background: color-mix(in srgb, var(--color-accent) 20%, var(--color-bg)); }
table.pj-table tr[hidden] { display: none; }

@media (max-width: 800px) {
  .pj { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .pj-tree { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--color-border); }
  table.pj-table .pj-first { min-width: 160px; }
}
/* formula bar: the formula in words, under the real formula */
.fbar-words { display: block; margin-top: .25rem; padding-top: .25rem; border-top: 1px solid var(--color-border); color: var(--color-text-2); font-family: var(--font); }

/* ---- Forecast model pages ---- */
.fc .pj-bar label { display: inline-flex; align-items: center; gap: 6px; }
.fc-error { font-weight: 600; box-shadow: inset 4px 0 0 var(--color-primary); padding: 6px 10px; background: var(--color-primary-soft); }
.fc-ok { font-weight: 600; box-shadow: inset 4px 0 0 var(--color-accent); padding: 6px 10px; background: var(--color-accent-soft); }
.fc-start { margin-bottom: 16px; max-width: 520px; }
.fc-wrap { max-height: calc(100vh - 260px); }
table.fc-table td { padding: .15rem .3rem; white-space: nowrap; }
table.fc-table td input[type=text] { min-width: 4.5rem; }
table.fc-table td.n input[type=text] { text-align: right; width: 6.5rem; min-width: 0; }
table.fc-table td.fc-year input[type=text] { width: 6.5rem; }
input.fc-flag, select.fc-flag { outline: 2px solid var(--color-primary); }
table.fc-table td select { min-width: 11rem; max-width: 15rem; }
table.fc-table td input:disabled { opacity: .35; }
table.fc-table .fc-first { position: sticky; left: 0; z-index: 1; background: var(--color-bg); box-shadow: inset -1px 0 0 var(--color-border); }
table.fc-table thead .fc-first { z-index: 3; }
table.fc-table td.fc-first input { min-width: 13rem; font-weight: 500; }
table.fc-table tbody tr:hover td.fc-first { background: color-mix(in srgb, var(--color-accent) 20%, var(--color-bg)); }
.fc-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0 4px; }
.fc-add input[type=text] { min-width: 16rem; padding: .25rem .5rem; border: 1px dashed var(--color-border-strong); border-radius: 4px; font: inherit; }
.fc-add select { font: inherit; padding: .2rem .3rem; }
table.fc-ramp td input[type=text] { width: 3.6rem; min-width: 0; text-align: right; }
.fc-workings { margin-top: 8px; }
.fc-workings table.fc-sum { width: auto; }

table.fc-days td input[type=text] { width: 3.2rem; min-width: 0; text-align: right; }
table.fc-days input.fc-default { color: var(--color-text-2); }
td.fc-adjusted { text-decoration: underline dotted var(--color-primary); text-underline-offset: 3px; }
.fc-add input.fc-short { min-width: 7rem; width: 7rem; }
.fc-add input[type=month] { font: inherit; padding: .15rem .3rem; }
table.fc-oh td.fc-q input[type=text] { width: 4.6rem; min-width: 0; text-align: right; }
table.fc-oh input.fc-default { color: var(--color-text-2); }
.fc-years { flex-wrap: wrap; }
.fc-years a { padding: .22rem .5rem; }

table.fc-table td input.fc-when { min-width: 9rem; width: 11rem; }
/* hectares per season: every crop column the same width (colgroup in the view); a darker line between crops */
table.fc-ha { table-layout: fixed; width: auto; }
table.fc-ha col.fc-col-label { width: 6rem; }
table.fc-ha col:not(.fc-col-label) { width: 8.5rem; }
table.fc-ha th.fc-group { text-align: center; }
table.fc-ha th.fc-group, table.fc-ha .fc-crop-end { border-right-color: var(--color-border-strong); }
table.fc-ha td input[type=text] { width: 100%; min-width: 0; }

.fc-note { margin: 0 0 4px; }

/* ---- Reports ---- */
.fc-report-form { display: grid; gap: 10px; }
.fc-fieldset { border: 1px solid var(--color-border); border-radius: 6px; padding: 6px 10px; display: grid; gap: 2px; }
.fc-check { display: flex; gap: 6px; align-items: center; font-size: .9rem; }
.fc-check input { accent-color: var(--color-primary); }
body.report-page { background: var(--color-bg); color: var(--color-text); }
.report-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--color-border); }
.report { max-width: 1100px; margin: 0 auto; padding: 16px; }
.report-logo { height: 48px; width: auto; }
.report h1 { font-size: 1.5rem; margin: .5rem 0 .25rem; }
.report-meta { color: var(--color-text-2); font-size: .85rem; margin: 0 0 1rem; }
.report-part { break-inside: avoid; margin-bottom: 1.25rem; }
.report-part h2 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.report-table { border-collapse: collapse; width: 100%; font-size: .78rem; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { padding: .2rem .35rem; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.report-table th { border-bottom: 1px solid var(--color-border-strong); text-align: left; }
.report-table .n { text-align: right; }
.report-table tr.b td { font-weight: 700; border-top: 1px solid var(--color-border-strong); }
.report-chart .chart { max-height: 320px; }
.report-caption { font-size: .78rem; font-style: italic; color: var(--color-text-2); margin: .3rem 0 0; }
@media print {
  .no-print { display: none !important; }
  .report { max-width: none; padding: 0; }
  @page { size: A4 landscape; margin: 12mm; }
}

/* ---------- Map → Projection (link.ejs) ---------- */
.lk section { margin-top: 18px; }
.lk-status { display: inline-block; }
.lk-table td { vertical-align: top; }
.lk-table input[type=text] { width: 8rem; text-align: right; }
.lk-src { display: flex; gap: 4px; align-items: baseline; margin: 0; }
.lk-warn { color: var(--color-primary); font-weight: 600; margin-top: 2px; }
.lk-years summary, .lk-match > summary { cursor: pointer; }
.lk-match > summary { list-style-position: inside; }
.lk-inline { display: inline; }
.lk-mini { border-collapse: collapse; margin: 6px 0; font-size: .8rem; }
.lk-mini th, .lk-mini td { padding: 2px 6px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.lk-mini td.lk-diff { background: var(--color-primary-soft); font-weight: 600; }

/* read-only project pages (templates, developer view) */
.ro-tag { font-size: .8rem; font-weight: 600; padding: .15rem .6rem; border-radius: 99px; background: var(--color-primary-soft); color: var(--color-primary); white-space: nowrap; }
.invite-link { width: 100%; margin-top: 6px; font: inherit; font-size: .85rem; padding: .25rem .4rem; }
.invite-card { max-width: 560px; margin: 24px auto; }

/* Sign in with Google (projects site login) */
.btn-google { display: block; text-align: center; margin-bottom: 8px; }
.login-or { text-align: center; margin: 4px 0 10px; }
