:root {
  /* Standard tokens (incl. fonts: Source Sans Pro / Source Serif Pro) come from the
     TG Hub design system. RIFT keeps only tokens with no design-system equivalent. */
  --header-bg:     var(--tg-dark);          /* hamburger / drawer background */
  --menu-bg-hover: #3d4248;
  --menu-sep:      rgba(255,255,255,.12);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); font-size: 13px; color: var(--text-1); background: var(--bg); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ── */
/* Top bar: exact TG Hub nav (Source/index.css). */
nav { background: #5F7D09; color: #E8E6E0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 58px; position: sticky; top: 0; z-index: 100; flex-shrink: 0; }
.nav-left { display: flex; align-items: center; gap: 16px; }
.nav-brand { font-size: 15px; font-weight: 600; letter-spacing: .04em; color: #fff; line-height: 1; display: flex; align-items: center; }
.nav-center { display: flex; align-items: center; gap: 4px; }
.nav-tab { font-size: 12px; color: rgba(255,255,255,.72); cursor: pointer; padding: 5px 16px; border: 1px solid rgba(255,255,255,.28); background: none; font-family: inherit; line-height: 1; transition: all .15s; }
.nav-tab.active, .nav-tab:hover { color: #fff; border-color: rgba(255,255,255,.55); }
.nav-right { display: flex; align-items: center; gap: 10px; }
/* Language switcher — minimal "EN · FR" text toggle (TG Hub presentations style). */
.nav-mode { display: flex; align-items: center; gap: 5px; font-family: var(--font-sans); font-size: 12px; letter-spacing: .06em; margin-right: 14px; }
.nav-mode-opt { cursor: pointer; color: rgba(255,255,255,.5); font-weight: 400; transition: color .12s; }
.nav-mode-opt:hover { color: #fff; }
.nav-mode-opt.active { color: #fff; font-weight: 500; cursor: default; }
.nav-mode-sep { color: rgba(255,255,255,.35); }
.nav-lang { display: flex; align-items: center; gap: 5px; font-family: var(--font-sans); font-size: 12px; letter-spacing: .06em; margin-right: 8px; }
.nav-lang-opt { cursor: pointer; color: rgba(255,255,255,.5); font-weight: 400; transition: color .12s; }
.nav-lang-opt:hover { color: #fff; }
.nav-lang-opt.active { color: #fff; font-weight: 500; cursor: default; }
.nav-lang-sep { color: rgba(255,255,255,.35); }
.hamburger { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.72); font-size: 18px; padding: 4px 8px; line-height: 1; }
.hamburger:hover { color: #fff; }
.apps-wrap { position: relative; }
.apps-btn { background: none; border: 1px solid rgba(255,255,255,.25); color: rgba(255,255,255,.9); font-family: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; cursor: pointer; letter-spacing: .03em; transition: background .12s; }
.apps-btn:hover { background: rgba(255,255,255,.12); }
.apps-dd { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 200px; z-index: 1000; padding: 6px 0; }
.apps-dd.open { display: block; }
.apps-dd-sec { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 8px 14px 4px; }
.apps-dd-item { display: flex; align-items: center; padding: 7px 14px; font-size: 13px; color: var(--text-1); text-decoration: none; cursor: default; transition: background .1s; }
a.apps-dd-item { cursor: pointer; }
a.apps-dd-item:hover { background: var(--bg); }
.apps-dd-item.current { background: var(--tg-green); color: #fff; cursor: default; }
.apps-dd-item.current:hover { background: var(--tg-green); }
.apps-dd-item.disabled { opacity: .4; cursor: not-allowed; }
a.apps-dd-item.disabled { pointer-events: none; }
.apps-dd-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Buttons (TG Hub design system) ── */
/* Buttons come from the TG Hub design system (tg-design-system.css).
   RIFT keeps only the pieces the design system has no equivalent for. */
.btn-ghost   { background: transparent; color: var(--text-2); border: 1px solid var(--border); } /* light-context ghost; the DS ghost is for dark surfaces */
.btn-ghost:hover { color: var(--text-1); border-color: var(--text-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary:disabled { opacity: 1; color: rgba(255,255,255,0.38); cursor: not-allowed; pointer-events: none; }
.btn-lg { padding: 9px 22px; font-size: 13px; }

/* ── Home / sub-landing screens ── */
#panel-home, #panel-sarcisp { display: none; flex: 1; background: var(--bg); overflow-y: auto; }
#panel-home.active, #panel-sarcisp.active { display: block; }
#panel-model { padding: 0; }
#model-frame { flex: 1; width: 100%; border: 0; display: block; background: var(--bg); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header-end { justify-content: flex-end; }
.help-btn { flex: none; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: 15px; font-weight: 700; line-height: 1; color: var(--tg-green); background: none; border: .5px solid var(--border-2); cursor: pointer; padding: 0; }
.help-btn:hover { border-color: var(--tg-green); }
.navcrumb { font-size: 16px; color: var(--text-2); margin-bottom: 8px; letter-spacing: .01em; }
.navcrumb:empty { display: none; }
.navcrumb .nclink { color: var(--tg-green); cursor: pointer; text-decoration: none; }
.navcrumb .nclink:hover { text-decoration: underline; }
.pane-help { position: absolute; top: 14px; right: 20px; z-index: 50; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: 15px; font-weight: 700; line-height: 1; color: var(--tg-green); background: var(--surface); border: 1px solid var(--border-2); cursor: pointer; padding: 0; }
.pane-help:hover { border-color: var(--tg-green); }
.page-title { font-size: 24px; font-family: var(--font-serif); font-weight: 600; color: var(--text-1); line-height: 1.2; }
.home-group { width: 100%; }
#sarcisp-cards { display: flex; flex-direction: column; gap: 28px; }
.home-group-h { font-family: var(--font-serif); font-size: 18px; font-weight: 600; color: var(--text-1); margin: 0 0 12px; }
.hmenu-item.hm-sub { padding-left: 38px; font-size: 12.5px; color: rgba(255,255,255,.5); }
.home-inner { max-width: 1000px; padding: 28px 32px; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.home-title { font-family: var(--font-serif); font-size: 28px; font-weight: 600; color: var(--text-1); text-align: center; line-height: 1.2; }
.home-tagline { font-size: 14px; color: var(--text-2); text-align: center; max-width: 620px; line-height: 1.5; }
.home-quote { margin: 0; max-width: 620px; text-align: center; }
.home-quote p { font-family: var(--font-serif); font-size: 20px; font-style: italic; color: var(--text-1); line-height: 1.4; margin: 0; }
.home-quote cite { display: block; font-size: 12px; font-style: normal; color: var(--text-3); letter-spacing: .06em; margin-top: 12px; }
.home-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; width: 100%; }
.home-cards.cards-2 { grid-template-columns: repeat(2, 1fr); max-width: 720px; }
/* Standard TG Hub card (Source/index.css .init-card / .lead-card). */
.home-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #5F7D09; padding: 14px 16px; cursor: pointer; transition: box-shadow .15s; display: flex; flex-direction: column; gap: 6px; }
.home-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.08); }
.home-card.soon { opacity: .5; cursor: default; border-left-color: var(--border); pointer-events: none; }
.home-card.soon:hover { box-shadow: none; }
.home-card-title { font-size: 14px; font-weight: 600; color: var(--text-1); line-height: 1.3; }
.home-card-sub { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.home-card-status { align-self: flex-start; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; background: var(--bg-2); }
.home-card-status.st-dev { color: var(--ok); }
.home-card-status.st-plan { color: var(--tg-slate); }
.home-head { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.home-cards.cards-1 { grid-template-columns: 1fr; max-width: 360px; margin: 0 auto; }
.home-note { font-size: 12px; color: var(--text-3); text-align: center; max-width: 620px; line-height: 1.5; }
/* ── Interventions (templates) ── */
#panel-interventions { display: none; flex: 1; background: var(--bg); overflow-y: auto; }
#panel-interventions.active { display: block; }
.iv-wrap { max-width: 940px; margin: 0 auto; padding: 28px 24px 48px; }
.iv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.iv-title { font-family: var(--font-serif); font-size: 22px; font-weight: 600; color: var(--text-1); }
.iv-tagline { font-size: 13px; color: var(--text-2); line-height: 1.5; max-width: 640px; margin: 6px 0 20px; }
.iv-list { display: grid; gap: 14px; }
.iv-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--tg-green); padding: 14px 16px; }
.iv-card.draft { border-left-color: var(--border-2); }
.iv-card-top { display: flex; align-items: flex-start; gap: 12px; }
.iv-name { font-family: var(--font-serif); font-size: 16px; font-weight: 600; color: var(--text-1); flex: 1 1 auto; }
.iv-name-block { flex: 1 1 auto; min-width: 0; }
.iv-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.iv-tag { font-size: 10px; padding: 2px 7px; letter-spacing: .04em; background: var(--bg-2); color: var(--text-2); }
.iv-tag.pre { background: var(--ok-l); color: var(--ok); }
.iv-tag.draft { background: var(--bg-2); color: var(--text-3); }
.iv-top-right { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.iv-sw { width: 30px; height: 16px; background: var(--border-2); position: relative; cursor: pointer; flex: 0 0 auto; }
.iv-sw.on { background: var(--tg-green); }
.iv-sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: #fff; transition: left .15s; }
.iv-sw.on::after { left: 16px; }
.iv-sw.locked { cursor: default; opacity: .55; }
.iv-card.off { opacity: .55; }
/* Intervention Templates left panel (TG Hub sidebar) */
#panel-interventions { padding: 0; }
.iv-sidebar { width: 220px; min-width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.iv-main { flex: 1; overflow-y: auto; }
.sb-search-wrap { padding: 18px 14px; }
.sb-search { width: 100%; box-sizing: border-box; border: 1px solid var(--border); padding: 5px 10px; font-size: 12px; font-family: inherit; outline: none; color: var(--text-1); background: var(--bg); }
.sb-search:focus { border-color: var(--tg-green); }
.sb-sep { height: 1px; background: var(--border); }
.sb-body { flex: 1; overflow-y: auto; }
.sb-list { display: flex; flex-direction: column; padding: 6px 0; }
.sb-list-item { padding: 5px 14px; font-size: 13px; color: var(--text-2); cursor: pointer; border-left: 3px solid transparent; }
.sb-list-item:hover { background: var(--bg-2); color: var(--text-1); }
.sb-list-item.off { color: var(--text-3); }
.rift-sidebar { width: 220px; min-width: 220px; flex: 0 0 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sb-sec-title { padding: 14px 14px 4px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.sb-list-item.sb-sub { padding-left: 28px; color: var(--text-3); }
.sb-list-item.active { background: var(--bg-2); color: var(--text-1); font-weight: 600; border-left-color: #5F7D09; }
[data-tip] { cursor: help; }
#iv-tip { position: fixed; display: none; background: rgba(28,28,30,0.92); color: #E8E6E0; font-size: 11px; padding: 7px 10px; pointer-events: none; z-index: 9998; line-height: 1.5; max-width: 250px; }
.iv-conf { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); flex: 0 0 auto; }
.iv-conf i { width: 9px; height: 9px; display: inline-block; }
.iv-sum { font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin: 8px 0 10px; }
.iv-evbar { display: flex; width: 160px; height: 8px; border: 1px solid var(--border-2); overflow: hidden; margin-bottom: 4px; }
.iv-evbar > div { height: 100%; }
.iv-params { border-top: 1px solid var(--border); margin-top: 8px; }
.iv-prow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bg-2); font-size: 12.5px; }
.iv-plabel { font-weight: 600; color: var(--text-1); flex: 0 0 120px; }
.iv-pval { font-family: var(--font-serif); color: var(--text-1); flex: 0 0 120px; }
.iv-pdot { width: 9px; height: 9px; flex: 0 0 auto; }
.iv-plevel { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); flex: 0 0 84px; }
.iv-pnote { font-size: 11.5px; color: var(--text-2); flex: 1 1 auto; line-height: 1.4; }
.iv-pacts { flex: 0 0 auto; display: flex; gap: 8px; }
.iv-acts { display: flex; gap: 12px; margin-top: 10px; }
.iv-linkbtn { background: none; border: none; color: var(--tg-green-d); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.iv-linkbtn:hover { text-decoration: underline; }
.iv-linkbtn.danger { color: var(--err); }
.iv-empty { text-align: center; color: var(--text-3); padding: 40px; font-size: 13px; }
.iv-field { margin-bottom: 10px; }
.iv-field label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-bottom: 4px; }
.iv-field textarea.modal-input { resize: vertical; }
@media (max-width: 720px) {
  .home-cards, .home-cards.cards-2 { grid-template-columns: 1fr; }
}

/* ── Forecasting sub-landing ── */
#panel-forecasting.show-landing .forecast-layout,
#panel-forecasting.show-landing .forecast-totals { display: none; }
.fc-landing { display: none; flex: 1; align-items: center; justify-content: center; padding: 40px 24px; overflow-y: auto; background: var(--bg); }
#panel-forecasting.show-landing .fc-landing { display: flex; }

/* ── Layout ── */
.main { display: flex; flex: 1; overflow: hidden; min-height: 0; position: relative; }
.mode-panel { display: none; flex: 1; overflow: hidden; position: relative; }
.mode-panel.active { display: flex; }
/* Overlay mode: detail panel floats over the map instead of pushing it */
body.overlay-detail #panel-accounting .detail-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 50; box-shadow: -4px 0 12px rgba(0,0,0,0.08); }

/* ── Sidebar ── */
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-title { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; margin-top: 4px; }
.sidebar-sep { border-top: 1px solid var(--border); margin: 10px 0; }
.param-block { margin-bottom: 10px; }
.param-label { font-size: 11px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.param-val { font-size: 11px; font-weight: 700; color: var(--tg-green); min-width: 36px; text-align: right; }
select.param-select { width: 100%; font-size: 11px; font-family: inherit; border: 1px solid var(--border); background: var(--bg-2); color: var(--text-1); padding: 3px 5px; outline: none; transition: border-color .12s; }
select.param-select:focus { border-color: var(--tg-green); }
.btn-block { width: 100%; }
.sidebar .btn { margin-top: 6px; }

/* ── Map area ── */
.map-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }
.map-zoom-controls { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 2px; z-index: 10; }
.map-zoom-btn { width: 28px; height: 28px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; font-family: inherit; }
.map-zoom-btn:hover { background: var(--bg-2); border-color: var(--border-2); color: var(--tg-green); }
.layer-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 5px 12px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; height: 34px; }
.layer-bar label { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.layer-select { font-size: 12px; font-family: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text-1); padding: 2px 6px; outline: none; transition: border-color .12s; }
.layer-select:focus { border-color: var(--tg-green); }
.basis-badge { font-size: 11px; font-weight: 500; letter-spacing: .02em; background: var(--bg-2); color: var(--tg-green); padding: 1px 10px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; line-height: 1.4; }
.basis-badge::before { content: 'Basis'; font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.map-container { flex: 1; position: relative; overflow: hidden; background: #e8eedc; }
#map-svg { width: 100%; height: 100%; }
.region-path { stroke: rgba(255,255,255,0.75); stroke-width: calc(1px * var(--stroke-scale, 1)); shape-rendering: geometricPrecision; cursor: pointer; transition: fill .12s; }
.region-path.selected { fill: var(--tg-terra); }
.region-path:hover { fill: var(--tg-slate); }
.context-path { fill: #dde2a8; stroke: rgba(255,255,255,0.5); stroke-width: calc(0.5px * var(--stroke-scale, 1)); shape-rendering: geometricPrecision; pointer-events: none; }
.region-label { font-size: var(--label-fontsize, 7.5px); fill: rgba(28,28,30,0.7); pointer-events: none; text-anchor: middle; dominant-baseline: middle; font-family: var(--font-sans); transition: fill .12s; }
.region-label.selected, .region-label.hovered { fill: #fff; }
.loading-msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }
.map-legend { position: absolute; bottom: 10px; right: 10px; background: rgba(255,255,255,0.93); border: 1px solid var(--border); padding: 8px 10px; font-size: 10px; }
.legend-title { font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.legend-swatch-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--text-2); }
.legend-swatch { width: 12px; height: 12px; flex-shrink: 0; }
.legend-gradient { display: block; height: 8px; width: 120px; margin-bottom: 3px; }
.legend-ends { display: flex; justify-content: space-between; color: var(--text-3); font-size: 9px; width: 120px; }
.tooltip { position: absolute; background: rgba(28,28,30,0.92); color: #E8E6E0; font-size: 11px; padding: 7px 10px; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 20; line-height: 1.5; }
.caveat-bar { background: var(--bg-2); border-top: 1px solid var(--border); padding: 4px 14px; font-size: 10px; color: var(--text-3); line-height: 1.4; flex-shrink: 0; }

/* ── Detail panel ── */
.detail-panel { width: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--border); flex-shrink: 0; transition: width .2s; display: flex; flex-direction: column; }
.detail-panel.open { width: 280px; }
.detail-inner { padding: 14px 13px; overflow-y: auto; height: 100%; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.detail-country-label { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.detail-name { font-family: var(--font-serif); font-size: 15px; font-weight: 600; line-height: 1.2; }
.detail-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.detail-sep { border-top: 1px solid var(--border); margin: 11px 0; }
.detail-section-title { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--text-2); }
.kv-val { font-weight: 600; color: var(--text-1); text-align: right; max-width: 55%; }
.kv-val.hi { color: var(--tg-green); }
.kv-val.med { color: var(--warn); }
.kv-val.lo { color: var(--err); }
.accounting-card { background: var(--bg-2); padding: 8px 9px; margin-bottom: 6px; border-left: 3px solid var(--border-2); }
.accounting-card.official { border-left-color: var(--tg-green); }
.accounting-card.adjusted { border-left-color: var(--tg-terra); }
.accounting-card.verified { border-left-color: var(--ok); }
.ac-basis { font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.ac-ha { font-size: 16px; font-weight: 700; color: var(--text-1); line-height: 1; }
.ac-ha-label { font-size: 9px; color: var(--text-3); margin-top: 1px; }
.ac-factors { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.ac-factor { font-size: 9px; background: rgba(255,255,255,0.7); padding: 1px 5px; color: var(--text-2); }
.ac-confidence { font-size: 9px; font-weight: 700; margin-top: 4px; }
.ac-confidence.hi { color: var(--ok); }
.ac-confidence.med { color: var(--warn); }
.ac-confidence.lo { color: var(--err); }
.source-card { background: var(--bg-2); padding: 7px 9px; margin-bottom: 5px; }
.source-title { font-size: 11px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.source-meta { font-size: 10px; color: var(--text-3); }
.readiness-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 3px 9px; margin-bottom: 10px; }
.readiness-badge.ready { background: var(--ok-l); color: var(--ok); }
.readiness-badge.caution { background: var(--warn-l); color: var(--warn); }
.readiness-badge.insufficient { background: var(--err-l); color: var(--err); }

/* ── Forecasting mode ── */
#panel-forecasting { flex-direction: column; }
.forecast-layout { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.forecast-sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 11px; overflow-y: auto; flex-shrink: 0; }
.forecast-map-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }
#fc-map-svg { width: 100%; height: 100%; }
.forecast-main { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid var(--border); }
.forecast-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 14px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.forecast-title-input { font-size: 13px; font-weight: 600; font-family: inherit; border: none; background: none; color: var(--text-1); flex: 1; outline: none; border-bottom: 1px solid transparent; }
.forecast-title-input:focus { border-bottom-color: var(--tg-green); }
.forecast-title-input::placeholder { color: var(--text-3); font-weight: 400; }
.forecast-actions { display: flex; gap: 6px; margin-left: auto; }
.forecast-body { flex: 1; overflow-y: auto; padding: 14px; }
.measure-card { background: var(--surface); border: 1px solid var(--border); padding: 13px 14px; margin-bottom: 10px; position: relative; }
.measure-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.measure-card-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.measure-card-del { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1; padding: 0 2px; }
.measure-card-del:hover { color: var(--err); }
.measure-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.mf { display: flex; flex-direction: column; gap: 3px; }
.mf label { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.mf select, .mf input { font-size: 12px; font-family: inherit; border: 1px solid var(--border); background: var(--bg-2); color: var(--text-1); padding: 4px 6px; }
.mf input[type=number] { width: 100%; }
.measure-outputs { background: var(--bg-2); padding: 8px 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mo-stat { text-align: center; }
.mo-val { font-size: 13px; font-weight: 700; color: var(--tg-green); line-height: 1.1; }
.mo-lbl { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }
.mo-val.warn { color: var(--warn); }
.add-measure-btn { background: none; border: 1px dashed var(--border-2); width: 100%; padding: 12px; font-size: 12px; color: var(--text-3); cursor: pointer; font-family: inherit; }
.add-measure-btn:hover { background: var(--bg-2); color: var(--text-2); border-color: var(--tg-green); }
.forecast-totals { background: var(--bg-2); border-top: 1px solid var(--border); padding: 8px 14px; display: flex; gap: 24px; flex-shrink: 0; align-items: center; flex-wrap: wrap; min-height: 44px; }
.ft-stat { display: flex; flex-direction: column; }
.ft-lbl { font-size: 8px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.ft-val { font-size: 14px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.ft-val.green { color: var(--tg-green); }
.ft-caveat { font-size: 10px; color: var(--text-3); margin-left: auto; max-width: 300px; line-height: 1.4; }
.region-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); font-size: 11px; padding: 2px 7px; margin: 2px 2px 2px 0; }
.fc-saved-item { padding: 6px 8px; cursor: pointer; border: 1px solid var(--border); background: var(--bg-2); margin-bottom: 4px; }
.fc-saved-item:hover { background: var(--surface); border-color: var(--border-2); }
.fc-saved-item.selected { border-left: 3px solid var(--tg-green); }
.fc-saved-name { font-size: 11px; font-weight: 600; color: var(--text-1); line-height: 1.2; }
.fc-saved-meta { font-size: 10px; color: var(--text-3); margin-top: 1px; }
.fc-saved-empty { font-size: 11px; color: var(--text-3); padding: 4px 0; }
.home-card.disabled { cursor: not-allowed; opacity: .5; pointer-events: none; }
.region-chip-del { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 12px; line-height: 1; padding: 0 1px; }
.region-chip-del:hover { color: var(--err); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.assumption-detail { font-size: 10px; color: var(--text-3); line-height: 1.6; margin-top: 4px; }
.confidence-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; text-transform: uppercase; }
.confidence-badge.High { background: var(--ok-l); color: var(--ok); }
.confidence-badge.Medium { background: var(--warn-l); color: var(--warn); }
.confidence-badge.Low { background: var(--err-l); color: var(--err); }

/* ── Strategy Drafts mode ── */
.drafts-layout { flex: 1; display: flex; overflow: hidden; }
.drafts-list { width: 280px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
.drafts-list-header { padding: 12px 13px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drafts-list-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.draft-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.draft-item:hover { background: var(--bg); }
.draft-item.selected { background: var(--bg-2); border-left: 3px solid var(--tg-green); }
.draft-item-name { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 3px; }
.draft-item-meta { font-size: 10px; color: var(--text-3); }
.draft-detail { flex: 1; overflow-y: auto; padding: 24px 28px; }
.draft-detail-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-3); font-size: 13px; }
.draft-headline { font-family: var(--font-serif); font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.draft-sub { font-size: 11px; color: var(--text-3); margin-bottom: 20px; }
.draft-kpi-row { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.draft-kpi { background: var(--bg-2); padding: 12px 14px; min-width: 120px; }
.draft-kpi-val { font-size: 20px; font-weight: 700; color: var(--tg-green); line-height: 1; }
.draft-kpi-lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }
.draft-section-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; margin-top: 20px; }
.draft-measure-card { border: 1px solid var(--border); padding: 11px 13px; margin-bottom: 8px; }
.draft-measure-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.draft-caveat { background: var(--bg-2); border-left: 3px solid var(--border-2); padding: 9px 12px; font-size: 11px; color: var(--text-2); line-height: 1.6; margin-top: 20px; }

/* ── Hamburger menu ── */
.hmenu-overlay { position: fixed; inset: 0; z-index: 400; display: flex; justify-content: flex-end; opacity: 0; pointer-events: none; transition: opacity .2s; }
.hmenu-overlay.open { opacity: 1; pointer-events: all; }
.hmenu-bg { position: absolute; inset: 0; background: rgba(28,28,30,.4); }
.hmenu { position: relative; width: 240px; background: var(--dark-panel); height: 100%; display: flex; flex-direction: column; padding: 20px 0; transform: translateX(100%); transition: transform .25s ease; }
.hmenu-overlay.open .hmenu { transform: translateX(0); }
.hmenu-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.4); padding: 4px 20px 14px; }
.hmenu-item { display: flex; align-items: center; padding: 3px 20px; cursor: pointer; color: rgba(255,255,255,.7); font-size: 13px; transition: all .15s; }
.hmenu-item:hover { background: var(--dark-panel-hover); color: #fff; }
.hmenu-item.soon { opacity: .4; cursor: default; pointer-events: none; }
.hmenu-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 20px; cursor: pointer; color: rgba(255,255,255,.7); font-size: 13px; transition: all .15s; }
.hmenu-toggle:hover { background: var(--menu-bg-hover); color: #fff; }
.hmenu-switch { width: 28px; height: 14px; background: rgba(255,255,255,.18); position: relative; flex-shrink: 0; transition: background .15s; }
.hmenu-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; background: #fff; transition: left .15s; }
.hmenu-switch.on { background: var(--tg-green); }
.hmenu-switch.on::after { left: 16px; }
.hmenu-sep { height: 1px; background: var(--dark-panel-sep); margin: 8px 20px; }
.hmenu-section { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.35); padding: 14px 20px 4px; }
.hmenu-footer { padding: 14px 20px; border-top: 1px solid var(--menu-sep); display: flex; align-items: center; gap: 10px; margin-top: auto; }
.lang-label { font-size: 11px; color: rgba(255,255,255,.45); }
.lang-toggle { display: flex; }
.lang-btn { background: none; border: 1px solid var(--menu-sep); color: rgba(255,255,255,.6); padding: 4px 12px; cursor: pointer; font-size: 12px; font-weight: 600; font-family: inherit; }
.lang-btn:first-child { border-right: none; }
.lang-btn.active { background: var(--tg-green); color: #fff; border-color: var(--tg-green); }

/* ── Modals ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 9999; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); padding: 28px 24px; min-width: 320px; max-width: 460px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.modal-box-lg { background: var(--surface); padding: 28px 28px; max-width: 760px; width: 95%; max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.18); position: relative; }
.pane-help-box { max-width: 860px; }
.pane-help-body h3 { font-family: var(--font-serif); font-size: 14.5px; font-weight: 600; margin: 16px 0 5px; color: var(--text-1); }
.pane-help-body h3:first-child { margin-top: 0; }
.pane-help-body p { font-size: 13.5px; color: var(--text-2); line-height: 1.6; margin: 0 0 8px; }
.pane-help-body b { color: var(--text-1); }
.pane-help-body .help-lead { color: var(--text-1); margin: 0 0 14px; }
.pane-help-body .help-formula { font-size: 13px; color: var(--text-1); background: var(--bg-2); padding: 9px 12px; margin: 6px 0; line-height: 1.5; }
/* Standard top-right close button for help-style modals (SVG cross, absolute corner) */
.modal-close-x { position: absolute; top: 10px; right: 10px; background: none; border: none; cursor: pointer; padding: 6px; line-height: 0; color: var(--text-3); transition: color .12s, background .12s; }
.modal-close-x:hover { color: var(--text-1); background: var(--bg-2); }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.modal-close-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.modal-close-btn { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-3); line-height: 1; padding: 0 2px; }
.modal-close-btn:hover { color: var(--text-1); }
.content-h2 { font-family: var(--font-serif); font-size: 22px; font-weight: 600; color: var(--text-1); }
.content-p { font-size: 13px; color: var(--text-2); line-height: 1.65; margin-top: 10px; }
.content-h3 { font-size: 11px; font-weight: 700; color: var(--text-1); margin-top: 20px; text-transform: uppercase; letter-spacing: .06em; }
.content-list { list-style: square; margin: 8px 0 0; padding-left: 20px; }
.content-list li { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-top: 4px; }
.home-lead { font-size: 13.5px; color: var(--text-2); line-height: 1.6; max-width: 720px; margin: 0; }
.home-lead-link { display: inline-block; margin-top: 8px; color: #5F7D09; cursor: pointer; font-weight: 600; }
.home-lead-link:hover { text-decoration: underline; }
.modal-input { width: 100%; border: 1px solid var(--border); padding: 8px 10px; font-size: 13px; background: var(--bg); color: var(--text-1); margin-bottom: 10px; font-family: inherit; }
.modal-input:focus { outline: none; border-color: var(--tg-green); }
.modal-note { font-size: 11px; color: var(--text-3); margin-bottom: 12px; line-height: 1.5; }

/* Auth modal (mirrors TG Hub login screen) */
.auth-brand-logo { display: flex; align-items: center; gap: 10px; }
.auth-brand-icon { height: 32px; width: 32px; display: block; }
.auth-brand-text { font-family: var(--font-serif); font-size: 22px; font-weight: 600; color: var(--text-1); line-height: 1; letter-spacing: .01em; }
.auth-subtitle { font-size: 12px; color: var(--text-3); letter-spacing: .04em; margin-top: 6px; }
.auth-divider { height: 1px; background: var(--border); margin: 18px 0; }
.auth-field { margin-bottom: 12px; }
.auth-field-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); margin-bottom: 5px; }
.auth-field .modal-input { margin-bottom: 0; }
.modal-row { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.modal-btn-p { flex: 1; background: #2F3538; color: #fff; border: 1px solid #4D5C64; padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600; }
.modal-btn-p:hover { background: var(--tg-green); border-color: var(--tg-green); }
.modal-btn-c { background: none; border: 1px solid var(--border); color: var(--text-2); padding: 8px 14px; cursor: pointer; font-size: 13px; font-family: inherit; }
.modal-btn-c:hover { background: var(--bg-2); }
.modal-status { font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.modal-status.ok  { color: var(--ok); }
.modal-status.err { color: var(--err); }

/* ── Lens picker (per mode panel) ── */
.mode-panel { position: relative; }
/* Default: standalone overlay (used by Forecasting + Planning until they get a top-strip restructure) */
.lens-picker-bar { position: absolute; top: 6px; right: 12px; z-index: 5; display: inline-flex; gap: 0; }
/* When embedded inside an existing top strip (.layer-bar in Accounting, .forecast-header in Forecasting), drop the overlay positioning */
.layer-bar > .lens-picker-bar,
.forecast-header > .lens-picker-bar { position: static; }
.lens-tab { font-size: 11px; font-weight: 500; padding: 3px 10px; cursor: pointer; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); font-family: inherit; line-height: 1.45; letter-spacing: .01em; white-space: nowrap; transition: all .12s; height: 22px; box-sizing: border-box; }
.lens-picker-bar > .lens-tab + .lens-tab { border-left: 0; }
.lens-tab:hover:not(.active) { color: var(--text-1); background: var(--bg-2); }
.lens-tab.active { background: var(--tg-green); color: #fff; border-color: var(--tg-green); position: relative; z-index: 1; }
.lens-pane { display: contents; }
.lens-pane:not(.active) { display: none !important; }
/* CFSI lens-pane needs its own column layout so its layer-bar (top strip with lens picker) sits above cfsi-shell */
.lens-pane.active[data-lens="cfsi-food-system"] { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
/* Planning panel uses flex-column so the lens-pane's layer-bar sits above drafts-layout */
#panel-planning.active { flex-direction: column; }

/* ── CFSI shell (used inside cfsi-food-system lens panes) ── */
.cfsi-shell { padding: 32px 32px 48px; max-width: 1100px; margin: 0 auto; width: 100%; box-sizing: border-box; flex: 1; overflow-y: auto; }
/* Flex-row body so the lens-pane can have a sidebar on the left + main content area */
.cfsi-body { display: flex; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.cfsi-sidebar-note { font-size: 12px; color: var(--text-2); line-height: 1.55; padding: 4px 4px 0; }
.cfsi-sidebar-note strong { color: var(--text-1); font-weight: 600; }
.cfsi-page-title { font-family: var(--font-serif); font-size: 24px; font-weight: 600; color: var(--text-1); margin: 0 0 8px; }
.cfsi-page-sub { font-size: 13px; color: var(--text-2); margin: 0 0 28px; line-height: 1.55; max-width: 760px; }
.cfsi-section-h { font-family: var(--font-serif); font-size: 16px; font-weight: 600; color: var(--text-1); margin: 28px 0 10px; }

/* ── CFSI Accounting: leakage matrix ── */
.cfsi-matrix { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.cfsi-matrix th, .cfsi-matrix td { padding: 11px 12px; text-align: left; font-size: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cfsi-matrix th { font-weight: 600; color: var(--text-2); background: var(--bg-2); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
.cfsi-matrix th:first-child { width: 240px; }
.cfsi-matrix td.chain-name { font-weight: 600; color: var(--text-1); font-size: 13px; line-height: 1.3; }
.cfsi-matrix td.chain-name .chain-tag { display: block; font-size: 10px; font-weight: 500; color: var(--text-3); margin-left: 0; margin-top: 3px; text-transform: uppercase; letter-spacing: .05em; }
.cfsi-matrix tr:last-child td { border-bottom: none; }
.cfsi-cell-rating { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border: 1px solid var(--border); margin-bottom: 4px; }
.cfsi-cell-rating.high { color: var(--err); border-color: var(--err); background: var(--err-l); }
.cfsi-cell-rating.med  { color: var(--text-2); border-color: var(--border-2); background: var(--bg-2); }
.cfsi-cell-rating.low  { color: var(--ok); border-color: var(--ok); background: var(--ok-l); }
.cfsi-cell-rating.unknown { color: var(--text-3); border-color: var(--border); background: transparent; }
.cfsi-cell-note { display: block; font-size: 11px; color: var(--text-3); line-height: 1.35; }
/* Click-to-edit affordance on data cells */
.cfsi-matrix tbody td.cfsi-cell-editable { cursor: pointer; transition: background .12s; }
.cfsi-matrix tbody td.cfsi-cell-editable:hover { background: var(--bg-2); }

/* Help icon (used inline next to titles to open a help modal) */
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: var(--bg-2); color: var(--text-2); font-size: 11px; font-weight: 700; cursor: pointer; border: 1px solid var(--border); margin-left: 8px; line-height: 1; vertical-align: middle; font-family: inherit; padding: 0; transition: all .12s; }
.help-icon:hover { background: var(--tg-green); color: #fff; border-color: var(--tg-green); }
.cfsi-page-title .help-icon { width: 22px; height: 22px; font-size: 12px; }
.cfsi-source-ref { font-size: 10px; color: var(--text-3); margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); text-transform: uppercase; letter-spacing: .04em; }
/* Help modal content styles */
.help-content h3 { font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--text-1); margin: 18px 0 8px; }
.help-content h3:first-child { margin-top: 0; }
.help-content p, .help-content ul { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0 0 10px; }
.help-content ul { padding-left: 18px; }
.help-content ul li { margin-bottom: 6px; }
.help-content ul li strong { color: var(--text-1); }
.help-content .help-source { font-size: 11px; color: var(--text-3); font-style: italic; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── CFSI Strategic Planning: pilot draft ── */
.cfsi-pilot-card { background: var(--surface); border: 1px solid var(--border); padding: 22px 24px; margin-top: 12px; }
.cfsi-pilot-name { font-family: var(--font-serif); font-size: 18px; font-weight: 600; color: var(--text-1); margin: 0 0 4px; }
.cfsi-pilot-context { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.cfsi-pilot-desc { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0 0 18px; }
.cfsi-pilot-conditions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; margin-top: 16px; }
.cfsi-condition { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg-2); border-left: 2px solid var(--border-2); font-size: 12px; color: var(--text-2); }
.cfsi-condition.met { border-left-color: var(--ok); color: var(--text-1); }
.cfsi-condition .cond-label { flex: 1; }
.cfsi-condition .cond-status { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.cfsi-condition.met .cond-status { color: var(--ok); }

/* ── CFSI Forecasting placeholder ── */
.cfsi-coming-soon { text-align: center; padding: 60px 24px; color: var(--text-3); max-width: 520px; margin: 0 auto; }
.cfsi-coming-soon h2 { font-family: var(--font-serif); font-size: 18px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; }
.cfsi-coming-soon p { font-size: 13px; line-height: 1.55; margin: 0; }

/* ── CFSI loading + empty states ── */
.cfsi-matrix-loading,
.cfsi-pilot-loading { padding: 22px 14px; text-align: center; color: var(--text-3); font-size: 12px; font-style: italic; }
.cfsi-pilot-empty { background: var(--bg-2); border: 1px dashed var(--border-2); padding: 32px 28px; text-align: center; margin-top: 12px; }
.cfsi-pilot-empty-text { font-size: 13px; color: var(--text-2); margin: 0 0 14px; line-height: 1.5; }
.cfsi-pilot-error { padding: 14px 16px; background: var(--err-l); color: var(--err); border: 1px solid var(--err); font-size: 12px; margin-top: 12px; }
