:root {
    --mobile-crm-purple: #6750d8;
    --mobile-crm-purple-dark: #4f3db3;
    --mobile-crm-purple-soft: #f0edff;
    --mobile-crm-ink: #202334;
    --mobile-crm-muted: #7b8094;
    --mobile-crm-line: #e8e8f1;
    --mobile-crm-bg: #f7f7fb;
}

.mobile-customer-heading,
.mobile-search-bar,
.mobile-customer-list,
.mobile-add-customer,
.mobile-bottom-nav,
.mobile-detail-hero,
.mobile-detail-actions,
.mobile-follow-customer,
.mobile-tool-label {
    display: none;
}

@media (max-width: 768px) {
    html,
    body {
        background: var(--mobile-crm-bg);
        color: var(--mobile-crm-ink);
        overscroll-behavior-y: none;
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
        font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    }

    .top-nav {
        height: calc(54px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 16px 0;
        box-sizing: border-box;
        background: rgba(255, 255, 255, .96);
        border-bottom: 1px solid var(--mobile-crm-line);
        box-shadow: none;
        backdrop-filter: blur(16px);
    }

    .top-nav .nav-title-sub {
        color: var(--mobile-crm-ink);
        font-size: 16px !important;
        font-weight: 750;
    }

    .hamburger-btn {
        margin-right: 4px;
        border-radius: 12px;
        background: #f2f2f7;
    }

    .nav-right .btn-text {
        display: none;
    }

    .content {
        margin-top: calc(54px + env(safe-area-inset-top));
        padding: 18px 16px calc(102px + env(safe-area-inset-bottom));
        background: var(--mobile-crm-bg);
    }

    #contentArea > .page-header:has(+ .mobile-customer-heading) {
        display: none;
    }

    .mobile-customer-heading {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        margin: 0 2px 16px;
    }

    .mobile-customer-heading h3 {
        margin: 2px 0 4px;
        color: var(--mobile-crm-ink);
        font-size: 25px;
        line-height: 1.25;
    }

    .mobile-customer-heading p {
        margin: 0;
        color: var(--mobile-crm-muted);
        font-size: 12px;
    }

    .mobile-brand-kicker {
        color: #9a9db0;
        font-size: 9px;
        font-weight: 800;
        letter-spacing: 1px;
    }

    .mobile-total-badge {
        display: grid;
        place-items: center;
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        box-sizing: border-box;
        color: var(--mobile-crm-purple-dark);
        background: var(--mobile-crm-purple-soft);
        border-radius: 999px;
        font-size: 13px;
        font-weight: 800;
    }

    .mobile-search-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        margin-bottom: 12px;
    }

    .mobile-search-bar input {
        min-width: 0;
        height: 48px;
        padding: 0 15px;
        color: var(--mobile-crm-ink);
        background: #fff;
        border: 1px solid #dfdfea;
        border-radius: 15px;
        outline: none;
        font-size: 16px;
    }

    .mobile-search-bar input:focus {
        border-color: #b8adf3;
        box-shadow: 0 0 0 3px rgba(103, 80, 216, .1);
    }

    .mobile-search-bar button {
        height: 48px;
        padding: 0 13px;
        color: #fff;
        background: var(--mobile-crm-purple);
        border: 0;
        border-radius: 15px;
        font-size: 12px;
        font-weight: 700;
    }

    .mobile-search-bar .mobile-filter-toggle {
        color: var(--mobile-crm-purple-dark);
        background: var(--mobile-crm-purple-soft);
    }

    .tab-filter {
        margin: 0 0 14px;
        padding: 0 0 3px;
        gap: 8px;
        background: transparent;
        border-radius: 0;
    }

    .tab-filter .tab-item,
    .tab-filter .tab-item[data-group] {
        min-height: 34px;
        padding: 7px 12px !important;
        color: #64697e;
        background: #fff !important;
        border: 1px solid var(--mobile-crm-line);
        border-radius: 999px !important;
    }

    .tab-filter .tab-item.active {
        color: var(--mobile-crm-purple-dark) !important;
        background: var(--mobile-crm-purple-soft) !important;
        border-color: #cec5ff;
    }

    .tab-filter .tab-item::after {
        display: none !important;
    }

    #filterRow:not(.mobile-open) {
        display: none !important;
    }

    #filterRow.mobile-open {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin: 0 0 14px !important;
        padding: 14px !important;
        background: #fff;
        border: 1px solid var(--mobile-crm-line);
        border-radius: 18px;
        box-shadow: 0 10px 28px rgba(42, 35, 88, .07);
    }

    #filterRow.mobile-open input,
    #filterRow.mobile-open select,
    #filterRow.mobile-open button {
        height: 44px !important;
        border-radius: 12px !important;
    }

    .customer-toolbar,
    .data-table {
        display: none !important;
    }

    .mobile-customer-list {
        display: grid;
        gap: 13px;
    }

    .mobile-customer-card {
        padding: 15px;
        background: #fff;
        border: 1px solid var(--mobile-crm-line);
        border-radius: 20px;
        box-shadow: 0 8px 24px rgba(42, 35, 88, .045);
    }

    .mobile-card-heading {
        display: flex;
        align-items: center;
        gap: 11px;
    }

    .mobile-avatar {
        display: grid;
        place-items: center;
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
        color: var(--mobile-crm-purple-dark);
        background: #eee9ff;
        border-radius: 15px;
        font-size: 17px;
        font-weight: 800;
    }

    .mobile-avatar.blue {
        color: #2872a3;
        background: #e8f6ff;
    }

    .mobile-avatar.amber {
        color: #9b6418;
        background: #fff3dd;
    }

    .mobile-avatar.large {
        width: 58px;
        height: 58px;
        border-radius: 18px;
        font-size: 21px;
    }

    .mobile-card-title {
        display: flex;
        min-width: 0;
        flex: 1;
        flex-direction: column;
        gap: 5px;
    }

    .mobile-card-title > div {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-card-title strong {
        overflow: hidden;
        color: var(--mobile-crm-ink);
        font-size: 17px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-card-title > span {
        color: var(--mobile-crm-muted);
        font-size: 12px;
    }

    .mobile-stage {
        display: inline-flex;
        align-items: center;
        min-height: 24px;
        padding: 0 9px;
        color: var(--mobile-crm-purple-dark);
        background: var(--mobile-crm-purple-soft);
        border-radius: 999px;
        font-size: 10px;
        font-weight: 700;
        white-space: nowrap;
    }

    .mobile-card-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 11px 14px;
        margin: 14px 0 12px;
        padding: 13px;
        color: #43485b;
        background: #f8f8fb;
        border-radius: 15px;
        font-size: 12px;
    }

    .mobile-card-meta span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-card-meta b {
        display: block;
        margin-bottom: 4px;
        color: #9b9eae;
        font-size: 9px;
        font-weight: 500;
    }

    .mobile-customer-card > p {
        display: -webkit-box;
        overflow: hidden;
        margin: 0 0 13px;
        color: #676c80;
        font-size: 12px;
        line-height: 1.6;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .mobile-card-actions {
        display: grid;
        grid-template-columns: 1.25fr 1fr;
        gap: 8px;
    }

    .mobile-card-actions button,
    .mobile-card-actions a,
    .mobile-card-actions .disabled {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        box-sizing: border-box;
        color: #555a70;
        background: #f0f0f5;
        border: 0;
        border-radius: 13px;
        font-size: 12px;
        font-weight: 700;
        text-decoration: none;
    }

    .mobile-card-actions button {
        color: #fff;
        background: var(--mobile-crm-purple);
    }

    .mobile-empty-state {
        display: flex;
        align-items: center;
        min-height: 180px;
        justify-content: center;
        flex-direction: column;
        gap: 7px;
        color: var(--mobile-crm-muted);
        background: #fff;
        border: 1px solid var(--mobile-crm-line);
        border-radius: 20px;
    }

    .mobile-empty-state strong {
        color: var(--mobile-crm-ink);
        font-size: 15px;
    }

    .pagination-toolbar {
        margin: 14px 0 0;
        padding: 12px;
        background: #fff;
        border: 1px solid var(--mobile-crm-line);
        border-radius: 16px;
    }

    .pagination-controls {
        overflow-x: auto;
    }

    .page-size-wrap,
    .jump-wrap {
        display: none !important;
    }

    .mobile-add-customer {
        display: block;
        position: fixed;
        right: 18px;
        bottom: calc(76px + env(safe-area-inset-bottom));
        z-index: 450;
        min-width: 76px;
        height: 48px;
        padding: 0 16px;
        color: #fff;
        background: var(--mobile-crm-purple);
        border: 0;
        border-radius: 16px;
        box-shadow: 0 12px 28px rgba(103, 80, 216, .34);
        font-size: 13px;
        font-weight: 750;
    }

    .mobile-bottom-nav {
        display: grid;
        position: fixed;
        z-index: 440;
        right: 0;
        bottom: 0;
        left: 0;
        grid-template-columns: repeat(4, 1fr);
        height: calc(66px + env(safe-area-inset-bottom));
        padding: 7px 10px env(safe-area-inset-bottom);
        box-sizing: border-box;
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid var(--mobile-crm-line);
        backdrop-filter: blur(18px);
    }

    .mobile-bottom-nav button {
        color: #9296a7;
        background: transparent;
        border: 0;
        border-radius: 13px;
        font-size: 12px;
    }

    .mobile-bottom-nav button.active {
        color: var(--mobile-crm-purple-dark);
        background: var(--mobile-crm-purple-soft);
        font-weight: 750;
    }

    .modal-box--mobile-page {
        width: 100% !important;
        max-width: none !important;
        height: 100dvh;
        max-height: none !important;
        border-radius: 0 !important;
    }

    .modal-box--mobile-page .modal-header {
        flex: 0 0 auto;
        min-height: calc(56px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 18px 0;
        box-sizing: border-box;
        background: rgba(255, 255, 255, .97);
    }

    .modal-box--mobile-page .modal-header h3 {
        color: var(--mobile-crm-ink);
        font-size: 19px;
    }

    .modal-box--mobile-page .modal-close {
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        background: #f2f2f7;
        border-radius: 13px;
    }

    .modal-box--mobile-page .modal-body {
        padding: 16px 16px calc(94px + env(safe-area-inset-bottom));
        background: var(--mobile-crm-bg);
    }

    .mobile-detail-hero,
    .mobile-follow-customer {
        display: flex;
        align-items: center;
        gap: 13px;
    }

    .mobile-detail-hero {
        padding: 5px 2px 16px;
    }

    .mobile-detail-hero > div {
        min-width: 0;
        flex: 1;
    }

    .mobile-detail-hero h2 {
        margin: 0;
        color: var(--mobile-crm-ink);
        font-size: 25px;
    }

    .mobile-detail-hero p {
        margin: 5px 0 0;
        color: var(--mobile-crm-muted);
        font-size: 12px;
    }

    .mobile-detail-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }

    .mobile-detail-actions button,
    .mobile-detail-actions a,
    .mobile-detail-actions span {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 43px;
        color: var(--mobile-crm-purple-dark);
        background: #fff;
        border: 1px solid #ddd9ed;
        border-radius: 13px;
        font-size: 12px;
        font-weight: 700;
        text-decoration: none;
    }

    .modal-box--detail .cdet-section {
        margin-bottom: 13px;
        border-color: var(--mobile-crm-line);
        border-radius: 19px;
        box-shadow: 0 8px 22px rgba(42, 35, 88, .04);
    }

    .modal-box--detail .cdet-section-title {
        padding: 15px 16px 10px;
        color: var(--mobile-crm-ink);
        background: #fff;
        border-bottom: 0;
        font-size: 15px;
    }

    .modal-box--detail .cdet-section-title::before {
        display: none;
    }

    .modal-box--detail .cdet-grid {
        grid-template-columns: 1fr;
        padding: 0 16px 7px;
    }

    .modal-box--detail .cdet-row {
        min-height: 45px;
        padding: 10px 0;
        align-items: center;
    }

    .modal-box--detail .cdet-label {
        min-width: 94px;
        max-width: 94px;
        color: #969aab;
        font-size: 12px;
    }

    .modal-box--detail .cdet-value {
        color: #363a4b;
        font-size: 13px;
        font-weight: 650;
        text-align: right;
    }

    .modal-box--detail .follow-basic-section .cdet-grid .cdet-row:nth-child(1),
    .modal-box--detail .follow-basic-section .cdet-grid .cdet-row:nth-child(2),
    .modal-box--detail .follow-basic-section .cdet-grid .cdet-row:nth-child(4) {
        display: none;
    }

    .modal-box--detail .cdet-action-bar {
        position: fixed;
        z-index: 4;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: 1fr 1.35fr;
        gap: 9px;
        padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .98);
        border-top: 1px solid var(--mobile-crm-line);
    }

    .modal-box--detail .cdet-action-bar .btn-text {
        display: none;
    }

    .modal-box--detail .cdet-action-bar button {
        min-height: 48px;
        margin: 0;
        border: 0;
        border-radius: 14px;
        font-size: 13px;
        font-weight: 750;
    }

    .modal-box--detail .cdet-action-bar .btn-edit-brown {
        color: #565b70;
        background: #efeff5;
    }

    .modal-box--detail .cdet-action-bar .btn-follow {
        color: #fff;
        background: var(--mobile-crm-purple);
    }

    .modal-box--followup .modal-body {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .mobile-follow-customer {
        order: 0;
        padding: 3px 2px 12px;
    }

    .mobile-follow-customer > div {
        display: flex;
        min-width: 0;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-follow-customer strong {
        color: var(--mobile-crm-ink);
        font-size: 17px;
    }

    .mobile-follow-customer span:last-child {
        overflow: hidden;
        color: var(--mobile-crm-muted);
        font-size: 11px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modal-box--followup .customer-detail-full {
        display: flex;
        flex-direction: column;
    }

    .modal-box--followup .follow-form-basic,
    .modal-box--followup .follow-form-history {
        display: none;
    }

    .modal-box--followup .follow-form-composer {
        order: 1;
    }

    .modal-box--followup .follow-form-fields {
        order: 2;
    }

    .modal-box--followup .follow-form-composer .cdet-section-title::before {
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px;
        color: #fff;
        background: var(--mobile-crm-purple);
        border-radius: 8px;
        content: "1";
        font-size: 11px;
    }

    .modal-box--followup .follow-form-fields .cdet-section-title::before {
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px;
        color: #fff;
        background: var(--mobile-crm-purple);
        border-radius: 8px;
        content: "2";
        font-size: 11px;
    }

    .modal-box--followup .cdet-hint-editable {
        display: none;
    }

    .modal-box--followup .follow-form {
        margin-top: 0 !important;
        padding: 0 16px 16px;
    }

    .modal-box--followup .follow-textarea {
        min-height: 150px;
        padding: 14px;
        color: var(--mobile-crm-ink);
        background: #f8f8fb;
        border: 1px solid #ececf3;
        border-radius: 15px;
        font-size: 16px !important;
        line-height: 1.65;
    }

    .modal-box--followup .follow-toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px;
        margin-top: 12px;
        padding: 0;
        background: transparent;
    }

    .modal-box--followup .follow-toolbar > button:first-child {
        display: none;
    }

    .modal-box--followup .follow-toolbar #voiceBtn,
    .modal-box--followup .follow-toolbar > button:nth-of-type(3) {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: auto;
        min-height: 44px;
        padding: 0 16px;
        border: 0;
        border-radius: 13px;
    }

    .modal-box--followup .follow-toolbar #voiceBtn {
        color: #fff;
        background: var(--mobile-crm-purple);
    }

    .modal-box--followup .follow-toolbar > button:nth-of-type(3) {
        color: #555a70;
        background: #efeff5;
    }

    .modal-box--followup .mobile-tool-label {
        display: inline;
        font-size: 12px;
        font-weight: 700;
    }

    .modal-box--followup .follow-form-fields .cdet-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
        padding: 0 16px 16px;
    }

    .modal-box--followup .follow-form-fields .cdet-row {
        display: grid;
        grid-template-columns: 90px minmax(0, 1fr);
        min-height: 48px;
        padding: 0;
        overflow: hidden;
        background: #f8f8fb;
        border: 1px solid #ececf3;
        border-radius: 13px;
    }

    .modal-box--followup .follow-form-fields .cdet-label {
        min-width: 0;
        max-width: none;
        padding: 0 10px;
        color: var(--mobile-crm-purple-dark);
        font-size: 11px;
    }

    .modal-box--followup .follow-field-select,
    .modal-box--followup .follow-field-input {
        max-width: none;
        min-height: 46px;
        background-color: #fff;
        border: 0;
        border-radius: 0;
        font-size: 16px;
    }

    .modal-box--followup .modal-footer {
        position: fixed;
        z-index: 5;
        right: 0;
        bottom: 0;
        left: 0;
        padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .98);
        border-top: 1px solid var(--mobile-crm-line);
    }

    .modal-box--followup .modal-footer .btn-secondary {
        display: none;
    }

    .modal-box--followup .modal-footer .btn-primary {
        min-height: 50px;
        color: #fff;
        background: var(--mobile-crm-purple);
        border: 0;
        border-radius: 14px;
        font-weight: 750;
    }
}
