/* Mobile web shell — layout chrome (tokens: --app-mobile-*) */

body.app-mobile #app-sidebar {
    display: none !important;
}

body.app-mobile #app-container {
    flex-direction: column;
}

body.app-mobile {
    /* Chiều thanh dưới + tai thỏ — dùng chung cho list/detail/form */
    --app-mobile-nav-clearance: calc(var(--app-mobile-nav-h, 3.75rem) + env(safe-area-inset-bottom, 0px));
}
body.app-mobile main {
    padding-bottom: var(--app-mobile-nav-clearance);
}

body.app-mobile #header-title {
    max-width: 55% !important;
}

body.app-mobile #global-finder-root {
    display: none;
}

/* Modal desktop (Sửa / Xem) mount vào overlay — phủ trên list/detail + bottom nav */
body.app-mobile #app-overlay-host {
    top: var(--app-header-h, 4rem);
    bottom: 0;
    z-index: 9500;
}
body.app-mobile #app-overlay-host.is-active {
    bottom: 0;
}

/* Domain wayfinding tones — Operate mobile menu / bottom nav */
:root {
    /* Align mobile type/radius with DESIGN tokens where possible */
    --ms-text-nano: 0.625rem;
    --ms-text-mini: var(--app-text-mini, 0.6875rem);
    --ms-text-meta: var(--app-text-meta, 0.75rem);
    --ms-text-body: var(--app-text-body, 0.875rem);
    --ms-text-title: var(--app-title-section, 1rem);
    --ms-radius: var(--app-panel-radius, 0.5rem);
    --ms-radius-lg: 0.65rem;
    --ms-radius-xl: 0.75rem;
    --ms-tone-home: #475569;
    --ms-tone-home-soft: #f1f5f9;
    --ms-tone-workspace: #4f46e5;
    --ms-tone-workspace-soft: #eef2ff;
    --ms-tone-lead: #0284c7;
    --ms-tone-lead-soft: #e0f2fe;
    --ms-tone-consult: #0891b2;
    --ms-tone-consult-soft: #cffafe;
    --ms-tone-customer: #0d9488;
    --ms-tone-customer-soft: #ccfbf1;
    --ms-tone-quote: #7c3aed;
    --ms-tone-quote-soft: #ede9fe;
    --ms-tone-docs: #d97706;
    --ms-tone-docs-soft: #fef3c7;
    --ms-tone-service: #2563eb;
    --ms-tone-service-soft: #dbeafe;
    --ms-tone-teach: #059669;
    --ms-tone-teach-soft: #d1fae5;
    --ms-tone-cost: #e11d48;
    --ms-tone-cost-soft: #ffe4e6;
    --ms-tone-cash: #0e7490;
    --ms-tone-cash-soft: #cffafe;
    --ms-tone-more: #64748b;
    --ms-tone-more-soft: #f1f5f9;
}

.mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: none;
    height: var(--app-mobile-nav-h, 3.75rem);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--app-mobile-nav-bg, #0f172a);
    color: #e2e8f0;
    border-top: 1px solid #1e293b;
    justify-content: space-around;
    align-items: stretch;
}

body.app-mobile .mobile-bottom-nav {
    display: flex;
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: var(--ms-text-nano, 0.625rem);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #94a3b8;
    background: transparent;
    border: 0;
    padding: 0.35rem 0.15rem;
    min-width: 0;
}

.mobile-nav-btn.is-active {
    color: #fff;
}

