@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700&display=swap');

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #F6F5F5;
  font-family: Arial, "Helvetica Neue", sans-serif;
  color: #232323;
}
#app { min-height: 100vh; }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }

.loading { padding: 40px; color: #8A9299; font-size: 13px; }

/* ---------- buttons ---------- */
.toolbtn {
  border: none; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: transform .1s ease, opacity .15s ease;
  font-family: Arial, sans-serif; white-space: nowrap;
  background: #10A45E; color: #fff;
}
.toolbtn:active { transform: scale(0.97); }
.toolbtn:hover { opacity: 0.9; }
.toolbtn:disabled { opacity: 0.5; cursor: default; }
.toolbtn.ghost { background: rgba(255,255,255,0.14); color: #fff; }
.toolbtn.subtle { background: #F6F5F5; color: #10A45E; }
.toolbtn.subtle-neutral { background: #F6F5F5; color: #232323; }
.toolbtn.cta { background: #2770A4; color: #fff; }
.toolbtn.cta-on-brand { background: #fff; color: #10A45E; }
.toolbtn.full-width { width: 100%; }
.toolbtn.small { padding: 6px 9px; font-size: 11px; }
.icon-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; color: #8A9299; }
.link-btn { border: none; background: transparent; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.link-btn.danger { color: #C00000; }

/* ---------- toolbar ---------- */
.toolbar {
  background: #10A45E; color: #fff; padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.toolbar-left { display: flex; align-items: center; gap: 14px; }
.toolbar-left .toolbtn { padding: 9px 11px; }
.toolbar-title { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.toolbar-subtitle { font-size: 12.5px; opacity: 0.78; margin-top: 2px; }
.toolbar-right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; background: rgba(0,0,0,0.15); border-radius: 10px; padding: 3px; }
.tabbtn {
  border: none; background: transparent; padding: 8px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; border-radius: 8px; font-family: Arial, sans-serif; color: rgba(255,255,255,0.75);
}
.tabbtn.active { background: rgba(255,255,255,0.18); color: #fff; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- KPI row ---------- */
.kpi-row { display: flex; gap: 12px; padding: 18px 28px 0; flex-wrap: wrap; }
.kpi-pill {
  background: #fff; border-radius: 10px; padding: 10px 16px; display: flex; align-items: center; gap: 9px;
  box-shadow: 0 1px 3px rgba(33,48,56,0.08);
}
.kpi-label { font-size: 13px; color: #595959; }
.kpi-count { font-size: 15px; font-weight: 800; }
.status-dot { border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ---------- filter panel ---------- */
.filter-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(33,48,56,0.15);
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.filter-backdrop.visible { opacity: 1; pointer-events: auto; }
.filter-panel {
  position: fixed; top: 0; left: 0; height: 100vh; width: 240px; background: #fff;
  box-shadow: 2px 0 16px rgba(33,48,56,0.15); z-index: 90; padding: 20px 18px;
  transform: translateX(-100%); transition: transform .18s ease; overflow-y: auto;
}
.filter-panel.open { transform: translateX(0); }
.filter-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.filter-panel-title { font-size: 15px; font-weight: 800; color: #10A45E; }
.title-filter { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.title-filter-mode {
  padding: 7px 10px; border-radius: 8px; border: 1px solid #D8DCDE;
  font-size: 12.5px; font-family: Arial, sans-serif; color: #232323; background: #fff; cursor: pointer;
}
.title-filter-input-wrap { position: relative; display: flex; align-items: center; }
.title-filter-input {
  flex: 1; padding: 8px 30px 8px 10px; border-radius: 8px; border: 1px solid #D8DCDE;
  font-size: 12.5px; font-family: Arial, sans-serif; color: #232323; background: #fff; width: 100%;
}
.title-filter-input:focus, .title-filter-mode:focus {
  outline: none; border-color: #1ADE82; box-shadow: 0 0 0 3px rgba(26,222,130,0.18);
}
.title-filter-clear { position: absolute; right: 4px; border: none; background: transparent; cursor: pointer; color: #8A9299; }
.title-filter-clear[hidden] { display: none; }
/* Small dot on the toolbar's filter button whenever anything is narrowing the
   rows on screen — a persisted text filter is otherwise invisible until you
   open the panel, which reads as "rows have gone missing". */
.toolbtn.filters-active { position: relative; }
.toolbtn.filters-active::after {
  content: ""; position: absolute; top: -2px; right: -2px;
  width: 7px; height: 7px; border-radius: 50%; background: #E4572E; border: 1.5px solid #fff;
}

.filter-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.linkbtn {
  border: none; background: transparent; padding: 0; cursor: pointer;
  font-family: Arial, sans-serif; font-size: 11px; font-weight: 700; color: #10A45E;
}
.linkbtn:hover { text-decoration: underline; }
/* Owner lists in particular can run long — cap and scroll rather than pushing
   Date range and Status off the bottom of the panel. */
.facet-list { max-height: 188px; overflow-y: auto; margin-bottom: 4px; }
.facet-swatch { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.facet-swatch-none { background: #D8DCDE; }

.data-health { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 28px 0; }
.data-health-label { font-size: 11px; font-weight: 700; color: #8A9299; text-transform: uppercase; letter-spacing: 0.04em; }
.data-health-ok { font-size: 12px; color: #8A9299; }
.health-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid #F0D9C8; background: #FFF6F0; color: #8A5A3C;
  border-radius: 999px; padding: 4px 11px; font-family: Arial, sans-serif; font-size: 11.5px;
}
.health-chip:hover { border-color: #E4572E; color: #E4572E; }
.health-chip.active { background: #E4572E; border-color: #E4572E; color: #fff; }
.health-count { font-weight: 700; }

.filter-section-label { font-size: 11px; font-weight: 700; color: #8A9299; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.filter-divider { height: 1px; background: #F0F1F2; margin: 0 0 16px; }
.scope-list { margin-bottom: 4px; }
.scope-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; font-size: 13.5px; }
.scope-row input { accent-color: #10A45E; width: 15px; height: 15px; }
.scope-active { color: #232323; font-weight: 700; }
.scope-inactive { color: #595959; }
.scope-hint { font-size: 11px; color: #B9C0C4; margin: 4px 0 18px; padding-left: 4px; line-height: 1.4; }
.status-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; cursor: pointer; font-size: 13.5px; }
.status-row input { accent-color: #10A45E; width: 15px; height: 15px; }
.status-count { margin-left: auto; color: #B9C0C4; font-size: 12px; }

/* ---------- cards / empty state ---------- */
.card { margin: 18px 28px 32px; background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(33,48,56,0.08); overflow: hidden; }
.empty-state { padding: 56px 24px; text-align: center; color: #8A9299; }
.empty-title { font-size: 15px; font-weight: 700; color: #232323; margin-bottom: 6px; }
.empty-body { font-size: 13px; margin-bottom: 16px; }

/* ---------- Timeline / Gantt ---------- */
.timeline-card { overflow: visible; }
/* This is the one and only vertical scroll container for the Gantt view. */
.timeline-body { max-height: 70vh; overflow-y: auto; overflow-x: hidden; }

/* The header row is a DIRECT child of .timeline-body — deliberately not
   nested inside .timeline-scroll. Per the CSS overflow spec, an element with
   overflow-x:auto (like .timeline-scroll) counts as a scroll container for
   BOTH axes regardless of its overflow-y value, so anything sticky inside it
   resolves against *it*, not .timeline-body — and since .timeline-scroll
   never actually has vertical overflow of its own, that sticky never
   triggers. Keeping the header entirely outside .timeline-scroll avoids the
   problem outright, at the cost of needing to mirror horizontal scroll
   position via JS (see wireTimelineInteractions) instead of getting it for
   free from shared DOM nesting. */
.timeline-header-row { display: flex; position: sticky; top: 0; z-index: 6; background: #fff; }
.timeline-header-spacer {
  flex-shrink: 0; height: 56px; border-bottom: 1px solid #EEF0F1; border-right: 1px solid #EEF0F1;
  display: flex; align-items: center; padding-left: 16px;
  font-size: 11px; font-weight: 700; color: #8A9299; text-transform: uppercase; letter-spacing: 0.04em;
  background: #fff;
}
.timeline-header-clip { flex: 1; overflow-x: hidden; } /* never directly scrolled by the user - JS keeps its scrollLeft mirrored to #timeline-scroll */

.timeline-layout { display: flex; }
.label-col { flex-shrink: 0; border-right: 1px solid #EEF0F1; position: relative; }
.row-label {
  height: var(--row-height, 72px); display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 16px; border-bottom: 1px solid #F4F5F6; position: relative;
}
.row-label-main { min-width: 0; }
.row-label-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 4px; min-width: 0; }
/* Truncation moved off .row-label-name onto the title itself, so a long name
   gets the ellipsis while the ↗ beside it stays visible. */
.row-label-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row-label-link { color: inherit; text-decoration: none; cursor: pointer; }
.row-label-link:hover { color: #10A45E; text-decoration: underline; }
.row-label-link:focus-visible { outline: 2px solid #1ADE82; outline-offset: 2px; border-radius: 3px; }
.row-label-ext { flex-shrink: 0; font-size: 10px; font-weight: 400; color: #B9C0C4; }
.row-label:hover .row-label-ext { color: #10A45E; }
.row-label-id-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.row-label-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.row-label-id { font-size: 10px; color: #B9C0C4; }
.row-label-dates { font-size: 10.5px; color: #8A9299; margin-top: 6px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-label-dates-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.results-btn {
  flex-shrink: 0; display: inline-block; padding: 1px 7px; border-radius: 999px;
  border: 1px solid #CDEBDC; background: #F1FBF6; color: #10A45E;
  font-family: Arial, sans-serif; font-size: 10px; font-weight: 700;
  text-decoration: none; line-height: 15px; white-space: nowrap;
}
.results-btn:hover { background: #10A45E; border-color: #10A45E; color: #fff; }
.results-btn:focus-visible { outline: 2px solid #1ADE82; outline-offset: 1px; }
.row-delete {
  border: none; background: transparent; color: #B9C0C4; font-size: 16px; cursor: pointer;
  flex-shrink: 0; padding: 4px; opacity: 0; transition: opacity .15s ease;
}
.row-label:hover .row-delete { opacity: 1; }

.resize-handle { width: 5px; flex-shrink: 0; align-self: stretch; cursor: col-resize; background: transparent; transition: background .12s ease; }
.resize-handle:hover { background: #10A45E; }

.timeline-scroll { flex: 1; overflow-x: auto; overflow-y: visible; }
.timeline-scroll::-webkit-scrollbar { height: 8px; }
.timeline-scroll::-webkit-scrollbar-thumb { background: #D8DCDE; border-radius: 8px; }
.month-header { display: flex; height: 36px; border-bottom: 1px solid #EEF0F1; background: #fff; }
.day-subheader { height: 20px; border-bottom: 1px solid #EEF0F1; background: #fff; }
.flex-subheader { display: flex; }
.day-cell { flex-shrink: 0; text-align: center; font-size: 10px; color: #8A9299; line-height: 20px; }
.weekday-subheader { height: 18px; border-bottom: 1px solid #F4F5F6; background: #fff; }
.weekday-cell { flex-shrink: 0; text-align: center; font-size: 9px; font-weight: 700; color: #B9C0C4; line-height: 18px; letter-spacing: 0.02em; }
.abs-subheader { position: relative; }
.week-label { position: absolute; top: 0; font-size: 10px; color: #8A9299; line-height: 20px; padding-left: 2px; white-space: nowrap; }

.timeline-controls {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid #EEF0F1;
}
.zoom-tabs { display: flex; background: #F6F5F5; border-radius: 8px; padding: 3px; }
.zoom-btn { border: none; background: transparent; padding: 6px 14px; font-size: 12.5px; font-weight: 700; color: #595959; border-radius: 6px; cursor: pointer; }
.zoom-btn.active { background: #10A45E; color: #fff; }
.timeline-controls { flex-wrap: wrap; }
.colour-by { display: flex; align-items: center; gap: 7px; }
.colour-by-label { font-size: 12.5px; color: #8A9299; white-space: nowrap; }
.surface-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 16px; margin-top: -4px;
}
.surface-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: #595959; }
.surface-chip-unset { color: #8A9299; }
.surface-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

.timeline-sort { display: flex; align-items: center; gap: 7px; margin-right: auto; }
.timeline-sort-label { font-size: 12.5px; color: #8A9299; white-space: nowrap; }
.timeline-sort-select {
  padding: 6px 10px; border-radius: 8px; border: 1px solid #D8DCDE;
  font-size: 12.5px; font-family: Arial, sans-serif; color: #232323; background: #fff; cursor: pointer;
}
.timeline-sort-select:focus { outline: none; border-color: #1ADE82; box-shadow: 0 0 0 3px rgba(26,222,130,0.18); }
.sort-dir-btn {
  border: 1px solid #D8DCDE; background: #fff; border-radius: 8px; cursor: pointer;
  width: 30px; height: 30px; font-size: 10px; color: #595959; line-height: 1; padding: 0;
}
.sort-dir-btn:hover:not(:disabled) { background: #F6F5F5; }
.sort-dir-btn:disabled { opacity: 0.35; cursor: default; }
.timeline-sort-note { font-size: 11.5px; color: #8A9299; white-space: nowrap; cursor: help; }
.weekend-toggle { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #595959; cursor: pointer; }
.weekend-toggle input { accent-color: #10A45E; width: 14px; height: 14px; }
.month-seg { display: flex; align-items: center; padding-left: 8px; font-size: 12px; font-weight: 700; color: #10A45E; flex-shrink: 0; background: #fff; }
.bars-area { position: relative; }
.dependency-layer { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; z-index: 1; }
.dependency-line { fill: none; stroke: #000; stroke-width: 2; }
.week-line { position: absolute; top: 0; bottom: 0; width: 1px; background: #F0F1F2; }
.today-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #F3F208; z-index: 3; }
.today-dot { position: absolute; top: -8px; left: -4px; width: 8px; height: 8px; border-radius: 50%; background: #F3F208; }
/* Bar rows stack in normal flow, exactly like the .row-label divs in the
   label column — same height, same box model, same mechanism. They used to be
   absolutely positioned at a JS-computed top: i * ROW_HEIGHT, which only
   matched the label column by coincidence; any padding, border or content
   change on either side would have silently pulled the two out of register
   with nothing to catch it. Now the browser stacks both columns identically,
   so they cannot drift apart. */
.bar-row { position: relative; height: var(--row-height, 72px); border-bottom: 1px solid #F8F9F9; }
/* A bar that ends at a *planned* stop rather than a real one. The faded,
   striped tail is the whole point: it has to be obvious at a glance that the
   right-hand edge is a plan that may move, not a date something happened. */
.bar-scheduled::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 34%;
  border-radius: 0 7px 7px 0; pointer-events: none;
  background: repeating-linear-gradient(135deg,
    rgba(255,255,255,0.55) 0 4px, rgba(255,255,255,0) 4px 8px);
}
.bar-scheduled { border-right: 2px dashed rgba(35,35,35,0.35); }
/* Mirror of .bar-scheduled for the other end: this test hasn't started yet,
   so its left edge is a plan too. */
.bar-planned-start::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 34%;
  border-radius: 7px 0 0 7px; pointer-events: none;
  background: repeating-linear-gradient(135deg,
    rgba(255,255,255,0.55) 0 4px, rgba(255,255,255,0) 4px 8px);
}
.bar-planned-start { border-left: 2px dashed rgba(35,35,35,0.35); }
/* Scheduled stop already in the past, test still running. */
.bar-overdue { border-right: 2px solid #E4572E; }
/* Tick inside an overdue bar showing where it was meant to stop. */
.bar-missed-stop {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: #E4572E; border-radius: 1px; pointer-events: auto; cursor: help;
}
.date-scheduled { color: #595959; }
.date-overdue { color: #E4572E; font-weight: 700; }

.bar {
  position: absolute; border-radius: 7px; cursor: pointer;
  /* Vertically centred by CSS rather than a computed top offset, so the bar
     follows the row height automatically. */
  top: 50%; transform: translateY(-50%);
  transition: filter .12s ease, transform .12s ease;
}
.bar:hover { filter: brightness(1.06); transform: translateY(calc(-50% - 1px)); }
.bar-label {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Sheet / Notes tables ---------- */
.table-scroll { overflow-x: auto; }
.sheet-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.sheet-table thead tr { background: #10A45E; }
.sheet-table th { padding: 10px 8px; font-size: 11.5px; color: #fff; font-weight: 700; text-align: left; }
.th-num { width: 36px; font-size: 11px; color: rgba(255,255,255,0.7); text-align: center; }
.th-id { width: 110px; }
.th-date { width: 150px; }
.th-status { width: 140px; }
.th-surface { width: 130px; }
.th-link { width: 160px; }
.th-name-notes { width: 220px; }
.sheet-row td { border-bottom: 1px solid #F0F1F2; }
.row-num { text-align: center; font-size: 11.5px; color: #B9C0C4; }
.surface-cell { display: flex; align-items: center; gap: 2px; }
.surface-cell .cell-input { flex: 1; }
.conflict-flag { color: #C0392B; font-size: 13px; flex-shrink: 0; cursor: help; }
.cell-input {
  width: 100%; border: 1px solid transparent; background: transparent; padding: 7px 8px;
  font-size: 13px; font-family: Arial, sans-serif; color: #232323; border-radius: 6px; outline: none;
}
.cell-input:focus { border: 1px solid #1ADE82 !important; background: #fff !important; box-shadow: 0 0 0 3px rgba(26,222,130,0.18); }
.cell-input:hover { background: #E7F6EF; }
.cell-select { cursor: pointer; font-weight: 700; }
.row-delete-cell { text-align: center; width: 36px; }
.sheet-delete { border: none; background: transparent; color: #B9C0C4; font-size: 16px; cursor: pointer; opacity: 0; transition: opacity .15s ease; }
.sheet-row:hover .sheet-delete { opacity: 1; }
.table-footer { padding: 12px 16px; }
.sheet-controls { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #EEF0F1; }
.sheet-search-column-select {
  flex-shrink: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid #D8DCDE;
  font-size: 13px; font-family: Arial, sans-serif; color: #232323; background: #fff; cursor: pointer;
}
.sheet-search-input {
  flex: 1; max-width: 320px; padding: 8px 12px; border-radius: 8px; border: 1px solid #D8DCDE;
  font-size: 13px; font-family: Arial, sans-serif; outline: none;
}
.sheet-search-input:focus { border-color: #1ADE82; box-shadow: 0 0 0 3px rgba(26,222,130,0.18); }
.sheet-row-count { font-size: 12px; color: #8A9299; margin-left: auto; white-space: nowrap; }
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { background: rgba(255,255,255,0.12); }
.sortable-th.sorted { color: #fff; }
.sheet-empty-row { text-align: center; padding: 32px 16px; color: #8A9299; font-size: 13px; }

.notes-id-cell { padding: 10px 8px; font-size: 12px; color: #595959; vertical-align: top; }
.notes-name-cell { padding: 10px 8px; font-size: 13px; font-weight: 600; vertical-align: top; }
.notes-textarea-cell { padding: 6px 8px; }
.notes-textarea { resize: vertical; min-height: 40px; }

/* ---------- undo toast ---------- */
@keyframes shrinkBar { from { width: 100%; } to { width: 0%; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  opacity: 0.85;
  vertical-align: -2px;
  margin-right: 7px;
}
.toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 95;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; /* only the individual toast cards (children) should capture clicks */
}
.toast-stack > * { pointer-events: auto; }
.undo-toast {
  background: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(33,48,56,0.28);
  min-width: 320px; max-width: 90vw; overflow: hidden; animation: fadeIn .15s ease;
}
.undo-toast-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.undo-toast-text { flex: 1; font-size: 13px; color: #232323; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-btn { border: none; background: transparent; color: #10A45E; font-weight: 800; font-size: 13px; cursor: pointer; padding: 4px 8px; flex-shrink: 0; }
.undo-track { height: 4px; background: #F0F1F2; position: relative; }
.undo-fill { height: 100%; }

.message-toast {
  background: #232323; color: #fff; border-radius: 10px; box-shadow: 0 12px 32px rgba(33,48,56,0.28);
  min-width: 280px; max-width: 90vw; padding: 12px 16px; font-size: 13px;
  display: flex; align-items: center; gap: 10px; animation: fadeIn .15s ease;
}
.message-toast-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ---------- popover ---------- */
.overlay-scrim { position: fixed; inset: 0; z-index: 40; }
.popover {
  position: fixed; z-index: 50; background: #fff; border-radius: 10px;
  box-shadow: 0 10px 28px rgba(33,48,56,0.28); padding: 6px; min-width: 170px;
}
.popover-title {
  font-size: 10.5px; color: #8A9299; padding: 5px 8px 7px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 1px solid #F6F5F5; margin-bottom: 4px;
}
.popover-link {
  display: block; margin-top: 4px; padding: 7px 8px; border-top: 1px solid #F6F5F5;
  font-size: 12px; font-weight: 700; color: #10A45E; text-decoration: none; border-radius: 6px;
}
.popover-link:hover { background: #F6F5F5; text-decoration: underline; }
.popover-option {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: none;
  background: transparent; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: #232323; font-family: Arial, sans-serif;
}
.popover-option.active { background: #F6F5F5; font-weight: 700; }

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(33,48,56,0.45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s ease;
}
.modal-card { background: #fff; border-radius: 14px; padding: 24px; width: 400px; max-width: 100%; box-shadow: 0 20px 50px rgba(33,48,56,0.3); }
.modal-card.wide { width: 480px; }
.modal-title { font-size: 16px; font-weight: 800; color: #10A45E; margin-bottom: 6px; }
.modal-subtitle { font-size: 12.5px; color: #8A9299; margin-bottom: 16px; }
.field-label { display: block; font-size: 12px; font-weight: 700; color: #595959; margin-bottom: 4px; }
.modal-input { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid #D8DCDE; margin-bottom: 16px; font-size: 13px; font-family: Arial, sans-serif; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; }
.modal-footer-right { display: flex; gap: 8px; }

.modal-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.error-dot { width: 10px; height: 10px; border-radius: 50%; background: #C0392B; flex-shrink: 0; display: inline-block; }
.modal-body-text { font-size: 13px; color: #595959; margin-bottom: 10px; line-height: 1.5; }
.error-detail { font-size: 12px; color: #8A9299; background: #E7F6EF; border-radius: 8px; padding: 8px 10px; margin-bottom: 16px; font-family: monospace; word-break: break-word; }
.steps-title { font-size: 12.5px; font-weight: 700; color: #10A45E; margin-bottom: 8px; }
.steps-list { font-size: 12.5px; color: #595959; line-height: 1.9; margin: 0 0 14px; padding-left: 20px; }
.command-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.command-code { flex: 1; background: #F6F5F5; border-radius: 6px; padding: 6px 8px; font-size: 11.5px; overflow-x: auto; white-space: nowrap; }
.fine-print { font-size: 11px; color: #B9C0C4; margin-bottom: 16px; line-height: 1.5; }

/* ---------- splash screen ---------- */
.splash-wrap {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: #F6F5F5;
  padding: 20px;
}
.splash-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(33,48,56,0.15);
}
.splash-title { font-size: 22px; font-weight: 800; color: #10A45E; margin-bottom: 8px; }
.splash-subtitle { font-size: 13.5px; color: #595959; line-height: 1.5; margin-bottom: 20px; }
.splash-divider { display: flex; align-items: center; margin: 16px 0; color: #B9C0C4; font-size: 12px; }
.splash-divider::before, .splash-divider::after { content: ""; flex: 1; border-bottom: 1px solid #EEF0F1; }
.splash-divider span { padding: 0 10px; }
.splash-skip { display: block; width: 100%; text-align: center; margin-top: 16px; color: #8A9299; font-weight: 600; font-size: 12.5px; }
.splash-skip:hover { color: #595959; }

.row-label-type {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: 2px;
}
.outcome-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 9px; font-weight: 800; color: #fff; margin-left: 2px; flex-shrink: 0;
  cursor: help;
}
.stage-tag {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 8px;
  font-size: 8.5px; font-weight: 800; color: #fff; text-transform: uppercase; letter-spacing: 0.02em;
  margin-left: 2px; flex-shrink: 0; white-space: nowrap;
}

.toolkit-link {
  display: block;
  width: 100%;
  text-align: center;
  color: #2770A4;
  font-size: 12.5px;
  margin: 10px 0 6px;
}
.toolkit-link:hover { text-decoration: underline; }
.inline-code {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  background: #F6F5F5;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10.5px;
  color: #232323;
}

/* ---------- Help view ---------- */
.help-layout { display: flex; gap: 24px; align-items: flex-start; margin: 18px 28px 32px; }
.help-toc { flex-shrink: 0; width: 190px; position: sticky; top: 90px; display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.help-toc-link {
  display: block; padding: 7px 12px; font-size: 13px; color: #595959; text-decoration: none;
  border-radius: 0 8px 8px 0; border-left: 2px solid transparent; transition: all .12s ease;
}
.help-toc-link:hover { background: #F6F5F5; color: #232323; }
.help-toc-link.active { color: #10A45E; font-weight: 700; border-left-color: #10A45E; background: #E7F6EF; }
.help-card { padding: 28px 32px; flex: 1; min-width: 0; margin: 0; }
.help-section { scroll-margin-top: 90px; }
.help-section { margin-bottom: 28px; }
.help-section:last-child { margin-bottom: 0; }
.help-heading { font-size: 15px; font-weight: 800; color: #10A45E; margin-bottom: 10px; }
.help-text { font-size: 13.5px; color: #232323; line-height: 1.6; margin: 0 0 10px; max-width: 700px; }
.help-list { margin: 0; padding-left: 20px; max-width: 700px; }
.help-list li { font-size: 13.5px; color: #232323; line-height: 1.7; margin-bottom: 8px; }
.help-list li:last-child { margin-bottom: 0; }

/* Optify account, connection and save states */
:root {
  --optify-ink: #112f2a;
  --optify-primary: #075d4b;
  --optify-accent: #69e3ad;
  --optify-surface: #edf6f2;
}
[hidden] { display: none !important; }
.access-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 20% 15%, #dbf3e8, transparent 65%), var(--optify-surface);
}
.access-card {
  width: min(100%, 420px);
  padding: clamp(24px, 6vw, 40px);
  border: 1px solid #d4e8df;
  border-radius: 20px;
  background: #fff;
  color: var(--optify-ink);
  box-shadow: 0 16px 42px #112f2a12;
}
.wordmark {
  margin: 0;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -.07em;
}
.wordmark span { color: #087a5e; }
.product-name { margin: 4px 0 32px; font-size: 14px; color: #3f6660; }
.access-card h1 { margin: 0 0 12px; font-size: 23px; }
.access-status { margin: 12px 0; color: #3f6660; font-size: 13px; line-height: 1.45; }
.access-status:empty { margin: 0; }
.access-card .toolbtn { margin-top: 12px; }
.access-card .modal-input, .optify-dialog .modal-input { min-height: 42px; }
.optify-dialog {
  padding: 0;
  border: 0;
  border-radius: 14px;
  max-width: calc(100% - 32px);
  color: inherit;
  box-shadow: 0 20px 50px #142f2b40;
}
.optify-dialog::backdrop { background: #142f2b80; }
.optify-dialog .modal-card { box-shadow: none; }
.optify-dialog h2, .modal-card h2 { margin-top: 0; }
.toolbar { background: var(--optify-ink); }
.toolbar-title span { font-size: 14px; font-weight: 600; }
.toolbar-subtitle, .tabbtn { color: #e1f2eb; opacity: 1; }
.toolbar-actions { flex-wrap: wrap; }
.toolbtn.cta { background: var(--optify-primary); }
.toolbtn.cta-on-brand { color: var(--optify-ink); background: var(--optify-accent); }
.splash-title { margin-top: 0; color: var(--optify-ink); }
.splash-skip, .toolbtn.subtle { color: var(--optify-primary); }
.splash-wrap { background: var(--optify-surface); }
:where(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--optify-primary);
  outline-offset: 3px;
}
.toolbar :focus-visible { outline-color: var(--optify-accent); }
.save-status {
  position: fixed;
  z-index: 105;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: min(440px, calc(100% - 32px));
  padding: 10px 14px;
  border: 1px solid #c7e3d7;
  border-radius: 8px;
  background: #fff;
  color: var(--optify-ink);
  box-shadow: 0 4px 16px #112f2a1c;
  font-size: 13px;
}

.access-dialog { width: 640px; max-height: calc(100% - 32px); }
.access-dialog-content { padding: clamp(16px, 4vw, 28px); }
.access-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.access-dialog-heading h2 { margin: 0; font-size: 22px; }
.access-dialog-description { color: #365b54; font-size: 14px; line-height: 1.5; margin: 12px 0 20px; }
.access-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 12px;
  border-top: 1px solid #d4e8df;
  padding: 12px 0;
  font-size: 14px;
}
.access-account > span:first-child { overflow-wrap: anywhere; }
.access-account select {
  border: 1px solid #70877e;
  border-radius: 6px;
  background: #fff;
  color: var(--optify-ink);
  padding: 7px;
  font: inherit;
}
.access-account-status { grid-column: 1 / -1; color: #365b54; font-size: 13px; }
.access-account-status:empty { display: none; }
.cell-input:disabled, .cell-input[readonly] { opacity: 1; cursor: default; }
.bar:not([data-action]) { cursor: default; }

@media (max-width: 480px) {
  .access-account { grid-template-columns: minmax(0, 1fr) auto; }
  .access-account > span:first-child { grid-column: 1 / -1; }
}
