/* Theme A · business modules. Visual overrides only; source, state and permissions stay unchanged.
   Scoped selectors also win over the administration styles injected after page load.
   Keep print rendering in the original stylesheets. */
@media screen {
  body :is(.pw-form-modal,.delivery-root,.delivery-modal,.dc-root,.project-journal,
    #ai-employees,.ai-modal,.pa-panel,.pa-dialog,.rg-panel,.account-dialog) {
    --primary:var(--a-primary);--blue:var(--a-primary);--route:var(--a-primary);
    --ai-accent:var(--a-primary);--dc-blue:var(--a-primary);
    --ink:var(--a-ink);--paper:var(--a-ink);--dc-ink:var(--a-ink);
    --muted:var(--a-muted);--ink-subtle:var(--a-muted);--ink-secondary:var(--a-muted);
    --ink-tertiary:var(--a-muted);--panel:var(--a-surface);--canvas:var(--a-surface);
    --panel-2:var(--a-tint);--surface-0:var(--a-canvas);--soft:var(--a-canvas);
    --surface-2:#f6f8f4;--surface-pearl:#f6f8f4;--canvas-parchment:var(--a-canvas);
    --dc-background:var(--a-surface);--dc-soft:var(--a-tint);
    --line:var(--a-line);--hairline:var(--a-line);--hairline-strong:#b8c5be;
    --divider-soft:var(--a-line);--apple-blue:var(--a-primary);--apple-blue-focus:var(--a-primary);
    --status-success:#236d4d;--status-warning:var(--a-amber);--status-danger:#ad383b;
    color:var(--a-ink);
    font-size:14px;
  }

  /* Forms and their AI assistant share a quiet mint rail, not a second page-sized blue card. */
  body :is(.ai-modal,.pw-form-modal,.delivery-modal,.account-dialog,.pa-dialog) {
    border:1px solid var(--a-line);
    border-radius:12px;
    background:var(--a-surface);
    color:var(--a-ink);
    box-shadow:0 22px 70px rgba(23,40,34,.2);
  }
  body :is(.ai-modal,.account-dialog,.pa-dialog)::backdrop {
    background:rgba(23,35,32,.44);
    backdrop-filter:blur(3px);
  }
  body .ai-modal-head {padding:18px 24px;border-bottom-color:var(--a-line);background:var(--a-surface)}
  body .ai-modal-head h2 {font-size:21px;line-height:1.4;font-weight:650;letter-spacing:-.02em}
  body .ai-modal-body {background:var(--a-surface)}
  body .ai-modal-foot {padding:15px 24px;background:#f8faf6;border-top-color:var(--a-line)}
  body .ai-close {width:34px;min-height:34px;border-radius:8px;color:var(--a-muted);line-height:1}
  body .ai-close:hover {background:var(--a-canvas);color:var(--a-ink)}
  body .ai-field {font-size:13px;font-weight:600;color:var(--a-ink)}
  body .ai-field :is(input,select,textarea),
  body .delivery-item :is(input,select,textarea),
  body .account-form :is(input:not([type=checkbox]):not([type=radio]),select) {
    padding:10px 12px;border:1px solid #becbc4;border-radius:8px;
    background:var(--a-surface);color:var(--a-ink);font-size:14px;line-height:1.6;
  }
  body .ai-field :is(input,select),body .delivery-item :is(input,select),
  body .account-form :is(input:not([type=checkbox]):not([type=radio]),select) {min-height:40px}
  body .ai-field :is(input,textarea)::placeholder {color:#737d77;opacity:1}
  body .ai-field small,body .ai-modal-head p {color:var(--a-muted);font-size:12px}
  body :is(.ai-modal,.delivery-root,.account-dialog) input[type=checkbox],
  body :is(.ai-modal,.delivery-root,.account-dialog) input[type=radio] {accent-color:var(--a-primary)}
  body .pw-form-modal :is(.ai-field input,.ai-field select,.ai-field textarea):focus-visible,
  body .delivery-item :is(input,select,textarea):focus-visible,
  body .ai-button:focus-visible,body .ai-close:focus-visible,
  body .account-form :is(input,select,button):focus-visible {
    outline:2px solid var(--a-primary);outline-offset:3px;
  }
  body .pw-ai-panel {
    padding:16px 18px;margin:16px 0 22px;
    border:1px solid #c8dfd6;border-left:3px solid var(--a-primary);
    border-radius:10px;background:var(--a-tint);
  }
  body .pw-ai-panel h3 {font-size:16px;line-height:1.55;color:#185e55}
  body .pw-ai-panel :is(.pw-note,.pw-status) {font-size:13px;color:#516a60;line-height:1.75}
  body .pw-ai-panel [data-result]>h3 {font-size:14px;line-height:1.75;color:var(--a-ink);font-weight:550}
  body .pw-ai-panel pre {background:#f8fbf7;padding:12px;border-radius:8px;font-size:13px}
  body .pw-ai-panel .pw-evidence {border-color:#92bdb0;background:rgba(255,255,255,.42);padding:8px 12px}
  body .pw-ai-suggestion {background:var(--a-surface);border-color:var(--a-line);border-radius:8px}
  body .pw-ai-btn {border-color:#a9cdc0!important;background:#f7fbf8!important;color:var(--a-primary)!important;border-radius:8px!important}
  body .pw-ai-btn:hover:not(:disabled) {border-color:var(--a-primary)!important;background:#dceee5!important}
  body .pw-subform {background:#f9fbf7;border-color:var(--a-line);border-radius:10px}
  body .pw-subform h3 {font-size:15px;line-height:1.6}
  body .pw-child-head strong {font-size:13px;color:var(--a-muted)}
  body .pw-project-selector {border-color:var(--a-line);border-radius:10px;background:#f8faf6}
  body .pw-project-selector>span {font-size:12px;color:var(--a-amber)}
  body .pw-form-modal details>summary {color:var(--a-primary);font-size:13px;line-height:1.8}

  /* Shared workspaces: compact segmented entries and readable, bordered records. */
  body .pw-header {margin-bottom:20px;gap:16px}
  body .pw-header h2 {font-size:23px;line-height:1.4;letter-spacing:-.025em}
  body :is(.pw-header p,.pw-note) {color:var(--a-muted);font-size:13px}
  body .pw-scope {font-size:12px;color:var(--a-primary);letter-spacing:.015em}
  body .pw-categories {
    padding:5px;background:#e9eeea;border-color:var(--a-line);border-radius:10px;
    scrollbar-color:#a3bcb0 transparent;
  }
  body .pw-categories::-webkit-scrollbar-thumb {background:#a3bcb0}
  body .pw-categories .pw-note {background:#e9eeea;color:var(--a-muted);letter-spacing:0;border-color:#cfd9d2}
  body .pw-categories .ghost {font-size:13px!important;min-height:34px;color:#57675d!important}
  body .pw-categories .ghost:hover {background:#dce8df!important;color:var(--a-primary)!important}
  body .pw-categories .ghost:focus-visible {outline-color:var(--a-primary)}
  body .pw-categories button[disabled] {
    background:var(--a-surface)!important;color:var(--a-primary)!important;
    box-shadow:0 1px 3px rgba(23,40,34,.09),inset 0 0 0 1px #c6d9ce!important;
  }
  body .pw-categories button[disabled]::after {background:var(--a-primary)}
  body :is(.pw-project,.pw-template-card,.pw-plan-summary) {background:var(--a-surface);border-color:var(--a-line);border-radius:12px;box-shadow:0 2px 4px rgba(27,45,36,.025)}
  body .pw-project-head {padding:18px 20px}
  body .pw-project-head h3 {font-size:16px;line-height:1.5}
  body .pw-expanded {border-color:var(--a-line);background:#fafcf8}
  body .pw-record-row {padding:14px 0;border-color:var(--a-line);font-size:14px}
  body .pw-record-row strong {font-weight:600;line-height:1.65}
  body .pw-record-row p {font-size:12px;line-height:1.8;color:var(--a-muted)}
  body .pw-actions button.primary {
    min-height:38px;padding:9px 14px;border:1px solid var(--a-primary);border-radius:8px;
    background:var(--a-primary);color:#fff;font:600 13px/1.5 var(--body);cursor:pointer;
  }
  body .pw-actions button.primary:hover:not(:disabled) {background:var(--a-primary-hover);border-color:var(--a-primary-hover)}
  body .pw-actions button.primary:focus-visible {outline:2px solid var(--a-primary);outline-offset:3px}
  body .pw-actions button.primary:disabled {opacity:.45;cursor:not-allowed}
  body .pw-section {font-size:18px;line-height:1.5;letter-spacing:-.02em}
  body .pw-form-type {border-color:var(--a-line)!important;background:var(--a-surface)!important;border-radius:10px!important;color:var(--a-ink)!important}
  body .pw-form-type:hover:not(:disabled) {border-color:#9bbfb0!important;background:#f2f8f1!important}
  body .pw-form-type small {font-size:12px;color:var(--a-muted)}
  body .pw-detail-table {border-color:var(--a-line);border-radius:8px}
  body .pw-detail-table :is(th,td) {padding:10px 12px;border-color:var(--a-line);font-size:13px}
  body .pw-detail-table th {background:#eef3ed;color:#506158;font-weight:600}
  body .pw-pager .ghost {border-radius:8px;font-size:13px}

  /* Delivery workflows keep their ordered steps; only the visual hierarchy changes. */
  body .delivery-root :is(.delivery-intro h2,.delivery-heading h2) {font-size:22px;line-height:1.4;letter-spacing:-.02em}
  body .delivery-stages {border-color:var(--a-line);border-radius:10px;overflow:hidden}
  body .delivery-stages button {background:var(--a-surface);border-radius:0;border-color:var(--a-line);padding:14px 12px}
  body .delivery-stages button.active {background:var(--a-tint);color:var(--a-primary);box-shadow:inset 0 -3px var(--a-primary)}
  body .delivery-stages button small {font-size:12px;color:var(--a-muted)}
  body :is(.delivery-task,.delivery-plan,.delivery-results details,.delivery-history,.delivery-scope,.delivery-item,.delivery-template-editor details) {
    border-color:var(--a-line);border-radius:12px;background:var(--a-surface);
  }
  body .delivery-task {padding:18px}
  body .delivery-task h3 {font-size:16px;line-height:1.5}
  body :is(.delivery-task p,.delivery-plan p,.delivery-plan details,.delivery-task dl,.delivery-plan dl) {font-size:13px;line-height:1.8}
  body :is(.delivery-next,.delivery-access,.delivery-visit-result) {background:var(--a-tint);border-color:var(--a-primary);border-radius:0 10px 10px 0}
  body .delivery-next strong {font-size:17px;color:var(--a-ink)}
  body :is(.delivery-plan-kind,.delivery-route .active button) {color:var(--a-primary)}
  body .delivery-route {border-color:var(--a-line)}
  body .delivery-route button {font-size:12px}
  body .delivery-actions button,body .delivery-runs button,body .delivery-modules button {border-radius:8px;min-height:36px;font-size:13px}
  body .delivery-template-table :is(th,td) {border-color:var(--a-line);font-size:13px}
  body .delivery-template-table th {background:#eef3ed;color:#506158}
  body .delivery-empty {background:#f9fbf7;border-color:#c3d0c8;border-radius:10px}

  /* Reading surfaces and the project journal remain neutral so source material is legible. */
  body .project-journal .pj-heading h2,body .dc-root .dc-heading h2 {font-size:22px;letter-spacing:-.025em}
  body :is(.pj-entry,.pj-filters,.pj-empty,.dc-reader-layout) {border-color:var(--a-line);border-radius:12px;background:var(--a-surface)}
  body .pj-entry h3 {font-size:17px;color:var(--a-ink)}
  body .pj-preview {font-size:14px;line-height:1.85}
  body .pj-views button {border-radius:8px;background:var(--a-surface);font-size:13px;min-height:38px}
  body .pj-views button.active {color:var(--a-primary);border-color:#a8c7b8;background:var(--a-tint);box-shadow:none}
  body .pj-type {background:#edf1eb;color:var(--a-muted);font-size:11px}
  body .pj-source {color:var(--a-primary)}
  body .pj-conclusion {background:#edf5ef;border-left:2px solid #9fc2ad;border-radius:0 8px 8px 0}
  body :is(.pj-content-note,.pj-maintenance,.pj-maintenance-reason,.pj-content pre,.pj-provenance pre) {background:#f2f5ef}
  body .pj-content summary,body .pj-advanced summary,body .pj-help summary {color:var(--a-primary)}
  body .pj-entry-meta {font-size:11px;color:var(--a-muted)}
  body .pj-links .card-link {border-radius:8px;font-size:13px}
  body .dc-modes button {border-radius:10px;padding:16px 18px}
  body .dc-modes button.active {background:var(--a-tint);border-color:#a8c7b8;box-shadow:none}
  body .dc-modes b {font-size:26px;letter-spacing:-.03em}
  body .dc-categories button {border-radius:8px;font-size:13px;min-height:36px}
  body .dc-categories button.active {border-color:#a8c7b8;background:var(--a-tint);color:var(--a-primary)}
  body .dc-record {border-radius:8px}
  body .dc-record:hover {background:#f0f5ed}
  body .dc-record.active {background:var(--a-tint);border-color:#c6dccc}
  body .dc-record-category,body .dc-kicker {color:var(--a-primary);font-size:12px}
  body .dc-record strong {font-size:14px}
  body .dc-record-summary {font-size:12px}
  body .dc-record-meta {font-size:11px}
  body .dc-document-head {background:#f9fbf7}
  body .dc-document-head h3 {font-size:21px;letter-spacing:-.025em}
  body .dc-field-list dd {font-size:14px;line-height:1.85}
  body .dc-field-list dt {font-size:13px;color:var(--a-muted)}
  body .dc-nested-table :is(th,td) {font-size:12px;border-color:var(--a-line)}
  body .dc-nested-table th {background:#eef3ed;color:#506158}
  body .dc-root .dc-nested-table tbody tr:hover {background:#f6f9f2}
  body .dc-raw-value {background:#f1f5ee}
  body .model-help {border-color:var(--a-line);border-radius:10px;background:#f8fbf5}
  body .model-text pre {border-radius:8px;background:#f1f5ee;font-size:14px}
  body :is(.model-text summary,.model-help summary) {color:var(--a-primary)}
  body .journal-entry {border-left-color:var(--a-primary)}

  /* AI employees: make status purposeful, not every panel a primary action. */
  body .ai-button {border:1px solid #bdccc3;border-radius:8px;padding:9px 13px;min-height:36px;background:var(--a-surface);color:var(--a-ink);font-size:13px}
  body .ai-button.primary,body .delivery-modal [data-save] {background:var(--a-primary);border-color:var(--a-primary);color:#fff}
  body .ai-button.primary:hover:not(:disabled),body .delivery-modal [data-save]:hover:not(:disabled) {background:var(--a-primary-hover);border-color:var(--a-primary-hover);filter:none}
  body .ai-connection {background:#edf3ed;border-color:var(--a-line);border-radius:10px}
  body .ai-employee {background:var(--a-surface);border-color:var(--a-line);border-radius:12px}
  body .ai-employee p {font-size:13px;line-height:1.8}
  body .ai-avatar {background:var(--a-tint);color:var(--a-primary);border-radius:10px}
  body .ai-runs {background:var(--a-surface);border-color:var(--a-line);border-radius:12px}
  body .ai-run {border-color:var(--a-line)}
  body .ai-run:hover {background:#f1f6ed}
  body .ai-run strong {font-size:14px}
  body .ai-badge {font-size:11px;background:#edf0ea;color:#5a665f;border-radius:5px}
  body .ai-badge.running {background:#e2f2ed;color:#126258}
  body .ai-badge.needs_review {background:#fff0d7;color:#86551a}
  body .ai-badge.reviewed {background:#e6f3e7;color:#266d3f}
  body .ai-badge.failed,body .ai-badge.interrupted {background:#fff0ec;color:#a43636}
  body .ai-notice,body .ai-draft,body .ai-evidence {background:#f1f5ee;border-color:var(--a-line);color:#4e6254}
  body .ai-evidence {border-left-color:var(--a-primary)}
  body .ai-detail-summary {font-size:14px;line-height:1.85}

  /* Permission / role / account administration. No visibility or permission rules here. */
  body .pa-drawer,body .rg-drawer {background:rgba(23,35,32,.44)}
  body .pa-panel,body .rg-panel {background:var(--a-canvas);color:var(--a-ink);box-shadow:-12px 0 36px rgba(23,40,34,.14)}
  body .pa-head h2,body .rg-head h2 {font-size:25px;line-height:1.4;letter-spacing:-.025em}
  body .pa-head,body .rg-head {border-bottom-color:var(--a-line)}
  body .pa-head p,body .rg-head p {color:var(--a-muted);font-size:13px}
  body .pa-card {padding:20px;border:1px solid var(--a-line);border-radius:12px;background:var(--a-surface)}
  body .pa-card>h3 {font-size:18px;line-height:1.5}
  body .pa-card>p.pa-hint {font-size:13px;color:var(--a-muted)}
  body :is(.pa-list,.pa-tree,.pa-picker-side,.pa-picker-main,.pa-scroll,.rg-list,.rg-people) {border-color:var(--a-line);border-radius:10px;background:var(--a-surface)}
  body .pa-tab,body .pa-btn,body .rg-btn,body .pa-switch button,body .account-form button,body .account-action {
    border-radius:8px;border:1px solid #bdccc3;background:var(--a-surface);color:var(--a-ink);
    font-size:13px;min-height:38px;line-height:1.5;padding:8px 14px;
  }
  body .pa-btn.primary,body .rg-btn.primary,body .account-form button[type=submit] {background:var(--a-primary);border-color:var(--a-primary);color:#fff}
  body .pa-btn.primary:hover:not(:disabled),body .rg-btn.primary:hover:not(:disabled),body .account-form button[type=submit]:hover:not(:disabled) {background:var(--a-primary-hover);border-color:var(--a-primary-hover)}
  body .pa-btn.ghost {background:var(--a-surface);border-color:#a8c7b8;color:var(--a-primary)}
  body .pa-btn.danger,body .rg-btn.danger {color:#a43636;border-color:#dfb6ad;background:#fff8f5}
  body .pa-tab[aria-selected=true],body .pa-switch button[aria-pressed=true],body .pa-tree-label[aria-selected=true],
  body .pa-list button.active,body .rg-list button.active,body .pa-scope label.on {
    background:var(--a-tint);color:var(--a-primary);border-color:#a8c7b8;
  }
  body .pa-tabs {padding:5px;border-radius:10px;background:#e7ede6;gap:4px}
  body .pa-tab {border-color:transparent;background:transparent}
  body .pa-tab[aria-selected=true] {background:var(--a-surface);box-shadow:0 1px 3px rgba(23,40,34,.08)}
  body .pa-list button,body .rg-list button {background:var(--a-surface);color:var(--a-ink);border-color:var(--a-line);font-size:14px}
  body .pa-list small,body .rg-list small,body .rg-hint,body .rg-count,body .rg-scope,body .rg-empty {color:var(--a-muted)}
  body .pa-field :is(input[type=text],input[type=date],select,textarea),
  body .pa-toolbar :is(input[type=text],select),body .pa-picker-side>input,body .pa-picker-main>input,
  body .rg-field :is(input,select) {border:1px solid #bdccc3;border-radius:8px;background:var(--a-surface);color:var(--a-ink);font-size:14px;min-height:40px}
  body .pa-tree-label {border-radius:8px;color:var(--a-ink)}
  body .pa-tree-label:hover,body .pa-picker-row:hover {background:#eef4e9}
  body .pa-tree-label[aria-selected=true] small {color:var(--a-primary)}
  body .pa-picker-row {border-radius:8px}
  body .pa-scope label {border-radius:8px;border-color:var(--a-line);background:var(--a-surface)}
  body :is(.pa-perms,.pa-picker-row,.rg-perms,.rg-scope,.rg-people) input,
  body .pa-check {accent-color:var(--a-primary)}
  body .pa-chip,body .rg-chip {border-radius:6px;border-color:var(--a-line);background:#e9efe7;color:#465b4e}
  body .pa-chip button,body .rg-chip button {color:#556b5c}
  body .rg-matched {background:var(--a-tint);color:#426558}
  body .rg-matched b {color:var(--a-primary)}
  body .pa-tag {border-radius:5px;background:#edf1e9;border-color:var(--a-line)}
  body .pa-tag.ok {background:#e6f3e7;color:#266d3f;border-color:#c5dfcb}
  body .pa-tag.off {background:#fff0d7;color:#86551a;border-color:#ead2ab}
  body .pa-tag.danger {background:#fff0ec;color:#a43636;border-color:#dfb6ad}
  body .pa-table th {background:#edf2e9;border-color:var(--a-line);color:#506158;font-size:13px;font-weight:600}
  body .pa-table td {border-color:var(--a-line);font-size:14px;color:var(--a-ink)}
  body .pa-table tbody tr:hover,body .pa-table tr.clickable:hover {background:#f2f7ed}
  body .account-projects,body .account-row {border-color:var(--a-line)}
  body .account-projects {background:#f7faf3;border-radius:8px}
  body .pa-btn:focus-visible,body .rg-btn:focus-visible,
  body .pa-tab:focus-visible,body .pa-switch button:focus-visible,
  body .rg-field :is(input,select):focus-visible {
    outline:2px solid var(--a-primary);outline-offset:3px;
  }
}

@media screen and (max-width:760px) {
  body .ai-modal-head,body .ai-modal-body,body .ai-modal-foot {padding:16px}
  body .ai-modal-head h2 {font-size:19px}
  body .pw-ai-panel {padding:14px;border-radius:10px}
  body .pw-header h2 {font-size:21px}
  body .pw-project-head {padding:16px}
  body .pw-record-row {gap:10px}
  body .pw-categories .ghost {min-height:44px;font-size:12px!important}
  body .pw-form-type {min-height:66px}
  body .delivery-task {padding:14px}
  body .dc-document-head h3 {font-size:19px}
  body :is(.pw-actions,.pw-global-filters,.pw-pager,.delivery-actions,.delivery-runs,.delivery-modules) button,
  body .pw-actions button.primary,body .ai-button,body .ai-close,body .pa-btn,body .pa-tab,body .rg-btn,
  body .pa-switch button,body .account-action,body .account-form button,
  body .pj-views button,body .dc-search .ghost,body .dc-pagination .ghost,
  body .pj-filter-main>.ghost,body .pj-pagination .ghost,
  body .ai-field :is(input,select),body .account-form :is(input:not([type=checkbox]):not([type=radio]),select) {min-height:44px}
  body .ai-close {width:44px}
  body .pa-card {padding:16px}
  body .pa-head h2,body .rg-head h2 {font-size:22px}
  body .pa-tabs {gap:4px}
}

@media screen and (prefers-reduced-motion:reduce) {
  body :is(.ai-button,.pa-btn,.rg-btn,.pw-ai-btn,.pw-form-type) {transition:none!important}
}
