/* SiteCensus Offsets. Components built on the SiteCensus tokens in css/tokens.css.
   RULE (from SiteCensus): components read tokens; no hex or px palette values here. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: var(--t-md); line-height: 1.45; color: var(--text); background: var(--navy-dark); transition: background-color .35s ease, color .35s ease; }
* { scrollbar-width: thin; scrollbar-color: var(--divider) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--divider); border-radius: var(--r-xs); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--t-3xl); font-weight: 700; letter-spacing: -.01em; margin: 0 0 var(--s1); line-height: 1.15; }
h2 { font-size: var(--t-xs); font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); margin: var(--s10) 0 var(--s3); }
h2:first-child { margin-top: 0; }
h3 { font-size: var(--t-lg); font-weight: 700; margin: var(--s7) 0 var(--s2); }
p { margin: var(--s2) 0; }
.sub { color: var(--text-dim); font-size: var(--t-base); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: var(--t-base); }
kbd { font-family: ui-monospace, Consolas, monospace; font-size: var(--t-sm); background: var(--inset); border: 1px solid var(--divider); border-radius: var(--r-xs); padding: 0 4px; }

/* ── wordmark: one mark, matching the SiteCensus app and biogeo.com.au/sitecensus ── */
.sc-wordmark { font-family: Inter, 'Avenir Next', 'Segoe UI', Arial, sans-serif; font-weight: 800; letter-spacing: -.02em; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.sc-suffix { font-family: Inter, 'Avenir Next', 'Segoe UI', Arial, sans-serif; font-weight: 600; letter-spacing: -.02em; color: var(--text); margin-left: .28em; }
.sc-logo { display: inline-block; line-height: 1; white-space: nowrap; flex-shrink: 0; transform: translateY(-0.05em); }
.sc-logo-top { font-size: 30px; }
.sc-logo-gate { font-size: 30px; }

/* ── topbar: the gradient rule is the app's signature edge ── */
#app { display: flex; flex-direction: column; height: 100vh; }
#topbar { height: 72px; flex-shrink: 0; background: var(--navy-dark); border-bottom: 2px solid transparent; border-image: var(--brand-grad) 1; display: flex; align-items: center; padding: 0 22px; gap: 14px; z-index: 100; position: relative; box-shadow: var(--e3); transition: background-color .35s ease; }
.tb-brand { display: flex; align-items: center; min-width: 0; }
.tb-div { width: 1px; height: 26px; background: var(--divider); flex-shrink: 0; margin: 0 2px; }
.tb-juris { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 6px 12px 6px 11px; border: 1px solid transparent; border-radius: var(--r-pill); font-size: var(--t-lg); font-weight: 600; color: var(--text); white-space: nowrap; }
.tb-juris-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-grad); flex-shrink: 0; box-shadow: 0 0 7px rgba(29,158,117,.7); }
.tb-ver { font-size: var(--t-xs); color: var(--text-dim); white-space: nowrap; flex-shrink: 0; padding-left: 12px; border-left: 1px solid var(--divider); }
.crumbs { flex: 1; min-width: 0; margin: 0 var(--s4); color: var(--text-dim); font-size: var(--t-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs a { color: var(--text-dim); }
.crumbs a:hover { color: var(--teal); text-decoration: none; }
.crumbs .sep { margin: 0 6px; opacity: .6; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── buttons: SiteCensus .tbtn ── */
button, .tbtn { font-size: var(--t-sm); padding: 6px 12px; border: 1px solid var(--divider); border-radius: var(--radius); background: var(--navy-dark); color: var(--text-muted); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease, background .15s ease; box-shadow: 0 2px 8px rgba(0,0,0,.18); white-space: nowrap; }
button:hover, .tbtn:hover { border-color: var(--teal); color: var(--teal); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.22); }
button:active { transform: translateY(0); }
button.primary, .tbtn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(29,158,117,.35); }
button.primary:hover { filter: brightness(1.08); color: #fff; box-shadow: 0 6px 20px rgba(29,158,117,.45); }
button.danger { color: var(--red); border-color: var(--red-border); background: transparent; box-shadow: none; }
button.danger:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }
button.small { padding: 3px 9px; font-size: var(--t-xs); box-shadow: none; }
.tbtn-ic { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.theme-ic { width: 15px; height: 15px; display: block; }
.theme-ic-moon { display: none; }
html[data-theme="light"] .theme-ic-sun { display: none; }
html[data-theme="light"] .theme-ic-moon { display: block; }
.btnrow { display: flex; gap: var(--s2); flex-wrap: wrap; margin: var(--s4) 0; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--divider); background: var(--navy); }
.tree { flex: 1; overflow: auto; padding: var(--s4) 0; }
.panel { overflow: auto; padding: 24px 30px 70px; }
.panel > * { max-width: 1180px; }

/* ── readiness strip: the Guide's five steps, read from the project state ── */
#steps { flex-shrink: 0; padding: var(--s4) var(--s4) var(--s3); border-bottom: 1px solid var(--divider); background: var(--navy-dark); }
#steps:empty { display: none; }
.steps-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--t-xs); font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); margin: 0 4px var(--s2); }
ol.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--r-md); cursor: pointer; color: var(--text-dim); font-size: var(--t-base); }
.step:hover { background: var(--surface-tint); color: var(--text); }
.step.active { background: var(--teal-dim); color: var(--text); font-weight: 600; }
.step-n { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--divider); display: inline-flex; align-items: center; justify-content: center; font-size: var(--t-2xs); font-weight: 700; flex-shrink: 0; color: var(--text-dim); }
.step.done .step-n { background: var(--teal); border-color: var(--teal); color: #fff; }
.step.warns .step-n { border-color: var(--amber); color: var(--amber); }
.step.errors .step-n { border-color: var(--red); color: var(--red); }
.step.pending { opacity: .55; }
.step-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-state { font-size: var(--t-2xs); font-weight: 700; padding: 0 5px; border-radius: var(--r-xs); }
.step.errors .step-state { background: var(--red-dim); color: var(--red); }
.step.warns .step-state { background: var(--amber-dim); color: var(--amber); }
.step.done .step-state { color: var(--teal); }
.steps-next { margin: var(--s3) 4px 0; font-size: var(--t-sm); color: var(--text-dim); line-height: 1.4; }
.steps-next a { color: var(--teal); }
.nextbar { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--divider-soft); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nextbar .sub { flex: 1; min-width: 200px; }
.start-steps { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 6px; }
.start-steps li { display: flex; gap: 10px; align-items: baseline; color: var(--text-dim); font-size: var(--t-base); }
.start-steps li.now { color: var(--text); font-weight: 600; }
.start-steps .step-n { align-self: center; }

/* ── guidance: toggle, panel cards, field popovers ── */
#guide-toggle.on { background: var(--teal-dim); border-color: var(--teal-border); color: var(--teal); }
.guide-card { background: var(--teal-dim); border: 1px solid var(--teal-border); border-radius: var(--r-lg); padding: 12px 16px; margin: var(--s4) 0 var(--s5); }
.guide-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.guide-tag { font-size: var(--t-2xs); font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--teal); }
.guide-off { margin-left: auto; font-size: var(--t-xs); color: var(--text-dim); white-space: nowrap; }
.guide-card p { margin: 4px 0; color: var(--text); }
.guide-pitfalls { margin: 6px 0 4px; padding-left: 18px; color: var(--text-muted); font-size: var(--t-base); }
.hp-src { font-size: var(--t-xs); color: var(--text-faint); margin: 6px 0 0; }
.field label.has-help { display: flex; align-items: center; gap: 6px; }
.field label.has-help > span { flex: 1; min-width: 0; }
.help-btn { width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 1px solid var(--teal-border); background: var(--teal-dim); color: var(--teal); font-size: 10px; font-weight: 700; line-height: 1; box-shadow: none; margin-left: auto; flex-shrink: 0; cursor: help; display: inline-flex; align-items: center; justify-content: center; }
.help-btn:hover { background: var(--teal); color: #fff; transform: none; box-shadow: none; }
label.inline .help-btn { margin-left: 4px; }
#help-pop { position: fixed; z-index: 3000; width: min(420px, calc(100vw - 24px)); max-height: min(72vh, 600px); overflow: auto; background: var(--glass-bg); backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%); border: 1px solid var(--divider); border-radius: var(--r-lg); box-shadow: var(--e4); font-size: var(--t-base); color: var(--text); line-height: 1.5; }
.hp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--divider); background: var(--surface-tint); position: sticky; top: 0; backdrop-filter: blur(10px); }
.hp-close { width: 24px; height: 24px; padding: 0; border-radius: 50%; box-shadow: none; font-size: 14px; line-height: 1; }
.hp-body { padding: 10px 12px 12px; }
.hp-body p { margin: 6px 0; }
.hp-kv { display: grid; grid-template-columns: 54px 1fr; gap: 4px 10px; margin: 8px 0; }
.hp-kv div:nth-child(odd) { color: var(--text-faint); font-size: var(--t-2xs); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding-top: 3px; }
.hp-table { margin: 8px 0 2px; font-size: var(--t-sm); }
.hp-trap { color: var(--amber); }

