/* Shared CRM surfaces and readable theme colours. Keep print labels and the
   standalone owner console independent; no universal text-colour override. */
@media screen {
  :root[data-theme] {
    --surface: var(--bg-card);
    --surface-2: var(--bg-elevated);
    --surface-subtle: var(--surface-soft);
    --card: var(--bg-card);
    --panel: var(--bg-card);
    --bg-page: var(--bg);
    --bg-secondary: var(--bg-elevated);
    --ink: var(--text);
    --muted: var(--text-muted);
    --line: var(--border);
    --canvas: var(--bg);
    --accent: var(--lime);
    --on-primary: #fff;
    --on-accent: #171912;
    --focus-ring: var(--primary);
    --violet-text: #694995;
    --asx-inventory-v211-on-accent: var(--on-primary);
  }

  html[data-theme='light'] { --text-muted: #61655a; --text-dim: #686c61; }
  :root[data-theme='dark'] { --text-muted: #b5beaa; --text-dim: #a3ad97; --on-primary: #171912; --violet-text: #c6abea; }
  html[data-theme='ocean'] { --text-muted: #4e6568; --text-dim: #566b6e; }
  html[data-theme='forest'] { --text-muted: #57664e; --text-dim: #606c57; }
  html[data-theme='sunset'] { --text-muted: #6a594c; --text-dim: #726153; --primary: #885839; }
  html[data-theme='violet'] { --text-muted: #62536d; --text-dim: #6b5d74; }
  html[data-theme='rose'] { --text-muted: #6c5559; --text-dim: #745e61; }
  :root[data-theme]:not([data-theme='dark']) {
    --success: #416b28;
    --warning: #825517;
    --danger: #a13e37;
    --info: #3c6389;
    --pink: #a02761;
  }

  :root[data-theme] body { background-color: var(--bg); color: var(--text); }
  :root[data-theme] [hidden]:not([hidden='until-found']) { display: none !important; }
  :root[data-theme] input::placeholder,
  :root[data-theme] textarea::placeholder { color: var(--text-dim); opacity: 1; }
  :root[data-theme] select option,
  :root[data-theme] select optgroup { color: var(--text); background: var(--bg-card); }

  /* Owner-console links belong to the CRM shell; the owner page's reset does not. */
  :root[data-theme] .asx-owner-nav { border-color: var(--border); }
  :root[data-theme] .asx-owner-nav-label { color: var(--text-dim); }
  :root[data-theme] .asx-owner-console-link,
  :root[data-theme] .asx-owner-console-account {
    border-color: var(--border-light) !important;
    background: var(--primary-soft) !important;
    color: var(--text) !important;
  }
  :root[data-theme] .asx-owner-console-link:hover,
  :root[data-theme] .asx-owner-console-account:hover { background: var(--active-nav) !important; }
  :root[data-theme] .asx-support-mode-banner {
    border-color: var(--border-light); background: var(--bg-card); color: var(--text);
  }
  :root[data-theme] .asx-support-mode-banner a { background: var(--primary); color: var(--on-primary); }

  /* Charts need theme-aware labels, grids and tooltip surfaces as well as series. */
  :root[data-theme] .recharts-cartesian-axis-tick-value,
  :root[data-theme] .recharts-polar-angle-axis-tick-value,
  :root[data-theme] .recharts-polar-radius-axis-tick-value { fill: var(--text-muted); }
  :root[data-theme] .recharts-cartesian-grid line { stroke: var(--border-light); }
  :root[data-theme] .recharts-cartesian-axis-line,
  :root[data-theme] .recharts-cartesian-axis-tick-line { stroke: var(--border-light); }
  :root[data-theme] .recharts-default-tooltip {
    background: var(--bg-elevated) !important; border-color: var(--border-light) !important;
    color: var(--text) !important; border-radius: 10px;
  }
  :root[data-theme] .recharts-tooltip-label,
  :root[data-theme] .recharts-tooltip-item { color: var(--text) !important; }
  :root[data-theme] .recharts-legend-item-text { color: var(--text-muted) !important; }
  :root[data-theme] .analytics-v2-table-wrap td.positive { color: var(--success); }
  :root[data-theme] .analytics-v2-table-wrap tbody tr:first-child .analytics-v2-rank {
    color: var(--success); background: var(--success-soft);
  }

  /* Integrations, pagination and account dialogs use the same surfaces as CRM. */
  :root[data-theme] .commerce-dialog {
    background: var(--bg-elevated); color: var(--text); border-color: var(--border-light);
  }
  :root[data-theme] .commerce-card,
  :root[data-theme] .commerce-form,
  :root[data-theme] .commerce-button {
    background: var(--bg-card); color: var(--text); border-color: var(--border);
  }
  :root[data-theme] .commerce-button:hover { background: var(--bg-hover); }
  :root[data-theme] .commerce-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
  :root[data-theme] .commerce-primary:hover { background: var(--primary-hover); }
  :root[data-theme] .commerce-muted { color: var(--text-muted); }
  :root[data-theme] .commerce-badge { background: var(--primary-soft); color: var(--text); }
  :root[data-theme] .commerce-field input { background: var(--bg-card); border-color: var(--border-light); color: var(--text); }
  :root[data-theme] .commerce-error,
  :root[data-theme] .commerce-dialog .is-error { color: var(--danger); }
  :root[data-theme] .commerce-nav-button { border-color: var(--border); }
  :root[data-theme] .commerce-button:focus-visible,
  :root[data-theme] .commerce-field input:focus-visible,
  :root[data-theme] .commerce-nav-button:focus-visible { outline-color: var(--focus-ring); }

  :root[data-theme] .asx-order-action-status-body > small.success,
  :root[data-theme] .asx-phone-state.verified { color: var(--success); }
  :root[data-theme] .asx-order-action-status-body > small.error,
  :root[data-theme] .asx-order-products-actions small.error,
  :root[data-theme] .asx-phone-message.error,
  :root[data-theme] .asx-phone-link.danger { color: var(--danger); }
  :root[data-theme] .asx-phone-state.pending { color: var(--warning); }
  :root[data-theme] .asx-np-selection > span,
  :root[data-theme] .order-detail-modal .asx-order-payment-dropzone > span,
  :root[data-theme] .order-detail-modal .asx-order-payment-control > header > div > span { color: var(--text); }
  :root[data-theme] .lp-rating-badge.is-good { color: var(--success); background: var(--success-soft); }
  :root[data-theme] .lp-rating-badge.is-medium { color: var(--warning); background: var(--warning-soft); }
  :root[data-theme] .lp-rating-badge.is-low { color: var(--danger); background: var(--danger-soft); }

  :root[data-theme] .settings-tab.active > span { color: var(--on-accent); background: var(--lime); }
  :root[data-theme] .asx-warehouse-empty-icon { color: var(--primary); }
  :root[data-theme] .analytics-v2-kpi { --kpi-accent: var(--success); --kpi-soft: var(--success-soft); }
  :root[data-theme] .analytics-v2-kpi.blue { --kpi-accent: var(--info); --kpi-soft: var(--info-soft); }
  :root[data-theme] .analytics-v2-kpi.green { --kpi-accent: var(--success); --kpi-soft: var(--success-soft); }
  :root[data-theme] .analytics-v2-kpi.violet { --kpi-accent: #694995; --kpi-soft: var(--violet-soft); }
  :root[data-theme='dark'] .analytics-v2-kpi.violet { --kpi-accent: #c6abea; }
  :root[data-theme] .analytics-v2-kpi.rose { --kpi-accent: var(--danger); --kpi-soft: var(--danger-soft); }
  :root[data-theme] .analytics-v2-kpi.amber { --kpi-accent: var(--warning); --kpi-soft: var(--warning-soft); }
  :root[data-theme] .analytics-v2-eyebrow,
  :root[data-theme] .analytics-v2-insights-title,
  :root[data-theme] .analytics-v2-funnel > footer,
  :root[data-theme] .analytics-v2-office-grid > button > footer strong,
  :root[data-theme] .analytics-v2-team-list > div > i.leader,
  :root[data-theme] .asx-manager-live-badge,
  :root[data-theme] .asx-manager-live-call time { color: var(--success); }
  :root[data-theme] .asx-manager-backlog-value { color: var(--warning); background: var(--warning-soft); }
  :root[data-theme] .analytics-delta.negative,
  :root[data-theme] .analytics-delta.down { color: var(--danger); background: var(--danger-soft); }

  /* Payment windows retain their brand marks; text and surfaces follow the CRM. */
  :root[data-theme] .asx-stripe-crm-button,
  :root[data-theme] .asx-stripe-dialog > header,
  :root[data-theme] .asx-stripe-connection-summary { background: var(--violet-soft); color: var(--text); border-color: var(--border-light); }
  :root[data-theme] .asx-stripe-crm-button > b,
  :root[data-theme] .asx-stripe-dialog > header span { color: var(--text-muted); }
  :root[data-theme] .asx-stripe-security { background: var(--surface-soft); color: var(--text); border-color: var(--border); }
  :root[data-theme] .asx-stripe-security > span { background: var(--bg-hover); }
  :root[data-theme] .asx-stripe-security small { color: var(--text-muted); }
  :root[data-theme] .asx-stripe-charge-state { background: var(--success-soft); color: var(--success); border-color: var(--success); }
  :root[data-theme] .asx-stripe-charge-state.warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
  :root[data-theme] .asx-stripe-charge-state > span { background: var(--bg-card); }
  :root[data-theme] .asx-stripe-form-status.success { color: var(--success); }
  :root[data-theme] .asx-stripe-form-status.warning { color: var(--warning); }
  :root[data-theme] .asx-stripe-form-status.error { color: var(--danger); }
  :root[data-theme] .asx-stripe-form-actions button.danger,
  :root[data-theme] .asx-stripe-load-error > span { color: var(--danger); background: var(--danger-soft); border-color: var(--border-light); }
  :root[data-theme] .asx-billing-dialog-header span,
  :root[data-theme] .asx-billing-current-copy > span,
  :root[data-theme] .asx-billing-owned > header span,
  :root[data-theme] .asx-billing-addons > header span { color: var(--text-muted); }
  :root[data-theme] .asx-billing-validity b,
  :root[data-theme] .asx-billing-level-label,
  :root[data-theme] .asx-billing-owned-card > header > span,
  :root[data-theme] .asx-billing-owned-empty > span,
  :root[data-theme] .asx-billing-grant-card header > span,
  :root[data-theme] .asx-billing-addon > span,
  :root[data-theme] .asx-billing-popular,
  :root[data-theme] .asx-billing-plan-payment-kind,
  :root[data-theme] .asx-billing-plan-rule { color: var(--text); background: var(--primary-soft); }
  :root[data-theme] .asx-billing-plan li[data-plan-feature='order-bonus'],
  :root[data-theme] .asx-billing-plan li::before { color: var(--success); }
  :root[data-theme] .asx-billing-current.trial-expired,
  :root[data-theme] .asx-billing-current.past-due { background: var(--warning-soft); }
  :root[data-theme] .asx-billing-usage.warning .asx-billing-level-label,
  :root[data-theme] .asx-billing-usage.bonus .asx-billing-level-label { color: var(--warning); background: var(--warning-soft); }
  :root[data-theme] .asx-billing-usage.critical .asx-billing-level-label,
  :root[data-theme] .asx-billing-usage.blocked .asx-billing-level-label { color: var(--danger); background: var(--danger-soft); }
  :root[data-theme] .asx-billing-card-button { color: var(--text); background: var(--primary-soft); }
  :root[data-theme] .asx-billing-card-button:hover { background: var(--active-nav); }
  :root[data-theme] .asx-billing-interval button span { color: var(--text); background: var(--bg-card); }
  :root[data-theme] .asx-workspace-lock-copy > span { color: var(--danger); }
  :root[data-theme] .asx-workspace-lock-copy small { color: var(--text-muted); }
  :root[data-theme] .asx-workspace-lock-copy small b { color: var(--success); }

  /* Client ratings and the shared client directory previously used a separate
     light-only palette, including white table cells inside dark dialogs. */
  :root[data-theme] .asx-customer-rating-strip,
  :root[data-theme] .asx-customer-rating-profile > header,
  :root[data-theme] .asx-customer-rating-recommendation > div,
  :root[data-theme] .asx-customer-rating-no-history { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
  :root[data-theme] .asx-customer-rating-metrics article,
  :root[data-theme] .asx-developer-customer-summary article,
  :root[data-theme] .asx-developer-customer-filters label,
  :root[data-theme] .asx-developer-customer-filters input,
  :root[data-theme] .asx-developer-customer-filters select,
  :root[data-theme] .asx-developer-customer-table-wrap,
  :root[data-theme] .asx-developer-customer-pagination button { background: var(--bg-card); color: var(--text); border-color: var(--border); }
  :root[data-theme] .asx-customer-rating-metrics article.success,
  :root[data-theme] .asx-developer-customer-summary article.success { background: var(--success-soft); }
  :root[data-theme] .asx-customer-rating-metrics article.warning,
  :root[data-theme] .asx-developer-customer-summary article.warning { background: var(--warning-soft); }
  :root[data-theme] .asx-customer-rating-metrics article.danger,
  :root[data-theme] .asx-developer-customer-summary article.danger { background: var(--danger-soft); }
  :root[data-theme] .asx-customer-rating-strip small,
  :root[data-theme] .asx-customer-rating-strip > em,
  :root[data-theme] .asx-customer-rating-inline-metrics,
  :root[data-theme] .asx-customer-rating-profile > header p,
  :root[data-theme] .asx-customer-rating-metrics article small,
  :root[data-theme] .asx-developer-customer-summary article small,
  :root[data-theme] .asx-customer-rating-recommendation small,
  :root[data-theme] .asx-customer-rating-orders small,
  :root[data-theme] .asx-developer-customers-loading,
  :root[data-theme] .asx-developer-customer-table-wrap td > button small,
  :root[data-theme] .asx-developer-customer-table-wrap td > small,
  :root[data-theme] .asx-developer-customer-table-wrap td.empty,
  :root[data-theme] .asx-developer-customer-pagination { color: var(--text-muted); }
  :root[data-theme] .asx-customer-rating-inline-metrics b,
  :root[data-theme] .asx-customer-rating-profile > header strong,
  :root[data-theme] .asx-customer-rating-metrics article strong,
  :root[data-theme] .asx-developer-customer-summary article strong,
  :root[data-theme] .asx-customer-rating-recommendation strong,
  :root[data-theme] .asx-developer-customer-table-wrap td,
  :root[data-theme] .asx-developer-customer-table-wrap td > button { color: var(--text); border-color: var(--border); }
  :root[data-theme] .asx-customer-rating-recommendation { background: var(--border); }
  :root[data-theme] .asx-developer-customer-table-wrap th { background: var(--surface-soft); color: var(--text-muted); border-color: var(--border); }
  :root[data-theme] .asx-developer-customer-table-wrap tbody tr:hover { background: var(--bg-hover); }
  :root[data-theme] .asx-developer-customer-filters button { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
  :root[data-theme] .asx-developer-customer-table-wrap td.success { color: var(--success); }
  :root[data-theme] .asx-developer-customer-table-wrap td.warning { color: var(--warning); }
  :root[data-theme] .asx-developer-customer-table-wrap td.danger { color: var(--danger); }
  :root[data-theme] .asx-customer-rating-grade,
  :root[data-theme] .asx-customer-rating-orders em { background: var(--bg-hover); color: var(--text-muted); }
  :root[data-theme] .asx-customer-rating-grade.grade-a-plus,
  :root[data-theme] .asx-customer-rating-grade.grade-a,
  :root[data-theme] .asx-customer-rating-orders em.outcome-picked { background: var(--success-soft); color: var(--success); }
  :root[data-theme] .asx-customer-rating-grade.grade-b { background: var(--info-soft); color: var(--info); }
  :root[data-theme] .asx-customer-rating-grade.grade-c,
  :root[data-theme] .asx-customer-rating-orders em.outcome-returned { background: var(--warning-soft); color: var(--warning); }
  :root[data-theme] .asx-customer-rating-grade.grade-d,
  :root[data-theme] .asx-customer-rating-grade.error,
  :root[data-theme] .asx-customer-rating-orders em.outcome-refused { background: var(--danger-soft); color: var(--danger); }
  :root[data-theme] .asx-customer-rating-grade.grade-new { background: var(--violet-soft); color: var(--text); }

  /* Custom status colours remain in the swatch/background. Mix label ink with
     the theme text so even lime/yellow or deep violet statuses remain legible. */
  :root[data-theme] .status-badge {
    color: color-mix(in srgb, var(--status-color, var(--primary)) 30%, var(--text)) !important;
  }
  :root[data-theme] .status-badge .dot { background: var(--status-color, currentColor); }

  /* An inactive record is still readable data, not a disabled control. */
  :root[data-theme] .products-table tbody tr,
  :root[data-theme] .data-table tbody tr[style*='opacity'],
  :root[data-theme] .payment-methods-table tbody tr.is-inactive,
  :root[data-theme] .payment-methods-table tbody tr.is-inactive td,
  :root[data-theme] .reference-table tbody tr.is-inactive td,
  :root[data-theme] .payments-table tbody tr.is-inactive,
  :root[data-theme] .automation-rule.disabled,
  :root[data-theme] .api-key-row.disabled,
  :root[data-theme] .integration-card.asx-integration-disabled { opacity: 1 !important; }
  :root[data-theme] .products-table tbody tr[style*='opacity: 0.5'],
  :root[data-theme] .payment-methods-table tbody tr.is-inactive,
  :root[data-theme] .payments-table tbody tr.is-inactive { background: var(--surface-soft); }
  :root[data-theme] .payment-category-tag { color: var(--text); background: var(--bg-hover); }
  :root[data-theme] .payment-category-tag.basic { color: var(--success); background: var(--success-soft); }
  :root[data-theme] .payment-category-tag.marketplace { color: var(--text); background: var(--violet-soft); }
  :root[data-theme] .payment-category-tag.service,
  :root[data-theme] .payment-category-tag.card { color: var(--info); background: var(--info-soft); }
  :root[data-theme] .payment-category-tag.wallet { color: var(--warning); background: var(--warning-soft); }
  :root[data-theme] .payment-method-icon { color: var(--text) !important; }

  :root[data-theme] .asx-modal .asx-field label { color: var(--text-muted); }
  :root[data-theme] .asx-modal .asx-field input,
  :root[data-theme] .asx-modal .asx-field select,
  :root[data-theme] .asx-modal .asx-field textarea { background: var(--bg-card); color: var(--text); border-color: var(--border); }
  :root[data-theme] #asx-platform-root:has(.asx-account-page),
  :root[data-theme] .asx-account-page { background: var(--bg); color: var(--text); }
  :root[data-theme] .asx-account-header { background: var(--bg-elevated); border-color: var(--border); }
  :root[data-theme] .asx-account-user,
  :root[data-theme] .asx-platform-brand.dark,
  :root[data-theme] .asx-account-help strong { color: var(--text); }
  :root[data-theme] .asx-account-workspace,
  :root[data-theme] .asx-account-empty,
  :root[data-theme] .asx-account-help,
  :root[data-theme] .asx-account-logout,
  :root[data-theme] .asx-settings-card,
  :root[data-theme] .asx-workspace-trash-item,
  :root[data-theme] .asx-notification-list { background: var(--bg-card); color: var(--text); border-color: var(--border); }
  :root[data-theme] .asx-account-user:hover,
  :root[data-theme] .asx-account-user:focus-visible,
  :root[data-theme] .asx-account-settings-tabs,
  :root[data-theme] .asx-account-settings-tabs button:hover,
  :root[data-theme] .asx-account-settings-tabs button:focus-visible,
  :root[data-theme] .asx-two-factor-secret { background: var(--surface-soft); }
  :root[data-theme] .asx-account-settings-tabs button.active { background: var(--bg-card); color: var(--text); }
  :root[data-theme] .asx-account-workspace-rename,
  :root[data-theme] .asx-account-workspace-delete { background: var(--bg-card); color: var(--text-muted); }
  :root[data-theme] .asx-account-workspace-rename:hover { background: var(--bg-hover); color: var(--text); }
  :root[data-theme] .asx-account-workspace-delete:hover { background: var(--danger-soft); color: var(--danger); }
  :root[data-theme] .asx-account-user small,
  :root[data-theme] .asx-platform-brand.dark > small,
  :root[data-theme] .asx-account-hero p,
  :root[data-theme] .asx-account-workspace-copy small,
  :root[data-theme] .asx-account-workspace-copy code,
  :root[data-theme] .asx-account-workspace-open,
  :root[data-theme] .asx-account-settings-tabs button,
  :root[data-theme] .asx-settings-section-heading p,
  :root[data-theme] .asx-account-settings-content .asx-field small,
  :root[data-theme] .asx-account-settings-message,
  :root[data-theme] .asx-security-heading small,
  :root[data-theme] .asx-notification-list small,
  :root[data-theme] .asx-two-factor-secret small,
  :root[data-theme] .asx-account-empty p { color: var(--text-muted); }
  :root[data-theme] .asx-account-page .asx-eyebrow,
  :root[data-theme] .asx-settings-section-heading > span { color: var(--success); }
  :root[data-theme] .asx-account-user > .asx-account-avatar,
  :root[data-theme] .asx-security-icon { color: var(--text); background: var(--primary-soft); }
  :root[data-theme] .asx-two-factor-secret code { color: var(--text); }
  :root[data-theme] .asx-account-settings-content .asx-field input[readonly] { color: var(--text-muted); background: var(--surface-soft); }
  :root[data-theme] .asx-status-pill { color: var(--text-muted); background: var(--bg-hover); }
  :root[data-theme] .asx-status-pill.success { color: var(--success); background: var(--success-soft); }
  :root[data-theme] .asx-status-pill.pending { color: var(--warning); background: var(--warning-soft); }
  :root[data-theme] .dept-stats strong[style] { color: color-mix(in srgb, var(--dept-color, var(--primary)) 30%, var(--text)) !important; }
  :root[data-theme] .office-metrics strong[style] { color: color-mix(in srgb, var(--office-color, var(--primary)) 30%, var(--text)) !important; }
  :root[data-theme] .shipment2-actions button small { opacity: 1; }
  :root[data-theme] .asx-order-presence-slot-192.is-active,
  :root[data-theme] .asteron-sms-status-idle,
  :root[data-theme] .asx-customer-rating-inline-metrics i { color: var(--text-muted) !important; }
  :root[data-theme] .asx-order-history-toggle output { color: var(--on-accent); background: var(--lime); }
  :root[data-theme] .order-detail-modal .asx-order-payment-dropzone > i,
  :root[data-theme] .order-detail-modal .asx-order-payment-control > header > div > span { color: var(--on-accent); background: var(--lime); }
  :root[data-theme] .workflow-icon.blue { color: var(--info); }
  :root[data-theme] .workflow-icon.sand { color: var(--warning); }
  :root[data-theme] .workflow-icon.violet { color: #694995; }
  :root[data-theme='dark'] .workflow-icon.violet { color: #c6abea; }
  :root[data-theme] .asteron-mobile-nav__new > strong { color: var(--text); }
  :root[data-theme] .asx-manager-live-row.viewing .asx-manager-live-state { color: var(--violet-text); }
  :root[data-theme] .asx-manager-live-row.editing .asx-manager-live-state,
  :root[data-theme] .callcenter-kpis .info strong,
  :root[data-theme] .callcenter-dialer-label { color: var(--info); }
  :root[data-theme] .asx-manager-live-row.calling .asx-manager-live-state { color: var(--success); }
  :root[data-theme] .profile-connection-card[data-asx-provider-config='missing']::after { color: var(--warning); }
}

/* Mobile theme palette r26: retain desktop rules and channel/status identities. */
@media screen and (max-width: 900px) {
  html[data-theme] {
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --bg-primary: var(--bg);
    --surface-alt: var(--bg-elevated);
    --asteron-mobile-ink: var(--on-accent);
    --asteron-mobile-accent: var(--lime);
    --asteron-mobile-paper: var(--bg);
  }

  html[data-theme] .asteron-pwa-install,
  html[data-theme] .asteron-pwa-status {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
  }
  html[data-theme] .asteron-pwa-install__copy span,
  html[data-theme] .asteron-pwa-install__close { color: var(--text-muted); }
  html[data-theme] .asteron-pwa-install__action {
    background: var(--primary);
    color: var(--on-primary);
  }
  html[data-theme] .asteron-pwa-status[data-tone="warning"] {
    background: var(--bg-card);
    color: var(--warning);
    border-color: var(--warning);
  }
  html[data-theme] .asteron-pwa-status[data-tone="success"] {
    background: var(--bg-card);
    color: var(--success);
    border-color: var(--success);
  }

  html[data-theme] .social-comment-subviews button.active {
    background: var(--primary-soft);
    color: var(--primary);
  }
  html[data-theme] .social-comment-client.active,
  html[data-theme] .social-reply-template-item.active {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: inset 3px 0 var(--primary);
  }
  html[data-theme] .social-comment-client-avatar {
    background: var(--bg-hover);
    color: var(--text);
  }
  html[data-theme] .social-comment-private-compose blockquote { border-left-color: var(--primary); }
  html[data-theme] .social-reply-template-example small { color: var(--primary); }
  html[data-theme] .social-comment-send-status.success {
    background: var(--bg-card);
    color: var(--success);
    border-color: var(--success);
  }
  html[data-theme] .social-comment-send-error,
  html[data-theme] .social-comment-partial,
  html[data-theme] .social-reply-template-error,
  html[data-theme] .social-reply-template-pending,
  html[data-theme] .social-reply-template-delete-confirm,
  html[data-theme] .social-reply-template-hint {
    background: var(--bg-card);
    color: var(--warning);
    border-color: var(--warning);
  }

  html[data-theme] :is(.profile-settings-modal, .orders-page, .meta-simple-connect) input:is([type="checkbox"], [type="radio"]) {
    accent-color: var(--primary);
  }
  html[data-theme] :is(.profile-settings-modal, .orders-page, .meta-simple-connect, .social-comment-clients, .social-comment-subviews, .social-reply-templates-dialog, .order-conversation-card) :focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
  }
  html[data-theme] .asteron-quick-nav__link > svg.lucide,
  html[data-theme] .profile-settings-nav button > svg.lucide,
  html[data-theme] .header-actions > .icon-btn > svg.lucide,
  html[data-theme] .orders-mobile-filter-toggle > svg.lucide,
  html[data-theme] .orders-layout-edit-button > svg.lucide {
    color: inherit;
    stroke: currentColor;
    fill: none;
  }
}

.asteron-mobile-theme-tab,.asteron-mobile-theme-section{display:none}
@media(max-width:900px){.profile-settings-nav .asteron-mobile-theme-tab{display:flex;align-items:center;gap:8px;min-height:44px}.asteron-mobile-theme-section{display:block;min-width:0}.asteron-mobile-theme-section header{margin-bottom:12px}.asteron-mobile-theme-section h3{margin:0 0 6px;font-size:19px;line-height:1.3}.asteron-mobile-theme-section header p,.asteron-mobile-theme-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px;line-height:1.55}.asteron-mobile-theme-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.asteron-mobile-theme-option{display:flex;align-items:center;gap:10px;min-width:0;min-height:88px;padding:12px;border:1px solid var(--border);border-radius:12px;text-align:left;background:var(--bg-card);color:var(--text);font:inherit;cursor:pointer}.asteron-mobile-theme-option.active{border-color:var(--primary);box-shadow:inset 0 0 0 1px var(--primary)}.asteron-mobile-theme-option:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.asteron-mobile-theme-option:disabled{opacity:.65;cursor:default}.asteron-mobile-theme-preview{display:flex;flex:0 0 40px;height:44px;border:1px solid var(--border);border-radius:8px;overflow:hidden}.asteron-mobile-theme-preview>span{flex:1}.asteron-mobile-theme-copy{min-width:0;flex:1}.asteron-mobile-theme-copy strong{display:block;font-size:13px;line-height:1.4;overflow-wrap:anywhere}.asteron-mobile-theme-copy small{display:block;margin-top:3px;font-size:11px;line-height:1.5;color:var(--text-muted);overflow-wrap:anywhere}.asteron-mobile-theme-option>svg{flex:0 0 18px;color:var(--text)}}
@media(max-width:520px){.asteron-mobile-theme-grid{grid-template-columns:minmax(0,1fr)}.asteron-mobile-theme-option{min-height:76px}}
@media(max-width:900px){.profile-settings-modal .profile-settings-nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));min-width:0}.profile-settings-modal .profile-settings-nav>button{min-width:0;min-height:44px;overflow-wrap:anywhere}.profile-settings-modal .profile-settings-nav>button>svg{flex-shrink:0}.profile-settings-modal .profile-settings-nav>button>span{min-width:0}.profile-settings-modal .profile-settings-nav>.profile-summary,.profile-settings-modal .profile-settings-nav>.profile-logout{grid-column:1 / -1;min-width:0}}

/* A single workspace selector, shared by desktop and mobile headers. */
.header .asx-workspace-switcher-header {
  position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr) 20px;
  align-items: center; gap: 10px; flex: 0 1 210px; width: 210px; min-width: 150px;
  height: 46px; min-height: 46px; margin: 0; padding: 6px 10px 6px 7px;
  border: 1px solid var(--border, #dfe2d8); border-radius: 13px;
  color: var(--text, #171912); background: var(--bg-card, #fff);
  box-shadow: 0 2px 5px rgb(20 24 17 / 3%); text-align: left;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.header .asx-workspace-switcher-header .asx-workspace-logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--text, #171912); color: var(--bg-card, #fff);
  font: 700 13px/1 Inter, "Segoe UI", sans-serif;
}
.header .asx-workspace-switcher-header .asx-workspace-copy small {
  display: block; margin: 0 0 2px; color: var(--text-muted, #707369);
  font-size: 8px; font-weight: 650; line-height: 1.1; letter-spacing: .08em; text-transform: uppercase;
}
.header .asx-workspace-switcher-header .asx-workspace-copy strong {
  font-size: 13px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
}
.header .asx-workspace-switcher-header .asx-workspace-chevron {
  width: 20px; height: 20px; padding: 2px; border-radius: 6px;
  background: var(--surface-soft, #f3f4ee); color: var(--text-muted, #707369);
  transition: transform .16s;
}
.header .asx-workspace-switcher-header:hover,
.header .asx-workspace-switcher-header[aria-expanded="true"] {
  background: var(--bg-elevated, #fbfbf8); border-color: var(--border-light, #cdcec4);
  box-shadow: 0 3px 10px rgb(20 24 17 / 6%);
}
.header .asx-workspace-switcher-header[aria-expanded="true"] .asx-workspace-chevron { transform: rotate(180deg); }
.header .asx-workspace-switcher-header:focus-visible,
.asx-workspace-menu button:focus-visible { outline: 2px solid var(--text, #171912); outline-offset: 3px; }
.asx-workspace-menu { border-radius: 16px; box-shadow: 0 16px 48px rgb(20 24 17 / 14%), 0 3px 10px rgb(20 24 17 / 5%); }
.asx-workspace-menu-item { border-radius: 11px; }
@media (max-width: 760px) {
  .header .asx-workspace-switcher-header {
    flex: 0 1 190px; width: 190px; min-width: 0; height: 42px; min-height: 42px;
    grid-template-columns: 28px minmax(0, 1fr) 16px; gap: 7px; padding: 5px 7px;
    border-radius: 11px;
  }
  .header .asx-workspace-switcher-header .asx-workspace-logo { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
  .header .asx-workspace-switcher-header .asx-workspace-copy small { font-size: 7px; letter-spacing: .05em; }
  .header .asx-workspace-switcher-header .asx-workspace-copy strong { font-size: 12px; }
  .header .asx-workspace-switcher-header .asx-workspace-chevron { width: 16px; height: 16px; padding: 1px; }
  .header .header-actions { flex-shrink: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .header .asx-workspace-switcher-header,
  .header .asx-workspace-switcher-header .asx-workspace-chevron { transition: none; }
}

/* Secondary workspace actions stay inside the workspace menu. */
.asx-workspace-menu { background: var(--bg-card, #fff); }
.asx-workspace-menu-actions {
  display: grid; gap: 2px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border, #dfe2d8);
}
.asx-workspace-menu-actions > button {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; min-height: 44px; margin: 0; padding: 10px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--text, #171912); font: 600 12px/1.4 Inter, "Segoe UI", sans-serif;
  text-align: left; cursor: pointer;
}
.asx-workspace-menu-actions > button:hover { background: var(--surface-soft, #f3f4ee); }
.asx-workspace-menu-actions > button > svg {
  width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-muted, #707369);
}
.asx-workspace-menu-actions > button > span:first-of-type { flex: 1; min-width: 0; }
.asx-workspace-action-arrow { flex: 0 0 12px; font-size: 18px; font-weight: 400; color: var(--text-muted, #707369); text-align: center; }
html[data-asx-ios="1"] [data-asx-billing-menu] { display: none !important; }

/* Compact navigation: everyday destinations first, one secondary group at a time. */
.sidebar .sidebar-logo { flex-shrink: 0; gap: 8px; min-height: 48px; padding: 0 4px 12px; }
.sidebar .sidebar-brand { gap: 8px; }
.sidebar .sidebar-logo .logo-mark { flex: 0 0 30px; width: 30px; height: 30px; }
.sidebar .sidebar-logo .logo-text { min-width: 0; }
.sidebar .sidebar-logo .logo-text strong { font-size: 14px; line-height: 1.3; white-space: nowrap; letter-spacing: -.4px; }
.sidebar .sidebar-logo .logo-text > span,
.sidebar .sidebar-logo .brand-badge { display: none; }
.sidebar .sidebar-collapse-button { flex: 0 0 28px; width: 28px; height: 28px; }
.sidebar .sidebar-nav { min-height: 0; gap: 2px; padding: 4px 0 10px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sidebar .nav-section { margin: 0; padding: 8px 10px 7px; font-size: 9px; letter-spacing: .09em; }
.sidebar .nav-item { min-height: 36px; height: auto; padding: 8px 10px; gap: 10px; border-radius: 9px; font-size: 12.5px; line-height: 20px; }
.sidebar .nav-icon { flex: 0 0 17px; width: 17px; height: 17px; }
.sidebar .nav-item > span:not(.badge) { min-width: 0; }
.sidebar .nav-group-toggle { min-height: 34px; margin: 3px 0 0; padding: 7px 10px; border-radius: 8px; color: var(--text-muted); font-size: 11px; line-height: 20px; font-weight: 650; text-transform: none; letter-spacing: .01em; }
.sidebar .asx-work-group-toggle { margin-top: 12px; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; padding-top: 10px; min-height: 40px; }
.sidebar .nav-group-toggle:hover { color: var(--text); background: var(--bg-hover); }
.sidebar .nav-group-toggle.open { color: var(--text); }
.sidebar .nav-group-toggle > svg { transform: rotate(-90deg); }
.sidebar .nav-group-toggle.open > svg { transform: rotate(0deg); }
.sidebar .nav-group-items { gap: 1px; margin: 2px 0 3px 8px; padding: 0 0 0 7px; border-left: 1px solid var(--border); }
.sidebar .nav-group-items .nav-item { min-height: 34px; padding: 7px 9px; font-weight: 500; }
.sidebar .asx-work-group-items[hidden],
.sidebar .asx-system-shortcuts[hidden] { display: none !important; }
.sidebar .asx-system-shortcuts { display: grid; gap: 1px; margin: -2px 0 3px 8px; padding-left: 7px; border-left: 1px solid var(--border); }
.sidebar .asx-system-shortcuts .crm-migration-nav { width: 100%; min-height: 34px; margin: 0; padding: 7px 9px; font-size: 11.5px; line-height: 20px; text-align: left; color: var(--text-muted); }
.sidebar .asx-system-shortcuts .asx-owner-nav { margin: 0; padding: 0; border: 0; }
.sidebar .asx-system-shortcuts .asx-owner-nav-label { display: none; }
.sidebar .asx-system-shortcuts .asx-owner-console-link { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 9px; color: var(--text-muted); background: transparent; box-shadow: none; font-size: 12px; line-height: 20px; font-weight: 500; }
.sidebar .asx-system-shortcuts .asx-owner-console-link svg { flex: 0 0 17px; width: 17px; height: 17px; }
.sidebar .asx-system-shortcuts :is(.crm-migration-nav, .asx-owner-console-link):hover { color: var(--text); background: var(--bg-hover); }
.sidebar .sidebar-bottom { flex-shrink: 0; padding-top: 8px; border-top: 1px solid var(--border); }
.sidebar .sidebar-footer { margin: 0; padding: 0; border: 0; }
.sidebar .user-card { min-height: 48px; padding: 7px 6px; gap: 8px; border-radius: 9px; }
.sidebar .user-avatar { flex: 0 0 30px; width: 30px; height: 30px; font-size: 10px; border-radius: 9px; }
.sidebar .user-info { min-width: 0; }
.sidebar .user-info strong { font-size: 11.5px; }
.sidebar .user-info span { font-size: 9px; }
.sidebar :is(.nav-item, .nav-group-toggle, .asx-owner-console-link, .user-card):focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
@media (min-width: 901px) {
  html[data-theme] .app-shell:not(.sidebar-collapsed) > .sidebar { width: 220px; padding: 16px 10px 10px; }
}
@media (max-width: 900px), (pointer: coarse) {
  .sidebar .nav-item, .sidebar .nav-group-toggle,
  .sidebar .nav-group-items .nav-item,
  .sidebar .asx-system-shortcuts .crm-migration-nav,
  .sidebar .asx-system-shortcuts .asx-owner-console-link { min-height: 44px; }
}

/* Settings and automation: readable controls, restrained color, clear rules. */
.settings-page { width: 100%; max-width: 1280px; margin: 0 auto; }
.settings-page .settings-page-header { margin-bottom: 20px; }
.settings-page .settings-page-header h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.7px; }
.settings-page .settings-page-header p { margin-top: 6px; font-size: 13px; line-height: 1.5; }
.settings-page .settings-page-header .eyebrow { margin-bottom: 6px; font-size: 10px; letter-spacing: .08em; }
.settings-page .settings-tabs { display: flex; width: fit-content; max-width: 100%; gap: 4px; margin-bottom: 24px; padding: 5px; border-radius: 12px; background: var(--surface-soft); overflow-x: auto; }
.settings-page .settings-tab { flex: 0 0 auto; min-height: 40px; padding: 9px 14px; gap: 8px; font-size: 12px; white-space: nowrap; }
.settings-page .settings-tabs :is(.asx-billing-settings-tab,.asx-account-resource-link) { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 14px; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: var(--text-muted); font: inherit; font-size: 12px; text-decoration: none; white-space: nowrap; }
.settings-page .settings-tabs :is(.asx-billing-settings-tab,.asx-account-resource-link):hover { background: var(--bg-card); color: var(--text); }
.settings-page .settings-tabs :is(.asx-billing-settings-tab,.asx-account-resource-link) > strong { font-size: inherit; font-weight: 600; }
.settings-page .settings-tabs :is(.asx-billing-settings-tab,.asx-account-resource-link) > span { display: inline-grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px; border: 0; border-radius: 5px; background: transparent; color: inherit; font-size: 12px; }
.settings-page .settings-tabs .asx-account-resource-link-danger:hover { color: var(--danger); }
:root[data-theme] .settings-page .settings-tab.active > span { background: var(--success-soft); color: var(--success); font-size: 10px; }
.settings-page .automation-page { gap: 20px; }
.settings-page .automation-hero { padding: 24px; gap: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-card); box-shadow: none; }
.settings-page .automation-hero-copy { gap: 16px; }
.settings-page .automation-hero-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--success-soft); color: var(--success); box-shadow: none; }
.settings-page .automation-hero .eyebrow { font-size: 10px; letter-spacing: .08em; color: var(--text-muted); }
.settings-page .automation-hero h2 { margin: 5px 0 8px; font-size: 22px; line-height: 1.25; letter-spacing: -.5px; }
.settings-page .automation-hero p { margin: 0; max-width: 540px; font-size: 13px; line-height: 1.6; }
.settings-page .automation-hero-actions { min-width: 310px; gap: 12px; }
.settings-page .automation-master-switch { padding: 0 0 12px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.settings-page .automation-master-switch > div { gap: 4px; }
.settings-page .automation-master-switch strong { font-size: 13px; font-weight: 650; }
.settings-page .automation-master-switch span { font-size: 11px; line-height: 1.4; }
.settings-page .automation-action-row { gap: 8px; }
.settings-page .automation-action-row .btn { flex: 1; min-width: 0; min-height: 40px; padding: 9px 12px; font-size: 12px; }
.settings-page .automation-action-row .btn-primary:disabled { opacity: 1; background: var(--surface-soft); border-color: var(--border); color: var(--text-muted); box-shadow: none; }
.settings-page .automation-stats { gap: 12px; overflow: visible; border: 0; border-radius: 0; background: transparent; }
.settings-page .automation-stats > div { grid-template-columns: minmax(0,1fr) 22px; gap: 8px 12px; min-height: 100px; padding: 17px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card); }
.settings-page .automation-stats > div:last-child { border: 1px solid var(--border); }
.settings-page .automation-stats svg { grid-column: 2; grid-row: 1; justify-self: end; color: var(--text-muted); }
.settings-page .automation-stats span { grid-column: 1; grid-row: 1; font-size: 12px; line-height: 1.4; }
.settings-page .automation-stats strong { grid-column: 1 / -1; grid-row: 2; font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.settings-page .automation-stats > div:last-child strong { font-size: 18px; letter-spacing: -.2px; }
.settings-page .automation-rules-card { overflow: visible; border: 0; background: transparent; box-shadow: none; }
.settings-page .automation-section-head { padding: 4px 0 16px; border: 0; }
.settings-page .automation-section-head h3 { font-size: 17px; font-weight: 650; }
.settings-page .automation-section-head p { font-size: 12px; line-height: 1.5; }
.settings-page .automation-section-head .btn { min-height: 40px; padding: 9px 14px; font-size: 12px; background: var(--bg-card); }
.settings-page .automation-rules-body { padding: 0; background: transparent; }
.settings-page .automation-rule-list { gap: 16px; }
.settings-page .automation-rule { border-radius: 16px; box-shadow: 0 2px 5px color-mix(in srgb, var(--text) 3%, transparent); }
.settings-page .automation-rule-head { min-height: 76px; padding: 14px 18px; gap: 12px; background: var(--bg-card); }
.settings-page .automation-rule-number { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); color: var(--text-muted); font-size: 12px; font-weight: 650; }
.settings-page .automation-rule-title { gap: 2px; }
.settings-page .automation-rule-title label { margin-left: 8px; font-size: 10px; line-height: 1.4; font-weight: 500; letter-spacing: .02em; text-transform: none; }
.settings-page .automation-rule-title input { width: 100%; min-height: 34px; padding: 5px 8px; border-radius: 7px; font-size: 14px; font-weight: 650; }
.settings-page .automation-rule-controls { gap: 10px; }
.settings-page .automation-rule-controls > span { font-size: 11px; font-weight: 500; }
.settings-page .automation-delete { width: 34px; height: 34px; margin-left: 6px; color: var(--text-muted); background: transparent; border-color: transparent; }
.settings-page .automation-delete:hover { color: var(--danger); background: var(--danger-soft); }
.settings-page .automation-flow { grid-template-columns: minmax(0,1fr) 24px minmax(0,.8fr) 24px minmax(0,1fr); gap: 8px; padding: 20px 18px; }
.settings-page .automation-flow-arrow { transform: none; opacity: .65; }
.settings-page .automation-step { min-width: 0; gap: 10px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.settings-page .automation-step.accent { border: 0; background: transparent; }
.settings-page .automation-step > label { min-height: 18px; gap: 6px; font-size: 11px; font-weight: 500; line-height: 1.4; }
.settings-page .automation-step > label svg { flex-shrink: 0; }
.settings-page .automation-status-select select,
.settings-page .automation-delay-input input,
.settings-page .automation-delay-input select { width: 100%; min-width: 0; height: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 9px; background-color: var(--surface-soft); color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500; }
.settings-page .automation-status-select select { padding: 8px 26px 8px 28px; }
.settings-page .automation-status-select i { left: 12px; }
.settings-page .automation-delay-input { grid-template-columns: 72px minmax(0,1fr); gap: 8px; }
.settings-page .automation-delay-input input { padding: 8px 10px; text-align: center; font-variant-numeric: tabular-nums; }
.settings-page .automation-delay-input select { padding: 8px 10px; }
.settings-page .automation-rule-summary { min-height: 46px; padding: 11px 18px; gap: 9px; background: var(--surface-soft); font-size: 11px; line-height: 1.5; }
.settings-page .automation-rule-summary strong { font-weight: 550; }
.settings-page .automation-rule-summary small { font-size: 10px; }
.settings-page .automation-bottom-grid { grid-template-columns: minmax(0,1.6fr) minmax(260px,1fr); gap: 16px; }
.settings-page .automation-history-card { border-radius: 14px; }
.settings-page .automation-history-card .card-header { padding: 16px 18px; }
.settings-page .automation-history-card h3 { font-size: 14px; font-weight: 650; }
.settings-page .automation-history-card .card-body { padding: 8px 18px; }
.settings-page .automation-history-item { min-height: 60px; gap: 10px; }
.settings-page .automation-history-item strong { font-size: 12px; }
.settings-page .automation-history-item span,
.settings-page .automation-history-item time { font-size: 11px; line-height: 1.4; }
.settings-page .automation-history-empty { min-height: 92px; padding: 16px; font-size: 12px; line-height: 1.6; }
.settings-page .automation-info-card { display: grid; grid-template-columns: 32px minmax(0,1fr); align-content: start; gap: 10px 12px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card); }
.settings-page .automation-info-card > div { width: 32px; height: 32px; margin: 0; border-radius: 9px; background: var(--surface-soft); color: var(--text-muted); }
.settings-page .automation-info-card h3 { align-self: center; margin: 0; font-size: 13px; font-weight: 650; }
.settings-page .automation-info-card p { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.65; }
.settings-page .automation-info-card > span { grid-column: 1 / -1; font-size: 11px; font-weight: 500; color: var(--text-muted); }
.settings-page .automation-rule-chooser { margin-bottom: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.settings-page .automation-rule-chooser-head > div strong { font-size: 14px; }
.settings-page .automation-rule-chooser-head > div span { font-size: 12px; line-height: 1.5; }
.settings-page .automation-template-card { padding: 14px; }
.settings-page .automation-template-copy strong { font-size: 12px; white-space: normal; }
.settings-page .automation-template-copy small,
.settings-page .automation-template-copy em { font-size: 11px; }
.settings-page .automation-blank-rule { min-width: 240px; padding: 12px; }
.settings-page .automation-blank-rule strong { font-size: 12px; }
.settings-page .automation-blank-rule small { font-size: 10px; }
.settings-page .automation-empty { border: 1px dashed var(--border); border-radius: 14px; background: var(--bg-card); }
.settings-page .automation-empty p { font-size: 13px; }
.settings-page :is(button,input,select):focus-visible { outline: 2px solid var(--success); outline-offset: 3px; }
@media (max-width: 1180px) {
  .settings-page .automation-hero { flex-direction: column; align-items: stretch; gap: 20px; }
  .settings-page .automation-hero-actions { min-width: 0; grid-template-columns: minmax(0,1fr) auto; align-items: center; }
  .settings-page .automation-master-switch { padding: 0; border: 0; }
  .settings-page .automation-action-row .btn { min-width: 130px; }
  .settings-page .automation-flow { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .settings-page .automation-flow-arrow { display: none; }
  .settings-page .automation-step { grid-template-columns: minmax(160px,.8fr) minmax(0,1.2fr); align-items: center; }
}
@media (max-width: 700px) {
  .settings-page .settings-tabs { width: 100%; margin-bottom: 20px; }
  .settings-page .settings-page-header h1 { font-size: 26px; }
  .settings-page .automation-hero { padding: 18px; }
  .settings-page .automation-hero-copy { gap: 12px; align-items: flex-start; }
  .settings-page .automation-hero-icon { width: 38px; height: 38px; border-radius: 11px; }
  .settings-page .automation-hero h2 { font-size: 20px; }
  .settings-page .automation-hero-actions { grid-template-columns: 1fr; gap: 16px; }
  .settings-page .automation-master-switch { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
  .settings-page .automation-action-row { flex-direction: row; }
  .settings-page .automation-action-row .btn { min-width: 0; min-height: 44px; }
  .settings-page .automation-stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .settings-page .automation-stats > div { min-height: 96px; padding: 14px; }
  .settings-page .automation-stats > div:last-child { grid-column: 1 / -1; min-height: 80px; }
  .settings-page .automation-section-head { flex-direction: row; align-items: center; gap: 12px; }
  .settings-page .automation-section-head h3 { font-size: 16px; }
  .settings-page .automation-section-head p { font-size: 11px; }
  .settings-page .automation-section-head .btn { flex-shrink: 0; min-height: 44px; padding: 8px 10px; }
  .settings-page .automation-rule-head { flex-direction: row; flex-wrap: wrap; padding: 14px; gap: 8px; }
  .settings-page .automation-rule-title { flex-basis: calc(100% - 48px); }
  .settings-page .automation-rule-controls { width: 100%; padding-top: 7px; justify-content: flex-end; }
  .settings-page .automation-delete { width: 40px; height: 40px; }
  .settings-page .automation-flow { padding: 16px 14px; gap: 16px; }
  .settings-page .automation-step { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .settings-page .automation-step > label { font-size: 12px; }
  .settings-page .automation-rule-title input,
  .settings-page .automation-status-select select,
  .settings-page .automation-delay-input input,
  .settings-page .automation-delay-input select { font-size: 16px; }
  .settings-page .automation-rule-summary { padding: 12px 14px; align-items: flex-start; flex-wrap: wrap; }
  .settings-page .automation-rule-summary > span { flex: 1; }
  .settings-page .automation-rule-summary small { width: 100%; margin-left: 23px; }
  .settings-page .automation-bottom-grid { grid-template-columns: minmax(0,1fr); }
  .settings-page .automation-rule-chooser-head { flex-direction: column; align-items: stretch; }
  .settings-page .automation-template-grid { grid-template-columns: minmax(0,1fr); }
  .settings-page .automation-blank-rule { min-width: 0; }
  .settings-page .automation-blank-rule small { white-space: normal; }
  .settings-page .automation-history-item { grid-template-columns: 28px minmax(0,1fr); padding: 10px 0; }
  .settings-page .automation-history-item time { grid-column: 2; }
}

/* Registration: independent password visibility controls. */
@media screen {
  #asx-platform-auth-form .asx-password-field { position: relative; min-width: 0; }
  #asx-platform-auth-form .asx-password-field input { padding-right: 54px; }
  #asx-platform-auth-form .asx-password-field input::-ms-reveal,
  #asx-platform-auth-form .asx-password-field input::-ms-clear { display: none; }
  #asx-platform-auth-form .asx-password-toggle {
    position: absolute; top: 50%; right: 3px; transform: translateY(-50%);
    display: grid; place-items: center; width: 44px; height: 44px;
    margin: 0; padding: 0; border: 0; border-radius: 9px;
    color: #62695c; background: transparent; box-shadow: none;
    cursor: pointer; touch-action: manipulation;
  }
  #asx-platform-auth-form .asx-password-toggle svg { display: block; width: 20px; height: 20px; pointer-events: none; }
  #asx-platform-auth-form .asx-password-toggle[aria-pressed="true"] { color: #405a2e; }
  #asx-platform-auth-form .asx-password-toggle:focus-visible { outline: 2px solid #78954a; outline-offset: -3px; }
  @media (hover: hover) {
    #asx-platform-auth-form .asx-password-toggle:hover { color: #35472a; background: #eff4e7; }
  }
}

/* Shared layout bounds: desktop, small laptops, and mobile WebKit/Chromium. */
@media screen {
  :root { --asx-visible-height: 100vh; }
  @supports (height: 100dvh) { :root { --asx-visible-height: 100dvh; } }
  .app-shell { height: var(--asx-visible-height); }
  .app-shell > .main-area, .app-shell .main-area > .content { min-width: 0; min-height: 0; }
  .content .tabs { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .content .tabs > * { flex-shrink: 0; }
  .header .header-actions, .header .icon-btn > svg { flex-shrink: 0; }
  .header .asx-workspace-switcher-header { min-width: 0; }
  .content :is(.page-header, .page-actions, .filters) { min-width: 0; }
  .content :is(.page-header, .page-actions) > * { min-width: 0; }
  @media (min-width: 901px) {
    .asteron-mobile-client-list, .asteron-products-selection-bar,
    .asteron-product-state, .asteron-socials-back { display: none !important; }
  }

  /* Toolbars wrap at laptop widths; wide tables keep their own scroll area. */
  @media (min-width: 901px) and (max-width: 1440px) {
    .orders-page .orders-toolbar { flex-wrap: wrap; }
    .orders-page .orders-toolbar-views { min-width: 0; max-width: 100%; flex-wrap: wrap; row-gap: 6px; }
    .orders-page .orders-toolbar-views > * { max-width: 100%; }
  }

  @media (max-width: 900px) {
    html.asteron-quick-nav-visible:not(.asx-platform-route) { overflow: hidden; }
    html.asteron-pwa.asteron-quick-nav-visible:not(.asx-platform-route) body { padding: 0; }
    .app-shell {
      box-sizing: border-box;
      padding-top: env(safe-area-inset-top, 0px);
      padding-left: env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
    }
    .app-shell > .sidebar {
      top: env(safe-area-inset-top, 0px);
      height: calc(var(--asx-visible-height) - env(safe-area-inset-top, 0px));
      padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }
    .header { gap: 8px; }
    .header .mobile-menu-button { flex: 0 0 44px; width: 44px; min-height: 44px; }
    .header .header-actions { gap: 4px; }
    .header .header-actions .icon-btn { width: 44px; min-height: 44px; }
    .header .asx-workspace-switcher-header { flex: 0 1 190px; max-width: 190px; }
    .header .asx-workspace-switcher-header .asx-workspace-copy { min-width: 0; }
    .content .page-header { flex-wrap: wrap; gap: 12px; }
    .content .page-actions { flex-wrap: wrap; max-width: 100%; }
    .content .filters { flex-wrap: wrap; max-width: 100%; }
    .content .filters > :is(input, select, .search-box, .product-filter-combobox) { min-width: 0; max-width: 100%; }
    .content .integrations-grid { min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
    .content .integration-card { min-width: 0; overflow-wrap: anywhere; }
    .settings-page .automation-page { min-width: 0; grid-template-columns: minmax(0, 1fr); }
    .settings-page .automation-page > * { min-width: 0; max-width: 100%; }
    .settings-page .automation-hero-copy > div { min-width: 0; }
    .settings-page .automation-action-row .btn { white-space: normal; line-height: 1.35; }
    /* The generated customer cards replace this source table on narrow screens. */
    .asteron-clients-page .asteron-clients-source-table { display: none !important; }

    /* Keep text fields readable without iOS focus zoom; native pickers remain native. */
    html :is(.content, .modal, .asx-modal, .asx-auth-card, .crm-migration-dialog, .commerce-dialog, .social-connect-dialog)
      :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]), select, textarea) {
      min-width: 0;
      max-width: 100%;
      font-size: 16px !important;
    }
    input[type="date"], input[type="datetime-local"], input[type="time"] { min-inline-size: 0; }
    input::-webkit-date-and-time-value { text-align: start; }

    /* Chat height follows its available flex area, including a visible keyboard. */
    html.asteron-route-socials .main-area > .content:has(.asteron-socials-chat-mode) {
      display: flex; flex-direction: column; overflow: hidden; padding: 8px;
    }
    html.asteron-route-socials .socials-page.asteron-socials-chat-mode {
      flex: 1 1 0; height: auto !important; min-height: 0 !important; max-height: 100%;
    }
    html.asteron-route-socials .socials-page.asteron-socials-chat-mode .socials-layout {
      display: flex; flex-direction: column; overflow: hidden;
      flex: 1 1 0 !important; height: auto !important; min-height: 0 !important; max-height: 100% !important;
    }
    html.asteron-route-socials .socials-page.asteron-socials-chat-mode .socials-chat-pane {
      flex: 1 1 0; height: auto; min-height: 0; max-height: 100%;
    }
    html.asteron-route-socials .socials-page .page-header > div:not(.page-actions) { display: none !important; }
    html.asteron-route-socials .socials-page .page-header { min-height: 0; margin-bottom: 8px; padding: 0; gap: 6px; }
    html.asteron-route-socials .socials-view-tabs { margin-bottom: 8px; }
    html.asteron-route-socials .socials-list-toolbar { min-width: 0; padding: 8px; gap: 8px; }

    /* Fit overlays to the visible height, rather than the height behind the keyboard. */
    html .modal-overlay {
      padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
      height: var(--asx-visible-height); box-sizing: border-box;
    }
    html .modal-overlay > .modal {
      min-width: 0; max-width: 100%;
      max-height: calc(var(--asx-visible-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    }
    html .new-order-modal[data-asx-compact-new-order="true"] > .modal-body {
      max-height: max(80px, calc(var(--asx-visible-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 148px));
    }
  }
}

/* Account cards: keep billing controls in their own row above workspace details. */
.asx-account-grid .asx-account-workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 228px;
  padding: 18px;
}
.asx-account-grid .asx-billing-card-button,
.asx-account-grid .asx-billing-card-button.has-delete {
  position: static;
  order: -1;
  align-self: flex-start;
  max-width: calc(100% - 42px);
  min-height: 32px;
  flex-shrink: 0;
  text-align: left;
}
.asx-account-grid .asx-billing-card-button strong { white-space: normal; overflow-wrap: anywhere; }
.asx-account-grid .asx-account-workspace-enter {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 144px;
  min-width: 0;
  padding: 0 0 44px;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-content: start;
  align-items: start;
}
.asx-account-grid .asx-account-workspace-copy { padding-left: 0; }
.asx-account-grid .asx-account-workspace-copy small {
  display: block;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
}
.asx-account-grid .asx-account-workspace-copy h3 { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.asx-account-grid .asx-account-workspace-open { right: 0; bottom: 0; min-height: 32px; }
.asx-account-grid .asx-account-workspace-rename { bottom: 18px; left: 18px; min-height: 32px; }
.asx-account-grid .asx-account-workspace-delete { top: 18px; right: 18px; }
@media (max-width: 560px) {
  .asx-account-grid .asx-account-workspace { padding: 16px; }
  .asx-account-grid .asx-account-workspace-enter { padding-bottom: 52px; }
  .asx-account-grid .asx-account-workspace-rename { bottom: 16px; left: 16px; min-height: 40px; }
  .asx-account-grid .asx-account-workspace-open { min-height: 40px; }
}

/* Empty social inbox: one clear path to workspace-scoped connections. */
.socials-connect-empty { min-width: 0; min-height: 380px; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; border: 1px solid var(--border, #e3e5dc); border-radius: 16px; background: var(--bg-card, #fff); }
.socials-connect-empty-icons { display: flex; gap: 12px; color: var(--text-muted, #687063); }
.socials-connect-empty-icons > svg { box-sizing: content-box; padding: 16px; background: var(--bg-hover, #f3f5ed); border-radius: 18px; }
.socials-connect-empty h2 { margin: 4px 0 0; font-size: 26px; line-height: 1.2; }
.socials-connect-empty p { margin: 0; max-width: 460px; color: var(--text-muted, #687063); line-height: 1.65; }
.socials-connect-empty .btn { min-height: 44px; padding: 12px 20px; text-decoration: none; margin-top: 6px; white-space: normal; }
@media(max-width: 560px) { .socials-connect-empty { min-height: 340px; padding: 28px 20px; } .socials-connect-empty h2 { font-size: 23px; } }

/* General settings: one card, three editable company fields. */
.settings-page.settings-general-only{max-width:900px}
.settings-general-only .settings-company-card{width:100%;max-width:720px}
.settings-general-only .card-header>div{display:flex;align-items:center;gap:12px}
.settings-general-only .card-header h2{margin:0;font-size:18px;line-height:1.3}
.settings-general-only .settings-general-form{padding:24px}
.settings-general-only fieldset{display:flex;flex-direction:column;gap:22px;min-width:0;border:0;margin:0;padding:0}
.settings-general-only .form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
.settings-general-only .form-row{display:flex;flex-direction:column;gap:8px;margin:0;min-width:0}
.settings-general-only input,.settings-general-only select{width:100%;min-width:0;min-height:44px;font-size:14px}
.settings-general-only .btn-primary{align-self:flex-start;min-height:42px;gap:8px;padding:10px 18px}
.settings-general-only .settings-general-error{color:var(--danger,#b33e38);font-size:13px}
@media(max-width:600px){.settings-general-only .settings-general-form{padding:18px}.settings-general-only .form-grid{grid-template-columns:minmax(0,1fr);gap:20px}.settings-general-only input,.settings-general-only select{font-size:16px}}

/* The sidebar social link has no unread-count badge. */
.sidebar .nav-item[href="/socials"] > .badge,
.sidebar .nav-item[href^="/socials?"] > .badge { display: none !important; }
