/*
 * Full UI unification contract.
 *
 * This file is intentionally loaded after the legacy surface styles. The
 * application still has several focused renderers, but typography, action
 * hierarchy and compact-shell geometry must not drift between them.
 */
:root {
  --ui-body-size: 14px;
  --ui-secondary-size: 12px;
  --ui-interactive-size: 13px;
  --ui-financial-size: 13px;
  --ui-row-height: 40px;
 /* Readable secondary ink on light Telegram themes (was #777–#999 / hint). */
  --ui-muted: color-mix(in srgb, var(--tg-theme-text-color, #111) 78%, #334155);
  --ui-muted-strong: color-mix(in srgb, var(--tg-theme-text-color, #111) 90%, #1f2937);
 /* Active solid fills must keep white label ≥ WCAG AA (raw #3390ec fails ~3.3:1). */
  --ui-accent-solid: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 40%, #03101c);
  --ui-on-accent: #ffffff;
 /* Accent *text* (eyebrows / active nav) — dark enough on white *and* accent-soft wells. */
  --ui-accent-ink: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 22%, #0a1f38);
}

html[data-theme="dark"] {
  --ui-accent-solid: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 58%, #07111c);
  --ui-muted: color-mix(in srgb, var(--tg-theme-text-color, #f5f5f5) 82%, #cbd5e1);
  --ui-muted-strong: color-mix(in srgb, var(--tg-theme-text-color, #f5f5f5) 92%, #e2e8f0);
 /* Light ink ≥ 4.5:1 on dark nav active soft (#344a63-class wells). */
  --ui-accent-ink: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 28%, #eaf3ff);
}

body {
  min-width: 0;
  font-size: var(--ui-body-size);
  line-height: 1.42;
}

:where(button, [role="button"], input, select, textarea, summary) {
  font-size: max(var(--ui-interactive-size), 1em);
}

:where(.fin, .meta, .hint, .muted, small, .workspace-eyebrow, .workspace-nav-group,
  .workspace-nav-badge, .workspace-empty > span:not(.workspace-empty-icon),
  .admin-state span, .platform-panel-head p, .platform-kpi span, .platform-kpi small,
  .platform-overview-note, .platform-mode-banner small, .pf-freshness) {
  font-size: var(--ui-secondary-size);
  line-height: 1.4;
}

.platform-panel-head p,
.pf-config-hint {
  font-size: 12px !important;
}

:where(.ovv, .dc-net, .dc-feed-profit, .reg-stack-value, .led-strong, .fin-flow,
  .cash-balance-table td, .platform-kpi b, .pf-bill-num, .pf-remain-num) {
  font-size: max(var(--ui-financial-size), 1em);
  font-variant-numeric: tabular-nums;
}

/* Global chrome: one compact header row plus one navigation row at 1024px. */
#hdr {
  min-height: 46px;
  box-sizing: border-box;
}

/* Keep headerBottom ≤66 at the 1024 compact-chrome e2e contract.
 Geometry = body top padding (≥8) + #hdr box; reclaim ~4px inside #hdr only. */
@media (min-width: 921px) and (max-width: 1100px) {
 #hdr {
    padding: 2px 5px;
    gap: 3px 6px;
    margin-bottom: 5px;
    min-height: 38px;
  }

  .hdr-btn,
  body.pro .hdr-btn,
  .hdr-appearance {
    min-width: 32px;
    min-height: 32px;
    border-radius: 9px;
  }

  body.lite #hdr-tools .hdr-icon-btn,
  body.lite #hdr-tools .help-q {
    min-width: var(--app-control-height, 44px);
    min-height: var(--app-control-height, 44px);
  }

  .appearance-toggle {
    min-height: 30px;
    padding: 2px;
  }

  .appearance-segment {
    min-height: 26px;
  }

  body.lite #search-btn.hdr-search,
  body.pro #search-btn.hdr-search {
    min-height: 32px;
  }
}

#status,
#search-btn.hdr-search,
.appearance-toggle,
.appearance-segment,
.tab {
  font-size: var(--ui-interactive-size);
}

#tabs {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

#tabs .tab {
  min-height: 40px;
}

body.lite #tabs .tab {
  font-size: var(--ui-interactive-size);
}

@media (min-width: 921px) and (max-width: 1100px) {
  body.pro #hdr {
    min-height: 46px;
  }

  body.pro #tabs {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }
}

@media (min-width: 701px) {
  body.lite #hdr {
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 420px) auto;
    grid-template-areas: "tenant search tools";
    min-height: 46px;
  }

  body.lite #hdr #status {
    display: none;
  }

  body.lite #search-btn.hdr-search {
    width: 100%;
    min-height: 38px;
  }
}

