@media (max-width: 768px) {
  html.crm-mobile-html,
  body.crm-mobile-mode {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    background: #f4f7fb;
  }

  body.crm-mobile-mode #root {
    display: none !important;
  }

  body.crm-mobile-mode #mobile-crm-root {
    display: block;
  }

  body:not(.crm-mobile-mode) #mobile-crm-root {
    display: none;
  }

  .mcrm-app {
    min-height: 100dvh;
    color: #102033;
    background:
      radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.14), transparent 28rem),
      linear-gradient(180deg, #f7faff 0%, #eef4fb 100%);
    font-family: Inter, "DM Sans", Arial, sans-serif;
    padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
  }

  .mcrm-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -14px -14px 12px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid rgba(203, 213, 225, 0.7);
    background: rgba(247, 250, 255, 0.92);
    backdrop-filter: blur(18px);
  }

  .mcrm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .mcrm-logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 14px;
    color: #ffffff;
    background: linear-gradient(135deg, #155eef, #0f8cff);
    box-shadow: 0 14px 28px rgba(21, 94, 239, 0.22);
  }

  .mcrm-brand-title {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.05;
    color: #0f172a;
  }

  .mcrm-brand-subtitle {
    margin: 2px 0 0;
    overflow: hidden;
    color: #64748b;
    font-size: 12px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mcrm-action,
  .mcrm-icon-button,
  .mcrm-chip,
  .mcrm-segment,
  .mcrm-stage-button {
    min-height: 44px;
    border: 0;
    border-radius: 16px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mcrm-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    color: #ffffff;
    background: #155eef;
    box-shadow: 0 12px 24px rgba(21, 94, 239, 0.2);
  }

  .mcrm-action.secondary {
    color: #1e3a5f;
    background: #ffffff;
    border: 1px solid #dce7f5;
    box-shadow: none;
  }

  .mcrm-icon-button {
    width: 44px;
    flex: 0 0 auto;
    color: #1e3a5f;
    background: #ffffff;
    border: 1px solid #dce7f5;
  }

  .mcrm-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0 14px;
  }

  .mcrm-title {
    margin: 0;
    font-size: 28px;
    font-weight: 950;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: #0f172a;
  }

  .mcrm-muted {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.45;
  }

  .mcrm-grid {
    display: grid;
    gap: 12px;
  }

  .mcrm-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mcrm-card {
    border: 1px solid rgba(209, 220, 235, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
  }

  .mcrm-card.pad {
    padding: 16px;
  }

  .mcrm-kpi-label {
    margin: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
  }

  .mcrm-kpi-value {
    margin: 8px 0 0;
    color: #0f172a;
    font-size: 28px;
    font-weight: 950;
    letter-spacing: -0.04em;
    line-height: 1.05;
  }

  .mcrm-kpi-foot {
    margin-top: 8px;
    color: #7b8ba1;
    font-size: 12px;
  }

  .mcrm-list {
    display: grid;
    gap: 10px;
  }

  .mcrm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    border: 1px solid #e4edf7;
    border-radius: 18px;
    background: #ffffff;
  }

  .mcrm-row-main {
    min-width: 0;
  }

  .mcrm-row-title {
    margin: 0;
    color: #0f172a;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.3;
  }

  .mcrm-row-meta {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
  }

  .mcrm-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    color: #1d4ed8;
    background: #eaf2ff;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
  }

  .mcrm-pill.green {
    color: #047857;
    background: #dcfce7;
  }

  .mcrm-pill.orange {
    color: #b45309;
    background: #ffedd5;
  }

  .mcrm-input,
  .mcrm-select {
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
    border: 1px solid #dce7f5;
    border-radius: 17px;
    background: #ffffff;
    color: #14233a;
    font: inherit;
    font-size: 15px;
    outline: none;
    padding: 0 14px;
  }

  .mcrm-input:focus,
  .mcrm-select:focus {
    border-color: #155eef;
    box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.12);
  }

  .mcrm-filterbar {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }

  .mcrm-task-filter-row {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 12px;
    padding: 2px 2px 8px;
    overscroll-behavior-x: contain;
  }

  .mcrm-chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mcrm-chip-row::-webkit-scrollbar {
    display: none;
  }

  .mcrm-chip {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0 13px;
    color: #334155;
    background: #ffffff;
    border: 1px solid #dce7f5;
  }

  .mcrm-chip.active {
    color: #ffffff;
    background: #155eef;
    border-color: #155eef;
  }

  .mcrm-client-card,
  .mcrm-task-card,
  .mcrm-funnel-card,
  .mcrm-team-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    text-align: left;
  }

  .mcrm-card-button {
    width: 100%;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
  }

  .mcrm-card-title {
    margin: 0;
    color: #0f172a;
    font-size: 16px;
    font-weight: 950;
    line-height: 1.25;
  }

  .mcrm-card-meta {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.4;
  }

  .mcrm-card-footer,
  .mcrm-inline-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }

  .mcrm-stage-button {
    padding: 0 12px;
    color: #1e3a5f;
    background: #f3f7fc;
    border: 1px solid #dce7f5;
    font-size: 13px;
  }

  .mcrm-stage {
    display: grid;
    gap: 10px;
    padding: 14px;
  }

  .mcrm-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mcrm-stage-title {
    margin: 0;
    font-size: 18px;
    font-weight: 950;
    color: #102033;
  }

  .mcrm-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(203, 213, 225, 0.8);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.08);
  }

  .mcrm-nav-item {
    min-height: 52px;
    border: 0;
    border-radius: 16px;
    color: #64748b;
    background: transparent;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
  }

  .mcrm-nav-item svg {
    display: block;
    width: 20px;
    height: 20px;
    margin: 0 auto 4px;
  }

  .mcrm-nav-item.active {
    color: #155eef;
    background: #eaf2ff;
  }

  .mcrm-empty {
    padding: 28px 16px;
    text-align: center;
    color: #64748b;
  }

  .mcrm-loading,
  .mcrm-error {
    min-height: 60dvh;
    display: grid;
    place-items: center;
    text-align: center;
    color: #64748b;
  }

  .mcrm-error {
    color: #b91c1c;
  }

  .mcrm-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: flex;
    align-items: flex-end;
    background: rgba(15, 23, 42, 0.5);
  }

  .mcrm-detail {
    width: 100%;
    max-height: 88dvh;
    overflow: auto;
    border-radius: 28px 28px 0 0;
    background: #ffffff;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -24px 70px rgba(15, 23, 42, 0.26);
  }

  .mcrm-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
  }

  .mcrm-detail-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.12;
    letter-spacing: -0.03em;
    font-weight: 950;
    color: #0f172a;
  }

  .mcrm-detail-grid {
    display: grid;
    gap: 10px;
  }

  .mcrm-fact {
    padding: 12px;
    border-radius: 18px;
    background: #f6f9fd;
  }

  .mcrm-fact-label {
    margin: 0 0 4px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
  }

  .mcrm-fact-value {
    margin: 0;
    color: #132238;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  body.crm-mobile-mode .mnc-overlay,
  body.crm-mobile-mode .mnt-overlay {
    align-items: stretch;
    padding: 0;
  }

  body.crm-mobile-mode .mnc-modal {
    width: 100%;
    height: 94dvh;
    max-height: 94dvh;
    border-radius: 28px 28px 0 0;
  }

  body.crm-mobile-mode .mnt-modal {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    overflow: auto;
  }

  body.crm-mobile-mode .mnc-head,
  body.crm-mobile-mode .mnt-head {
    padding: 18px 16px;
  }

  body.crm-mobile-mode .mnc-form,
  body.crm-mobile-mode .mnt-form {
    padding: 18px 16px 22px;
  }

  body.crm-mobile-mode .mnc-grid,
  body.crm-mobile-mode .mnc-grid-3,
  body.crm-mobile-mode .mnt-grid,
  body.crm-mobile-mode .mnt-grid-3 {
    grid-template-columns: 1fr;
  }

  body.crm-mobile-mode .mnc-field input,
  body.crm-mobile-mode .mnc-field select,
  body.crm-mobile-mode .mnc-field textarea,
  body.crm-mobile-mode .mnt-field input,
  body.crm-mobile-mode .mnt-field select,
  body.crm-mobile-mode .mnt-field textarea {
    min-height: 48px;
    font-size: 16px;
  }

  body.crm-mobile-mode .mnc-footer,
  body.crm-mobile-mode .mnt-footer {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    align-items: stretch;
    flex-direction: column;
  }

  body.crm-mobile-mode .mnt-footer {
    position: static;
    border-top: 0;
    padding-top: 4px;
  }
}

@media (min-width: 769px) {
  #mobile-crm-root {
    display: none !important;
  }
}