/* ── tree ── */
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer; border-left: 3px solid transparent; font-size: var(--t-base); color: var(--text-muted); }
.tree .node:hover { background: var(--surface-tint); color: var(--text); }
.tree .node.active { background: var(--teal-dim); border-left-color: var(--teal); color: var(--text); font-weight: 600; }
.tree .node .tag { font-size: var(--t-2xs); color: var(--text-faint); border: 1px solid var(--divider); border-radius: var(--r-xs); padding: 0 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tree .node .score { margin-left: auto; font-size: var(--t-sm); font-weight: 700; color: var(--teal); }
.tree .node .sub { font-size: var(--t-xs); }
.tree .d1 .node { padding-left: 24px; }
.tree .d2 .node { padding-left: 38px; }
.tree .d3 .node { padding-left: 52px; }
.tree .empty { padding: 12px 16px; color: var(--text-faint); font-size: var(--t-base); }

/* ── cards and forms ── */
.card { background: var(--navy); border: 1px solid var(--divider); border-radius: var(--r-lg); padding: var(--s7) 18px; margin: var(--s5) 0; box-shadow: var(--e1); }
.card.warn { border-color: var(--amber-border); background: var(--amber-dim); }
.card.bad { border-color: var(--red-border); background: var(--red-dim); }
.card.soft { border-color: var(--teal-border); background: var(--teal-dim); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s4) var(--s7); }
.grid.narrow { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: var(--t-sm); color: var(--text-muted); }
.field .hint { font-size: var(--t-xs); color: var(--text-faint); }
.field.wide { grid-column: 1 / -1; }
input[type=text], input[type=number], input[type=date], select, textarea { width: 100%; padding: 7px 9px; background: var(--inset); border: 1px solid var(--divider); border-radius: var(--radius); color: var(--text); font-size: var(--t-md); transition: border-color .15s ease, box-shadow .15s ease; }
input[type=number] { font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29,158,117,.18); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select option { background: var(--navy); color: var(--text); }
textarea { min-height: 66px; resize: vertical; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
input[type=checkbox] { accent-color: var(--teal); width: 14px; height: 14px; }

/* ── tables ── */
table { border-collapse: collapse; width: 100%; font-size: var(--t-base); background: var(--navy); }
th, td { border: 1px solid var(--divider-soft); padding: 6px 9px; text-align: left; vertical-align: top; }
th { background: var(--surface-tint); font-weight: 700; font-size: var(--t-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.sub { color: var(--text-dim); }
tr.total td { font-weight: 700; background: var(--surface-tint); }
tr.sub-row td { color: var(--text-dim); font-size: var(--t-sm); }
tr.sub-row td:first-child { padding-left: 24px; }
table input[type=number], table input[type=text], table select { padding: 4px 7px; }
.tablewrap { overflow-x: auto; margin: var(--s3) 0; border-radius: var(--r-md); }
td.missing { background: var(--amber-dim); color: var(--amber); }

/* ── badges and stats ── */
.badge { display: inline-block; border-radius: var(--r-sm); padding: 2px 8px; font-size: var(--t-sm); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge.good { background: var(--teal-dim); color: var(--teal); border: 1px solid var(--teal-border); }
.badge.warn { background: var(--amber-dim); color: var(--amber); border: 1px solid var(--amber-border); }
.badge.bad { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-border); }
.badge.neutral { background: var(--surface-tint); color: var(--text-muted); border: 1px solid var(--divider); }
.big { font-size: var(--t-3xl); font-weight: 700; color: var(--teal); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats { display: flex; flex-wrap: wrap; gap: var(--s4) 30px; margin: var(--s2) 0 var(--s5); }
.stat { display: inline-flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: var(--t-sm); color: var(--text-dim); }

/* ── misc ── */
.note { font-size: var(--t-base); color: var(--text-dim); }
.warnlist { margin: var(--s2) 0; padding-left: 18px; color: var(--amber); font-size: var(--t-base); }
.warnlist.bad { color: var(--red); }
.plot { border-left: 3px solid var(--teal-border); padding-left: 14px; margin: var(--s7) 0; }
.plot h3 { margin-top: 0; }
.rowlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--s2); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.projects-list .item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--divider-soft); }
.projects-list .item .name { font-weight: 600; cursor: pointer; color: var(--text); }
.projects-list .item .name:hover { color: var(--teal); }
.projects-list .item .meta { color: var(--text-dim); font-size: var(--t-sm); }
.projects-list .item .spacer { flex: 1; }
.empty-state { color: var(--text-faint); padding: 30px 0; }

/* ── access gate: the SiteCensus sign-in card ── */
#authGate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20000; padding: 20px; overflow: hidden;
  background: radial-gradient(circle at 16% 18%, rgba(29,158,117,0.12), transparent 42%), radial-gradient(circle at 84% 82%, rgba(46,79,110,0.40), transparent 46%), linear-gradient(160deg, #111e2e 0%, #0c1826 55%, #070d15 100%);
  transition: opacity .45s ease, transform .45s ease; }
#authGate::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .55; background-image: repeating-radial-gradient(circle at 50% 42%, rgba(255,255,255,0.028) 0, rgba(255,255,255,0.028) 1px, transparent 1px, transparent 36px); }
#authGate.gate-exit { opacity: 0; transform: scale(.97); pointer-events: none; }
#authGate[hidden] { display: none; }
#authGate .gate-box { position: relative; z-index: 1; width: 100%; max-width: 392px; background: rgba(26,46,68,0.70); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--r-2xl); padding: 32px 30px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,0.06), 0 0 0 1px rgba(29,158,117,0.08); animation: gateBoxIn .5s .15s cubic-bezier(.2,.8,.2,1) both; color: #fff; }
@keyframes gateBoxIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
#authGate .gate-logo { display: flex; align-items: center; margin-bottom: 22px; }
#authGate .gate-logo .sc-suffix { color: #fff; }
#authGate .gate-sub { font-size: var(--t-sm); color: #7A9BB5; margin-bottom: 18px; line-height: 1.5; }
#authGate .gate-field { margin-bottom: 12px; }
#authGate .gate-field label { display: block; font-size: var(--t-sm); color: #A8BFD0; margin-bottom: 5px; }
#authGate input { width: 100%; padding: 10px 11px; background: rgba(17,30,46,0.65); border: 1px solid #28405A; border-radius: var(--radius); color: #fff; font-size: var(--t-lg); letter-spacing: .08em; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
#authGate input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29,158,117,0.18); }
#authGate .gate-submit { width: 100%; padding: 10px; margin-top: 6px; background: var(--brand-grad); border: none; border-radius: var(--radius); color: #fff; font-size: var(--t-md); font-weight: 600; cursor: pointer; box-shadow: none; }
#authGate .gate-submit:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(29,158,117,.32); transform: none; color: #fff; }
#authGate .gate-err { font-size: var(--t-base); color: #F09595; background: #2A1515; border: 1px solid rgba(240,149,149,0.3); border-radius: var(--r-md); padding: 8px 10px; margin-bottom: 12px; display: none; }
#authGate .gate-hint { font-size: var(--t-xs); color: #4A6A85; margin-top: 16px; line-height: 1.5; }
body.gated #app { filter: blur(2px); pointer-events: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .tree { display: none; }
  .crumbs { display: none; }
  .sc-logo-top { font-size: 24px; }
}