/* Shared workspaces: remove duplicate hero prose and keep the current task. */
.workspace-hero {
  min-height: 50px;
  padding: 9px 12px;
}

.workspace-hero h1 {
  margin: 0;
  font-size: 18px;
}

.workspace-hero p {
  display: none;
}

.workspace-eyebrow {
  margin-bottom: 2px;
}

.workspace-nav-item {
  min-height: 40px;
  font-size: var(--ui-interactive-size);
}

.workspace-nav-icon {
  font-size: var(--ui-interactive-size);
}

.platform-panel-head h2,
.cab-panel-head h2 {
  font-size: 18px;
}

/* Tables are working surfaces, never micro-copy. */
:where(#grid, .mini, .refs-table, .pf-client-table, .pf-billing-table, .cash-balance-table) {
  font-size: var(--ui-body-size);
}

:where(#grid, .mini, .refs-table, .pf-client-table, .pf-billing-table, .cash-balance-table) th {
  min-height: 34px;
  padding-block: 8px;
  font-size: var(--ui-interactive-size);
  line-height: 1.3;
}

:where(#grid, .mini, .refs-table, .pf-client-table, .pf-billing-table, .cash-balance-table) td {
  height: var(--ui-row-height);
  padding-block: 8px;
  font-size: var(--ui-body-size);
  line-height: 1.35;
}

body.pro #grid:not(.deals-registry) > tbody > tr > td,
body.pro #grid tbody table td {
  font-size: var(--ui-body-size);
}

/* Deals readability tail → ui-unification_deals.css. */

/* Finance: cash tasks are a dense table, not tall cards. */
.cash-tasks-head,
.cash-zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin: 0 0 3px;
}

.cash-tasks-title,
.cash-zone-title {
  font-size: 12px;
  letter-spacing: -.1px;
}

.cash-tasks-wrap {
  position: relative;
  z-index: 1;
  max-height: min(28vh, 220px);
  overflow: auto;
  margin-bottom: 12px;
  border: 1px solid rgba(127, 127, 127, .16);
  border-radius: 10px;
  background: var(--tg-theme-secondary-bg-color, rgba(127, 127, 127, .04));
}

.cash-tasks-view-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cash-tasks-view-table .cash-tasks-table {
  min-width: 680px;
}
@media (max-width: 700px) {
  .cash-tasks-view-table .cash-tasks-table { min-width: 0; }
}


/* Compact cash-task / sidebar / onchain density → ui-unification_compact.css */
/* Counterparties and Platform use the same list readability floor. */
.refs-table,
.pf-client-table,
#platform-bar .pf-billing-table {
  font-size: var(--ui-body-size);
}

.refs-table th,
.pf-client-table th,
#platform-bar .pf-billing-table th,
.rf-table-id,
.pf-client-actions :where(.rk, .del),
#platform-bar .pf-bill-badge {
  font-size: var(--ui-secondary-size);
}

.rf-name,
.rf-table-name,
.workspace-stack-head b {
  font-size: var(--ui-body-size);
}

/* Settings and admin: explicit save scopes and separated destructive zones. */
.set-section {
  max-width: 920px;
}

.set-section-head h3,
body.dense .set-section-head h3 {
  font-size: 15px;
}

