/* Corpact visual system. See src/specs/design_system.md. */
:root {
  color-scheme: light;
  --forest: #0e1a16;
  --night: #07130f;
  --chalk: #f5f3ee;
  --paper: #fcfbf7;
  --signal: #6fa36b;
  --mineral: #a7aaad;
  --fjord: #587584;
  --teal: #356b63;
  --dusk: #746f88;
  --mist: #cbd5d7;
  --graphite: #26322e;
  --ink: var(--forest);
  --muted: #526159;
  --surface: var(--paper);
  --field: var(--chalk);
  --line: rgba(14, 26, 22, 0.22);
  --control-line: #7c8880;
  --accent: var(--teal);
  --selected: #e8eee3;
  --hover: #edf0e9;
  --action: var(--forest);
  --action-ink: var(--chalk);
  --focus: var(--teal);
  --success: var(--teal);
  --feedback: var(--graphite);
  --feedback-surface: #e8e6ed;
  --shadow: 0 16px 48px rgba(14, 26, 22, 0.16);
  --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --radius-control: 4px;
  --motion: 160ms;
  font-family: var(--font-sans);
  font-synthesis: none;
}

:root[data-theme="dark"], .focus-surface {
  color-scheme: dark;
  --ink: var(--chalk);
  --muted: var(--mist);
  --surface: var(--night);
  --field: var(--forest);
  --line: rgba(245, 243, 238, 0.28);
  --control-line: var(--mineral);
  --accent: var(--signal);
  --selected: #20362a;
  --hover: #192b22;
  --action: var(--signal);
  --action-ink: var(--forest);
  --focus: var(--signal);
  --feedback: var(--chalk);
  --feedback-surface: #302d39;
  --ledger-matter: var(--signal);
  --ledger-claim: var(--fjord);
  --ledger-decision: var(--dusk);
  --ledger-approval: var(--teal);
  --ledger-action: var(--teal);
  --ledger-outcome: var(--signal);
  color: var(--ink);
  background: var(--surface);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--field);
}

