/* Extracted from ecosystem.css — Residual dark-theme and responsive surface rules. */
/* Load after ecosystem.css and before existing ecosystem feature sheets; original order preserved. */

/* B2C showcase → ecosystem_market.css. */
/* Platform SLO + audit operations moved to ecosystem_platform.css. */

/* Finance analytics leftovers → ecosystem_finance.css. */
/* Dashboard flat sections → ecosystem_dashboard.css. */

.sf-price-form :is(input, select) {
  width: 100%;
  max-width: none;
}

html[data-theme="dark"] :where(.rcard, .collap, .card, .fin-card, .dash-sec,
  .ecosystem-card, .sf-profile-card, .sf-price-card),
.overlay[data-theme="dark"] :where(.rcard, .collap, .card, .fin-card, .dash-sec,
  .ecosystem-card, .sf-profile-card, .sf-price-card) {
  background: var(--tg-theme-secondary-bg-color, #2b3949) !important;
  border-color: rgb(255 255 255 / 12%) !important;
  box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
  color: var(--tg-theme-text-color, #f5f5f5);
}

html[data-theme="dark"] .ui-action.ecosystem-secondary,
html[data-theme="dark"] .rk.ecosystem-secondary,
html[data-theme="dark"] #nf-cancel,
html[data-theme="dark"] #pm-cancel,
.overlay[data-theme="dark"] .ui-action.ecosystem-secondary,
.overlay[data-theme="dark"] .rk.ecosystem-secondary,
.overlay[data-theme="dark"] #nf-cancel,
.overlay[data-theme="dark"] #pm-cancel {
  color: var(--tg-theme-text-color, #f5f5f5);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.10);
}

html[data-theme="dark"] .finance-metric {
  background: color-mix(in srgb, var(--tg-theme-secondary-bg-color, #2b3949) 82%, #000);
  border-color: rgb(255 255 255 / 12%);
}

html[data-theme="dark"] .finance-metric.is-primary {
  background: color-mix(in srgb, var(--tg-theme-button-color, #5288c1) 16%, var(--tg-theme-secondary-bg-color, #2b3949));
  border-color: color-mix(in srgb, var(--tg-theme-button-color, #5288c1) 40%, transparent);
}

html[data-theme="dark"] .mk-count.is-warn {
  color: #ffc56a;
}

@media (max-width: 700px) {
  :root {
    --ui-control-h: 44px;
  }

  .finance-kpi-grid,
  .finance-analysis-grid,
  .finance-operation-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-analysis-head {
    align-items: stretch;
    padding: 9px 10px;
  }

  .finance-analysis-head select {
    width: 136px;
  }

  .finance-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .finance-metric {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    min-height: 74px;
    gap: 4px;
    padding: 10px;
  }

  .finance-metric-value {
    text-align: left;
  }

  .finance-data-row,
  .finance-operation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-operation-list {
    gap: 12px;
    padding-bottom: 16px;
  }

  .finance-operation-detail:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  #deals-command-bar,
  #deal-bar,
  #led-sheets,
  #led-balances,
  #led-filters {
    border-radius: 13px;
  }

  .sf-content-grid,
  .sf-profile-grid {
    grid-template-columns: 1fr;
  }

  .sf-profile-grid .ecosystem-field-row:nth-last-child(-n + 2) {
    grid-column: auto;
  }

  .sf-price-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sf-price-row > span {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .sf-price-row .ui-action {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-height: 44px;
  }

  .sf-price-form .ecosystem-field-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

@media (max-width: 420px) {
  #deals-command-bar {
    align-items: stretch;
    flex-direction: column;
  }

  #deals-command-bar :is(#new-wrap, #new-btn, #filters, #f-period, #f-q) {
    width: 100%;
    max-width: none;
  }

  .sf-status-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .sf-status-strip .fbtns,
  .sf-status-strip button {
    width: 100%;
  }
}