.set-section-body .frow > label,
.platform-advanced .frow > label,
.pf-config-card .frow > label {
  font-size: var(--ui-interactive-size);
}

.ui-action.ecosystem-danger {
  font-size: var(--ui-interactive-size);
}

#settings-bar .ui-action,
#platform-bar .ui-action {
  font-size: var(--ui-interactive-size);
}

[data-workspace-panel="danger"] .set-section,
.ecosystem-danger-zone,
.pf-cab-danger {
  border-color: color-mix(in srgb, var(--ui-danger, #d43b43) 38%, transparent) !important;
  background: color-mix(in srgb, var(--ui-danger, #d43b43) 7%, var(--tg-theme-bg-color, #fff));
}

[data-workspace-panel="danger"] :where(.btn-primary, .rk.active) {
  color: var(--ui-danger, #d43b43);
  border-color: color-mix(in srgb, var(--ui-danger, #d43b43) 28%, transparent);
  background: transparent;
  box-shadow: none;
}

/*
 * Operational admin surfaces used legacy 9–11px utility copy. Keep their
 * compact geometry, but never shrink identifiers, labels or audit evidence
 * below the shared secondary-text floor.
 */
#platform-bar :where(
  .pf-cab-id, .pf-cab-metric span, .pf-cab-stats-line, .pf-section-label,
  .pf-ops-empty-note, .pf-event-note, .pf-copy-request-id,
  .pf-audit-meta-item, .pf-audit-summary, .pf-audit-details-body,
  .pf-chip-sm, .pf-muted-11, .pf-billing-table th, .pf-bill-badge,
  .pf-client-table th, .pf-client-actions .rk, .pf-client-actions .del,
  .platform-kpi span, .platform-kpi small, .platform-overview-note,
  .platform-mode-banner small, .pf-badge
) {
  font-size: var(--ui-secondary-size) !important;
  line-height: 1.4;
}

#settings-bar :where(
  .admin-state span, .admin-access-badge, .admin-field > span,
  .member-invite > .ecosystem-field-row > label, .member-identity small
) {
  font-size: var(--ui-secondary-size);
  line-height: 1.4;
}

/* Balanced populated and sparse grids. */
:where(.dash-grid, .dash-fin-grid, .platform-kpi-grid, .cab-summary-grid, #pf-cab-list,
  .mk-card-grid, .ui-responsive-grid) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  align-items: stretch;
}

:where(.admin-state, .workspace-empty, .ref-empty-state, .finance-empty) {
  width: min(100%, 760px);
  margin-inline: auto;
}

#platform-bar,
#platform-bar :where(.workspace-shell, .workspace-layout, .workspace-content, .workspace-panel,
  .platform-panel-body, .pf-domain, .pf-billing-table-wrap) {
  min-width: 0;
  max-width: 100%;
}

#platform-bar .pf-billing-search input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 700px) {
 #platform-bar .pf-billing-table-wrap {
    overflow-x: clip;
  }

 #platform-bar .pf-billing-table tr {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

 #platform-bar .pf-billing-table td {
    min-width: 0;
  }
}