.mobile-nav-btn.is-active .mobile-nav-ico {
    color: var(--ms-nav-accent, #93c5fd);
}

.mobile-nav-btn.mobile-tone--home.is-active { --ms-nav-accent: #cbd5e1; }
.mobile-nav-btn.mobile-tone--workspace.is-active { --ms-nav-accent: #a5b4fc; }
.mobile-nav-btn.mobile-tone--lead.is-active { --ms-nav-accent: #7dd3fc; }
.mobile-nav-btn.mobile-tone--consult.is-active { --ms-nav-accent: #67e8f9; }
.mobile-nav-btn.mobile-tone--customer.is-active { --ms-nav-accent: #5eead4; }
.mobile-nav-btn.mobile-tone--quote.is-active { --ms-nav-accent: #c4b5fd; }
.mobile-nav-btn.mobile-tone--docs.is-active { --ms-nav-accent: #fcd34d; }
.mobile-nav-btn.mobile-tone--service.is-active { --ms-nav-accent: #93c5fd; }
.mobile-nav-btn.mobile-tone--teach.is-active { --ms-nav-accent: #6ee7b7; }
.mobile-nav-btn.mobile-tone--cost.is-active { --ms-nav-accent: #fda4af; }
.mobile-nav-btn.mobile-tone--cash.is-active { --ms-nav-accent: #67e8f9; }
.mobile-nav-btn.mobile-tone--more.is-active { --ms-nav-accent: #cbd5e1; }

.mobile-nav-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    line-height: 1;
}

.mobile-nav-svg,
.mobile-nav-img {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    object-fit: contain;
}

.nav-feature-icon-img,
.nav-feature-sub.nav-feature-icon-img {
    object-fit: contain;
}

.nav-feature-sub {
    width: 1rem;
    height: 1rem;
    margin-right: 0.4rem;
}

.mobile-drawer-group-ico {
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    margin-right: 0.35rem;
    vertical-align: -0.15rem;
}

.mobile-drawer-group-ico .mobile-nav-svg,
.mobile-drawer-group-ico .mobile-nav-img {
    width: 1rem;
    height: 1rem;
}

.mobile-nav-lbl {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu-drawer {
    position: fixed;
    inset: 0;
    z-index: 70;
}

.mobile-menu-drawer.hidden {
    display: none;
}

.mobile-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.mobile-drawer-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(19rem, 88vw);
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    height: var(--app-header-h, 4rem);
}

.mobile-drawer-title {
    font-size: var(--ms-text-title);
    font-weight: 700;
    color: #0f172a;
}

.mobile-drawer-close {
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    background: transparent;
    border: 0;
    padding: 0.25rem 0.5rem;
}

.mobile-drawer-body {
    flex: 1;
    overflow: auto;
    padding: 0.35rem 0 1rem;
}

.mobile-drawer-group {
    padding-bottom: 0.35rem;
}

.mobile-drawer-group-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1rem 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ms-tone-fg, #64748b);
}

.mobile-drawer-group-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: var(--ms-tone-fg, #94a3b8);
    flex-shrink: 0;
}

.mobile-drawer-item,
.mobile-drawer-setup {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    padding: 0.55rem 1rem;
    font-size: var(--ms-text-body);
    color: #0f172a;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.mobile-drawer-item:active,
.mobile-drawer-item:hover,
.mobile-drawer-setup:active,
.mobile-drawer-setup:hover {
    background: #f8fafc;
}

.mobile-drawer-item-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.mobile-drawer-item-name {
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
}

.mobile-drawer-item-hint {
    font-size: var(--ms-text-mini);
    font-weight: 500;
    color: #64748b;
}

.mobile-icon-chip {
    flex-shrink: 0;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: var(--ms-radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ms-tone-soft, #f1f5f9);
    color: var(--ms-tone-fg, #475569);
}

.mobile-tone--home { --ms-tone-fg: var(--ms-tone-home); --ms-tone-soft: var(--ms-tone-home-soft); }
.mobile-tone--workspace { --ms-tone-fg: var(--ms-tone-workspace); --ms-tone-soft: var(--ms-tone-workspace-soft); }
.mobile-tone--lead { --ms-tone-fg: var(--ms-tone-lead); --ms-tone-soft: var(--ms-tone-lead-soft); }
.mobile-tone--consult { --ms-tone-fg: var(--ms-tone-consult); --ms-tone-soft: var(--ms-tone-consult-soft); }
.mobile-tone--customer { --ms-tone-fg: var(--ms-tone-customer); --ms-tone-soft: var(--ms-tone-customer-soft); }
.mobile-tone--quote { --ms-tone-fg: var(--ms-tone-quote); --ms-tone-soft: var(--ms-tone-quote-soft); }
.mobile-tone--docs { --ms-tone-fg: var(--ms-tone-docs); --ms-tone-soft: var(--ms-tone-docs-soft); }
.mobile-tone--service { --ms-tone-fg: var(--ms-tone-service); --ms-tone-soft: var(--ms-tone-service-soft); }
.mobile-tone--teach { --ms-tone-fg: var(--ms-tone-teach); --ms-tone-soft: var(--ms-tone-teach-soft); }
.mobile-tone--cost { --ms-tone-fg: var(--ms-tone-cost); --ms-tone-soft: var(--ms-tone-cost-soft); }
.mobile-tone--cash { --ms-tone-fg: var(--ms-tone-cash); --ms-tone-soft: var(--ms-tone-cash-soft); }
.mobile-tone--more { --ms-tone-fg: var(--ms-tone-more); --ms-tone-soft: var(--ms-tone-more-soft); }

.mobile-drawer-footer {
    margin-top: 0.75rem;
    padding-top: 0.35rem;
    border-top: 1px solid #e2e8f0;
}

.mobile-drawer-item-muted {
    color: #64748b;
    margin-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.mobile-pin-setup {
    padding: 0.25rem 0 1rem;
}

.mobile-pin-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.25rem 1rem 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    background: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--ms-radius);
    cursor: pointer;
}

.mobile-pin-lead {
    margin: 0 1rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #475569;
}

.mobile-pin-list {
    display: flex;
    flex-direction: column;
}

.mobile-pin-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    border: 0;
    background: transparent;
}

.mobile-pin-row.is-on {
    background: #f8fafc;
}

.mobile-pin-row input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #2563eb;
    flex-shrink: 0;
}

.mobile-pin-save {
    display: block;
    width: calc(100% - 2rem);
    margin: 1rem 1rem 0;
    min-height: 44px;
    border: 0;
    border-radius: var(--ms-radius-lg);
    background: #0f172a;
    color: #fff;
    font-size: var(--ms-text-body);
    font-weight: 650;
    cursor: pointer;
}

.mobile-pin-save:disabled {
    opacity: 0.65;
    cursor: wait;
}

.mobile-menu-setup-list {
    display: flex;
    flex-direction: column;
}
.mobile-menu-setup-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem 0.35rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}
.mobile-menu-setup-row.is-off {
    opacity: 0.55;
}
.mobile-menu-setup-row.is-on {
    background: #f8fafc;
}
.mobile-menu-setup-move {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex-shrink: 0;
}
.mobile-menu-move-btn {
    min-width: 2rem;
    min-height: 1.55rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.4rem;
    cursor: pointer;
}
.mobile-menu-move-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.mobile-menu-setup-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.mobile-menu-setup-main input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #0f766e;
    flex-shrink: 0;
}
.mobile-menu-setup-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.mobile-menu-reset {
    display: block;
    width: calc(100% - 2rem);
    margin: 0.5rem 1rem 0;
    min-height: 44px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--ms-radius-lg);
    background: #fff;
    color: #334155;
    font-size: var(--ms-text-body);
    font-weight: 600;
    cursor: pointer;
}

.mobile-view-toolbar {
    padding: 0.5rem 0.75rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.mobile-search {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius);
    padding: 0.5rem 0.75rem;
    font-size: var(--ms-text-body);
    outline: none;
}

.mobile-search:focus {
    border-color: #94a3b8;
}

/* Action Cell Desk — ô đủ cao hiện 2 dòng; gap + viền rõ */
.mobile-action-desk .mobile-view-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 0.75rem 0.75rem 1.25rem;
    box-sizing: border-box;
}

body.app-mobile .mobile-card,
body.app-mobile .mobile-action-cell,
body.app-mobile button.mobile-action-cell {
    display: flex;
    align-items: center; /* Nội dung canh giữa theo chiều dọc ô */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: left;
    /* Pad đều — tránh lệch đáy khi meta dài (tạm ứng…) */
    padding: 0.95rem;
    min-height: 4.75rem;
    /* Auto-size theo nội dung — không cố định / không cắt nửa dòng */
    height: auto !important;
    max-height: none !important;
    line-height: normal !important;
    white-space: normal !important;
    background: #fff;
    border: 1.5px solid #94a3b8;
    border-radius: var(--ms-radius-xl);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
    /* Clip trong khung — tránh chữ/› tràn ra ngoài viền */
    overflow: hidden;
}

.mobile-card:active,
.mobile-action-cell:active {
    filter: brightness(0.985);
}

/* Khung list tô theo tone trạng thái hệ thống */
body.app-mobile button.mobile-action-cell.mobile-action-cell--success {
    background: #ecfdf5;
    border-color: #34d399;
}
body.app-mobile button.mobile-action-cell.mobile-action-cell--info {
    background: #eff6ff;
    border-color: #60a5fa;
}
body.app-mobile button.mobile-action-cell.mobile-action-cell--warning {
    background: #fff7ed;
    border-color: #fb923c;
}
body.app-mobile button.mobile-action-cell.mobile-action-cell--danger {
    background: #fef2f2;
    border-color: #f87171;
}
body.app-mobile button.mobile-action-cell.mobile-action-cell--muted {
    background: #f8fafc;
    border-color: #cbd5e1;
}
body.app-mobile button.mobile-action-cell.mobile-action-cell--neutral {
    background: #fff;
    border-color: #94a3b8;
}

.mobile-action-cell-inner {
    display: flex;
    align-items: center; /* title/meta ↔ status/tiền cùng trục giữa */
    gap: 0.65rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.mobile-action-cell-main {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mobile-action-cell-aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.3rem;
    flex: 0 1 auto;
    /* Gọn hơn — nhường chỗ meta trái; vẫn hiện đủ tiền */
    max-width: min(42%, 9.75rem);
    min-width: 4.75rem;
}

.mobile-card-title {
    font-weight: 600;
    color: var(--app-color-title, #1e293b);
    font-size: 0.9375rem;
    line-height: 1.4;
    max-width: 100%;
    /* Tối đa 2 dòng — ellipsis cuối dòng, không cắt nửa glyph giữa ô */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.mobile-card-meta {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    margin-top: 0.35rem;
    font-size: var(--ms-text-meta);
    line-height: 1.4;
    min-height: 0;
    color: var(--app-color-meta, #64748b);
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

/* Status nằm trong khung, căn phải — hiện đủ chữ */
.mobile-card-status {
    margin: 0;
    max-width: 100%;
    text-align: right;
}

/* List ngoài: nhãn trạng thái gọn trong khung (không badge tràn ngoài) */
.mobile-status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    max-width: 100%;
    padding: 0.15rem 0.4rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    font-size: var(--ms-text-mini);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: unset;
    white-space: normal;
    text-align: right;
    box-sizing: border-box;
}
.mobile-status-chip--neutral {
    background: rgba(241, 245, 249, 0.9);
    color: #475569;
    border-color: #e2e8f0;
}
.mobile-status-chip--info {
    background: rgba(219, 234, 254, 0.85);
    color: #1e40af;
    border-color: #93c5fd;
}
.mobile-status-chip--success {
    background: rgba(167, 243, 208, 0.55);
    color: #047857;
    border-color: #6ee7b7;
}
.mobile-status-chip--warning {
    background: rgba(254, 215, 170, 0.55);
    color: #c2410c;
    border-color: #fdba74;
}
.mobile-status-chip--danger {
    background: rgba(254, 202, 202, 0.55);
    color: #b91c1c;
    border-color: #fca5a5;
}
.mobile-status-chip--muted {
    background: rgba(248, 250, 252, 0.9);
    color: #94a3b8;
    border-color: #e2e8f0;
}

/* Detail trong: màu font trạng thái */
.mobile-status-text {
    font-weight: 700;
}
.mobile-status-text--neutral { color: #475569; }
.mobile-status-text--info { color: #1d4ed8; }
.mobile-status-text--success { color: #047857; }
.mobile-status-text--warning { color: #c2410c; }
.mobile-status-text--danger { color: #b91c1c; }
.mobile-status-text--muted { color: #94a3b8; font-weight: 600; }

.mobile-cell-money {
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    /* Luôn hiện đủ số tiền — không ellipsis */
    overflow: hidden;
    text-overflow: unset;
    white-space: normal;
    word-break: break-word;
    text-align: right;
    max-width: 100%;
}

/* Chevron list tắt mặc định — chỉ hiện nếu caller bật s.chevron */
.mobile-cell-chevron {
    display: none;
}

/* —— Mobile form (full-screen stack) —— */
.mobile-form-panel {
    padding: 0.75rem 1rem calc(1.5rem + var(--app-mobile-nav-clearance, 3.75rem));
    background: #fff;
    min-height: 100%;
    box-sizing: border-box;
}
.mobile-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.5rem;
}
/* display:flex ở trên ghi đè thuộc tính hidden — tab không đổi màn */
.mobile-form-fields[hidden],
[data-ms-subpanel][hidden] {
    display: none;
}
.mobile-form-field label {
    display: block;
    font-size: var(--ms-text-meta);
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.3rem;
}
.mobile-form-field label .req {
    color: #e11d48;
}
.mobile-form-field .customer-search-select-wrap {
    width: 100%;
}
.mobile-lookup-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    font-size: var(--ms-text-body);
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--ms-radius);
}
.mobile-form-field input,
.mobile-form-field select,
.mobile-form-field textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    font-size: var(--ms-text-body);
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--ms-radius);
}
.mobile-form-field textarea {
    min-height: 5rem;
    resize: vertical;
}
.mobile-form-field-hint {
    margin-top: 0.35rem;
    font-size: var(--ms-text-meta);
    line-height: 1.35;
    color: #64748b;
}
.mobile-form-field-hint.is-ok {
    color: #047857;
}
.mobile-form-field-hint.is-warn {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--ms-radius);
    padding: 0.45rem 0.55rem;
}
.mobile-form-field-hint.hidden {
    display: none;
}
.mobile-form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-bottom: 0.5rem;
}
.mobile-form-actions .app-btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
}
.mobile-form-error {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--ms-radius);
    padding: 0.5rem 0.75rem;
}
.mobile-form-section {
    margin-top: 0.35rem;
    padding-top: 0.65rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.mobile-subtabs {
    display: flex;
    gap: 0.15rem;
    overflow-x: auto;
    margin: 0.65rem 0 0.15rem;
    border-bottom: 1px solid #e2e8f0;
}
.mobile-subtab {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.55rem 0.7rem;
    min-height: 44px;
    border-bottom: 2px solid transparent;
}
.mobile-subtab.is-active {
    color: #3730a3;
    border-bottom-color: #4f46e5;
}
.mobile-pay-total {
    margin: 0;
    font-size: 0.8125rem;
    color: #334155;
}
.mobile-pay-total strong {
    font-variant-numeric: tabular-nums;
    color: #1e1b4b;
}
.mobile-pay-hint {
    margin: 0.35rem 0 0;
    font-size: var(--ms-text-meta);
    color: #64748b;
}
.mobile-pay-row {
    display: grid;
    grid-template-columns: 1.4fr 0.6fr 1fr auto;
    gap: 0.4rem;
    align-items: end;
    margin-top: 0.65rem;
}
.mobile-pay-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
}
.mobile-pay-row select,
.mobile-pay-row input {
    width: 100%;
    min-height: 44px;
    padding: 0.4rem 0.5rem;
    font-size: var(--ms-text-body);
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--ms-radius);
}
.mobile-pay-row button {
    min-height: 44px;
    padding: 0 0.65rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #9f1239;
    border-radius: var(--ms-radius);
    font-size: var(--ms-text-meta);
    font-weight: 600;
}
.mobile-pending-note {
    margin: 0;
    padding: 0.55rem 0.85rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #3730a3;
    background: #eef2ff;
    border-bottom: 1px solid #e0e7ff;
}

.mobile-view-chrome {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

/* List → detail: full screen stack (không dropdown dưới filter) */
.mobile-view.is-showing-detail .mobile-view-chrome {
    display: none !important;
}
.mobile-view.is-showing-detail .mobile-view-list {
    display: none !important;
}
.mobile-view.is-showing-detail .mobile-view-detail {
    display: block !important;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Cuộn hết data; FAB cố định ngoài luồng — pad trong .mobile-detail-panel */
    padding-bottom: 0;
    box-sizing: border-box;
}

.mobile-filter-host {
    padding: 0.5rem 0.75rem 0.25rem;
}

/* —— Mobile filter: compact bar + bottom sheet —— */
.mobile-filter-shell {
    width: 100%;
}
.mobile-filter-compact-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mobile-filter-open-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius-xl);
}
.mobile-filter-open-btn[aria-expanded="true"] {
    border-color: #94a3b8;
    background: #fff;
}
.mobile-filter-open-ico {
    opacity: 0.7;
}
.mobile-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 9999px;
    background: #0f766e;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
}
.mobile-filter-reset-btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius-xl);
}
.mobile-filter-sheet {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.mobile-filter-sheet.hidden {
    display: none !important;
}
.mobile-filter-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.mobile-filter-sheet-panel {
    position: relative;
    z-index: 1;
    max-height: min(78vh, 36rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-filter-sheet-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.mobile-filter-sheet-head strong {
    font-size: 0.9375rem;
    color: #0f172a;
}
.mobile-filter-sheet-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}
.mobile-filter-sheet-x {
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    background: transparent;
    border: 0;
    padding: 0.15rem 0.35rem;
}
.mobile-filter-sheet-body {
    flex: 1;
    overflow: auto;
    padding: 0.75rem 1rem;
    -webkit-overflow-scrolling: touch;
}
.mobile-filter-sheet-body [data-list-filter-chips] {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
}
.mobile-filter-sheet-body [data-filter-chip] {
    width: 100%;
    max-width: none !important;
    min-height: 44px;
    padding: 0.45rem 0.65rem !important;
}
.mobile-filter-sheet-body [data-filter-chip] .relative,
.mobile-filter-sheet-body [data-filter-chip] input,
.mobile-filter-sheet-body [data-filter-chip] select {
    min-width: 0 !important;
    max-width: none !important;
    width: 100%;
    flex: 1;
}
.mobile-filter-sheet-foot {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
}
.mobile-filter-sheet-foot .app-btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
}
body.mobile-filter-sheet-open {
    overflow: hidden;
}

.mobile-sort-open-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 44px;
    max-width: 42%;
    padding: 0.5rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius-xl);
}
.mobile-sort-open-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-sort-open-caret {
    opacity: 0.65;
    font-size: 0.65rem;
}
.mobile-sort-sheet-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.mobile-sort-option {
    display: flex;
    align-items: center;
    min-height: 44px;
    width: 100%;
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
}
.mobile-sort-option.is-active {
    border-color: #0f766e;
    background: #f0fdfa;
    color: #0f766e;
    font-weight: 600;
}
.mobile-lifecycle-seg {
    margin-top: 0.15rem;
}

.mobile-dt-toolbar {
    padding: 0.25rem 0.75rem 0.5rem;
}

.mobile-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.mobile-seg-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem 0;
}

.mobile-seg-tab {
    flex: 1;
    padding: 0.45rem 0.5rem;
    font-size: var(--ms-text-meta);
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 0;
    border-radius: var(--ms-radius);
}

.mobile-seg-tab.is-active {
    color: #fff;
    background: var(--app-color-title, #1e293b);
}

.mobile-detail-hero {
    margin-bottom: 0.75rem;
}

.mobile-detail-hero-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mobile-detail-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-color-title, #1e293b);
    margin: 0;
    flex: 1;
    min-width: 0;
}

.mobile-detail-badge,
.mobile-detail-status {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 0;
    border: 0;
    background: transparent;
    text-transform: none;
}

.mobile-detail-money {
    margin-top: 0.35rem;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mobile-detail-sub {
    margin: 0.25rem 0 0;
    font-size: var(--ms-text-meta);
    color: var(--app-color-meta, #64748b);
}

.mobile-detail-panel {
    padding: 0.75rem 1rem;
    /* Chừa chỗ FAB + bottom nav — nội dung cuộn hết theo chiều dọc thiết bị */
    padding-bottom: calc(1.25rem + var(--app-mobile-fab-clearance, 3.25rem) + var(--app-mobile-nav-clearance, 3.75rem));
    background: #fff;
    min-height: 100%;
    box-sizing: border-box;
}

/* —— Detail actions: FAB nhỏ + bottom sheet (không lưới sticky đè data) —— */
body.app-mobile {
    --app-mobile-fab-clearance: 3.25rem;
}

.mobile-detail-actions-dock {
    position: static;
    pointer-events: none;
}
.mobile-detail-actions-dock.hidden {
    display: none !important;
}
.mobile-detail-actions-dock > * {
    pointer-events: auto;
}

/* FAB công cụ — cố định sát trên bottom nav */
.mobile-detail-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(0.75rem + var(--app-mobile-nav-clearance, 3.75rem));
    z-index: 45;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 0.95rem 0.55rem 0.75rem;
    border: 1.5px solid #334155;
    border-radius: 999px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.8125rem;
    font-weight: 650;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
    cursor: pointer;
}
.mobile-detail-fab:active {
    filter: brightness(1.08);
}
.mobile-detail-fab-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
}
.mobile-detail-fab-label {
    letter-spacing: 0.01em;
}

/* Sheet thao tác — gắn đáy form, trên bottom nav */
.mobile-detail-action-sheet {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.mobile-detail-action-sheet[hidden] {
    display: none !important;
}
.mobile-detail-action-sheet-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.42);
    cursor: pointer;
}
.mobile-detail-action-sheet-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: min(62vh, calc(100dvh - var(--app-mobile-nav-clearance, 3.75rem) - 3rem));
    margin: 0;
    padding: 0 0 calc(0.65rem + var(--app-mobile-nav-clearance, 3.75rem));
    border-radius: 1rem 1rem 0 0;
    background: #fff;
    box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.16);
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: mobileDetailSheetIn 160ms ease-out;
}
@keyframes mobileDetailSheetIn {
    from { transform: translateY(12%); opacity: 0.85; }
    to { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .mobile-detail-action-sheet-panel { animation: none; }
}
.mobile-detail-action-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.mobile-detail-action-sheet-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
}
.mobile-detail-action-sheet-x {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: var(--ms-radius);
    background: #f1f5f9;
    color: #334155;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.mobile-detail-action-sheet-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Nút trong sheet: lưới 2 cột — gọn chiều dọc */
.mobile-detail-action-btn {
    flex: none;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.65rem;
    border-radius: 0.55rem;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 650;
    line-height: 1.25;
    cursor: pointer;
    text-align: center;
}
.mobile-detail-action-label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
/* Lẻ nút cuối: kéo full hàng nếu chỉ còn 1 */
.mobile-detail-action-sheet-body > .mobile-detail-action-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}
.mobile-detail-action-btn:active {
    filter: brightness(0.97);
}
.mobile-detail-action-btn--primary {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}
.mobile-detail-action-btn--success {
    border-color: #6ee7b7;
    background: #ecfdf5;
    color: #047857;
}
.mobile-detail-action-btn--warning {
    border-color: #fdba74;
    background: #fff7ed;
    color: #c2410c;
}
.mobile-detail-action-btn--danger {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #b91c1c;
}
.mobile-detail-action-btn--info {
    border-color: #a5b4fc;
    background: #eef2ff;
    color: #3730a3;
}
.mobile-detail-action-btn--neutral {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #334155;
}

