/* =============================================================================
   COMPONENTS — the shared vocabulary every one of the 12 apps is built from.

   Rule for the team: if a screen needs a new visual, it gets a class in here
   first. Nothing in assets/js/apps/*.js is allowed to carry a colour, a radius
   or a shadow. That is the only thing keeping twelve apps looking like one
   platform.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   SURFACES
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev-2);
  position: relative;
}
.card-flat  { box-shadow: var(--elev-1); }
.card-lift  { transition: transform .18s cubic-bezier(.4,0,.2,1), box-shadow .18s ease; }
.card-lift:hover { transform: translateY(-2px); box-shadow: var(--elev-3); }
.card-click { cursor: pointer; }
.card-click:active { transform: translateY(0); }

.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.card-hd h3 { font-size: 13px; font-weight: 700; letter-spacing: -.005em; }
.card-hd .sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.card-bd { padding: 14px; }
.card-bd-tight { padding: 10px 12px; }
.card-bd-flush { padding: 0; }
.card-ft {
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  border-radius: 0 0 var(--radius) var(--radius);
}

.inset {
  background: var(--surface-2);
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* A card whose left edge carries its status. Used for risks, alerts and
   approvals, where the row's state must survive being skimmed. */
.edge { border-left: 3px solid var(--rag-grey); }
.edge-ok   { border-left-color: var(--rag-green); }
.edge-warn { border-left-color: var(--rag-amber); }
.edge-err  { border-left-color: var(--rag-red); }
.edge-info { border-left-color: var(--rag-blue); }

/* -----------------------------------------------------------------------------
   BUTTONS — 34px tall by default. Anything a finger touches is bumped to 44px
   by mobile.css; on the desktop control tower 34px is the density the screens
   were designed around.
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 13px;
  border-radius: calc(var(--radius) - 3px);
  font-size: 12.5px; font-weight: 600; line-height: 1;
  white-space: nowrap; cursor: pointer;
  transition: filter .15s ease, background .15s ease, border-color .15s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .48; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: var(--elev-1); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent  { background: var(--accent-grad); color: #fff; box-shadow: var(--elev-1); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost   { border: 1px solid var(--border-strong); color: var(--text); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-bare    { color: var(--muted); }
.btn-bare:hover { background: var(--surface-2); color: var(--text); }
.btn-soft    { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--on-pri); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.btn-ok      { background: color-mix(in srgb, var(--rag-green) 15%, transparent); color: var(--on-ok); }
.btn-ok:hover { background: color-mix(in srgb, var(--rag-green) 24%, transparent); }
.btn-danger  { background: color-mix(in srgb, var(--rag-red) 14%, transparent); color: var(--on-err); }
.btn-danger:hover { background: color-mix(in srgb, var(--rag-red) 22%, transparent); }

.btn-sm  { min-height: 28px; padding: 0 9px; font-size: 11.5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg  { min-height: 42px; padding: 0 20px; font-size: 14px; }
.btn-icon { padding: 0; width: 34px; min-height: 34px; }
.btn-icon.btn-sm { width: 28px; min-height: 28px; }
.btn-block { width: 100%; }

/* -----------------------------------------------------------------------------
   INPUTS
   -------------------------------------------------------------------------- */
.field { display: block; }
.label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  margin-bottom: 5px; letter-spacing: .01em;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) - 4px);
  padding: 8px 11px;
  font-size: 13px; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.textarea { min-height: 88px; resize: vertical; }
.select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.help { font-size: 11px; color: var(--muted); margin-top: 4px; }
/* Errors sit against the field, never only in a summary at the top of a form. */
.err-msg { font-size: 11px; color: var(--error); margin-top: 4px; font-weight: 600; }
.input.is-err { border-color: var(--error); }

.search {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px; padding: 0 12px; height: 34px;
  transition: border-color .15s ease, background .15s ease;
}
.search:focus-within { border-color: var(--primary); background: var(--surface); }
.search input { flex: 1; background: none; border: 0; outline: none; font-size: 12.5px; min-width: 0; }
.search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }

.switch {
  position: relative; width: 36px; height: 20px; flex: none;
  border-radius: 999px; background: var(--border-strong);
  transition: background .18s ease; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px; background: #fff;
  transition: transform .18s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(16px); }

.check {
  width: 17px; height: 17px; flex: none; border-radius: 5px;
  border: 1.5px solid var(--border-strong); cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease;
}
.check.on { background: var(--primary); border-color: var(--primary); }
.check svg { width: 11px; height: 11px; color: #fff; opacity: 0; }
.check.on svg { opacity: 1; }

/* -----------------------------------------------------------------------------
   CHIPS · BADGES · PILLS
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 9px;
  font-size: 11px; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid transparent;
}
.chip svg { width: 12px; height: 12px; }
.chip-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px;
  background: currentColor; flex: none;
}

/* RAG chips. The dot AND the word — colour alone never carries the meaning.
 *
 * The text is the status colour pushed 18% toward --text rather than the raw
 * token. A chip sits on a tint of its own hue, which lifts the background and
 * costs contrast: raw #dc2626 on the 15% red tint measured 4.34:1, just under
 * the 4.5 a chip's 11px text needs. Mixing toward --text is theme-aware in the
 * right direction on its own — it darkens the hue on a light theme and lightens
 * it on a dark one — so one rule fixes every palette without a light/dark fork,
 * and the chip still reads unmistakably red, amber or green. */
.chip-ok   { background: color-mix(in srgb, var(--rag-green) 15%, transparent); color: var(--on-ok); }
.chip-warn { background: color-mix(in srgb, var(--rag-amber) 17%, transparent); color: var(--on-warn); }
.chip-err  { background: color-mix(in srgb, var(--rag-red) 15%, transparent);   color: var(--on-err); }
.chip-info { background: color-mix(in srgb, var(--rag-blue) 15%, transparent);  color: var(--on-info); }
.chip-pri  { background: color-mix(in srgb, var(--primary) 13%, transparent);   color: var(--on-pri); }
.chip-acc  { background: color-mix(in srgb, var(--accent) 18%, transparent);    color: var(--on-acc); }
.chip-mute { background: var(--surface-2); color: var(--muted); }
.chip-out  { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.chip-solid{ background: var(--primary); color: #fff; }

.chip-lg { padding: 5px 12px; font-size: 12px; }

/* The marker on anything the platform inferred rather than a person entered.
   Ported from QSprint's .ai-chip — same contract, MarketVest wording. */
.auto-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 2px 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
  color: var(--on-acc);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.auto-chip svg { width: 11px; height: 11px; }

.kbd {
  display: inline-block; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2);
  padding: 1px 5px; font-size: 10px; font-weight: 700; color: var(--muted);
  font-family: var(--font-mono);
}

.count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px;
  background: var(--rag-red); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1;
}
.count-mute { background: var(--surface-3); color: var(--muted); }

/* A live status dot. Pulses only when it is bad, so the pulse means something. */
.dot { width: 8px; height: 8px; border-radius: 999px; flex: none; display: inline-block; }
.dot-ok { background: var(--rag-green); }
.dot-warn { background: var(--rag-amber); }
.dot-err { background: var(--rag-red); animation: pulse-ring 2s infinite; }
.dot-off { background: var(--rag-grey); }
@media (prefers-reduced-motion: reduce) { .dot-err { animation: none; } }

/* -----------------------------------------------------------------------------
   KPI TILES — the single most repeated object in the product.
   Every value in one is clickable; the requirement is explicit about it.
   -------------------------------------------------------------------------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--elev-1);
  position: relative; overflow: hidden;
  transition: transform .18s cubic-bezier(.4,0,.2,1), box-shadow .18s ease, border-color .18s ease;
}
.kpi-click { cursor: pointer; }
.kpi-click:hover { transform: translateY(-2px); box-shadow: var(--elev-3); border-color: var(--border-strong); }
.kpi-click:hover .kpi-go { opacity: 1; transform: none; }
.kpi-lbl { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.kpi-val { font-size: 27px; font-weight: 800; line-height: 1.12; margin-top: 3px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-val.sm { font-size: 21px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.kpi-go {
  position: absolute; top: 12px; right: 12px;
  width: 16px; height: 16px; color: var(--muted);
  opacity: 0; transform: translateX(-3px);
  transition: opacity .18s ease, transform .18s ease;
}
/* A thin tint bar keyed to the tile's meaning, drawn at the top edge. */
.kpi-bar { position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--primary); }
.kpi-bar.ok { background: var(--rag-green); } .kpi-bar.warn { background: var(--rag-amber); }
.kpi-bar.err { background: var(--rag-red); }  .kpi-bar.acc { background: var(--accent); }
.kpi-bar.info { background: var(--rag-blue); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 11px; }
.delta svg { width: 12px; height: 12px; }
.delta.up { color: var(--rag-green); } .delta.down { color: var(--rag-red); }
.delta.flat { color: var(--muted); }
/* Spend rising is not the same kind of news as generation rising. */
.delta.up.inverse { color: var(--rag-red); } .delta.down.inverse { color: var(--rag-green); }