/* Mobile/Lite keeps generous touch targets without turning fields into giant blocks. */
@media (max-width: 700px) {
  :where(button, [role="button"], summary, select) {
    min-height: 44px;
  }

  body.lite #hdr {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "search tools" "status status";
    gap: 4px;
    margin-bottom: 5px;
    padding: 5px;
  }

  body.lite #tenant {
    display: none;
  }

  body.lite #hdr-tools {
    width: 100%;
    min-width: 0;
    justify-self: stretch;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
  }

  body.lite #hdr-tools .appearance-toggle {
    min-width: 0;
    flex: 1 1 calc(33% - 6px);
  }

  body.lite #hdr-tools .appearance-mode,
  body.lite #hdr-tools .appearance-theme,
  body.lite #hdr-tools .appearance-lang {
    flex: 1 1 calc(33% - 6px);
  }

  body.lite #hdr-tools .appearance-segment {
    min-height: 36px;
    min-width: 0;
    padding: 0 6px;
  }

  body.lite #status {
    max-height: 32px;
    overflow: hidden;
  }

  body.lite #search-btn.hdr-search {
    width: var(--app-control-height, 44px);
    min-width: var(--app-control-height, 44px);
    min-height: var(--app-control-height, 44px);
    padding: 0;
    grid-template-columns: auto;
    justify-self: start;
  }

  .workspace-hero {
    min-height: 48px;
    padding: 8px 10px;
  }

  .workspace-hero h1 {
    font-size: 17px;
  }

  .cash-tasks-wrap {
    max-height: min(32vh, 240px);
  }

  .cash-tasks-view-table {
    max-height: min(40vh, 320px);
  }

  .cash-create { width: auto; }

  .cash-move-field > input,
  .cash-move-field > select,
  .cash-move-form > .cd-save {
    height: 44px !important;
    min-height: 44px;
    max-height: 44px;
  }

  .cash-move-form,
  .fin-modal-form > .frow,
  .fin-modal-grid,
  .cash-shift-counts {
    grid-template-columns: 1fr;
  }

 #grid.shift-grid {
    border: 0;
    border-collapse: separate;
    background: transparent;
  }

 #grid.shift-grid > tbody {
    display: grid;
    gap: 12px;
  }

 #grid.shift-grid > tbody > tr {
    margin: 0;
  }

 #grid.shift-grid .shift-count-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px 12px;
    padding: 11px;
    border: 1px solid var(--ui-border, rgb(0 0 0 / 8%));
    border-radius: 12px;
    background: var(--tg-theme-bg-color, #fff);
  }

 #grid.shift-grid .shift-count-row > td {
    display: grid;
    align-content: start;
    height: auto !important;
    min-height: 54px;
    padding: 0 !important;
    background: transparent !important;
    box-sizing: border-box;
  }

 #grid.shift-grid .shift-count-row > td::before {
    margin-bottom: 4px;
    font-size: var(--ui-secondary-size);
    line-height: 1.3;
  }

 #grid.shift-grid :is(.shift-intro-row, .shift-onchain-row, .shift-action-row) > td {
    grid-column: 1 / -1;
    width: 100%;
    height: auto !important;
    box-sizing: border-box;
  }

  :where(#grid, .mini, .refs-table, .pf-client-table, .pf-billing-table, .cash-balance-table) td {
    font-size: var(--ui-body-size);
  }
}

@media (max-width: 420px) {
  .workspace-eyebrow {
    display: none;
  }

  .workspace-hero {
    min-height: 44px;
  }
}

/* Cabinet + Platform content: same airy ecosystem contract as Finance */
#settings-bar .cab-panel-stack,
#platform-bar .workspace-panel-stack {
  gap: 10px;
}

#settings-bar .set-section.ecosystem-card,
#platform-bar .ecosystem-card {
  padding: 12px 13px;
  border-radius: 14px;
  border-color: rgba(127, 127, 127, 0.14);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.045);
}

#settings-bar .set-section-head h3,
#platform-bar .platform-panel-head h2,
#platform-bar .pf-card-head b {
  letter-spacing: -0.2px;
  font-weight: 700;
}

#settings-bar .set-section-body,
#platform-bar .ecosystem-form {
  display: grid;
  gap: 8px;
}

#settings-bar .ecosystem-field-row,
#platform-bar .ecosystem-field-row,
#platform-bar .pf-field-row {
  gap: 6px;
}

#platform-bar .platform-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px;
}

#platform-bar .platform-kpi {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(127, 127, 127, 0.14);
  background: var(--tg-theme-secondary-bg-color, rgba(127, 127, 127, 0.05));
  box-shadow: none;
}

#platform-bar .platform-kpi b {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  letter-spacing: -0.3px;
  line-height: 1.15;
}

#platform-bar .platform-kpi span,
#platform-bar .platform-kpi small {
  color: var(--tg-theme-hint-color, #68717d);
}

