/* What frames every page: the top bar with the account menu, the customer header with its four steps and next-step
   bar, and the loading line and page swaps. */
/* ---------- level 1: global bar ---------- */
.bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 24px; height: var(--bar-h); padding: 0 var(--edge); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--ctl-sm); min-width: var(--ctl-sm); font: 700 15px/1 var(--font-brand); color: var(--brand-ink); text-decoration: none; white-space: nowrap; }
.brand .mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r); background: var(--brand-grad); }
.brand .mark svg { width: 16px; height: 16px; fill: var(--on-brand); }
.brand .by { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 400; color: var(--ink-3); }
.brand .by img { height: 13px; width: auto; }
/* the logo's dark letters need a light copy on dark themes; same three-way rule as color-scheme */
.brand .logo-dark, :root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
.global { display: flex; gap: 4px; }
.global a { display: inline-flex; align-items: center; min-height: var(--ctl-sm); padding: 0 12px; border-radius: var(--r-pill); font-family: var(--font-brand); color: var(--ink-2); text-decoration: none; }
.global a:hover { background: var(--sunken); color: var(--ink); }
.global a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--accent-soft); }
.tools { margin-left: auto; }
.tools svg { display: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.user { display: flex; align-items: center; padding-left: 16px; border-left: 1px solid var(--line); }
.user:empty { display: none; }
/* the account button and its menu */
.acct { display: inline-flex; align-items: center; gap: 8px; min-height: var(--ctl-sm); padding: 0 8px 0 2px; border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-2); font: inherit; cursor: pointer; transition: background-color var(--t), color var(--t); }
.acct:hover, .acct:has(+ .menu:popover-open) { background: var(--sunken); color: var(--ink); }
.avatar { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-family: var(--font-brand); font-size: var(--fs-sm); font-weight: 600; }
.acct .chev { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.menu { position: fixed; inset: calc(var(--bar-h) - 4px) var(--edge) auto auto; margin: 0; min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); color: var(--ink); box-shadow: var(--lift); }
.menu-who { display: grid; margin: 0 0 6px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); }
.menu-who span { color: var(--ink-3); font-size: var(--fs-sm); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--ctl); padding: 0 10px; border: 0; border-radius: var(--r); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background-color var(--t); }
.menu-item:hover { background: var(--sunken); }
.menu-item .ico svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.status-bar { padding: 8px var(--edge); border-top: 1px solid var(--line); background: var(--panel); color: var(--ink-3); font-size: var(--fs-xs); }
/* ---------- level 2: customer header and page heads; level 3: tabs ---------- */
.ctx { padding-top: 16px; }
/* breadcrumb: the one way back up a level, on every page that has a parent */
.crumbs { display: flex; margin-bottom: 6px; }
.crumb { display: inline-flex; align-items: center; gap: 2px; min-height: var(--target); margin-left: -6px; padding: 0 8px 0 4px; border-radius: var(--r);
  color: var(--ink-2); font-size: var(--fs-sm); text-decoration: none; }
.crumb:hover { color: var(--ink); background: var(--sunken); }
.crumb svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ctx-row { display: flex; align-items: flex-start; gap: 12px 24px; flex-wrap: wrap; }
.ctx-id { flex: 1 1 480px; min-width: 0; }
.facts-line { display: flex; flex-wrap: wrap; gap: 2px 18px; color: var(--ink); font-size: var(--fs-sm); margin: 6px 0 0; padding: 0; list-style: none; }
.facts-line .faint { margin-right: 5px; }
.ctx-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; padding-top: 2px; }
.run-live { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.run-live progress { width: 96px; height: 6px; accent-color: var(--accent); }
/* the four steps of the work (Data, Findings, Review, Plan): number or tick, name, and where each stands */
.steps { margin-top: 18px; border-bottom: 1px solid var(--line); }
.steps ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.steps a { display: flex; align-items: center; gap: 10px; padding: 8px 12px 12px 0; margin-bottom: -1px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; }
.steps a:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.steps a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.steps .n { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--panel); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.steps .n svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.steps .done .n { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.steps a[aria-current="page"] .n { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.steps .t { display: grid; min-width: 0; }
.steps b { font-family: var(--font-brand); font-weight: 600; }
.steps .s { overflow: hidden; color: var(--ink-3); font-size: var(--fs-sm); white-space: nowrap; text-overflow: ellipsis; }
/* what to do now, and its one primary action (or the analysis's live progress) */
.next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 16px 0 4px; padding: 12px 12px 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.next p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; }
.next .run-slot:empty { display: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-top: 24px; margin-bottom: 20px; }

/* ---------- loading and page swaps (shell/router.js render): the page on screen stays until the next is ready ---------- */
.bar::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; opacity: 0; pointer-events: none; }
:root[data-loading] .bar::after { animation: loading 2.4s cubic-bezier(.1, .7, .2, 1) .15s forwards; }  /* fast loads finish before it shows */
@keyframes loading { from { transform: scaleX(0); opacity: 1; } to { transform: scaleX(.85); opacity: 1; } }
#page[aria-busy="true"] { opacity: .55; pointer-events: none; transition: opacity .2s ease-out; }  /* the same page, refreshing slowly */
@media (max-width: 860px) {
  .bar { gap: 12px; }
  .bar .brand-name, .bar .brand .by, .user .who { display: none; }
}
@media (max-width: 600px) {
  .bar { gap: 6px; }
  .global { gap: 0; }
  .global a { padding: 0 6px; }
  .tools svg { display: block; }
  .tools .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tools a { justify-content: center; min-width: var(--ctl-sm); padding: 0; }
  .user { padding-left: 4px; border-left: 0; }
  .acct { padding: 0; }
  .acct .chev { display: none; }
  .steps .s { display: none; }  /* four steps fit as number and name; each page says where it stands */
  .steps a { gap: 6px; padding-right: 4px; font-size: var(--fs-sm); }
  .steps .n { width: 24px; height: 24px; }
  .ctx-actions { margin-left: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .ctx-actions > *, .ctx-actions .btn { width: 100%; }
  .run-slot { display: flex; }
  .run-slot:has(.run-live) { grid-column: 1 / -1; }  /* live progress takes its own row under the two buttons */
}
@media (prefers-reduced-motion: reduce) {
  :root[data-loading] .bar::after { animation: loading-still 0s .15s forwards; }  /* appears after the same delay, without moving */
  #page[aria-busy="true"] { transition: none; }
}
@keyframes loading-still { to { transform: none; opacity: 1; } }
