:root {
  --canvas: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #f3f3f1;
  --ink: #202123;
  --ink-soft: #6e6e68;
  --line: #e4e4df;
  --line-strong: #d2d2cc;
  --green: #10a37f;
  --green-dark: #0d8f72;
  --green-soft: #e9f7f2;
  --blue: #3f6f8f;
  --blue-soft: #edf5f8;
  --amber: #9a6700;
  --amber-soft: #fbf3dd;
  --red: #c2413b;
  --red-soft: #fbeceb;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
}

body {
  background: var(--canvas);
  color: var(--ink);
}

.app-shell[hidden], .login-experience[hidden] { display: none !important; }
.login-experience {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0 40px;
  overflow: hidden;
  background: #f7f7f5;
}
.login-experience::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(#e8e8e3 1px, transparent 1px), linear-gradient(90deg, #e8e8e3 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .42;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}
.login-header, .login-layout, .login-footer { position: relative; z-index: 1; width: min(1280px, 100%); margin-inline: auto; }
.login-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-strong); }
.login-environment { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; }
.login-environment svg { width: 16px; }
.login-layout { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(360px,.72fr); gap: 72px; align-items: center; padding: 48px 0; }
.login-story { min-width: 0; }
.login-eyebrow { margin: 0 0 14px; color: var(--green-dark); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.login-story h1 { max-width: 780px; margin: 0; font-family: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif; font-size: 48px; line-height: 1.04; font-weight: 620; letter-spacing: 0; }
.login-lede { max-width: 720px; margin: 22px 0 0; color: #54544f; font-size: 17px; line-height: 1.65; }
.login-boundary-flow { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin-top: 36px; border-block: 1px solid var(--line-strong); }
.login-boundary-flow > div { min-width: 0; display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 4px 9px; padding: 17px 14px; border-right: 1px solid var(--line); }
.login-boundary-flow > div:first-child { padding-left: 0; }
.login-boundary-flow > div:last-child { border-right: 0; }
.login-boundary-flow span { grid-column: 1 / -1; color: var(--ink-soft); font: 600 10px/1.2 ui-monospace, "Cascadia Code", monospace; }
.login-boundary-flow svg { grid-row: 2 / 4; width: 18px; color: var(--green-dark); }
.login-boundary-flow strong { font-size: 13px; }
.login-boundary-flow small { color: var(--ink-soft); font-size: 11px; line-height: 1.45; }
.login-policy-preview { display: grid; grid-template-columns: minmax(150px,.4fr) minmax(0,1fr); gap: 18px; margin-top: 24px; padding: 16px 0; }
.login-policy-preview > div { display: grid; align-content: start; gap: 6px; }
.login-code-label { color: var(--blue); font-size: 10px; font-weight: 700; }
.login-policy-preview strong { font-size: 14px; }
.login-policy-preview pre { min-width: 0; margin: 0; padding: 14px 16px; overflow: auto; border-left: 3px solid var(--green); background: #202522; color: #e9f0eb; font: 12px/1.65 ui-monospace, "Cascadia Code", monospace; }
.login-evidence-note { display: flex; align-items: flex-start; gap: 9px; max-width: 720px; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.login-evidence-note svg { flex: 0 0 auto; width: 16px; color: var(--blue); }
.login-access { padding: 32px; border: 1px solid var(--line-strong); border-top: 4px solid var(--ink); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.login-access-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 50%; color: #fff; background: var(--ink); }
.login-access-icon svg { width: 20px; }
.login-access h2 { margin: 0 0 10px; font-size: 26px; font-weight: 620; }
.login-access > p:not(.login-eyebrow) { color: var(--ink-soft); line-height: 1.55; }
.login-role-choices { display: grid; gap: 10px; margin-top: 26px; }
.login-role-choice { width: 100%; min-height: 88px; display: grid; grid-template-columns: 40px minmax(0,1fr) 18px; gap: 13px; align-items: center; padding: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; font: inherit; }
.login-role-choice:hover { border-color: #8baea4; background: #f5faf8; }
.login-role-choice > span:nth-child(2) { min-width: 0; display: grid; gap: 5px; }
.login-role-choice strong { font-size: 14px; }
.login-role-choice small { color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.login-role-choice > svg { width: 17px; color: var(--ink-soft); }
.login-role-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--green-dark); background: var(--green-soft); }
.login-role-icon.approver { color: var(--blue); background: var(--blue-soft); }
.login-role-icon svg { width: 18px; }
.login-continue { width: 100%; justify-content: center; margin-top: 26px; }
.login-access-note { display: flex; align-items: flex-start; gap: 8px; margin: 20px 0 0 !important; padding-top: 18px; border-top: 1px solid var(--line); font-size: 11px; }
.login-access-note svg { flex: 0 0 auto; width: 15px; color: var(--green-dark); }
.login-footer { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--ink-soft); border-top: 1px solid var(--line-strong); font-size: 11px; }

@media (max-width: 900px) {
  .login-experience { min-height: 100dvh; padding: 0 22px; overflow: visible; }
  .login-layout { grid-template-columns: 1fr; gap: 36px; padding: 38px 0; }
  .login-story h1 { font-size: 40px; }
  .login-access { width: 100%; }
}
@media (max-width: 600px) {
  .login-experience { padding: 0 16px; }
  .login-header { min-height: 68px; }
  .login-header .brand-lockup span:last-child, .login-environment { font-size: 10px; }
  .login-layout { padding: 30px 0; }
  .login-story h1 { font-size: 34px; line-height: 1.08; }
  .login-lede { font-size: 15px; }
  .login-boundary-flow { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .login-boundary-flow > div:nth-child(2) { border-right: 0; }
  .login-boundary-flow > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .login-policy-preview { grid-template-columns: 1fr; }
  .login-access { padding: 24px 18px; }
  .login-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; }
}

.app-shell {
  grid-template-rows: 64px auto minmax(0, 1fr);
}

.topbar {
  height: 64px !important;
  padding: 0 28px !important;
  background: rgba(247, 247, 245, 0.92);
  border-color: var(--line);
}

.brand-lockup { gap: 12px; }
.brand-mark {
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.brand-lockup strong { font-size: 16px; font-weight: 650; }
.brand-lockup span:last-child { color: var(--ink-soft); }
.agent-connection code { color: var(--ink-soft); }

.button {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { color: #fff; background: #202123; }
.button-primary:hover { background: #000; }
.button-secondary { background: #fff; border-color: var(--line-strong); }
.button-secondary:hover { background: var(--surface-muted); }
.icon-button { width: 36px; height: 36px; border-radius: 8px; }
button:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid rgba(16, 163, 127, 0.45);
  outline-offset: 2px;
}

.session-bar {
  gap: 16px;
  padding: 10px 28px !important;
  min-height: 68px !important;
  background: #fff;
  border-color: var(--line);
}
.session-role-icon {
  width: 36px;
  height: 36px;
  color: var(--ink);
  background: var(--surface-muted);
  border: 0;
  border-radius: 50%;
}
.session-label { color: var(--ink-soft); font-size: 10px; font-weight: 650; }
.session-account strong { font-size: 14px; }
#sessionAccountProof { color: var(--ink-soft); }
.session-next { border-color: var(--line); }
#sessionNextAction { color: #4b4b47; }

.invoice-mission {
  --ink: #202123;
  --rule: #e3e3de;
  --paper: #fff;
  --muted: #6e6e68;
  --teal: #0d8f72;
  --coral: #b6463c;
  max-width: 1440px;
  padding: 32px 40px 48px;
}
.invoice-mission .mission-heading { margin-bottom: 22px; }
.invoice-mission .mission-heading h1 {
  font-family: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.12;
}
.invoice-mission .mission-heading p { color: var(--muted); font-size: 14px; }
.invoice-mission .mission-heading .mission-eyebrow { display: none; }

.invoice-demo-session {
  min-height: 48px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.invoice-demo-session strong { font-size: 13px; }
.invoice-demo-session time { margin-right: auto; }

.invoice-action-menu,
.invoice-session-menu { position: relative; }
.invoice-action-menu > summary,
.invoice-session-menu > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
.invoice-action-menu > summary::-webkit-details-marker,
.invoice-session-menu > summary::-webkit-details-marker { display: none; }
.invoice-action-menu > summary svg,
.invoice-session-menu > summary svg { width: 16px; height: 16px; }
.invoice-session-menu { margin-left: auto; }
.invoice-session-menu > summary { width: 36px; min-height: 36px; padding: 0; }
.invoice-action-menu-options,
.invoice-session-menu-options {
  position: absolute;
  z-index: 12;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.invoice-action-menu-options .button,
.invoice-session-menu-options .button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: 0;
}

.auth-dialog {
  width: min(460px, calc(100vw - 28px));
  border-color: var(--line);
  border-radius: 14px;
}
.auth-dialog::backdrop { background: rgba(0, 0, 0, 0.36); }
.auth-dialog .dialog-heading { padding: 22px 22px 18px; }
.auth-dialog .dialog-heading h1 { margin: 4px 0 0; font-size: 22px; font-weight: 600; }
.local-account-choices {
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 22px 12px;
}
.local-role-choice {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.local-role-choice:hover { background: var(--surface-muted); border-color: var(--line-strong); }
.local-role-choice > svg { width: 20px; color: var(--ink-soft); }
.local-role-choice > span { display: grid; gap: 4px; }
.local-role-choice strong { font-size: 14px; }
.local-role-choice small { color: var(--ink-soft); font-size: 12px; }
.local-role-choice.is-current { border-color: #8bcfbd; background: var(--green-soft); }
.local-role-choice.is-current::after {
  content: "Current";
  padding: 4px 7px;
  color: var(--green-dark);
  background: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
}
.auth-role-hint { margin: 0 22px 22px; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

.invoice-modes {
  width: fit-content;
  gap: 4px;
  margin: 18px 0 8px;
  padding: 4px;
  background: #ecece8;
  border: 0;
  border-radius: 10px;
}
.invoice-modes > .button {
  flex: none;
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
}
.invoice-modes > [aria-selected="true"] {
  color: var(--ink);
  background: #fff;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.invoice-runtime { border: 0; }
.invoice-runtime > summary { color: var(--muted); }

.invoice-mission .mission-rail {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 18px;
  border: 0;
}
.invoice-mission .mission-rail button {
  min-height: 62px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
}
.invoice-mission .mission-rail button:not(:disabled):hover { background: #efefec; }
.invoice-mission .mission-rail [aria-selected="true"] {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.invoice-mission .mission-rail button svg { color: #8a8a84; }
.invoice-mission .mission-rail [aria-selected="true"] svg { color: var(--green); }

.invoice-chapter { padding: 8px 2px 14px; }
.invoice-chapter h2 { font-size: 24px; font-weight: 600; }
.chapter-question { color: var(--green-dark); }
.chapter-state {
  padding: 5px 9px;
  color: var(--muted);
  background: #ecece8;
  border-radius: 999px;
}

.outcome-strip {
  padding: 18px 0 20px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.eyebrow { color: var(--green-dark); }
.outcome-metrics { margin-top: 18px; }
.outcome-metrics > div { border-color: var(--rule); }
.outcome-metrics dd strong {
  font-family: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  font-size: 30px;
  font-weight: 600;
}

.invoice-workbench {
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
  gap: 0;
  margin-top: 20px;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.invoice-workbench .mission-active { padding: 26px 28px 30px; }
.invoice-workbench .mission-evidence {
  padding: 26px 24px 30px;
  background: #fafaf8;
  border-color: var(--rule);
}
.invoice-workbench .mission-active > h2,
.request-trace h2 { font-size: 19px; font-weight: 600; }
.invoice-workbench p { color: var(--muted); }
.invoice-workbench select,
.invoice-scenario input {
  max-width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  text-overflow: ellipsis;
}
.selected-scenario { border: 0; padding: 14px; background: var(--surface-muted); border-radius: 9px; }
.change-review h3 { font-size: 22px; font-weight: 600; }
.change-review-heading, .change-list li, .invoice-technical, .invoice-advanced, .invoice-risks { border-color: var(--rule); }
.change-list li { padding: 15px 0; }
.change-list svg, .change-proof { color: var(--green-dark); }
.step-receipt { background: var(--surface-muted); border-radius: 6px; }

.invoice-primary-action {
  margin: 18px 0 0;
  padding: 16px;
  background: var(--surface-muted);
  border: 0;
  border-radius: 10px;
}

.proof-chain { border-left-color: #cacac5; }
.proof-chain li { padding: 12px; border-color: var(--rule); }
.proof-chain svg { color: var(--green); }
.trace-events { border: 1px solid var(--rule); border-radius: 9px; }
.trace-event { padding: 12px; background: transparent; border-color: var(--rule); }
.trace-event[aria-pressed="true"] { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.authority-note, .inspector-explanation { color: var(--muted); }

.invoice-secondary, .invoice-sandbox-inventory, .same-sandbox-test { border-color: var(--rule); }
.invoice-mission summary { border-radius: 6px; }
.invoice-mission summary:hover { color: var(--ink); }

@media (min-width: 901px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
  }
  .app-shell > .topbar,
  .app-shell > .session-bar,
  .app-shell > .demo-footer { flex: 0 0 auto; }
  .invoice-mission {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}

@media (max-width: 900px) {
  .invoice-mission { padding: 26px 24px 40px; }
  .invoice-workbench { grid-template-columns: minmax(0, 1fr); }
  .invoice-workbench .mission-evidence { border-left: 0; border-top: 1px solid var(--rule); }
}

@media (max-width: 700px) {
  .topbar { padding: 0 16px !important; }
  .agent-connection > div { display: none; }
  .invoice-action-menu-options { left: 0; right: auto; }
  .session-bar { padding: 10px 16px !important; }
  .invoice-mission { padding: 22px 14px 36px; }
  .invoice-mission .mission-heading h1 { font-size: 29px; }
  .invoice-mission .mission-rail {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .invoice-mission .mission-rail button { flex: 0 0 130px; }
  .invoice-workbench .mission-active,
  .invoice-workbench .mission-evidence { padding: 22px 18px; }
  .outcome-metrics { grid-template-columns: 1fr; }
  .outcome-metrics > div { padding: 10px 16px; border: 0; }
}