#platform-bar .pf-cab-table,
#platform-bar .pf-client-table,
#platform-bar .pf-billing-table {
  border-collapse: separate;
  border-spacing: 0;
}

#platform-bar :is(.pf-cab-table, .pf-client-table, .pf-billing-table) th {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--tg-theme-hint-color, #68717d);
}

#platform-bar :is(.pf-cab-table, .pf-client-table, .pf-billing-table) td {
  padding-top: 9px;
  padding-bottom: 9px;
}

html[data-theme="dark"] #settings-bar .set-section.ecosystem-card,
html[data-theme="dark"] #platform-bar .ecosystem-card,
html[data-theme="dark"] #platform-bar .platform-kpi {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 700px) {
 #settings-bar .set-section.ecosystem-card,
 #platform-bar .ecosystem-card {
    padding: 11px;
    border-radius: 12px;
  }

 #platform-bar .platform-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* —— Contrast + Platform density (analytics-like) —— */
:where(.fin, .muted, .kl, td.ro, .dash-fin-muted, .meta-muted, .reg-fpick-kind,
  .pf-mod-muted, .lh-bal-label, .lh-sub, .platform-panel-head p, .pf-config-hint,
  .workspace-nav-group, .workspace-nav-badge, .finance-metric-label,
  .platform-kpi span, .platform-kpi small, .pf-freshness, .workspace-stack-id,
  .workspace-stack-sub, .cash-tasks-table th) {
  color: var(--ui-muted) !important;
  opacity: 1;
}