.app-shell { height: 100vh; height: 100dvh; display: grid; place-items: center; padding: 2rem; position: relative; overflow: auto; }
corpact-app { display: contents; }
.login-card, .loading-card, .error-card {
  width: min(100%, 29rem);
  padding: clamp(2rem, 6vw, 3.25rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.login-wordmark { margin-bottom: var(--space-12); font-size: 1.75rem; letter-spacing: -0.05em; }

.eyebrow { margin: 0 0 0.6rem; color: var(--accent); font-size: 0.75rem; font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase; }
h1 { margin: 0; font-weight: 400; font-size: clamp(2rem, 7vw, 2.65rem); line-height: 1.1; letter-spacing: -0.045em; }
.intro { margin: 1rem 0 2rem; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 0.72rem; }
label { margin-top: 0.3rem; font-size: 0.83rem; font-weight: 500; }
input, textarea {
  width: 100%; padding: 0.92rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-control);
  color: var(--ink); background: var(--surface); font: inherit; outline: none; transition: background-color var(--motion) ease, border-color var(--motion) ease;
}
input:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 4px rgba(53,107,99,0.15); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; min-height: 7rem; line-height: 1.6; }
.form-message { min-height: 1.35rem; margin: 0.15rem 0 0; color: var(--feedback); font-size: 0.84rem; }
button { border: 0; border-radius: var(--radius-control); padding: 0.95rem 1.2rem; font: inherit; font-weight: 500; cursor: pointer; transition: background-color var(--motion) ease, border-color var(--motion) ease; }
button:disabled { cursor: not-allowed; color: var(--muted); background: var(--hover); border: 1px dashed var(--control-line); }
.primary-button { color: var(--action-ink); background: var(--action); }
.primary-button:hover:not(:disabled) { filter: brightness(1.15); }
.secondary-button { margin-top: 2rem; color: var(--accent); background: var(--selected); }
.secondary-button:hover:not(:disabled) { background: var(--hover); }
.build-label { position: fixed; right: 1rem; bottom: 0.8rem; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.loading-card { text-align: center; color: var(--muted); }
.spinner { width: 2rem; height: 2rem; margin: 0 auto 1rem; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}
.top-bar, .bottom-bar {
  border-color: var(--line);
  background: var(--surface);
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) 0.75rem max(1.5rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.025em;
  text-decoration: none;
}
.wordmark:focus-visible, button:focus-visible, .today-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.account-actions { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.profile-identity { display: flex; align-items: center; gap: 0.65rem; min-width: 0; color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.profile-avatar {
  display: grid;
  flex: 0 0 2.5rem;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: var(--selected);
}
.profile-name { overflow: hidden; max-width: 14rem; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { min-height: 2.75rem; padding: 0.7rem 1rem; color: var(--accent); background: var(--selected); }
.logout-button:hover:not(:disabled) { background: var(--hover); }
.workspace-main {
  display: grid;
  min-width: 0;
  padding: clamp(1.5rem, 3vw, 3rem);
  place-items: start;
  overflow: auto;
}
.workspace-main h1 { font-size: clamp(2rem, 4vw, 3rem); }
.today-overview { width: min(100%, 70rem); margin-inline: auto; }
.welcome-heading { margin-bottom: var(--space-8); padding-bottom: var(--space-8); border-bottom: 1px solid var(--line); }
.welcome-heading .eyebrow { margin-bottom: 1.5rem; }
.welcome-heading .eyebrow span { padding-inline: 0.5rem; color: var(--muted); }
.welcome-heading h1 { line-height: 1.18; overflow-wrap: anywhere; }
.welcome-heading h1 span { color: var(--accent); font-weight: 500; }
.welcome-intro { color: var(--muted); font-size: 1.1rem; line-height: 1.6; margin: 1rem 0 0; }
.overview-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0; border-block: 1px solid var(--line); }
.overview-card {
  min-width: 0; padding: var(--space-8); border: 0; border-radius: 0;
  background: var(--surface);
}
.overview-card h2, .matter-dialog h2, .drafts-section h2 { margin: 0; font-size: 1.5rem; line-height: 1.3; letter-spacing: -0.025em; }
.overview-card p { color: var(--muted); line-height: 1.65; margin: 1rem 0 0; }
.day-brief { background: var(--surface); border-right: 1px solid var(--line); }
.card-heading { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.brief-symbol { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: var(--radius-control); background: var(--selected); color: var(--accent); font-size: 1.5rem; }
.placeholder-label { color: var(--muted); font-size: 0.8rem; font-weight: 650; }
.overview-card .brief-footnote { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1rem; font-size: 0.85rem; }
.matter-start .eyebrow { display: block; margin-bottom: 1rem; }
.create-matter-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; min-height: 3rem; }
.create-matter-button span { font-size: 1.25rem; line-height: 1; }
.draft-notice { margin: 1rem 0; color: var(--accent); line-height: 1.6; overflow-wrap: anywhere; }
.draft-notice:empty { margin: 0; }
.drafts-section { margin-top: 2rem; }
.draft-retention { color: var(--muted); font-size: 0.85rem; line-height: 1.6; }
.matter-drafts { display: grid; gap: 0; list-style: none; padding: 0; }
.draft-card { overflow-wrap: anywhere; padding: var(--space-6) 0; border-bottom: 1px solid var(--line); background: transparent; }
.draft-card h3 { margin: 0.75rem 0 0; font-size: 1.15rem; }
.draft-card p { white-space: pre-wrap; }
.matter-dialog { width: min(34rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.matter-dialog::backdrop { background: rgba(7,19,15,0.55); backdrop-filter: blur(4px); }
.matter-form { display: grid; gap: 0.75rem; }
.matter-form > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; margin: 0 0 0.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1rem; }
.dialog-actions .secondary-button { margin-top: 0; }
.today-link { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 1rem; border-radius: var(--radius-control); color: var(--accent); background: var(--selected); font-weight: 500; text-decoration: none; }
.bottom-bar {
  min-height: 4rem;
  padding: 0.5rem max(1.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
}
body[data-view="workspace"] .build-label { z-index: 2; bottom: max(1rem, env(safe-area-inset-bottom)); }

@media (max-width: 48rem) {
  .overview-grid { grid-template-columns: 1fr; }
  .day-brief { border-right: 0; border-bottom: 1px solid var(--line); }
  .welcome-heading { margin-bottom: var(--space-8); padding-bottom: var(--space-8); border-bottom: 1px solid var(--line); }
}
@media (max-width: 34rem) {
  .app-shell { padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .login-card, .loading-card, .error-card { padding: 1.5rem; border-radius: var(--radius-control); }
  .top-bar { gap: 0.75rem; min-height: 4rem; padding-right: max(0.75rem, env(safe-area-inset-right)); padding-left: max(0.75rem, env(safe-area-inset-left)); }
  .wordmark { gap: 0.5rem; }
  .account-actions { gap: 0.45rem; }
  .profile-name { max-width: 6.5rem; }
  .logout-button { padding-right: 0.75rem; padding-left: 0.75rem; }
  .workspace-main { padding: 1.5rem; }
  .bottom-bar { min-height: 3.75rem; }
  .overview-card, .matter-dialog { padding: 1.5rem; }
  .create-matter-button { width: 100%; }
  .dialog-actions { flex-wrap: wrap; }
}
@media (max-width: 24rem) {
  .profile-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}
@media (max-height: 42rem) {
  body:not([data-view="workspace"]) .app-shell { place-items: start center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* Platform administration composes the shared controls and surface tokens. */
corpact-admin { display: contents; }
.admin-shell { grid-template-rows: auto minmax(0, 1fr); }
.admin-wordmark-label { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.admin-main { display: grid; grid-template-columns: 14rem minmax(0,1fr); min-height: 0; overflow: auto; }
/* Keep module navigation visible alongside the selected administration panel. */
.admin-sidebar { padding: 2rem 1rem; border-right: 1px solid var(--line); background: var(--surface); }
.admin-sidebar h1 { font-size: 1.25rem; margin-bottom: 1.5rem; }
.admin-tabs { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-tabs a { display: flex; align-items: center; min-height: 44px; padding: 0.75rem 1rem; border-left: 3px solid transparent; color: var(--ink); text-decoration: none; }
.admin-tabs a:hover { background: var(--hover); }
.admin-tabs a[aria-current="page"] { background: var(--selected); border-left-color: var(--signal); font-weight: 600; }
.admin-content { min-width: 0; min-height: 0; overflow: auto; }
.admin-customers { display: grid; grid-template-columns: 16rem minmax(0,1fr); min-height: 100%; }
.admin-scope { max-width: 32rem; margin-top: 2rem; }
.admin-scope label { display: block; margin-bottom: 0.5rem; }

@media (max-width: 1200px) {
  .admin-customers { grid-template-columns: 1fr; }
}

.customer-sidebar { padding: 2rem 1.5rem; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.admin-module-intro h1 { font-size: 1.8rem; }
.admin-module-intro p:not(.eyebrow), .muted { color: var(--muted); line-height: 1.6; }
.customer-sidebar > .primary-button { width: 100%; margin: 0.5rem 0 1.5rem; }
.customer-sidebar label { display: block; margin: 1rem 0 0.5rem; }
select { width: 100%; min-height: 2.75rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font: inherit; }
select:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.customer-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.5rem; }
.customer-list a { display: grid; gap: 0.5rem; padding: 1rem; border: 1px solid transparent; border-radius: var(--radius-control); text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.customer-list a:hover { background: var(--hover); }
.customer-list a[aria-current="page"] { background: var(--selected); border-color: var(--signal); }
.customer-list span { font-size: 0.75rem; color: var(--muted); }
.customer-main { padding: 2rem; min-width: 0; overflow: auto; }
.customer-heading { display: flex; align-items: start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.5rem; }
.customer-heading h1 { font-size: clamp(1.8rem,3vw,2.5rem); overflow-wrap: anywhere; }
.customer-heading .quiet-button { flex-shrink: 0; }
.quiet-button { background: var(--surface); color: var(--accent); border: 1px solid var(--line); min-height: 2.75rem; padding: 0.65rem 1rem; }
.quiet-button:hover { background: var(--selected); }
.tenant-status { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 1rem; margin-bottom: 1.5rem; display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; font-size: 0.8rem; }
.tenant-status > div { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; }
.status-pill, .sample-badge { display: inline-block; padding: 0.4rem 0.65rem; background: var(--selected); border-radius: var(--radius-control); color: var(--accent); font-size: 0.75rem; font-weight: 650; }
.admin-error { background: var(--feedback-surface); color: var(--feedback); padding: 1rem; border-radius: var(--radius-control); line-height: 1.6; }
.admin-notice { color: var(--accent); line-height: 1.6; }
.admin-notice:empty { display: none; }
.admin-empty { max-width: 30rem; margin: 5rem auto; line-height: 1.6; }
.admin-empty h2 { font-size: 2rem; letter-spacing: -0.03em; }
.admin-empty p { color: var(--muted); }
corpact-ledger-canvas { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 0; overflow: hidden; }
.ledger-toolbar { padding: 1rem 1.5rem; display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.ledger-toolbar .sample-badge { margin-left: 0.75rem; }
.graph-controls { display: flex; gap: 0.5rem; }
.graph-help { padding: 0 1.5rem; margin: 0 0 1rem; color: var(--muted); font-size: 0.85rem; line-height: 1.6; }
.ledger-explorer { display: grid; grid-template-columns: minmax(0,1fr) 15rem; border-top: 1px solid var(--line); }
.ledger-stage { min-width: 0; height: 36rem; position: relative; overflow: hidden; background: var(--surface); }
.ledger-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.ledger-stage canvas:active { cursor: grabbing; }
.node-details { padding: 1.5rem; border-left: 1px solid var(--line); overflow-wrap: anywhere; }
.node-details h3 { margin: 0.75rem 0; line-height: 1.4; }
.node-details p, .node-details dd { color: var(--muted); line-height: 1.6; font-size: 0.85rem; }
.node-details dt { margin-top: 1rem; font-size: 0.75rem; font-weight: 500; }
.node-details dd { margin: 0.4rem 0 0; }
.graph-legend { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.75rem; color: var(--muted); }
.graph-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.graph-legend i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--muted); }
.graph-legend .legend-matter { background: var(--ledger-matter); }
.graph-legend .legend-decision { background: var(--ledger-decision); }
.graph-legend .legend-claim { background: var(--ledger-claim); }
.graph-legend .legend-approval { background: var(--ledger-approval); }
.graph-legend .legend-outcome { background: var(--ledger-outcome); outline: 1px solid var(--ledger-outcome); outline-offset: 2px; }
.graph-legend .legend-action { background: var(--ledger-action); }
.ledger-list { border-top: 1px solid var(--line); padding: 1rem 1.5rem; }
summary { cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; color: var(--accent); font-weight: 650; }
summary::before { content: '+'; margin-right: 0.75rem; }
details[open] > summary::before { content: '−'; }
.ledger-list ol { padding-left: 1.5rem; }
.event-list-button { text-align: left; background: transparent; color: var(--ink); font-weight: 500; }
.event-list-button[aria-pressed="true"] { background: var(--selected); color: var(--accent); }
.migration-details { margin-top: 1rem; font-size: 0.85rem; overflow-wrap: anywhere; }
.migration-details p, .migration-details li { color: var(--muted); line-height: 1.6; }
@media (max-width: 75rem) { .ledger-explorer { grid-template-columns: 1fr; } .node-details { border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 48rem) {
  .admin-main { grid-template-columns: 1fr; }
  .admin-sidebar { padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-content { overflow: visible; }
  .customer-sidebar, .customer-main { overflow: visible; padding: 1.5rem; }
  .customer-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .customer-list { max-height: 15rem; overflow: auto; }
  .customer-heading { flex-direction: column; }
  .admin-wordmark-label { display: none; }
  .ledger-stage { height: 28rem; }
  .ledger-toolbar { padding: 1rem; }
  .admin-entry { font-size: 0.75rem; padding-inline: 0.5rem; }
  .top-bar:has(.admin-entry) { flex-wrap: wrap; }
  .top-bar:has(.admin-entry) .account-actions { margin-left: auto; }
}

.customer-back { display: none; }
@media (max-width: 48rem) {
  .admin-main:has(.customer-heading) .customer-sidebar { display: none; }
  .customer-back { display: inline-flex; margin-bottom: 1.5rem; }
  .admin-shell .top-bar { gap: 0.5rem; }
  .admin-shell .top-bar .today-link { padding-inline: 0.75rem; font-size: 0.8rem; }
}

corpact-workspace-selector { display: block; min-width: 0; max-width: 18rem; }
.workspace-picker { display: grid; gap: 0.25rem; margin: 0; min-width: 0; }
.workspace-picker > span { font-size: 0.75rem; color: var(--muted); }
.workspace-picker select { width: 14rem; max-width: 100%; text-overflow: ellipsis; padding-block: 0.5rem; }
.workspace-picker small { max-width: 14rem; font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.tenant-banner { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); overflow-wrap: anywhere; }
.tenant-banner span { color: var(--muted); font-size: 0.8rem; }
.top-bar:has(corpact-workspace-selector) { flex-wrap: wrap; }
.top-bar:has(corpact-workspace-selector) .account-actions { flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
@media (max-width: 48rem) {
  .top-bar:has(corpact-workspace-selector) .account-actions { width: 100%; }
  .workspace-picker select { width: 10rem; }
  corpact-workspace-selector { margin-right: auto; }
}

/* Shared structural rules: flat sections, readable metadata, bounded scroll areas. */
button, input, select { min-height: 44px; }
button, input, textarea, select { border-radius: var(--radius-control); }
input, textarea, select { font-size: 1rem; border-color: var(--control-line); }
.login-card, .loading-card, .error-card, .tenant-status, .tenant-banner, .customer-list a, .admin-error { border-radius: 0; }
.form-message:not(:empty) { border-left: 3px solid var(--dusk); padding-left: var(--space-3); }
.admin-error { border-left: 3px solid var(--dusk); }
.customer-list { gap: 0; }
.customer-list a { border-bottom: 1px solid var(--line); }
.customer-list a[aria-current="page"] { border-color: transparent; border-bottom-color: var(--line); box-shadow: inset 2px 0 var(--signal); }
.customer-heading { padding-bottom: var(--space-6); border-bottom: 1px solid var(--line); }
.status-pill, .sample-badge, .placeholder-label, .tenant-status, .node-details dt, .graph-legend { font-family: var(--font-mono); font-size: 0.75rem; }
.status-pill, .sample-badge { border: 1px solid var(--line); }
.focus-surface .eyebrow, .focus-surface .sample-badge, .focus-surface .quiet-button, .focus-surface summary { color: var(--ink); }
.focus-surface .quiet-button:hover { background: var(--hover); }
.graph-legend i { width: 0.75rem; height: 0.75rem; }
.graph-legend .legend-decision { border-radius: 0; transform: rotate(45deg); }
.graph-legend .legend-claim { background: transparent; border: 1px dashed var(--ledger-claim); }
.graph-legend .legend-action { border-radius: 0; background: transparent; color: var(--ledger-action); }
.graph-legend .legend-action::before { content: "→"; display: block; font-style: normal; line-height: 0.75rem; }
.focus-surface .event-list-button[aria-pressed="true"] { color: var(--ink); border-left: 2px solid var(--signal); }
.nav-label { display: none; color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.workspace-shell:not(.admin-shell) { grid-template-areas: "header" "content" "navigation"; }
.workspace-shell:not(.admin-shell) > .top-bar { grid-area: header; }
.workspace-shell:not(.admin-shell) > .workspace-main { grid-area: content; }
.workspace-shell:not(.admin-shell) > .bottom-bar { grid-area: navigation; }
.today-link[aria-current="page"] { border-radius: 0; box-shadow: inset 2px 0 var(--signal); color: var(--ink); }
.build-label { pointer-events: none; }
body[data-view="workspace"] .build-label { display: none; }
@media (min-width: 48.001rem) {
  .workspace-shell:not(.admin-shell) { grid-template-columns: 13.375rem minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "header header" "navigation content"; }
  .workspace-shell:not(.admin-shell) .bottom-bar { border-top: 0; border-right: 1px solid var(--line); padding: var(--space-8) var(--space-4); }
  .bottom-bar .nav-label { display: block; padding: 0 var(--space-3) var(--space-4); }
  .bottom-bar .today-link { display: flex; }
}
@media (max-width: 34rem) {
  .workspace-main, .customer-sidebar, .customer-main { padding: var(--space-4); }
  .overview-card { padding: var(--space-6); }
  .draft-card { padding-inline: 0; }
  .graph-controls { flex-wrap: wrap; }
  .wordmark { font-size: 1.2rem; }
}

/* The global dark theme gives working surfaces Forest depth; the ledger remains Night. */
:root[data-theme="dark"] { --surface: var(--forest); --field: var(--night); }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .today-link,
:root[data-theme="dark"] .logout-button,
:root[data-theme="dark"] .quiet-button,
:root[data-theme="dark"] .profile-avatar,
:root[data-theme="dark"] .status-pill,
:root[data-theme="dark"] .sample-badge { color: var(--ink); }
:root[data-theme="dark"] input:focus, :root[data-theme="dark"] textarea:focus { box-shadow: 0 0 0 3px var(--night); outline: 2px solid var(--signal); outline-offset: 2px; }
corpact-theme-switch { display: inline-block; flex-shrink: 0; }
.theme-switch { display: inline-flex; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--line); }
.theme-switch button { min-width: 44px; min-height: 44px; padding: var(--space-2) var(--space-3); color: var(--muted); background: transparent; font-size: 0.875rem; }
.theme-switch button[aria-pressed="true"] { color: var(--ink); background: var(--selected); box-shadow: inset 0 -2px var(--signal); }
.theme-switch button:hover { background: var(--hover); }
.theme-switch-corner { position: fixed; z-index: 3; top: var(--space-4); right: var(--space-4); background: var(--surface); }
body[data-view="workspace"] > .theme-switch-corner { display: none; }
body:not([data-view="workspace"]) .app-shell { padding-top: 6rem; padding-bottom: 3rem; }
@media (max-width: 75rem) {
  .top-bar .account-actions { flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 48rem) {
  .account-actions > corpact-theme-switch { order: 2; }
  .theme-switch button { padding-inline: var(--space-2); }
}

/* Shared topbar: workspace at the left, account actions behind the avatar. */
.product-topbar.top-bar { position: relative; z-index: 4; display: flex; flex-wrap: nowrap; justify-content: flex-start; gap: 0; min-height: 78px; padding: 0; background: var(--surface); }
.product-topbar .wordmark { align-self: stretch; flex: 0 0 13.375rem; padding: 0 24px; gap: 12px; border-right: 1px solid var(--line); font-size: 24px; font-weight: 600; letter-spacing: -0.04em; }
.brand-tile { position: relative; width: 24px; height: 24px; flex: 0 0 24px; overflow: hidden; border-radius: 4px; background: var(--teal); }
.brand-tile::after { content: ''; position: absolute; top: -4px; left: 11px; height: 34px; width: 2px; background: var(--chalk); transform: rotate(42deg); }
.topbar-workspace { display: flex; align-items: center; gap: 20px; min-width: 0; padding: 12px 24px; }
.topbar-section { color: var(--muted); font-size: 14px; }
.topbar-tools { display: flex; align-items: center; gap: 16px; margin-left: auto; padding: 12px 24px; flex-shrink: 0; }
.ui-icon { width: 22px; height: 22px; flex-shrink: 0; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; color: var(--muted); background: transparent; border-radius: 6px; text-decoration: none; }
.icon-button:hover { color: var(--ink); background: var(--hover); }
.product-topbar corpact-workspace-selector { max-width: 240px; }
.product-topbar .workspace-picker { position: relative; gap: 0; }
.product-topbar .workspace-picker-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.product-topbar .workspace-picker-icon { position: absolute; top: 11px; left: 14px; pointer-events: none; color: var(--muted); }
.product-topbar .workspace-picker select { width: 180px; height: 46px; padding: 0 12px 0 46px; border-color: var(--line); border-radius: 8px; font-size: 14px; }
.product-topbar .workspace-picker small { position: absolute; top: 100%; left: 0; background: var(--surface); padding: 4px; z-index: 1; }
.workspace-context { display: inline-flex; gap: 12px; align-items: center; color: var(--muted); }
corpact-account-menu { display: block; border-left: 1px solid var(--line); padding-left: 20px; }
.account-trigger { display: block; padding: 0; background: transparent; border-radius: 50%; }
.account-trigger .profile-avatar { width: 48px; height: 48px; border: 0; font-size: 18px; color: var(--ink); background: var(--selected); }
.account-dropdown { position: fixed; inset: 70px 20px auto auto; margin: 0; width: min(288px, calc(100vw - 24px)); max-height: calc(100dvh - 90px); overflow: auto; padding: 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(7,19,15,0.16); }
.account-summary { display: flex; align-items: center; gap: 14px; padding: 8px 8px 16px; }
.account-summary .profile-avatar { flex: 0 0 48px; width: 48px; height: 48px; border: 0; color: var(--ink); }
.account-summary > div { display: grid; gap: 6px; min-width: 0; }
.account-summary strong { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.account-summary > div > span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.account-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 44px; padding: 10px 12px; text-decoration: none; color: var(--muted); background: transparent; border-radius: 6px; font-size: 14px; font-weight: 400; text-align: left; }
.account-item:hover, .account-item:focus-visible { color: var(--ink); background: var(--hover); }
.account-admin { color: var(--ink); background: var(--selected); }
.account-separator { height: 1px; margin: 14px 8px; background: var(--line); }
.account-dialog p, .account-dialog dt { color: var(--muted); line-height: 1.6; }
.account-dialog dt { font-size: 13px; margin-top: 16px; }
.account-dialog dd { margin: 4px 0 0; overflow-wrap: anywhere; }
@media (max-width: 48rem) {
  .product-topbar.top-bar { flex-wrap: wrap; }
  .product-topbar .wordmark { min-height: 70px; flex-basis: auto; padding: 0 16px; border: 0; font-size: 22px; }
  .topbar-workspace { order: 3; width: 100%; padding: 8px 16px; border-top: 1px solid var(--line); }
  .topbar-tools { gap: 8px; padding: 10px 12px; }
  corpact-account-menu { padding-left: 8px; }
  .topbar-section { margin-left: auto; }
  .account-dropdown { top: 64px; right: 12px; }
  .product-topbar .workspace-picker select { width: 180px; }
}
@media (max-width: 24rem) {
  .product-topbar .wordmark { gap: 8px; padding-inline: 12px; font-size: 20px; }
  .product-topbar .brand-tile { width: 20px; height: 20px; flex-basis: 20px; }
  .topbar-tools { gap: 4px; padding-inline: 8px; }
  .account-trigger .profile-avatar { width: 44px; height: 44px; }
}

.account-dialog { width: min(34rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 32px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.account-dialog::backdrop { background: rgba(7,19,15,0.55); }
.account-dialog h2 { margin-top: 0; font-size: 24px; }

/* Main GUI: global header, clipboard, reading surface, minimap and composer. */
.workspace-shell.main-gui:not(.admin-shell) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "header" "content";
}
.main-gui .product-topbar { min-height: 72px; }
.main-gui .product-topbar .wordmark { flex-basis: 240px; }
.topbar-primary .today-link { font-size: 14px; background: transparent; }
corpact-workspace-layout { grid-area: content; display: block; min-width: 0; min-height: 0; }
.workspace-layout {
  display: grid; height: 100%; min-height: 0; min-width: 0;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "assets heading" "assets history" "assets composer";
  background: var(--field);
}
.workspace-layout.with-map {
  grid-template-columns: 240px minmax(0, 1fr) 256px;
  grid-template-areas: "assets heading map" "assets history map" "assets composer composer";
}
.workspace-layout.workspace-unavailable {
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "heading" "history";
}
.workspace-layout .workspace-main { grid-area: history; display: block; min-height: 0; padding: 24px 32px; overscroll-behavior: contain; scrollbar-gutter: stable; }
.workspace-main:focus-visible, .conversation-composer:focus-visible, .conversation-heading:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.conversation-heading { grid-area: heading; --panel-heading-inline-space: 32px; }
.conversation-heading h2 span { color: var(--muted); padding-inline: 8px; }
.workspace-view-controls { display: flex; flex-wrap: wrap; gap: 4px; }
.workspace-view-controls .quiet-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; margin: 0; font-size: 14px; }
.asset-panel, .conversation-map { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.asset-panel { grid-area: assets; border-right: 1px solid var(--line); }
.conversation-map { grid-area: map; border-left: 1px solid var(--line); }
/* One component owns the height, including its rule, for all three column headers. */
corpact-panel-heading { display: block; min-width: 0; flex-shrink: 0; }
.workspace-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 76px; padding: 12px var(--panel-heading-inline-space, 20px); border-bottom: 1px solid var(--line); background: var(--surface); }
.panel-heading-text { min-width: 0; }
.workspace-panel-heading p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 0; }
.workspace-panel-heading h2 { margin: 0; font-size: 14px; font-weight: 500; line-height: 1.5; }
.workspace-panel-heading > .ui-icon { color: var(--muted); width: 20px; }
.workspace-panel-heading form { margin: 0; }
.asset-collection, .minimap-collection { overflow-y: auto; min-height: 0; scrollbar-gutter: stable; }
.workspace-empty { padding: 32px 24px; color: var(--muted); }
.workspace-empty-symbol { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); margin-bottom: 16px; color: var(--accent); }
.workspace-empty h3 { margin: 0; color: var(--ink); font-size: 16px; font-weight: 500; line-height: 1.5; }
.workspace-empty p { margin: 12px 0 24px; font-size: 14px; line-height: 1.6; }
.workspace-empty .placeholder-label { font-weight: 400; line-height: 1.6; }
.conversation-composer { grid-area: composer; min-width: 0; padding: 12px 32px; border-top: 1px solid var(--line); background: var(--surface); }
.composer-inner { width: 100%; max-width: 64rem; }
.composer-heading, .composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.composer-heading { margin-bottom: 8px; }
.composer-heading label { font-size: 14px; margin: 0; }
.conversation-composer textarea { display: block; min-height: 56px; height: 56px; max-height: 160px; resize: none; padding: 8px 12px; font-size: 16px; line-height: 1.5; background: var(--field); opacity: 1; }
.composer-footer { margin-top: 8px; }
.composer-footer p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.composer-footer button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; min-height: 44px; cursor: not-allowed; }
corpact-transcription-composer { display: contents; }
.composer-actions, .transcription-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-footer .microphone-button { cursor: pointer; padding: 8px; }
.transcription-dialog select { width: 100%; min-height: 44px; background: var(--field); color: var(--ink); border: 1px solid var(--line); padding: 8px; font: inherit; }
.live-transcript { min-height: 120px; max-height: 35dvh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px; background: var(--field); border: 1px solid var(--line); line-height: 1.6; }
.transcription-actions { margin-top: 20px; }
.main-gui .today-overview { max-width: 64rem; }
.main-gui .welcome-heading { margin-bottom: 16px; padding-bottom: 16px; }
.main-gui .welcome-heading .eyebrow { margin-bottom: 12px; }
.main-gui .welcome-heading h1 { font-size: clamp(28px, 2.5vw, 36px); line-height: 1.15; }
.main-gui .welcome-intro { font-size: 14px; margin-top: 8px; }
.main-gui .overview-card { padding: 20px; }
.main-gui .overview-card h2 { font-size: 22px; }
.main-gui .overview-card p { font-size: 14px; line-height: 1.5; margin-top: 12px; }
.main-gui .card-heading { margin-bottom: 12px; gap: 8px; }
.main-gui .brief-symbol { width: 32px; height: 32px; }
.main-gui .matter-start .eyebrow { margin-bottom: 12px; }
.main-gui .create-matter-button { margin-top: 16px; font-size: 14px; }
.main-gui .draft-card { padding-inline: 0; }
.workspace-skip-links { position: fixed; top: 8px; left: 8px; z-index: 10; display: flex; gap: 8px; max-width: calc(100vw - 16px); clip-path: inset(50%); transform: translateY(-200%); }
.workspace-skip-links:focus-within { clip-path: none; transform: none; }
.workspace-skip-links button { background: var(--action); color: var(--action-ink); min-height: 44px; }
.workspace-panel-dialog { width: min(360px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.workspace-panel-dialog::backdrop { background: rgba(7, 19, 15, 0.55); }

@media (min-width: 769px) and (max-height: 800px) {
  .workspace-layout .workspace-main { padding-block: 16px; }
  .main-gui .welcome-heading { padding-bottom: 12px; margin-bottom: 12px; }
  .main-gui .welcome-heading h1 { font-size: 28px; }
  .main-gui .overview-card { padding: 16px; }
}
@media (max-width: 1200px) {
  .workspace-layout, .workspace-layout.with-map { grid-template-columns: 224px minmax(0, 1fr); grid-template-areas: "assets heading" "assets history" "assets composer"; }
  .conversation-map { display: none; }
  .main-gui .product-topbar .wordmark { flex-basis: 224px; }
  .workspace-layout .workspace-main, .conversation-composer { padding-inline: 24px; }
  .conversation-heading { --panel-heading-inline-space: 24px; }
}
@media (max-width: 768px) {
  .workspace-shell.main-gui:not(.admin-shell) { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .main-gui .product-topbar .wordmark { flex-basis: auto; }
  .main-gui .topbar-primary { position: fixed; inset: auto 0 0; min-height: 56px; padding: 4px 16px max(4px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .workspace-layout, .workspace-layout.with-map { grid-template-columns: minmax(0, 1fr); grid-template-areas: "heading" "history" "composer"; }
  .asset-panel { display: none; }
  .conversation-heading { --panel-heading-inline-space: 16px; }
  .workspace-panel-heading { height: auto; min-height: 76px; flex-wrap: wrap; gap: 4px 12px; }
  .conversation-heading p { display: none; }
  .workspace-view-controls .quiet-button { padding-inline: 8px; }
  .workspace-layout .workspace-main { padding: 20px 16px; }
  .conversation-composer { padding: 12px 16px; }
  .composer-heading .placeholder-label { font-size: 12px; }
  .main-gui .overview-grid { grid-template-columns: 1fr; }
  .main-gui .overview-card { padding: 20px; }
  .main-gui .welcome-heading h1 { font-size: 28px; }
  .assets-dialog { margin: 12px auto 12px 12px; height: calc(100dvh - 24px); }
}
/* Short viewports, including a mobile keyboard, use page flow instead of squeezing the reader. */
@media (max-height: 600px) {
  .workspace-shell.main-gui:not(.admin-shell) { position: absolute; inset: 0 0 auto; height: auto; min-height: 100dvh; grid-template-rows: auto auto; overflow: visible; }
  body:has(.main-gui) { overflow-y: auto; }
  body:has(.main-gui) .app-shell { height: auto; min-height: 100dvh; overflow: visible; }
  .workspace-layout { height: auto; grid-template-rows: auto minmax(200px, auto) auto; }
  .workspace-layout .workspace-main { overflow: visible; }
  .asset-collection, .minimap-collection { max-height: 60vh; }
}

/* Module navigation shares workspace scope and moves intact to the mobile bar. */
.main-gui .topbar-workspace { flex: 1; flex-wrap: wrap; gap: 8px 16px; }
.module-navigation { display: flex; align-items: center; gap: 4px; }
.module-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 12px; color: var(--muted); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; }
.module-link:hover { color: var(--ink); background: var(--hover); }
.module-link[aria-current="page"] { color: var(--ink); background: var(--selected); border-bottom-color: var(--accent); }
.module-link:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.module-link .ui-icon { width: 20px; height: 20px; }
corpact-timelines, corpact-perspective { grid-area: content; display: block; min-width: 0; min-height: 0; }
.visual-module { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; }
.module-body { overflow-y: auto; padding: 32px; min-width: 0; background: var(--field); }
.module-intro { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.module-intro h1 { font-size: clamp(28px, 3vw, 40px); }
.module-intro p:not(.eyebrow), .module-inspection p { color: var(--muted); line-height: 1.6; }
.module-intro .sample-badge { padding: 8px 12px; line-height: 1.5; max-width: 100%; }
.module-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 16px; border: 1px solid var(--line); background: var(--surface); }
.module-toolbar label { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 14px; }
.module-toolbar select { min-height: 44px; color: var(--ink); background: var(--field); border: 1px solid var(--control-line); padding: 8px 12px; font: inherit; }
.module-toolbar input[type="range"] { width: 144px; min-height: 44px; padding: 0; accent-color: var(--accent); }
.module-toolbar .quiet-button { margin: 0; min-height: 44px; }
.module-toolbar time { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.timeline-stage, .perspective-stage { position: relative; height: clamp(320px, 45vh, 520px); border: 1px solid var(--line); border-top: 0; overflow: hidden; background: var(--field); }
.timeline-stage canvas, .perspective-stage canvas { display: block; width: 100%; height: 100%; }
.module-caption { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 12px 0 24px; }
.canvas-empty { position: absolute; inset: auto 16px 24px; padding: 12px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.module-inspection { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); border-top: 1px solid var(--line); }
.module-inspection > section { padding: 24px; min-width: 0; }
.module-inspection h2 { font-weight: 500; font-size: 20px; margin: 0 0 16px; }
.module-detail { border-left: 1px solid var(--line); background: var(--surface); }
.event-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.zone-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.module-choice { display: flex; flex-direction: column; gap: 8px; min-height: 44px; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.module-choice span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.module-choice[aria-pressed="true"] { background: var(--selected); box-shadow: inset 3px 0 var(--accent); }
.module-choice:hover { background: var(--hover); }
.north-star { position: absolute; top: 3%; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; width: min(300px, 90%); color: var(--ink); text-align: center; pointer-events: none; }
.north-star > span { font-size: 36px; color: var(--accent); line-height: 1; }
.north-star strong { font-size: 14px; font-weight: 500; }
.north-star small { font-size: 12px; color: var(--muted); }
.zone-marker { position: absolute; transform: translate(-50%, -50%); padding: 8px 12px; min-height: 44px; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--control-line); }
.zone-marker[aria-pressed="true"] { border-color: var(--accent); background: var(--selected); box-shadow: inset 0 -2px var(--accent); }
.probability-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.probability-table caption { text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 12px; }
.probability-table th, .probability-table td { border-bottom: 1px solid var(--line); padding: 12px 0; text-align: left; font-weight: 400; }
.probability-table td { text-align: right; font-family: var(--font-mono); }
.module-rendering-status { padding: 16px; border-left: 2px solid var(--dusk); background: var(--feedback-surface); color: var(--feedback); }
@media (max-width: 768px) {
  .main-gui .topbar-workspace { flex-basis: 100%; }
  .main-gui .module-navigation { justify-content: space-around; padding-inline: 8px; gap: 0; }
  .module-link { flex-direction: column; gap: 2px; padding: 4px 8px; font-size: 12px; min-width: 0; flex: 1; }
  .module-link .ui-icon { width: 18px; height: 18px; }
  .module-body { padding: 20px 16px; }
  .module-toolbar { gap: 8px; padding: 8px; }
  .module-toolbar label { flex-wrap: wrap; }
  .module-toolbar time { width: 100%; margin: 8px 0; }
  .module-inspection { grid-template-columns: minmax(0, 1fr); }
  .module-inspection > section { padding: 20px 0; }
  .module-inspection .module-detail { border-left: 0; padding-inline: 16px; }
  .event-choices { grid-template-columns: minmax(0, 1fr); }
  .zone-marker { display: none; }
}
@media (max-height: 600px) {
  .visual-module { height: auto; grid-template-rows: auto auto; }
  .module-body { overflow: visible; }
}

/* AI configuration uses the shared form controls and readable field spacing. */
.ai-settings { max-width: 42rem; }
.ai-settings h2 { font-size: 2rem; font-weight: 400; }
.ai-settings fieldset { display: grid; gap: 0.75rem; min-width: 0; border: 0; padding: 0; margin: 1.5rem 0 0; }
.ai-settings input, .ai-settings select { min-width: 0; width: 100%; }
.ai-settings fieldset p { margin: 0 0 0.75rem; }
.ai-settings .ai-remove-key { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; }
.ai-settings .ai-remove-key input { width: 1.25rem; min-height: 1.25rem; }

/* Shared scales for new feature styles; palette values remain in the semantic theme above. */
:root {
  --text-small: 0.875rem;
  --text-body: 1rem;
  --text-section: 1.5rem;
  --leading-body: 1.6;
  --rule-width: 1px;
  --selection-width: 4px;
  --target-size: 44px;
  --measure-reading: 64rem;
  --measure-form: 36rem;
}

/* Setup is a scrolling reading surface, with all descendants and states scoped here. */
.workspace-shell.onboarding-shell:not(.admin-shell) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "header" "content";
  grid-template-rows: auto minmax(0, 1fr);
  overflow: auto;

  & > corpact-onboarding, & > main { grid-area: content; min-width: 0; min-height: 0; overflow: auto; }
}

.onboarding {
  width: min(100%, var(--measure-reading));
  margin-inline: auto;
  padding: var(--space-8);
  line-height: var(--leading-body);
  overflow-wrap: anywhere;

  & h1 { max-width: var(--measure-form); }
  & h1:focus { outline: none; }
  & h2 { font-size: var(--text-section); font-weight: 400; }
  & .onboarding-intro { color: var(--muted); max-width: var(--measure-form); margin-block: var(--space-4) var(--space-6); }
  & .onboarding-progress {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    color: var(--muted);
    font: var(--text-small) var(--font-mono);

    & progress { width: 100%; height: var(--space-1); accent-color: var(--accent); }
  }
  & .onboarding-choices {
    border: 0;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);

    & legend { margin-bottom: var(--space-4); }
    & .onboarding-choice {
      display: flex;
      align-items: start;
      gap: var(--space-3);
      padding: var(--space-4);
      border: var(--rule-width) solid var(--control-line);
      background: var(--surface);
      font-size: var(--text-body);
      cursor: pointer;

      &:has(:checked) { background: var(--selected); border-inline-start: var(--selection-width) solid var(--accent); }
      &:has(:disabled) { cursor: default; color: var(--muted); }
      & input { width: var(--space-4); min-width: var(--space-4); height: var(--target-size); margin: 0; accent-color: var(--accent); }
      & strong, & span { display: block; }
      & strong { font-size: var(--text-section); margin-bottom: var(--space-4); font-weight: 400; }
    }
  }
  & .onboarding-guidance, & .onboarding-preview {
    padding: var(--space-4);
    margin-block: var(--space-4);
    border: var(--rule-width) solid var(--line);
    background: var(--surface);

    & p:last-child { margin-bottom: 0; }
    & dl { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-3); }
    & dt { color: var(--muted); }
    & dd { margin: 0; }
  }
  & .onboarding-finding {
    border-block-start: var(--rule-width) solid var(--line);
    padding-block: var(--space-4);
    overflow-wrap: anywhere;

    & small { display: block; margin-top: var(--space-2); color: var(--muted); }
  }
  & .onboarding-draft {
    display: grid;
    gap: var(--space-4);
    padding-block: var(--space-4);

    & fieldset { min-width: 0; border: var(--rule-width) solid var(--line); }
    & label { display: grid; gap: var(--space-2); margin-block: var(--space-3); }
    & input { min-width: 0; width: 100%; }
  }
  & .onboarding-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-6); border-top: var(--rule-width) solid var(--line); padding-block: var(--space-6); }
  & .onboarding-error { background: var(--feedback-surface); color: var(--feedback); border-inline-start: var(--selection-width) solid var(--dusk); padding: var(--space-4); }
  & .onboarding-help { & summary { min-height: var(--target-size); } padding-block: var(--space-4); color: var(--muted); }
  & .secondary-button { margin-top: 0; }
  & a { color: var(--accent); }

  @media (max-width: 768px) {
    padding: var(--space-4);
    & .onboarding-choices { grid-template-columns: 1fr; }
    & .onboarding-preview dl { grid-template-columns: 1fr; }
    & .onboarding-footer { align-items: stretch; flex-direction: column; }
  }
}

.onboarding-skip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--target-size);
  font-size: var(--text-body);

  & input { width: var(--space-6); height: var(--space-6); flex-shrink: 0; accent-color: var(--accent); }
  & small { display: block; font-size: var(--text-small); color: var(--muted); }
}

.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);

  & .secondary-button { margin-top: 0; }
}

.company-members {
  border-block: var(--rule-width) solid var(--line);
  padding-block: var(--space-6);
  margin-block: var(--space-6);
  overflow-wrap: anywhere;

  & form { display: grid; gap: var(--space-4); max-width: var(--measure-form); }
  & ul { padding: 0; list-style: none; }
  & li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding-block: var(--space-3); border-bottom: var(--rule-width) solid var(--line); }
}

.drive-connector {
  & button[aria-busy="true"] { cursor: wait; }
  & fieldset { border: var(--rule-width) solid var(--line); margin-block: var(--space-6); padding: var(--space-4); min-width: 0; }
  & form { display: grid; gap: var(--space-4); }
  & ul { list-style: none; padding: 0; }
  & li { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; border-bottom: var(--rule-width) solid var(--line); }
  & input[type="number"] { max-width: var(--measure-form); }
  & button { white-space: normal; }
}

.onboarding-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  border-block: var(--rule-width) solid var(--line);

  & strong { display: block; font-size: var(--text-section); font-weight: 400; }
  & span { display: block; color: var(--muted); font-size: var(--text-small); }
  @media (max-width: 768px) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.onboarding-language {
  display: flex;
  align-items: center;
  justify-content: end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  color: var(--muted);

  & select { width: auto; max-width: 100%; }
}

/* Customer-scoped administration uses the shared semantic palette and spacing. */
.customer-tabs {
  display: flex;
  gap: var(--space-4);
  padding-block: var(--space-4);
  & a { color: var(--muted); padding: var(--space-2); }
  & a[aria-current="page"] { color: var(--ink); background: var(--selected); }
}
.customer-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  padding-block: var(--space-4);
  & label { display: grid; gap: var(--space-2); flex: 1; min-width: 0; }
  & input { width: 100%; }
}
.customer-users {
  display: grid;
  gap: var(--space-4);
  & header { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-4); }
  & label { display: grid; gap: var(--space-2); margin-block: var(--space-3); }
  & input { width: 100%; min-width: 0; }
  & dialog { color: var(--ink); background: var(--surface); }
  & dialog > button, & form > button { margin-block: var(--space-3); }
  & .customer-user-list {
    list-style: none;
    padding: 0;
    margin: 0;
    & li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-4); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
    & li > div:first-child { display: grid; gap: var(--space-1); min-width: 0; }
    & span { color: var(--muted); }
  }
  & .customer-user-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
}

.sophie-sources {
  border-top: var(--rule-width) solid var(--line);
  padding-block: var(--space-6);
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  overflow-wrap: anywhere;

  & h2, & h3, & p { margin: 0; }
  & p { color: var(--muted); }
  & label { display: grid; gap: var(--space-2); min-width: 0; }
  & input, & select { width: 100%; min-width: 0; max-width: 100%; }
  & form, & .source-index-controls { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); }
  & form label, & .source-index-controls label { flex: 1; min-width: min(100%, var(--measure-form)); }
  & button { white-space: normal; }
  & details { border-block: var(--rule-width) solid var(--line); padding-block: var(--space-4); }
  & summary { cursor: pointer; min-height: var(--target-size); }
  & .drive-connector { margin-block: var(--space-6); }
  & blockquote { margin: var(--space-4) 0; padding-inline-start: var(--space-4); border-inline-start: var(--rule-width) solid var(--line); white-space: pre-wrap; }
  & ol { padding-inline-start: var(--space-6); }
  & li { margin-block: var(--space-4); }
  & :focus-visible { outline: var(--rule-width) solid var(--focus); outline-offset: var(--space-1); }
  @media (max-width: 768px) {
    & form, & .source-index-controls { flex-direction: column; align-items: stretch; }
  }
}