/* Compat class cũ (nếu còn sót markup) */
.mobile-detail-actions {
    display: none !important;
}

.mobile-detail-back,
button.mobile-detail-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 40px;
    margin: 0 0 0.75rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a !important;
    background: #fff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: var(--ms-radius);
    box-shadow: none;
    text-decoration: none !important;
    cursor: pointer;
}
.mobile-detail-back:active,
button.mobile-detail-back:active {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
}

.mobile-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f8fafc;
    font-size: 0.8125rem;
}

.mobile-detail-row dt {
    color: #64748b;
    flex-shrink: 0;
}

.mobile-detail-row dd {
    color: #0f172a;
    text-align: right;
    word-break: break-word;
}

.mobile-detail-hydrate {
    margin-top: 0.35rem;
    padding: 0.35rem 0;
    font-size: var(--ms-text-meta);
    color: #94a3b8;
}

.mobile-detail-section {
    margin: 0.85rem 0 0.35rem;
    padding-top: 0.55rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.mobile-detail-section:first-child {
    margin-top: 0.25rem;
    padding-top: 0;
    border-top: 0;
}

.mobile-detail-block {
    margin: 0.5rem 0 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius);
}

.mobile-detail-block-title {
    font-size: var(--ms-text-meta);
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.35rem;
}