.dc-leg-in, .dc-leg-out {
  color: var(--ui-muted-strong) !important;
  font-weight: 650;
}
.dc-leg-in { color: #0a6b5c !important; }
.dc-leg-out { color: #3d4bb8 !important; }

#deals-cards .dcard {
  padding: 7px 9px;
}

/* Deal feed actions: never leave primary white text on a washed grey .act well. */
#deals-cards .dc-feed-actions,
#deals-cards .dc-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
#deals-cards .dc-feed-actions .ui-action.act,
#deals-cards .dc-acts .ui-action.act,
#deal-card .dc-head-acts .ui-action.act {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  opacity: 1;
}
#deals-cards .dc-feed-actions .ui-action.is-primary.act,
#deals-cards .dc-feed-actions .ui-action.act.is-complete,
#deals-cards .dc-feed-actions .ui-action.act[data-act="completed"],
#deal-card .dc-head-acts .ui-action.is-primary.act,
#deal-card .dc-head-acts .ui-action.act[data-act="completed"] {
  color: #fff !important;
  background: #1a8d3e !important;
  border: 1px solid rgba(14, 110, 48, .55) !important;
}
#deals-cards .dc-feed-actions .ui-action.is-danger.act,
#deals-cards .dc-feed-actions .ui-action.act[data-act="archived"],
#deal-card .dc-head-acts .ui-action.is-danger.act {
  color: #b42318 !important;
  background: rgba(180, 35, 24, .12) !important;
  border: 1px solid rgba(180, 35, 24, .35) !important;
}
#deals-cards .dc-feed-actions .ui-action.act.is-blocked,
#deals-cards .dc-feed-actions .ui-action.act:disabled {
  color: #8a4b00 !important;
  background: rgba(228, 138, 38, .18) !important;
  border: 1px solid rgba(196, 110, 20, .45) !important;
  opacity: 1;
}
.dc-feed-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 4px;
}
.dc-feed-progress .dc-feed-flag {
  font-size: 10.5px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ui-muted-strong);
  background: rgba(127, 127, 127, .12);
}
.dc-feed-progress .dc-feed-flag.is-pending {
  color: #8a4b00;
  background: rgba(228, 138, 38, .16);
}
.dc-feed-progress .dc-feed-flag.is-cash {
  color: #0b6e4f;
  background: rgba(26, 141, 62, .12);
}
.dc-feed-progress .dc-feed-flag.is-delivery {
  color: #2f5bb8;
  background: rgba(51, 144, 236, .14);
}
.dc-feed-progress .dc-feed-flag.is-debt {
  color: #b42318;
  background: rgba(180, 35, 24, .12);
}
html[data-theme="dark"] #deals-cards .dc-feed-actions .ui-action.act.is-blocked,
html[data-theme="dark"] #deals-cards .dc-feed-actions .ui-action.act:disabled {
  color: #ffd089 !important;
  background: rgba(228, 138, 38, .28) !important;
  border-color: rgba(255, 208, 137, .45) !important;
}
html[data-theme="dark"] .dc-feed-progress .dc-feed-flag.is-pending { color: #ffd089; }
html[data-theme="dark"] .dc-feed-progress .dc-feed-flag.is-debt { color: #ff8a80; }
html[data-theme="dark"] #deal-card .dc-head-acts .ui-action.is-danger.act {
  color: #ff8a80 !important;
}

/* New deal modal: theme-safe surfaces (no light wash on dark / grey-on-grey). */
#deal-form-modal #form .nf-section {
  background: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #eef2f7) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--tg-theme-hint-color, #708090) 28%, transparent);
}
#deal-form-modal #form .nf-section-title,
#deal-form-modal #form .nf-route-help,
#deal-form-modal #form .nf-head span {
  color: var(--ui-muted-strong) !important;
  opacity: 1;
}
#deal-form-modal #form .nf-segment-modes {
  display: flex;
  flex-wrap: nowrap !important;
  gap: 4px;
  width: 100%;
  grid-auto-flow: unset;
  grid-auto-columns: unset;
}
#deal-form-modal #form .nf-segment-modes .rk {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}
#deal-form-modal #form .nf-segment-modes .dm-buy-desk {
  flex: 1 1 0;
  order: 0;
  color: #0b6e4f !important;
  border: 1px solid rgba(26, 141, 62, .35);
  background: rgba(26, 141, 62, .12);
}
#deal-form-modal #form .nf-segment-modes .dm-buy-desk.active {
  color: #fff !important;
  background: #1a8d3e;
  border-color: transparent;
}
/* Dark: soft green well + dark ink fails axe — lift chip ink. */
html[data-theme="dark"] #deal-form-modal #form .nf-segment-modes .dm-buy-desk,
.overlay[data-theme="dark"] #deal-form-modal #form .nf-segment-modes .dm-buy-desk {
  color: #8af0c4 !important;
  border-color: rgba(138, 240, 196, .4);
  background: rgba(26, 141, 62, .28);
}
html[data-theme="dark"] #deal-form-modal #form .nf-segment-modes .dm-buy-desk.active,
.overlay[data-theme="dark"] #deal-form-modal #form .nf-segment-modes .dm-buy-desk.active {
  color: #fff !important;
  background: #1a8d3e;
  border-color: transparent;
}
#deal-form-modal #form .nf-section-purchase {
  border-color: rgba(26, 141, 62, .28);
  background: color-mix(in srgb, rgba(26, 141, 62, .08) 70%,
    var(--tg-theme-secondary-bg-color, #eef2f7));
}
html[data-theme="dark"] #deal-form-modal #form .nf-section,
.overlay[data-theme="dark"] #deal-form-modal #form .nf-section {
  background: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #1f2a36) 88%, #000);
  border-color: rgba(255, 255, 255, .12);
}

/* Platform advanced: short numeric fields, not full-bleed inputs. */
#platform-bar .pf-config-card .ecosystem-field-row {
  display: grid;
  grid-template-columns: minmax(9rem, 12rem) minmax(5rem, 8.5rem) auto;
  align-items: center;
  gap: 6px 10px;
  margin: 5px 0;
}
#platform-bar .pf-config-card .ecosystem-field-row > label {
  margin: 0;
  font-size: var(--ui-interactive-size);
  color: var(--ui-muted-strong);
}
#platform-bar .pf-config-card .pf-cfg-num {
  width: 7.5rem;
  max-width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--tg-theme-text-color, #111);
  background: var(--tg-theme-bg-color, #fff);
  border: 1px solid var(--ui-border-strong, rgba(127, 127, 127, .38));
  border-radius: 8px;
  box-sizing: border-box;
}
#platform-bar .pf-config-card .pf-cfg-text {
  max-width: min(28rem, 100%);
  flex: 0 1 28rem;
}
#platform-bar .pf-config-wide .ecosystem-field-row {
  grid-template-columns: minmax(9rem, 12rem) minmax(0, 1fr) auto;
}
#platform-bar .platform-plan-card .ecosystem-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  gap: 4px 8px;
}
#platform-bar .platform-plan-card .ecosystem-field-row input {
  max-width: 7rem;
  justify-self: end;
}

