/* 手机端线索页优化：所有规则均限制在 860px 以下，PC 端不受影响。 */

#mobileHighRiskAlertToggle {
  display: none;
}

@media (max-width: 860px) {
  /* 只分配一个方案的客户直接进入该方案，不展示方案切换工作台。 */
  body.mobile-client-single-scheme[data-view="events"] .workspace > .scheme-workbench {
    display: none !important;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body[data-view="events"] :is(
    .app-shell,
    .workspace,
    .event-workbench,
    .event-stream,
    .event-list
  ) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body[data-view="events"] .mobile-kpi-overview {
    display: none !important;
  }

  body.mobile-client .event-received-time,
  body.mobile-client .received-time-field,
  body.mobile-client dt.received-time-field + dd {
    display: none !important;
  }

  body[data-mobile-display-mode="compact"][data-view="events"] #eventList .event-title {
    display: block !important;
    -webkit-line-clamp: unset !important;
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
  }

  body[data-mobile-display-mode="compact"][data-view="events"] #eventList .event-summary {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1 !important;
    max-height: 1.5em !important;
    overflow: hidden !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    margin: 2px 0 0 !important;
  }

  body[data-mobile-display-mode="compact"] #eventList .event-row-judgment {
    display: none !important;
  }

  body[data-mobile-display-mode="compact"] #eventList .event-keywords {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
  }

  body[data-mobile-display-mode="compact"][data-view="events"] #eventList .event-meta {
    min-height: 0;
    margin: 0;
  }

  body[data-view="events"] .filters {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body[data-view="events"] #searchInput {
    grid-column: 1 / -1 !important;
    order: -2;
  }

  body[data-view="events"] #mergeSimilarFilter {
    display: block !important;
    grid-column: 1 / -1 !important;
    order: -1;
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #8fa9a3;
    border-radius: 6px;
    color: #24655a;
    background-color: #fff;
    font-size: 14px;
  }

  body[data-view="events"] :is(
    #readStateFilter,
    #processingStateFilter,
    #riskFilter,
    #sourceFilter,
    #ipRegionFilter,
    #sortFilter,
    #eventTimeFilter,
    .filter-note
  ) {
    display: none !important;
  }

  body[data-view="events"] :is(#categoryFilter, #verifyFilter),
  body[data-view="events"] #locationFilter:not([hidden]) {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 40px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-view="events"] .event-list {
    gap: 7px !important;
  }

  body[data-view="events"] .event-card {
    gap: 6px !important;
    padding: 9px 10px 8px !important;
    border-radius: 10px !important;
  }

  body[data-view="events"] .event-main {
    display: flex !important;
    min-width: 0;
    flex-direction: column !important;
  }

  body[data-view="events"] .event-meta {
    display: flex !important;
    order: 0 !important;
    min-height: 18px;
    align-items: center;
    gap: 7px;
    margin: 0 0 4px;
    color: #667a73;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
  }

  body[data-view="events"] .event-card-classification {
    order: 1 !important;
  }

  body[data-view="events"] .event-title {
    display: -webkit-box !important;
    order: 2 !important;
    overflow: hidden !important;
    margin: 4px 0 !important;
    font-size: 15px !important;
    line-height: 1.42 !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body[data-view="events"] .event-summary {
    display: -webkit-box !important;
    order: 3 !important;
    overflow: hidden !important;
    margin: 0 !important;
    font-size: 13px !important;
    line-height: 1.48 !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2 !important;
  }

  body[data-view="events"] .tags {
    gap: 4px !important;
    margin: 0 0 2px !important;
  }

  body[data-view="events"] .tag {
    min-height: 22px !important;
    height: auto !important;
    padding: 2px 7px !important;
    font-size: 10.5px !important;
    line-height: 1.25 !important;
  }

  body[data-view="events"] .event-icon-actions {
    display: none !important;
  }

  body[data-view="events"] .event-actions {
    min-height: 0 !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 7px !important;
    margin-top: 5px !important;
    padding-top: 5px !important;
  }

  body[data-view="events"] .event-actions-main {
    display: flex !important;
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start !important;
    gap: 7px;
  }

  body[data-view="events"] .mobile-summary-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-view="events"] .event-stream > .event-pagination {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    display: flex;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 56px;
    margin: 10px 0 0 !important;
    padding: 10px 0 calc(4px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid #dfeae5;
    border-bottom: 0 !important;
    background: transparent !important;
  }

  body[data-view="events"] .event-page-btn {
    min-width: 88px !important;
    height: 40px !important;
  }

  body[data-view="events"] .event-page-status {
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
  }

  #mobileHighRiskAlertToggle:not([hidden]) {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid #b9d7cf;
    border-radius: 8px;
    padding: 0 10px;
    color: #1f675b;
    background: #eef8f5;
    font-size: 12px;
    font-weight: 700;
  }

  #mobileHighRiskAlertToggle.is-enabled {
    color: #fff;
    border-color: #1d7567;
    background: #1d7567;
  }
}

@media (max-width: 380px) {
  body[data-view="events"] .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-view="events"] #locationFilter:not([hidden]) {
    grid-column: 1 / -1;
  }

  body[data-view="events"] .event-page-btn {
    min-width: 76px !important;
    padding-inline: 8px !important;
  }
}
