/* RC13-HF1 · Agency visual consistency and layout repair */
.ui-v6.org-agency{
  --agency-surface:var(--surface,#0d1420);
  --agency-surface-alt:var(--surface-alt,#111b2a);
  --agency-border:var(--border,#26354a);
  --agency-text:var(--text,#f4f7fb);
  --agency-muted:var(--muted,#94a3b8);
  --agency-primary:var(--brand-primary,#8b5cf6);
  --agency-secondary:var(--brand-secondary,#22d3ee);
}
.ui-v6.org-agency .r-main,
.ui-v6.org-agency .r-workspace{color:var(--agency-text)!important}
.ui-v6.org-agency .r-head h1,
.ui-v6.org-agency .r-head h2,
.ui-v6.org-agency .r-head p,
.ui-v6.org-agency .r-card h1,
.ui-v6.org-agency .r-card h2,
.ui-v6.org-agency .r-card h3,
.ui-v6.org-agency .r-card b,
.ui-v6.org-agency .r-card strong{color:var(--agency-text)!important}
.ui-v6.org-agency .r-head p,
.ui-v6.org-agency .r-muted,
.ui-v6.org-agency .r-card small{color:var(--agency-muted)!important}

.ui-v6.org-agency .r-card,
.ui-v6.org-agency .r-kpis>div,
.ui-v6.org-agency .core-kpi-grid>div,
.ui-v6.org-agency .core-kpi-grid>article{
  background:var(--agency-surface)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
  box-shadow:none!important;
}
.ui-v6.org-agency .r-card-head{border-color:var(--agency-border)!important}
.ui-v6.org-agency .r-card input,
.ui-v6.org-agency .r-card select,
.ui-v6.org-agency .r-card textarea,
.ui-v6.org-agency .r-form-grid input,
.ui-v6.org-agency .r-form-grid select,
.ui-v6.org-agency .r-form-grid textarea{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .r-card input::placeholder,
.ui-v6.org-agency .r-card textarea::placeholder{color:color-mix(in srgb,var(--agency-muted) 82%,transparent)!important}
.ui-v6.org-agency .r-btn:not(.danger):not(.wa){
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .r-btn.ghost{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-text)!important;
}
.ui-v6.org-agency .r-btn:not(.ghost):not(.danger):not(.wa),
.ui-v6.org-agency button.r-btn:not(.ghost):not(.danger){
  background:linear-gradient(135deg,var(--agency-primary),var(--agency-secondary))!important;
  color:#fff!important;
  border-color:transparent!important;
}

/* Intake: use Agency tokens instead of the Legal/light defaults. */
.ui-v6.org-agency #intake-hf2-root{
  --i-primary:var(--agency-primary)!important;
  --i-secondary:var(--agency-secondary)!important;
  --i-accent:var(--brand-accent,#d946ef)!important;
  --i-text:var(--agency-text)!important;
  --i-muted:var(--agency-muted)!important;
  --i-surface:var(--agency-surface)!important;
  --i-bg:var(--app-bg,#070b13)!important;
  color:var(--agency-text)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-toolbar h2,
.ui-v6.org-agency #intake-hf2-root .i-toolbar p,
.ui-v6.org-agency #intake-hf2-root .i-card h2,
.ui-v6.org-agency #intake-hf2-root .i-card header p{color:inherit!important}
.ui-v6.org-agency #intake-hf2-root .i-toolbar small,
.ui-v6.org-agency #intake-hf2-root .i-card header small,
.ui-v6.org-agency #intake-hf2-root .i-messages summary small{
  color:var(--agency-primary)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-kpis>div,
.ui-v6.org-agency #intake-hf2-root .i-card,
.ui-v6.org-agency #intake-hf2-root .i-link,
.ui-v6.org-agency #intake-hf2-root .i-revoked-group,
.ui-v6.org-agency #intake-hf2-root .i-empty{
  background:var(--agency-surface)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
  box-shadow:none!important;
}
.ui-v6.org-agency #intake-hf2-root .i-empty,
.ui-v6.org-agency #intake-hf2-root .i-link-body code,
.ui-v6.org-agency #intake-hf2-root .i-revoked-group>summary{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-muted)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-link-body,
.ui-v6.org-agency #intake-hf2-root .i-help li,
.ui-v6.org-agency #intake-hf2-root .i-request-row{border-color:var(--agency-border)!important}
.ui-v6.org-agency #intake-hf2-root .i-actions button,
.ui-v6.org-agency #intake-hf2-root .i-actions a{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-actions .wa{background:#169b72!important;color:#fff!important}
.ui-v6.org-agency #intake-hf2-root .i-hf7-message{
  background:var(--agency-surface-alt)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-hf7-message input,
.ui-v6.org-agency #intake-hf2-root .i-hf7-message textarea{
  background:#09111e!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-hf7-message-actions button{
  background:var(--agency-surface)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency #intake-hf2-root .i-hf7-message-actions button.primary{
  background:linear-gradient(135deg,var(--agency-primary),var(--agency-secondary))!important;
  border-color:transparent!important;
}

/* Agency Intake modal: branded shell, white QR canvas only. */
.ui-v6.org-agency .i-hf2-modal-wrap{
  --i-primary:var(--agency-primary)!important;
  --i-secondary:var(--agency-secondary)!important;
  --i-accent:var(--brand-accent,#d946ef)!important;
  --i-text:var(--agency-text)!important;
  --i-muted:var(--agency-muted)!important;
  --i-surface:var(--agency-surface)!important;
  background:rgba(3,7,14,.78)!important;
}
.ui-v6.org-agency .i-modal{
  background:var(--agency-surface)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .i-modal h2,
.ui-v6.org-agency .i-modal h3,
.ui-v6.org-agency .i-modal b{color:var(--agency-text)!important}
.ui-v6.org-agency .i-modal input,
.ui-v6.org-agency .i-modal select,
.ui-v6.org-agency .i-modal textarea,
.ui-v6.org-agency .i-modal .i-step,
.ui-v6.org-agency .i-modal .i-ready,
.ui-v6.org-agency .i-modal .i-preview-mini{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .i-modal .i-qr{background:#fff!important;border-color:#dbe3ec!important}
.ui-v6.org-agency .i-modal .i-note{background:#09111e!important;border-color:var(--agency-border)!important}

/* Finance surfaces in Agency */
.ui-v6.org-agency .responsive-table-wrap,
.ui-v6.org-agency .r-table,
.ui-v6.org-agency .work-list,
.ui-v6.org-agency .work-row{
  background:transparent!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .r-table th,
.ui-v6.org-agency .r-table td{border-color:var(--agency-border)!important}
.ui-v6.org-agency .r-table th{color:var(--agency-muted)!important}
.ui-v6.org-agency .dashboard-grid>.r-card{min-width:0!important}
html.page-finance-ledger .ui-v6.org-agency .dashboard-grid{
  grid-template-columns:minmax(500px,.9fr) minmax(0,1.45fr)!important;
  align-items:start!important;
}
html.page-finance-ledger .ui-v6.org-agency .dashboard-grid>.r-card:first-child{grid-column:auto!important}
html.page-finance-ledger .ui-v6.org-agency .dashboard-grid>.r-card.span-2{grid-column:auto!important}
html.page-finance-ledger .ui-v6.org-agency .r-form-grid{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:12px!important;
}
html.page-finance-ledger .ui-v6.org-agency .r-form-grid>*{min-width:0!important}

/* Settings singleton */
.ui-v6.org-agency .i-hf7-settings-card{
  grid-column:1/-1!important;
  width:100%!important;
  max-width:none!important;
  background:var(--agency-surface)!important;
  border-color:var(--agency-border)!important;
}
.ui-v6.org-agency .i-hf7-settings-card input{
  background:var(--agency-surface-alt)!important;
  color:var(--agency-text)!important;
  border-color:var(--agency-border)!important;
}

@media(max-width:980px){
  html.page-finance-ledger .ui-v6.org-agency .dashboard-grid{grid-template-columns:1fr!important}
}
@media(max-width:620px){
  html.page-finance-ledger .ui-v6.org-agency .r-form-grid{grid-template-columns:1fr!important}
}