/* -----------------------------------------------------------------------------
   PROGRESS
   -------------------------------------------------------------------------- */
.track { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.track-sm { height: 4px; } .track-lg { height: 9px; }
.fill { height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width .5s cubic-bezier(.4,0,.2,1); }
.fill.ok { background: var(--rag-green); } .fill.warn { background: var(--rag-amber); }
.fill.err { background: var(--rag-red); }  .fill.acc { background: var(--accent-grad); }
.fill.mute { background: var(--border-strong); }
/* The target notch on a budget bar — the "you should be here" marker. */
.track-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .55; }

.meter-row { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.meter-row .nm { width: 116px; flex: none; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-row .track { flex: 1; }
.meter-row .vl { width: 62px; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* -----------------------------------------------------------------------------
   TABLES — 34px rows, sticky headers, sortable, whole row clickable.
   -------------------------------------------------------------------------- */
.tbl-wrap { overflow: auto; max-width: 100%; }
.tbl { width: 100%; font-size: 12.5px; text-align: left; }
.tbl th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  padding: 9px 12px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort-i { display: inline-block; width: 10px; margin-left: 3px; opacity: .5; }
.tbl th.is-sorted .sort-i { opacity: 1; color: var(--primary); }
.tbl td { border-bottom: 1px solid var(--border); padding: 9px 12px; height: 38px; vertical-align: middle; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.is-sel { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl-compact td { height: 32px; padding: 6px 10px; }
.tbl-zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }

/* -----------------------------------------------------------------------------
   TABS · SEGMENTED · BREADCRUMB
   -------------------------------------------------------------------------- */
.tabs {
  display: flex; gap: 2px; overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 9px 13px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tab.on { color: var(--on-pri); border-bottom-color: var(--primary); }
/* The label takes the on-tint foreground (readable on every palette); the
   2px underline keeps the raw brand colour, where contrast rules do not
   apply to a non-text indicator of this size and the brand should show. */
.tab svg { width: 14px; height: 14px; }

.seg {
  display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px;
  border: 1px solid var(--border);
}
.seg button {
  padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); transition: background .15s ease, color .15s ease;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--elev-1); }

.crumb { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.crumb a, .crumb button { color: var(--muted); transition: color .15s ease; }
.crumb a:hover, .crumb button:hover { color: var(--primary); }
.crumb .sep { opacity: .45; }
.crumb .now { color: var(--text); font-weight: 600; }

/* -----------------------------------------------------------------------------
   AVATAR
   -------------------------------------------------------------------------- */
.av {
  width: 30px; height: 30px; border-radius: 999px; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  background: var(--brand-grad); color: #fff;
  box-shadow: var(--elev-1);
}
.av-sm { width: 24px; height: 24px; font-size: 9.5px; }
.av-lg { width: 40px; height: 40px; font-size: 14px; }
.av-xl { width: 60px; height: 60px; font-size: 20px; }
.av-stack { display: flex; }
.av-stack .av { margin-left: -8px; border: 2px solid var(--surface); }
.av-stack .av:first-child { margin-left: 0; }

/* -----------------------------------------------------------------------------
   ALERT BANNER — one line of consequence, never a decorative stripe.
   -------------------------------------------------------------------------- */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: calc(var(--radius) - 2px);
  font-size: 12.5px; border: 1px solid transparent;
}
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.banner-ok   { background: color-mix(in srgb, var(--rag-green) 11%, transparent); color: var(--on-ok);   border-color: color-mix(in srgb, var(--rag-green) 26%, transparent); }
.banner-warn { background: color-mix(in srgb, var(--rag-amber) 13%, transparent); color: var(--on-warn); border-color: color-mix(in srgb, var(--rag-amber) 30%, transparent); }
.banner-err  { background: color-mix(in srgb, var(--rag-red) 11%, transparent);   color: var(--on-err);  border-color: color-mix(in srgb, var(--rag-red) 26%, transparent); }
.banner-info { background: color-mix(in srgb, var(--rag-blue) 10%, transparent);  color: var(--on-info); border-color: color-mix(in srgb, var(--rag-blue) 24%, transparent); }
.banner strong { font-weight: 800; }
.banner .banner-body { color: var(--text); opacity: .88; }

/* -----------------------------------------------------------------------------
   MODAL · DRAWER · SHEET
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3, 8, 16, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade-in .18s ease backwards;
}
.modal {
  position: fixed; z-index: 91;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--elev-3);
  animation: pop-c .2s cubic-bezier(.4,0,.2,1) backwards;   /* -c keeps the centring translate */
  overflow: hidden;
}
.modal-sm { width: min(460px, calc(100vw - 32px)); }
.modal-lg { width: min(980px, calc(100vw - 32px)); }
.modal-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-bd { padding: 16px; overflow: auto; }
.modal-ft { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

.drawer {
  position: fixed; z-index: 91; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--elev-3);
  animation: slide-r .26s cubic-bezier(.4,0,.2,1) backwards;
}
.drawer-wide { width: min(680px, 100vw); }
.drawer-hd { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.drawer-bd { padding: 14px 16px; overflow: auto; flex: 1; }
.drawer-ft { padding: 12px 16px; border-top: 1px solid var(--border); flex: none; display: flex; gap: 8px; }

/* -----------------------------------------------------------------------------
   TOAST — bottom-right stack, auto-dismissing, never blocking.
   -------------------------------------------------------------------------- */
.toasts { position: fixed; z-index: 95; right: 16px; bottom: 16px; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 270px; max-width: 380px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--elev-3);
  font-size: 12.5px;
  animation: slide-r .26s cubic-bezier(.4,0,.2,1) backwards;
}
.toast.ok   { border-left-color: var(--rag-green); }
.toast.warn { border-left-color: var(--rag-amber); }
.toast.err  { border-left-color: var(--rag-red); }
.toast svg  { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast .tt  { font-weight: 700; }
.toast .tb  { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

/* -----------------------------------------------------------------------------
   TIMELINE · STEPPER · WORKFLOW CHAIN
   -------------------------------------------------------------------------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 15px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 4px;
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-item.ok::before   { background: var(--rag-green); border-color: var(--rag-green); }
.tl-item.warn::before { background: var(--rag-amber); border-color: var(--rag-amber); }
.tl-item.err::before  { background: var(--rag-red); border-color: var(--rag-red); }
.tl-item.now::before  { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }

/* The vertical event→action chain used to show a simulated workflow firing. */
.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 3px);
  background: var(--surface);
  transition: border-color .25s ease, background .25s ease, opacity .25s ease;
  opacity: .42;
}
.chain-step.done { opacity: 1; border-color: color-mix(in srgb, var(--rag-green) 40%, transparent); background: color-mix(in srgb, var(--rag-green) 6%, transparent); }
.chain-step.live { opacity: 1; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.chain-arrow { height: 16px; width: 2px; margin-left: 25px; background: var(--border-strong); flex: none; }
.chain-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
}
.chain-step.done .chain-ic { background: color-mix(in srgb, var(--rag-green) 16%, transparent); color: var(--rag-green); }
.chain-step.live .chain-ic { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.chain-ic svg { width: 14px; height: 14px; }

/* Horizontal lifecycle stepper (Development → … → Operations). */
.steps { display: flex; align-items: stretch; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step {
  flex: 1 1 0; min-width: 104px;
  padding: 9px 11px; border-radius: calc(var(--radius) - 4px);
  background: var(--surface-2); border: 1px solid transparent;
  position: relative;
}
.step.done { background: color-mix(in srgb, var(--rag-green) 11%, transparent); border-color: color-mix(in srgb, var(--rag-green) 28%, transparent); }
.step.now  { background: color-mix(in srgb, var(--primary) 11%, transparent); border-color: var(--primary); }
.step .st-n { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.step .st-v { font-size: 15px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* -----------------------------------------------------------------------------
   GANTT — hand-drawn, no library. A chart lib that measures its container on
   mount has nothing to measure inside a hidden tab panel and renders 0px wide.
   -------------------------------------------------------------------------- */
.gantt { position: relative; }
.gantt-axis { position: relative; height: 18px; margin-left: 150px; border-bottom: 1px solid var(--border); }
.gantt-tick { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.gantt-row { display: flex; align-items: center; gap: 8px; height: 28px; }
.gantt-row:hover .gantt-track { background: var(--surface-3); }
.gantt-lbl { width: 142px; flex: 0 0 142px; font-size: 11.5px; font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; flex: 1; height: 18px; border-radius: 4px; background: var(--surface-2); transition: background .15s ease; }
.gantt-bar {
  position: absolute; top: 3px; height: 12px; border-radius: 3px;
  background: var(--primary); cursor: pointer;
  transition: filter .15s ease;
}
.gantt-bar:hover { filter: brightness(1.15); }
.gantt-bar.ok { background: var(--rag-green); } .gantt-bar.warn { background: var(--rag-amber); }
.gantt-bar.err { background: var(--rag-red); }  .gantt-bar.plan { background: var(--border-strong); }
/* Actual progress drawn inside the planned bar. */
.gantt-bar .act { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: rgba(255,255,255,.42); }
.gantt-dia { position: absolute; top: 1px; transform: translateX(-50%); width: 11px; height: 11px; }
.gantt-dia i { display: block; width: 9px; height: 9px; transform: rotate(45deg); margin: 3px auto 0; background: var(--accent); }
.gantt-rules { position: absolute; left: 150px; right: 0; top: 18px; bottom: 0; pointer-events: none; }
.gantt-rule { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid-line); }
.gantt-rule.today { background: var(--rag-red); opacity: .7; }
.gantt-rule.today::after {
  content: "TODAY"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 8.5px; font-weight: 800; color: var(--rag-red); letter-spacing: .06em;
}

/* -----------------------------------------------------------------------------
   CHART CHROME — the SVG charts in core/charts.js draw into these.
   -------------------------------------------------------------------------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: var(--grid-line); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .ser-l  { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .ser-a  { opacity: .16; }
.chart .pt     { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); }
.legend .li { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
/* Chart tooltips are a div, not an SVG <title> — SVG titles wait ~1s for the
   OS tooltip and can't be styled. */
.ctip {
  position: fixed; z-index: 96; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 7px; box-shadow: var(--elev-3);
  padding: 7px 10px; font-size: 11.5px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.ctip .ct-t { font-weight: 700; margin-bottom: 3px; }
.ctip .ct-r { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.ctip .ct-r b { color: var(--text); margin-left: auto; font-variant-numeric: tabular-nums; }

/* -----------------------------------------------------------------------------
   TREE (document repository)
   -------------------------------------------------------------------------- */
.tree { font-size: 12.5px; }
.tree-node > .tree-row {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  transition: background .12s ease;
}
.tree-node > .tree-row:hover { background: var(--surface-2); }
.tree-node > .tree-row.on { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); }
.tree-kids { margin-left: 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.tree-caret { width: 12px; height: 12px; flex: none; color: var(--muted); transition: transform .18s ease; }
.tree-node.open > .tree-row .tree-caret { transform: rotate(90deg); }
.tree-ic { width: 15px; height: 15px; flex: none; color: var(--muted); }

/* -----------------------------------------------------------------------------
   KANBAN (work orders, change requests)
   -------------------------------------------------------------------------- */
.kb { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.kb-col { flex: 0 0 262px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.kb-hd { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.kb-bd { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); padding: 10px; box-shadow: var(--elev-1); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.kb-card:hover { transform: translateY(-1px); box-shadow: var(--elev-2); }

/* -----------------------------------------------------------------------------
   EMPTY · SKELETON
   -------------------------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .4; }
.empty .et { font-size: 13px; font-weight: 700; color: var(--text); }
.empty .eb { font-size: 12px; max-width: 320px; }

.skel { background: var(--surface-2); border-radius: 6px; position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 65%, transparent), transparent);
  animation: skel-slide 1.3s infinite;
}
@keyframes skel-slide { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

.spin { width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 999px; animation: spin .7s linear infinite; }

/* -----------------------------------------------------------------------------
   MISC
   -------------------------------------------------------------------------- */
.hr { height: 1px; background: var(--border); border: 0; }
.vr { width: 1px; align-self: stretch; background: var(--border); }
.dl { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 7px 14px; font-size: 12.5px; align-items: baseline; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.dl dd { color: var(--text); font-weight: 600; }

.ic-box {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}
.ic-box svg { width: 16px; height: 16px; }
.ic-box.acc  { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.ic-box.ok   { background: color-mix(in srgb, var(--rag-green) 15%, transparent); color: var(--rag-green); }
.ic-box.warn { background: color-mix(in srgb, var(--rag-amber) 17%, transparent); color: var(--rag-amber); }
.ic-box.err  { background: color-mix(in srgb, var(--rag-red) 15%, transparent); color: var(--rag-red); }
.ic-box.mute { background: var(--surface-2); color: var(--muted); }
.ic-box-lg { width: 40px; height: 40px; border-radius: 11px; }
.ic-box-lg svg { width: 20px; height: 20px; }

/* A photo tile in a field report / client gallery. No real images ship with the
   prototype, so these are generated gradients with a caption. */
.photo {
  aspect-ratio: 4/3; border-radius: calc(var(--radius) - 4px);
  background: var(--surface-3); position: relative; overflow: hidden;
  display: grid; place-items: center; color: var(--faint);
  border: 1px solid var(--border);
}
.photo svg { width: 22px; height: 22px; opacity: .5; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 7px; font-size: 10px; background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; }

/* The "this is simulated" marker. It appears on every screen carrying data the
   real platform would fetch, so nobody in the room mistakes the demo for a
   working integration. */
/* 10px and --muted, not 9.5px and --faint. This label is the honest disclaimer
   on every screen carrying simulated data — the one piece of text on the page
   that must never be dismissible as decoration, and --faint put it at 2.4:1. */
.mock-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); border: 1px dashed var(--border-strong);
  border-radius: 999px; padding: 2px 7px;
}