.mobile-detail-block .mobile-detail-row:last-child {
    border-bottom: 0;
}

.mobile-detail-empty {
    margin: 0.25rem 0 0.5rem;
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* Track B-mobile: form/detail line cards (parity desktop Form Line Cell Fill) */
.mobile-detail-lines {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.35rem 0 0.75rem;
}

.mobile-line-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius);
}

.mobile-line-card-main {
    min-width: 0;
    flex: 1;
}

.mobile-line-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
}

.mobile-line-card-meta {
    margin-top: 0.2rem;
    font-size: var(--ms-text-meta);
    color: #64748b;
    line-height: 1.4;
}

.mobile-line-card-money {
    flex-shrink: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    text-align: right;
    white-space: nowrap;
}

.mobile-line-card-money.is-out {
    color: #b91c1c;
}

.mobile-line-card-money.is-in {
    color: #15803d;
}

.mobile-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.mobile-kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--ms-radius);
    padding: 0.75rem;
}

.mobile-kpi-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.mobile-kpi-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

/* VietQR panel — form phiếu thu mobile */
.mobile-vietqr-panel {
    margin: 0.75rem 0 0;
    padding: 0.875rem;
    border: 1.5px solid #a7f3d0;
    border-radius: 0.75rem;
    background: #ecfdf5;
}

.mobile-vietqr-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #065f46;
    margin-bottom: 0.25rem;
}

.mobile-vietqr-hint {
    font-size: 0.75rem;
    color: #047857;
    margin: 0 0 0.75rem;
    line-height: 1.35;
}

.mobile-vietqr-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
    align-items: flex-start;
}

.mobile-vietqr-img {
    width: 168px;
    height: 168px;
    background: #fff;
    border: 1px solid #a7f3d0;
    border-radius: 0.5rem;
    padding: 0.35rem;
    object-fit: contain;
}

.mobile-vietqr-meta {
    flex: 1 1 10rem;
    font-size: 0.8125rem;
    color: #064e3b;
    line-height: 1.55;
}

.mobile-vietqr-meta b {
    font-weight: 700;
    color: #022c22;
}

.mobile-form-debt-lines {
    margin-bottom: 0.75rem;
}