/* Cabinets + cash desks: denser analytics-like cards. */
#platform-bar .pf-cab-card {
  padding: 10px 11px;
  border-radius: 12px;
  gap: 7px;
}
#platform-bar .pf-cab-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
#platform-bar .pf-cab-metric {
  padding: 5px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #eef2f7) 80%, transparent);
  border: 1px solid rgba(127, 127, 127, .10);
}
#platform-bar .pf-cab-metric b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#platform-bar .pf-cab-top-actions {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 5px;
}
#platform-bar .pf-cab-top-actions > button {
  min-height: 34px;
  font-size: 12.5px;
}
.cash-desk-card {
  padding: 9px 10px;
  border-radius: 12px;
}
.cash-desk-head {
  margin-bottom: 6px;
}
.cash-balance-table th,
.cash-balance-table td {
  padding: 4px 6px;
  font-size: 13px;
}

/* Platform shell: compact nav + wide dense content like Finance analytics */
#platform-bar {
  width: min(1480px, calc(100% - 16px)) !important;
  margin: 8px auto 20px !important;
}
#platform-bar .workspace-hero {
  min-height: 44px;
  padding: 8px 12px;
}
#platform-bar .workspace-hero h1 { font-size: 17px; }
#platform-bar .workspace-layout {
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 8px;
}
#platform-bar .workspace-nav {
  padding: 5px;
  gap: 2px;
  border-radius: 12px;
}
#platform-bar .workspace-nav-item {
  min-height: 34px;
  padding: 5px 7px;
 font-size: var(--ui-interactive-size); /* ≥13px — e2e guards interactive micro-copy */
  border-radius: 9px;
}
#platform-bar .workspace-nav-icon {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
  font-size: 11px;
  border-radius: 7px;
}
#platform-bar .workspace-nav-group {
  margin: 6px 6px 1px;
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--ui-muted-strong) !important;
}
#platform-bar .platform-kpi {
  min-height: 56px !important;
  padding: 9px 10px !important;
}
#platform-bar .platform-kpi b { font-size: 16px !important; }
#platform-bar .platform-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
#platform-bar .platform-plan-card {
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid rgba(127, 127, 127, .14);
  background: var(--tg-theme-bg-color, #fff);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#platform-bar .platform-plan-card .ecosystem-field-row input {
  max-width: 140px;
}
#platform-bar .platform-plan-mod-head {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ui-muted-strong);
}
#platform-bar .platform-plan-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
#platform-bar .platform-plan-mod {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--tg-theme-text-color, #111);
  cursor: pointer;
}
#platform-bar .pf-cab-metric,
#platform-bar .pf-cab-card .kl {
  color: var(--ui-muted-strong) !important;
}
#platform-bar .pf-cab-card .fin,
#platform-bar .pf-manage-sub {
  color: var(--ui-muted-strong) !important;
}

.cash-desk-card .fin-flow,
.cash-zone .fin-flow {
  font-weight: 700;
}
.cash-status.is-open {
  color: #0d6b2f !important;
  font-weight: 700;
}

@media (max-width: 920px) {
 #platform-bar .platform-plan-grid {
    grid-template-columns: 1fr;
  }
 #platform-bar .workspace-layout {
    grid-template-columns: 1fr;
  }
}


/* Axe/contrast dual-era cluster → ui-unification_contrast.css */
