/* Home Expenses — layout + theme + mobile enhancements */

:root,
[data-bs-theme="light"] {
    --app-font-sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --app-font-mono: "JetBrains Mono", "Noto Sans Mono CJK SC", ui-monospace, monospace;
    --app-font-size: 0.9375rem;
    --app-font-size-sm: 0.875rem;
    --app-font-size-xs: 0.8125rem;
    --app-font-size-lg: 1.0625rem;
    --app-font-size-xl: 1.25rem;
    --app-font-size-2xl: 1.5rem;
    --app-font-size-3xl: 1.75rem;
    --app-line-height: 1.55;
    --app-line-height-tight: 1.35;
    --app-sidebar-w: 265px;
    --app-bottom-nav-h: 62px;
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-vh: 1vh;
    --app-touch-min: 44px;
    /* iPhone 12–17 竖屏基准：390（12/13/14）～ 440（15–17 Pro Max） */
    --app-iphone-width-min: 390px;
    --app-iphone-pro-max-min: 428px;
    --app-header-h: 56px;
    --app-bg: #f4f7fc;
    --app-surface: #ffffff;
    --app-border: #e2e8f0;
    --app-text: #0f172a;
    --app-text-muted: #64748b;
    --app-nav-hover-bg: rgba(0, 180, 255, 0.08);
    --app-nav-active-bg: rgba(0, 180, 255, 0.12);
    --app-primary: #0099ee;
    --app-accent: #7c3aed;
    --app-glow: rgba(0, 153, 238, 0.22);
    --app-shadow: rgba(15, 23, 42, 0.08);
}

[data-bs-theme="dark"] {
    --app-bg: #050810;
    --app-surface: #0f1628;
    --app-border: rgba(0, 200, 255, 0.12);
    --app-text: #e8f4ff;
    --app-text-muted: #b4c5de;
    --app-nav-hover-bg: rgba(0, 200, 255, 0.1);
    --app-nav-active-bg: rgba(0, 200, 255, 0.16);
    --app-primary: #00c8ff;
    --app-accent: #a78bfa;
    --app-glow: rgba(0, 200, 255, 0.28);
    --app-shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

html, body,
.app-home-sidebar,
.app-home-main,
.modal,
.dropdown-menu,
.table,
.card,
.manual-content,
.manual-toc {
    font-family: var(--app-font-sans);
}

html, body {
    font-size: var(--app-font-size);
    line-height: var(--app-line-height);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    -webkit-text-size-adjust: 100%;
}

body.app-home-body,
body.app-login-body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
}

body.app-login-body .login-mobile-wrap {
    background: var(--app-bg);
}

[data-bs-theme="dark"] body.app-login-body .login-auth-bg {
    opacity: 0.72;
}

/* Metronic 全屏 loading 强制隐藏 */
body.page-loading,
body[data-kt-app-page-loading="on"] {
    overflow: auto !important;
}

.page-loading,
.app-page-loader,
#kt_app_page_loading,
.page-loader,
[data-kt-app-page-loading="on"]::before {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ===== 主布局：侧栏左上角全高 ===== */
.app-home-shell {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: calc(var(--app-vh, 1vh) * 100);
}

.app-home-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--app-sidebar-w);
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
    z-index: 110;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.app-home-sidebar-brand {
    border-bottom: 1px solid var(--app-border);
    min-height: var(--app-header-h);
    display: flex;
    align-items: center;
}

.app-home-sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.65rem 1rem;
}

.app-home-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    margin-bottom: 2px;
    border-radius: 0.5rem;
    border: none;
    color: var(--app-text-muted);
    text-decoration: none;
    font-size: var(--app-font-size-sm);
    font-weight: 500;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.app-home-header h1 {
    font-size: var(--app-font-size-lg);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.app-home-nav-link:hover {
    background: var(--app-nav-hover-bg);
    color: var(--app-primary);
}

.app-home-nav-link.active {
    background: var(--app-nav-active-bg);
    color: var(--app-primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--app-primary);
}

.app-home-nav-link i {
    flex-shrink: 0;
}

.app-home-nav-section {
    margin-top: 0.35rem;
}

.app-home-nav-section:first-child {
    margin-top: 0;
}

.app-home-nav-section + .app-home-nav-section {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--app-border);
}

.app-home-nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    margin: 0 0 0.2rem;
    padding: 0.35rem 0.5rem;
    border: none !important;
    border-radius: 0.375rem;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--app-text-muted);
    cursor: pointer;
    text-align: left;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: color 0.15s, background 0.15s;
}

.app-home-nav-section-toggle:hover {
    background: var(--app-nav-hover-bg) !important;
    color: var(--app-text);
}

.app-home-nav-section-toggle:focus {
    outline: none;
}

.app-home-nav-section-toggle:focus-visible {
    outline: 2px solid rgba(0, 153, 238, 0.35);
    outline-offset: 2px;
}

.app-home-nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.72;
}

.app-home-nav-section-chevron {
    font-size: 0.75rem;
    line-height: 1;
    transition: transform 0.2s ease, opacity 0.15s;
    flex-shrink: 0;
    opacity: 0.45;
}

.app-home-nav-section--collapsible.is-open .app-home-nav-section-chevron {
    transform: rotate(180deg);
    opacity: 0.7;
}

.app-home-nav-section-body {
    display: none;
    padding: 0 0 0.25rem 0.15rem;
}

.app-home-nav-section--collapsible.is-open .app-home-nav-section-body {
    display: block;
}

.app-home-nav-section--collapsible.is-open .app-home-nav-section-label {
    color: var(--app-primary);
    opacity: 1;
}

.app-home-nav-section--collapsible.is-open .app-home-nav-section-toggle {
    color: var(--app-text);
}

.app-home-nav-footer-sep {
    margin-top: 0.75rem;
}

.app-home-main {
    margin-left: var(--app-sidebar-w);
    min-width: 0;
}

.app-home-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    min-height: var(--app-header-h);
    display: flex;
    align-items: center;
}

.app-home-content {
    background: var(--app-bg);
}

.app-theme-switch .btn {
    min-width: 38px;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}

.app-header-toolbar--inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.app-header-toolbar--inline .app-header-toolbar__label {
    display: none;
}

.app-header-toolbar--inline .app-header-toolbar__user {
    font-size: var(--app-font-size-sm);
    color: var(--app-text-muted);
}

.app-header-toolbar--inline .app-header-toolbar__group,
.app-header-toolbar--inline .app-header-toolbar__row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.app-header-toolbar--inline .app-header-toolbar__prefs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.app-home-header .app-header-desktop-tools {
    max-width: min(72vw, 960px);
    justify-content: flex-end;
}

.app-mobile-settings-offcanvas:not(.show) {
    pointer-events: none !important;
}

.offcanvas-backdrop:not(.show) {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

@media (min-width: 992px) {
    .app-mobile-settings-offcanvas,
    .offcanvas-backdrop {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    .app-header-row {
        flex-wrap: nowrap;
    }

    .app-header-desktop-tools {
        overflow-x: auto;
        flex-wrap: nowrap;
        flex-shrink: 1;
        max-width: min(68vw, 920px);
        -webkit-overflow-scrolling: touch;
    }

    .app-header-toolbar--inline {
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .app-header-toolbar--inline .app-table-density-switch {
        display: none;
    }
}

.app-theme-switch .btn i {
    line-height: 1;
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content {
    background-color: var(--app-surface);
    border-color: var(--app-border);
}

[data-bs-theme="dark"] .table-row-dashed tbody tr {
    border-bottom-color: var(--app-border);
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .dataTables_wrapper .form-select,
[data-bs-theme="dark"] .dataTables_wrapper .form-control {
    background-color: #1b1d24;
    border-color: var(--app-border);
    color: var(--app-text);
}

[data-bs-theme="dark"] .page-link {
    background-color: #1b1d24;
    border-color: var(--app-border);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .separator {
    border-bottom-color: var(--app-border);
}

/* ===== 移动端 ===== */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 109;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.app-sidebar-backdrop.show {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

body.app-sidebar-open {
    overflow: hidden;
}

@media (max-width: 991.98px) {
    body.app-home-body {
        padding-bottom: calc(var(--app-bottom-nav-h) + var(--app-safe-bottom));
    }

    .app-home-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px var(--app-shadow);
        z-index: 111;
        padding-top: var(--app-safe-top);
        padding-left: var(--app-safe-left);
        padding-bottom: var(--app-safe-bottom);
    }

    .app-home-sidebar.show {
        transform: translateX(0);
    }

    .app-home-main {
        margin-left: 0;
        min-width: 0;
        width: 100%;
        overflow-x: clip;
    }

    .app-home-header {
        padding-left: max(0.75rem, var(--app-safe-left));
        padding-right: max(0.75rem, var(--app-safe-right));
        padding-top: max(0.5rem, var(--app-safe-top));
        min-height: auto;
    }

    .app-header-row {
        width: 100%;
        min-height: var(--app-touch-min);
    }

    .app-header-settings-btn {
        min-width: var(--app-touch-min);
        min-height: var(--app-touch-min);
    }

    .app-mobile-settings-offcanvas {
        --bs-offcanvas-height: min(78vh, 520px);
        border-top-left-radius: 1rem;
        border-top-right-radius: 1rem;
        z-index: 120;
    }

    .app-mobile-settings-offcanvas .offcanvas-body {
        padding-bottom: calc(1rem + var(--app-safe-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-header-toolbar--stacked {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .app-header-toolbar--stacked .app-header-toolbar__group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .app-header-toolbar--stacked .app-header-toolbar__row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .app-header-toolbar--stacked .app-header-toolbar__label {
        font-size: var(--app-font-size-xs);
        font-weight: 600;
        color: var(--app-text-muted);
        flex-shrink: 0;
    }

    .app-header-toolbar--stacked .app-header-toolbar__user {
        font-size: var(--app-font-size-sm);
        font-weight: 600;
        padding: 0.35rem 0;
    }

    .app-header-toolbar--stacked .app-display-prefs {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .app-header-toolbar--stacked .app-font-family-select {
        width: 100%;
        min-height: var(--app-touch-min);
    }

    .app-header-toolbar--stacked .app-font-scale-switch,
    .app-header-toolbar--stacked .app-table-density-switch {
        display: flex;
        width: 100%;
    }

    .app-header-toolbar--stacked .app-font-scale-switch .btn,
    .app-header-toolbar--stacked .app-table-density-switch .btn {
        flex: 1 1 0;
        min-height: var(--app-touch-min);
    }

    .app-header-toolbar--stacked .app-theme-switch {
        margin-left: auto;
    }

    .app-home-sidebar.show {
        z-index: 125;
    }

    .app-sidebar-backdrop.show {
        z-index: 124;
    }

    .app-page-dashboard .app-home-header h1 {
        display: none;
    }

    .app-home-content {
        padding-left: max(0.75rem, var(--app-safe-left));
        padding-right: max(0.75rem, var(--app-safe-right));
        padding-bottom: calc(1rem + var(--app-bottom-nav-h) + var(--app-safe-bottom));
        /* Do not set overflow-x here — page modals live inside main and need viewport-fixed positioning */
        -webkit-overflow-scrolling: touch;
        scroll-padding-bottom: calc(var(--app-bottom-nav-h) + var(--app-safe-bottom) + 1rem);
    }

    .app-mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 112;
        height: calc(var(--app-bottom-nav-h) + var(--app-safe-bottom));
        padding-bottom: var(--app-safe-bottom);
        background: var(--app-surface);
        border-top: 1px solid var(--app-border);
        box-shadow: 0 -4px 20px var(--app-shadow);
    }

    .app-mobile-bottom-nav a,
    .app-mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border: 0;
        background: transparent;
        color: var(--app-text-muted);
        font-size: var(--app-font-size-xs);
        font-weight: 600;
        text-decoration: none;
        min-height: var(--app-touch-min);
        padding: 6px 4px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .app-mobile-bottom-nav span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        line-height: 1.2;
    }

    .app-mobile-bottom-nav a.active,
    .app-mobile-bottom-nav button.active {
        color: var(--app-primary);
    }

    .app-mobile-bottom-nav i {
        font-size: 1.35rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch !important;
    }

    .card-header .card-toolbar {
        width: 100%;
    }

    .card-header .card-toolbar .btn,
    .card-header .card-toolbar .form-select {
        min-height: 40px;
    }

    .card-body .table-responsive:not(.matrix-sheet-wrap):not(.pm-matrix-sheet-wrap) {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
        padding-left: 2rem !important;
    }

    table.dataTable > tbody > tr.child ul.dtr-details {
        width: 100%;
    }

    table.dataTable > tbody > tr.child span.dtr-title {
        min-width: 38%;
        font-weight: 600;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-fullscreen-sm-down {
        min-height: calc(100% - 1rem);
    }

    .fs-2hx {
        font-size: calc(1.45rem + 0.9vw) !important;
    }

    .dashboard-filter-bar {
        width: 100%;
    }

    .dashboard-filter-bar .form-select {
        width: auto;
        min-width: 72px;
        max-width: 96px;
    }

    .dashboard-filter-bar .form-select,
    .dashboard-filter-bar .btn {
        flex: 0 1 auto;
        min-width: 0;
    }

    .dashboard-filter-bar .btn {
        flex: 0 0 auto;
    }

    #dash_recent_table thead {
        display: none;
    }

    #dash_recent_table tbody tr {
        display: block;
        border-bottom: 1px dashed var(--app-border);
        padding: 0.75rem 0;
    }

    #dash_recent_table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: 0;
        padding: 0.25rem 0;
        text-align: right !important;
    }

    #dash_recent_table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--app-text-muted);
        text-align: left;
        margin-right: 1rem;
        flex-shrink: 0;
    }

    .alert {
        padding: 1rem !important;
    }

    .alert .fs-2hx,
    .alert i.fs-2hx {
        font-size: 1.5rem !important;
    }

    /* 仪表盘 */
    .dash-hero-card .d-flex.flex-wrap.align-items-center.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
    }

    .dash-filter-inline {
        width: 100%;
        display: grid;
        grid-template-columns: auto 1fr auto 1fr;
        gap: 0.5rem;
        align-items: center;
    }

    .dash-filter-inline .form-select {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .dash-filter-inline #btn_dash_refresh {
        grid-column: 1 / -1;
        width: 100%;
        min-height: var(--app-touch-min);
    }

    .dash-filter-inline .dash-filter-divider {
        display: none;
    }

    .dash-filter-inline .dash-member-input,
    .dash-filter-inline #dash_member_id {
        grid-column: 1 / -1;
        max-width: none;
        width: 100%;
    }

    .dash-filter-inline > span.text-muted {
        grid-column: 1 / -1;
    }

    .dash-quick-links {
        margin-top: 0.5rem;
    }

    .dash-quick-links a {
        flex: 1 1 auto;
        text-align: center;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .dash-kpi-card:hover {
        transform: none;
    }

    .dash-chart-card .card-title {
        font-size: 0.875rem;
        line-height: 1.35;
    }

    .dash-chart-body {
        min-height: 220px;
        padding: 0.25rem 0.5rem 0.75rem;
    }

    .dash-chart-body.dash-chart-sm {
        min-height: 200px;
    }

    /* 分摊表 */
    .matrix-scroll-hint {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
        font-size: var(--app-font-size-sm);
        color: var(--app-text-muted);
        background: var(--app-nav-hover-bg);
        border-radius: 0.5rem;
    }

    .matrix-sheet-wrap,
    .pm-matrix-sheet-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x pan-y;
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
        padding-bottom: 0.5rem;
    }

    .matrix-sheet-table {
        font-size: var(--app-font-size-xs);
    }

    .matrix-sticky-col,
    .personal-matrix-table .pm-sticky-col {
        position: static;
        left: auto;
        z-index: auto;
        min-width: 100px;
        box-shadow: none;
    }

    .matrix-th-expense {
        min-width: 88px;
    }

    .matrix-cell-editable,
    .matrix-th-editable {
        min-height: var(--app-touch-min);
    }

    .app-mobile-filter-bar,
    .pm-matrix-filters {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
    }

    .app-mobile-filter-bar > div,
    .pm-matrix-filters > div {
        width: 100%;
    }

    .app-mobile-filter-bar .d-flex.gap-2,
    .pm-matrix-filters .d-flex.gap-2 {
        flex-wrap: nowrap;
        width: 100%;
    }

    .app-mobile-filter-bar .d-flex.gap-2 .form-control,
    .pm-matrix-filters .d-flex.gap-2 .form-control {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .app-mobile-filter-bar .form-control,
    .app-mobile-filter-bar .btn,
    .app-mobile-filter-bar > a.btn,
    .pm-matrix-filters .form-control,
    .pm-matrix-filters .btn {
        min-height: var(--app-touch-min);
    }

    .app-mobile-filter-bar > button,
    .app-mobile-filter-bar > a.btn,
    .pm-matrix-filters #pm_reload,
    .pm-matrix-filters > a.btn {
        width: 100%;
    }

    .matrix-page-toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        gap: 0.5rem;
    }

    .matrix-page-toolbar > a,
    .matrix-page-toolbar > button {
        width: 100%;
        margin: 0 !important;
        min-height: var(--app-touch-min);
    }

    .matrix-page-toolbar form.d-flex {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .matrix-page-toolbar form .form-select {
        width: 100%;
        min-height: var(--app-touch-min);
    }

    .personal-matrix-table th,
    .personal-matrix-table td {
        min-height: var(--app-touch-min);
        padding: 0.5rem 0.65rem;
        vertical-align: middle;
    }

    .matrix-sheet-wrap .matrix-cell-editable,
    .matrix-sheet-wrap .matrix-th-editable,
    .personal-matrix-table td,
    .personal-matrix-table th {
        touch-action: manipulation;
    }

    .pm-matrix-sheet-wrap,
    .matrix-sheet-wrap {
        isolation: isolate;
    }

    .nav-tabs.nav-line-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        padding-bottom: 0.25rem;
    }

    .nav-tabs.nav-line-tabs .nav-link {
        white-space: nowrap;
        min-height: var(--app-touch-min);
        display: inline-flex;
        align-items: center;
    }

    .matrix-hub-tabs .nav-link {
        min-height: var(--app-touch-min);
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .app-header-desktop-tools .app-display-prefs .app-font-scale-switch .btn {
        min-height: 2rem;
    }

    body.modal-open .app-mobile-bottom-nav {
        z-index: 100;
    }

    .modal .modal-footer .btn {
        min-height: var(--app-touch-min);
        flex: 1 1 auto;
    }

    .modal .modal-footer {
        flex-wrap: wrap;
    }

    .matrix-summary-block {
        width: 100%;
        max-width: 100%;
    }

    .matrix-summary-table {
        width: 100%;
    }

    .card-header .card-toolbar form.d-flex {
        width: 100%;
    }

    .card-header .card-toolbar form.d-flex .form-select {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
    }

    /* 账单页 */
    .app-invoice-main {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: 1.5rem;
    }

    .app-invoice-toolbar .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* DataTables */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        width: 100%;
        text-align: left;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: none;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        margin-top: 0.75rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.35rem 0.65rem;
        min-width: 2.25rem;
    }

    /* 弹窗 */
    #matrix_col_splits .col-md-6,
    #matrix_col_splits .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #record_splits_editor .col-md-6,
    #template_splits_editor .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Toast — 保持右上角，仅缩窄宽度 */
    #toast-container.toast-top-right,
    #toast-container.toastr-top-right {
        top: max(0.75rem, var(--app-safe-top)) !important;
        right: max(0.75rem, var(--app-safe-right)) !important;
        left: auto !important;
        width: auto;
        max-width: calc(100vw - 1.5rem - var(--app-safe-left) - var(--app-safe-right));
    }

    #toast-container > div {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 575.98px) {
    .matrix-page-toolbar form.d-flex {
        grid-template-columns: 1fr;
    }

    .matrix-page-toolbar .btn {
        font-size: var(--app-font-size-sm);
    }

    .login-mobile-wrap {
        padding: 1.25rem !important;
    }

    .login-mobile-box {
        padding: 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .card-header .card-toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .card-header .card-toolbar .btn,
    .card-header .card-toolbar .form-select,
    .card-header .card-toolbar a.btn {
        width: 100%;
        margin: 0 !important;
    }

    .card-header .card-toolbar form,
    .card-header .card-toolbar #btn_records_filter,
    .card-header .card-toolbar #btn_generate_month {
        grid-column: 1 / -1;
    }

    .dash-filter-inline {
        grid-template-columns: 1fr 1fr;
    }

    .dash-filter-inline > span.text-muted {
        grid-column: 1 / -1;
    }

    .app-home-header .btn-group.app-theme-switch,
    .app-home-header a.btn-sm {
        min-width: 40px;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .dash-kpi-value {
        font-size: 1.45rem;
    }

    .invoice-sheet-inner {
        padding: 1rem;
    }

    .invoice-lines {
        font-size: 0.8rem;
    }

    .invoice-summary {
        max-width: none;
    }
}

@media (min-width: 992px) {
    .app-mobile-bottom-nav {
        display: none !important;
    }
}

/* Password visibility toggle */
.app-password-wrap {
    position: relative;
}

.app-password-wrap .app-password-input,
.app-password-wrap input[type="password"],
.app-password-wrap input[type="text"].app-password-input {
    padding-right: 2.75rem;
}

.app-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--app-text-muted);
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.app-password-toggle:hover {
    color: var(--app-primary);
    background: var(--app-nav-hover-bg);
}

/* Toastr — 右上角固定，高于侧栏/顶栏 */
#toast-container {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
}

#toast-container.toast-top-right,
#toast-container.toastr-top-right {
    top: calc(var(--app-header-h) + 0.75rem) !important;
    right: 1rem !important;
    left: auto !important;
    bottom: auto !important;
}

#toast-container.toast-top-left {
    top: calc(var(--app-header-h) + 0.75rem) !important;
    right: 1rem !important;
    left: auto !important;
    bottom: auto !important;
}

body.app-login-body #toast-container.toast-top-right,
body.app-login-body #toast-container.toastr-top-right {
    top: 1rem !important;
    right: 1rem !important;
    left: auto !important;
}

#toast-container > div {
    opacity: 1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    border-radius: 0.625rem;
    padding: 0.85rem 1rem 0.85rem 3rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
    color: #fff;
    font-size: 0.925rem;
    line-height: 1.45;
}

#toast-container > div:hover {
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
}

[data-bs-theme="dark"] #toast-container > div {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#toast-container > .toast-success,
#toast-container > div.toastr-success {
    background-color: #50cd89;
}

#toast-container > .toast-error,
#toast-container > div.toastr-error {
    background-color: #f1416c;
}

#toast-container > .toast-info,
#toast-container > div.toastr-info {
    background-color: var(--app-primary);
}

#toast-container > .toast-warning,
#toast-container > div.toastr-warning {
    background-color: #ffc700;
    color: #3f2f00;
}

#toast-container .toastr-close-button {
    color: inherit;
    opacity: 0.75;
    text-shadow: none;
}

#toast-container .toastr-progress {
    background: rgba(255, 255, 255, 0.35);
    opacity: 1;
}

/* 确认对话框 */
#app_confirm_modal .modal-content {
    border-radius: 0.75rem;
}

#app_confirm_modal .modal-body {
    color: var(--app-text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.app-btn-loading {
    pointer-events: none;
}

/* 页面辅助说明 */
.app-page-hint {
    color: var(--app-text-muted);
    font-size: 0.875rem;
    margin-bottom: 0;
}

.app-empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
}

.app-empty-state i {
    font-size: 2.5rem;
    color: var(--app-text-muted);
    opacity: 0.65;
    margin-bottom: 0.75rem;
}

.app-empty-state .app-empty-title {
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 0.35rem;
}

.app-empty-state .app-empty-desc {
    color: var(--app-text-muted);
    font-size: 0.875rem;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

/* ===== Dashboard ===== */
.dash-hero-card {
    background: linear-gradient(135deg, rgba(0, 153, 238, 0.1) 0%, rgba(124, 58, 237, 0.06) 50%, rgba(80, 205, 137, 0.06) 100%);
    border: 1px solid var(--app-border);
    border-radius: 0.85rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

[data-bs-theme="dark"] .dash-hero-card {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.14) 0%, rgba(124, 58, 237, 0.1) 45%, rgba(8, 14, 28, 0.95) 100%);
}

.dash-hero-card .dash-period-label {
    font-size: var(--app-font-size-sm);
    color: var(--app-text-muted);
}

.dash-hero-card .fw-bold.fs-4 {
    font-size: var(--app-font-size-2xl) !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}

.dash-filter-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.dash-filter-inline .form-select {
    width: auto;
    min-width: 76px;
    max-width: 96px;
}

.dash-filter-inline .dash-member-input {
    min-width: 120px;
    max-width: 180px;
}

.dash-filter-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--app-border);
    margin: 0 0.25rem;
}

.dash-section-label {
    font-size: var(--app-font-size-lg);
    font-weight: 600;
    color: var(--app-text);
    display: flex;
    align-items: center;
}

.dash-kpi-card {
    border: 1px solid var(--app-border);
    border-radius: 0.85rem;
    overflow: hidden;
    height: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--app-shadow);
}

.dash-kpi-card .card-body {
    padding: 1.25rem 1.35rem;
}

.dash-kpi-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.dash-kpi-total .dash-kpi-icon { background: rgba(0, 153, 238, 0.14); color: var(--app-primary); }
.dash-kpi-fixed .dash-kpi-icon { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.dash-kpi-variable .dash-kpi-icon { background: rgba(124, 58, 237, 0.14); color: var(--app-accent, #7c3aed); }
.dash-kpi-budget .dash-kpi-icon { background: rgba(245, 158, 11, 0.16); color: #d97706; }

.dash-kpi-value {
    font-family: var(--app-font-mono);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: var(--app-line-height-tight);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.dash-kpi-variable .dash-kpi-value {
    color: var(--app-accent, #7c3aed);
}

.dash-kpi-variable .dash-kpi-progress > span {
    background: linear-gradient(90deg, var(--app-accent, #7c3aed), var(--app-primary));
}

.dash-kpi-card .text-muted.fs-7 {
    font-size: var(--app-font-size-sm) !important;
}

.dash-kpi-meta {
    font-size: var(--app-font-size-sm);
    color: var(--app-text-muted);
    margin-top: 0.35rem;
}

.dash-kpi-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--app-border);
    margin-top: 0.65rem;
    overflow: hidden;
}

.dash-kpi-progress > span {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--app-primary), #10b981, var(--app-accent, #7c3aed));
}

.dash-chart-card {
    border: 1px solid var(--app-border);
    border-radius: 0.85rem;
    height: 100%;
}

.dash-chart-card .card-header {
    border-bottom: 1px solid var(--app-border);
    min-height: 3.25rem;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.dash-chart-card .card-title {
    font-size: var(--app-font-size-lg);
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.01em;
}

.dash-chart-body {
    min-height: 300px;
    padding: 0.5rem 0.75rem 1rem;
    position: relative;
}

html.app-ui-tech .dash-chart-body {
    background:
        radial-gradient(ellipse 90% 70% at 50% 100%, rgba(0, 200, 255, 0.07) 0%, transparent 72%);
}

html.app-ui-tech[data-bs-theme="dark"] .dash-chart-body {
    background:
        radial-gradient(ellipse 85% 65% at 50% 100%, rgba(0, 200, 255, 0.1) 0%, transparent 70%);
}

html.app-ui-tech .dash-chart-body .apexcharts-canvas {
    margin: 0 auto;
}

html.app-ui-tech .apexcharts-tooltip {
    border: 1px solid rgba(0, 200, 255, 0.2) !important;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25), 0 0 20px rgba(0, 200, 255, 0.12) !important;
}

html.app-ui-tech .apexcharts-legend-text {
    font-weight: 500 !important;
    color: var(--app-text-muted) !important;
}

html.app-ui-tech .apexcharts-xaxis-label,
html.app-ui-tech .apexcharts-yaxis-label {
    fill: var(--app-text-muted) !important;
}

html.app-ui-tech .apexcharts-gridline {
    stroke: var(--app-border) !important;
}

html.app-ui-tech .apexcharts-datalabel,
html.app-ui-tech .apexcharts-datalabel-label,
html.app-ui-tech .apexcharts-datalabel-value {
    font-family: var(--app-font-mono), var(--app-font-sans) !important;
}

.dash-chart-body.dash-chart-sm {
    min-height: 260px;
}

.dash-chart-empty {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--app-text-muted);
    font-size: 0.9rem;
}

.dash-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.dash-filter-inline .text-muted,
.dash-filter-inline .form-select {
    font-size: var(--app-font-size-sm);
}

.dash-quick-links a {
    font-size: var(--app-font-size-sm);
    padding: 0.35rem 0.75rem;
    border-radius: 0.45rem;
    text-decoration: none;
    background: var(--app-nav-hover-bg);
    color: var(--app-primary);
    font-weight: 600;
}

.dash-quick-links a:hover {
    background: var(--app-nav-active-bg);
}

/* ===== Personal matrix (period view) ===== */
.personal-matrix-table .pm-sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 120px;
    background: var(--bs-body-bg, #fff);
}

.personal-matrix-table .pm-meta-col {
    min-width: 72px;
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.personal-matrix-table .pm-sticky-col.pm-meta-col {
    min-width: 120px;
    max-width: 160px;
}

.personal-matrix-table .pm-summary-row td {
    border-top: 1px dashed var(--bs-border-color, #e4e6ef);
    font-size: 0.75rem;
}

.personal-matrix-table .pm-summary-projected td {
    color: var(--bs-primary, #0099ee);
}

.personal-matrix-table .pm-summary-total td {
    border-top-width: 2px;
    border-top-style: solid;
}

.personal-matrix-table td.pm-cell-amount {
    cursor: pointer;
}

.personal-matrix-table td.pm-cell-amount:hover {
    background: rgba(0, 153, 238, 0.06);
}

.pm-cell-detail-dl dt {
    font-weight: 500;
}

.matrix-th-split-warn {
    box-shadow: inset 0 -3px 0 #ffc700;
}

.matrix-badge-split-warn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    margin-left: 0.2rem;
    border-radius: 50%;
    background: #fff8dd;
    color: #b78103;
    font-size: 0.65rem;
    font-weight: 700;
    vertical-align: middle;
}

[data-bs-theme="dark"] .personal-matrix-table .pm-sticky-col {
    background: var(--app-surface, #0f1628);
}

/* ===== Member matrix sheet (Excel style) ===== */
.matrix-scroll-hint {
    display: none;
}
.matrix-sheet-wrap,
.pm-matrix-sheet-wrap {
    overflow: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid #d9ead3;
    border-radius: 0.5rem;
    background: #fff;
}

[data-bs-theme="dark"] .matrix-sheet-wrap,
[data-bs-theme="dark"] .pm-matrix-sheet-wrap {
    border-color: var(--app-border);
    background: var(--app-surface);
}

.matrix-sheet-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.matrix-sheet-table th,
.matrix-sheet-table td {
    border: 1px solid #b6d7a8;
    padding: 0.45rem 0.65rem;
    white-space: nowrap;
    vertical-align: middle;
}

[data-bs-theme="dark"] .matrix-sheet-table th,
[data-bs-theme="dark"] .matrix-sheet-table td {
    border-color: var(--app-border);
}

.matrix-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    min-width: 140px;
    text-align: left;
    font-weight: 600;
}

[data-bs-theme="dark"] .matrix-sticky-col {
    background: var(--app-surface);
}

.matrix-th-name,
.matrix-row-name {
    background: #f3f3f3;
}

[data-bs-theme="dark"] .matrix-th-name,
[data-bs-theme="dark"] .matrix-row-name {
    background: #1e2028;
}

.matrix-th-expense {
    background: #d9ead3;
    color: #274e13;
    font-weight: 600;
    text-align: center;
    min-width: 110px;
}

.matrix-th-editable {
    cursor: pointer;
}

.matrix-th-editable:hover,
.matrix-th-editable:focus {
    outline: 2px solid var(--app-primary);
    outline-offset: -2px;
}

[data-bs-theme="dark"] .matrix-th-editable:hover,
[data-bs-theme="dark"] .matrix-th-editable:focus {
    outline-color: var(--app-accent, #a78bfa);
}

.matrix-split-row.matrix-split-focus {
    border-color: var(--app-primary) !important;
    box-shadow: 0 0 0 2px var(--app-glow, rgba(0, 200, 255, 0.2));
}

[data-bs-theme="dark"] .matrix-th-expense {
    background: #152a1f;
    color: #c8f0d8;
}

[data-bs-theme="dark"] .matrix-th-name,
[data-bs-theme="dark"] .matrix-row-name {
    background: #141a24;
    color: var(--app-text);
}

.matrix-th-total,
.matrix-cell-total {
    background: #93c47d;
    color: #fff;
    font-weight: 700;
    text-align: right;
}

.matrix-th-deduction,
.matrix-cell-deduction {
    background: #cfe2f3;
    font-weight: 600;
    text-align: right;
    min-width: 7.5rem;
    max-width: 11rem;
    vertical-align: top;
}

.matrix-ded-cell-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    line-height: 1.25;
}

.matrix-ded-amount {
    font-weight: 700;
    white-space: nowrap;
}

.matrix-ded-remarks {
    font-size: 0.68rem;
    font-weight: 500;
    color: #5b6b7a;
    text-align: right;
    max-width: 100%;
}

.matrix-ded-remarks li {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9.5rem;
}

.matrix-ded-count-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    background: rgba(28, 69, 135, 0.12);
    color: #1c4587;
}

.matrix-subtotal-deduction {
    font-weight: 700;
}

.matrix-deduction-summary .matrix-deduction-detail-table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--app-text-muted, #6b7280);
    border-bottom: 1px solid var(--app-border, #e5e7eb);
    padding-bottom: 0.35rem;
}

.matrix-deduction-detail-table td,
.matrix-deduction-detail-table th {
    padding: 0.35rem 0.5rem;
    vertical-align: top;
}

[data-bs-theme="dark"] .matrix-ded-remarks {
    color: #9ca3af;
}

[data-bs-theme="dark"] .matrix-ded-count-badge {
    background: rgba(158, 197, 254, 0.15);
    color: #9ec5fe;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-dialog {
    max-width: 28rem;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-modal {
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(var(--bs-primary-rgb), 0.15);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-header {
    background: linear-gradient(
        135deg,
        rgba(var(--bs-primary-rgb), 0.08) 0%,
        rgba(var(--bs-danger-rgb), 0.06) 100%
    );
    padding-top: 1.25rem;
    padding-bottom: 1rem;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-head-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    background: rgba(var(--bs-danger-rgb), 0.12);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-card {
    border-radius: 0.75rem;
    overflow: hidden;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-list {
    width: 100%;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-item {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
    background: transparent;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-item:hover,
#kt_modal_matrix_deduction_pick .matrix-ded-pick-item:focus {
    outline: none;
    background: rgba(var(--bs-primary-rgb), 0.06);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-item:active {
    background: rgba(var(--bs-primary-rgb), 0.1);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-item .symbol-label {
    border: 1px solid rgba(var(--bs-danger-rgb), 0.2);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-chevron {
    opacity: 0.45;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-item:hover .matrix-ded-pick-chevron,
#kt_modal_matrix_deduction_pick .matrix-ded-pick-item:focus .matrix-ded-pick-chevron {
    opacity: 1;
    transform: translateX(3px);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-total-bar {
    background: linear-gradient(
        90deg,
        rgba(var(--bs-danger-rgb), 0.08),
        rgba(var(--bs-danger-rgb), 0.14)
    );
    border-top: 1px solid rgba(var(--bs-danger-rgb), 0.2);
}

#kt_modal_matrix_deduction_pick .matrix-ded-pick-footer .btn-primary {
    box-shadow: 0 4px 14px rgba(var(--bs-primary-rgb), 0.35);
}

[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-modal {
    border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-header {
    background: linear-gradient(
        135deg,
        rgba(var(--bs-primary-rgb), 0.14) 0%,
        rgba(15, 23, 42, 0.5) 100%
    );
}

[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-item .fw-bold.text-gray-800 {
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-item:hover,
[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-item:focus {
    background: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] #kt_modal_matrix_deduction_pick .matrix-ded-pick-total-bar {
    background: linear-gradient(
        90deg,
        rgba(var(--bs-danger-rgb), 0.12),
        rgba(var(--bs-danger-rgb), 0.2)
    );
    border-top-color: rgba(var(--bs-danger-rgb), 0.25);
}

.matrix-th-deduction {
    color: #1c4587;
}

.matrix-cell-deduction {
    color: #c0392b;
}

[data-bs-theme="dark"] .matrix-th-deduction,
[data-bs-theme="dark"] .matrix-cell-deduction {
    background: #1a2a3d;
}

[data-bs-theme="dark"] .matrix-th-deduction {
    color: #9ec5fe;
}

[data-bs-theme="dark"] .matrix-cell-deduction {
    color: #f87171;
}

.matrix-th-net,
.matrix-cell-net {
    background: #ea9999;
    color: #7f0000;
    font-weight: 700;
    text-align: right;
}

[data-bs-theme="dark"] .matrix-th-net,
[data-bs-theme="dark"] .matrix-cell-net {
    background: #3d2020;
    color: #ffb4b4;
}

.matrix-cell-amount {
    text-align: right;
    color: #111;
}

.matrix-cell-editable {
    cursor: pointer;
}

.matrix-cell-editable:hover,
.matrix-cell-editable:focus {
    outline: 2px solid var(--app-primary);
    outline-offset: -2px;
    background: rgba(0, 153, 238, 0.08);
}

[data-bs-theme="dark"] .matrix-cell-editable:hover,
[data-bs-theme="dark"] .matrix-cell-editable:focus {
    background: rgba(0, 200, 255, 0.14);
    outline-color: var(--app-primary);
}

.matrix-th-fixed {
    background: #cfe8ff;
    color: #0d4a78;
    border-bottom: 2px solid var(--app-primary);
}

.matrix-cell-fixed {
    background: rgba(0, 153, 238, 0.14);
    font-weight: 600;
}

.matrix-th-projected {
    background: #e8f4fc;
    color: #1b567f;
}

.matrix-badge-projected {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    background: rgba(0, 153, 238, 0.12);
    color: var(--app-primary);
    font-size: 0.65rem;
    font-weight: 600;
}

.matrix-badge-installment {
    display: inline-block;
    margin-left: 0.2rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    background: rgba(124, 58, 237, 0.12);
    color: var(--app-accent);
    font-size: 0.65rem;
    font-weight: 600;
    vertical-align: middle;
}

.matrix-cell-projected {
    background: rgba(0, 153, 238, 0.06);
    font-style: italic;
}

[data-bs-theme="dark"] .matrix-th-fixed {
    background: #123a5c;
    color: #e8f4ff;
    border-bottom-color: var(--app-primary);
}

[data-bs-theme="dark"] .matrix-cell-fixed {
    background: rgba(0, 200, 255, 0.18);
}

[data-bs-theme="dark"] .matrix-th-projected {
    background: #152238;
    color: #b8dcff;
}

[data-bs-theme="dark"] .matrix-cell-projected {
    background: rgba(0, 200, 255, 0.1);
}

[data-bs-theme="dark"] .matrix-badge-projected {
    background: rgba(0, 200, 255, 0.2);
    color: #b8dcff;
}

[data-bs-theme="dark"] .matrix-cell-amount {
    color: var(--app-text);
}

.matrix-subtotal-row th,
.matrix-subtotal-row td {
    background: #fff2cc;
    font-weight: 600;
    text-align: right;
}

[data-bs-theme="dark"] .matrix-subtotal-row th,
[data-bs-theme="dark"] .matrix-subtotal-row td {
    background: #2a2618;
    color: #f5e6b8;
}

[data-bs-theme="dark"] .matrix-th-total,
[data-bs-theme="dark"] .matrix-cell-total {
    background: #1e4a28;
    color: #d4f5dc;
}

[data-bs-theme="dark"] .matrix-sheet-table {
    color: var(--app-text);
}

[data-bs-theme="dark"] .matrix-sheet-table th,
[data-bs-theme="dark"] .matrix-sheet-table td {
    border-color: rgba(0, 200, 255, 0.1);
}

.matrix-summary-block {
    display: inline-block;
    min-width: 280px;
}

.matrix-summary-table {
    border-collapse: collapse;
    font-size: 0.875rem;
}

.matrix-summary-table th,
.matrix-summary-table td {
    border: 1px solid #ccc;
    padding: 0.4rem 0.75rem;
}

.matrix-summary-table td {
    text-align: right;
    font-weight: 600;
    min-width: 120px;
}

.matrix-util-water { background: #6fa8dc; color: #fff; }
.matrix-util-electric { background: #93c47d; color: #fff; }
.matrix-util-internet { background: #f6b26b; color: #fff; }
.matrix-util-dispenser { background: #ffd966; color: #7f6000; }
.matrix-util-other { background: #d9d9d9; color: #333; }

.matrix-summary-grand th,
.matrix-summary-grand td {
    background: #efefef;
    font-weight: 700;
}

[data-bs-theme="dark"] .matrix-summary-grand th,
[data-bs-theme="dark"] .matrix-summary-grand td {
    background: #252830;
}

/* ===== Member invoices (print) ===== */
.app-invoice-body {
    background: #eef0f4;
    color: #181c32;
}

.app-invoice-toolbar {
    background: #fff;
    border-bottom: 1px solid #e4e6ef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-invoice-main {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 0.5rem 2rem;
}

/* 成员账单：屏幕上一排横排 */
.invoice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    align-items: stretch;
}

@media (min-width: 992px) {
    .invoice-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.invoice-grid-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.invoice-sheet {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.invoice-sheet-inner {
    background: #fff;
    border: 1px solid #e4e6ef;
    border-radius: 0.75rem;
    padding: 1.35rem 1.25rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    flex: 1;
}

.invoice-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--app-primary);
}

@media (min-width: 1200px) {
    .invoice-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
}

.invoice-meta.text-end {
    text-align: left !important;
}

@media (min-width: 1200px) {
    .invoice-meta.text-end {
        text-align: right !important;
    }
}

.invoice-sheet-inner {
    --invoice-accent: var(--app-primary);
}

.invoice-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--invoice-accent);
}

.invoice-header {
    border-bottom-color: var(--invoice-accent);
}

.invoice-summary-due strong {
    color: var(--invoice-accent);
}

.invoice-layout-modern {
    border-left: 5px solid var(--invoice-accent);
    border-radius: 0 0.75rem 0.75rem 0;
    padding-left: 1.25rem;
}

.invoice-layout-compact {
    font-size: 0.875rem;
}

.invoice-layout-compact .invoice-brand,
.invoice-layout-compact .invoice-member-name {
    font-size: 1.1rem;
}

.invoice-header-note {
    background: rgba(0, 153, 238, 0.06);
    border-left: 3px solid var(--invoice-accent);
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--bs-gray-700);
    border-radius: 0 0.35rem 0.35rem 0;
}

.invoice-installment-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--invoice-accent);
    background: rgba(0, 153, 238, 0.1);
    border-radius: 0.25rem;
}

.invoice-preview-wrap {
    overflow: auto;
    max-height: 720px;
}

.invoice-preview-sheet .invoice-sheet-inner {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.06);
}

.invoice-doc-type {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #78829d;
    margin-top: 0.25rem;
}

.invoice-no {
    font-size: 1.1rem;
    font-weight: 700;
}

.invoice-bill-to {
    margin-bottom: 1.5rem;
}

.invoice-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #78829d;
    margin-bottom: 0.35rem;
}

.invoice-member-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.invoice-lines {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.invoice-lines th,
.invoice-lines td {
    border-bottom: 1px solid #eff2f5;
    padding: 0.45rem 0.35rem;
}

.invoice-lines th {
    background: #f9f9f9;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #78829d;
}

.invoice-lines .col-no { width: 32px; text-align: center; }
.invoice-lines .col-desc { text-align: left; word-break: break-word; }
.invoice-lines .col-amt { width: 96px; min-width: 96px; max-width: 96px; text-align: right; white-space: nowrap; font-size: 0.8rem; }
.invoice-lines td.col-no { text-align: center; vertical-align: top; }
.invoice-lines td.col-desc { vertical-align: top; }
.invoice-lines td.col-amt { text-align: right; vertical-align: top; }
.invoice-line-deduct td { color: #f1416c; }

.invoice-installment-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--app-primary);
    background: var(--app-nav-hover-bg);
    border-radius: 0.35rem;
    vertical-align: middle;
    white-space: nowrap;
}

.invoice-summary {
    margin-left: auto;
    width: 100%;
    max-width: 280px;
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid #eff2f5;
}

.invoice-summary-row span:first-child {
    flex: 1;
    min-width: 0;
}

.invoice-summary-row strong {
    flex: 0 0 96px;
    text-align: right;
    white-space: nowrap;
}

.invoice-summary-due {
    border-bottom: none;
    border-top: 2px solid #181c32;
    margin-top: 0.35rem;
    padding-top: 0.75rem;
    font-size: 1.05rem;
}

.invoice-summary-due strong {
    color: var(--app-primary);
    font-size: 1.15rem;
}

.invoice-summary-deduct strong {
    color: #f1416c;
}

.invoice-line-deduct td:last-child {
    color: #f1416c;
    font-weight: 600;
}

.invoice-footer {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #78829d;
}

.invoice-print-actions {
    text-align: center;
    margin-top: 0.75rem;
}

@media (max-width: 991.98px) {
    .invoice-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    @page {
        margin: 10mm;
        size: landscape;
    }

    .no-print {
        display: none !important;
    }

    body.app-invoice-body {
        background: #fff;
    }

    .app-invoice-main {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .invoice-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8mm;
    }

    .invoice-grid-col {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .invoice-sheet {
        margin: 0;
        break-after: auto;
        page-break-after: auto;
    }

    .invoice-sheet-inner {
        border: 1px solid #ddd;
        box-shadow: none;
        border-radius: 0;
        padding: 6mm 5mm;
    }

    body.invoice-single-print .invoice-grid {
        grid-template-columns: 1fr;
    }

    body.invoice-single-print .invoice-grid-col {
        display: none;
    }

    body.invoice-single-print .invoice-grid-col.invoice-print-col-target {
        display: flex;
    }
}

/* ===== User manual ===== */
.manual-toc .nav-link {
    font-size: var(--app-font-size-sm);
    padding: 0.4rem 0.75rem;
    color: var(--app-text-muted);
    border-radius: 0.375rem;
    font-weight: 500;
}

.manual-toc .nav-link:hover {
    background: var(--app-nav-hover-bg);
    color: var(--app-primary);
}

.manual-toc .nav-link.active {
    background: var(--app-nav-active-bg);
    color: var(--app-primary);
    font-weight: 600;
}

.manual-content {
    font-size: var(--app-font-size);
    line-height: var(--app-line-height);
    color: var(--app-text);
}

.manual-content h2 {
    font-size: var(--app-font-size-2xl);
    font-weight: 700;
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--app-border);
    scroll-margin-top: 5rem;
    letter-spacing: -0.02em;
    color: var(--app-text);
}

.manual-content h2:first-child {
    margin-top: 0;
}

.manual-content h3 {
    font-size: var(--app-font-size-lg);
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--app-text);
}

.manual-content .manual-label {
    font-size: var(--app-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
    margin-top: 1rem;
    margin-bottom: 0.35rem;
}

.manual-content ol,
.manual-content ul {
    padding-left: 1.25rem;
}

.manual-content li {
    margin-bottom: 0.35rem;
    line-height: var(--app-line-height);
}

.manual-content .manual-tip {
    background: var(--app-nav-hover-bg);
    border-left: 3px solid var(--app-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    font-size: var(--app-font-size-sm);
    color: var(--app-text);
}

[data-bs-theme="dark"] .manual-content .manual-tip {
    background: rgba(0, 200, 255, 0.06);
}

.manual-updated-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.35rem;
    padding: 0.15rem 0.5rem;
    font-size: var(--app-font-size-xs);
    font-weight: 600;
    line-height: 1.3;
    color: #0d6e4f;
    background: rgba(25, 135, 84, 0.12);
    border: 1px solid rgba(25, 135, 84, 0.35);
    border-radius: 999px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.manual-section--updated {
    scroll-margin-top: 5rem;
}

.manual-update-legend {
    background: rgba(25, 135, 84, 0.06);
    border: 1px solid rgba(25, 135, 84, 0.25);
    border-radius: 0.5rem;
    padding: 1rem 1.15rem;
    margin: 1rem 0 1.25rem;
}

.manual-update-legend-title {
    font-weight: 700;
    font-size: var(--app-font-size-sm);
    color: #0d6e4f;
    margin-bottom: 0.35rem;
}

.manual-update-legend-intro {
    font-size: var(--app-font-size-sm);
    margin-bottom: 0.5rem;
    color: var(--app-text);
}

.manual-update-legend-list {
    margin: 0 0 0.5rem;
    padding-left: 1.25rem;
    font-size: var(--app-font-size-sm);
}

.manual-update-legend-list a {
    color: var(--app-primary);
    text-decoration: none;
}

.manual-update-legend-list a:hover {
    text-decoration: underline;
}

.manual-toc .manual-toc-updated {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.2;
    color: #0d6e4f;
    background: rgba(25, 135, 84, 0.12);
    border-radius: 0.25rem;
    vertical-align: middle;
}

.manual-toc .nav-link.manual-toc-link--updated {
    font-weight: 500;
}

.matrix-split-preview {
    min-height: 1.25rem;
}

.matrix-split-row.matrix-split-focus {
    border-color: var(--app-primary) !important;
    box-shadow: 0 0 0 1px rgba(var(--bs-primary-rgb), 0.25);
}

[data-bs-theme="dark"] .manual-updated-badge,
[data-bs-theme="dark"] .manual-update-legend-title,
[data-bs-theme="dark"] .manual-toc .manual-toc-updated {
    color: #5ee9b5;
}

[data-bs-theme="dark"] .manual-updated-badge {
    background: rgba(94, 233, 181, 0.12);
    border-color: rgba(94, 233, 181, 0.35);
}

[data-bs-theme="dark"] .manual-update-legend {
    background: rgba(94, 233, 181, 0.06);
    border-color: rgba(94, 233, 181, 0.2);
}

[data-bs-theme="dark"] .manual-toc .nav-link:hover {
    background: var(--app-nav-hover-bg);
}

/* ===== Tech UI (cyber / glass) ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Nunito:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&family=Noto+Serif+SC:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

html.app-ui-tech[data-bs-theme="light"] {
    --app-bg: #edf2fa;
    --app-surface: rgba(255, 255, 255, 0.88);
    --app-surface-solid: #ffffff;
    --app-border: rgba(0, 120, 200, 0.14);
    --app-text: #0c1222;
    --app-text-muted: #5a6d86;
    --app-nav-hover-bg: rgba(0, 180, 255, 0.08);
    --app-nav-active-bg: rgba(0, 180, 255, 0.14);
    --app-primary: #0099ee;
    --app-accent: #7c3aed;
    --app-glow: rgba(0, 153, 238, 0.26);
    --app-grid: rgba(0, 100, 180, 0.06);
    --app-shadow: rgba(8, 24, 48, 0.1);
}

html.app-ui-tech[data-bs-theme="dark"] {
    --app-bg: #050810;
    --app-surface: rgba(12, 20, 38, 0.82);
    --app-surface-solid: #0f1628;
    --app-border: rgba(0, 200, 255, 0.14);
    --app-text: #eef6ff;
    --app-text-muted: #b4c5de;
    --app-nav-hover-bg: rgba(0, 200, 255, 0.1);
    --app-nav-active-bg: rgba(0, 200, 255, 0.18);
    --app-primary: #00c8ff;
    --app-accent: #a78bfa;
    --app-glow: rgba(0, 200, 255, 0.35);
    --app-grid: rgba(0, 200, 255, 0.05);
    --app-shadow: rgba(0, 0, 0, 0.45);
}

/* Typography — readable CN/EN scale */
html.app-ui-tech {
    font-size: 16px;
}

html.app-ui-tech body {
    font-family: var(--app-font-sans);
    font-size: var(--app-font-size);
    line-height: var(--app-line-height);
    text-rendering: optimizeLegibility;
}

html.app-ui-tech .fs-8 { font-size: var(--app-font-size-xs) !important; line-height: 1.45 !important; }
html.app-ui-tech .fs-7 { font-size: var(--app-font-size-sm) !important; line-height: 1.5 !important; }
html.app-ui-tech .fs-6 { font-size: var(--app-font-size-lg) !important; }
html.app-ui-tech .fs-5 { font-size: var(--app-font-size-xl) !important; }
html.app-ui-tech .fs-4 { font-size: var(--app-font-size-2xl) !important; }
html.app-ui-tech .fs-3 { font-size: var(--app-font-size-3xl) !important; }

html.app-ui-tech .text-muted,
html.app-ui-tech .text-gray-500,
html.app-ui-tech .text-gray-600 {
    color: var(--app-text-muted) !important;
}

html.app-ui-tech .form-label {
    font-size: var(--app-font-size-sm);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

html.app-ui-tech .form-control,
html.app-ui-tech .form-select {
    font-size: var(--app-font-size-sm);
    line-height: 1.45;
}

html.app-ui-tech .form-control-sm,
html.app-ui-tech .form-select-sm {
    font-size: var(--app-font-size-sm);
    min-height: 2.25rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

html.app-ui-tech .btn {
    font-size: var(--app-font-size-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
}

html.app-ui-tech .btn-sm {
    font-size: var(--app-font-size-sm);
    padding: 0.4rem 0.85rem;
}

html.app-ui-tech table.dataTable,
html.app-ui-tech .table {
    font-size: var(--app-font-size-sm);
}

html.app-ui-tech table.dataTable thead th,
html.app-ui-tech .table thead th {
    font-size: var(--app-font-size-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

html.app-ui-tech .card .card-title,
html.app-ui-tech .card h2 {
    font-size: var(--app-font-size-lg);
    font-weight: 700;
}

html.app-ui-tech .app-home-header .text-gray-600.fs-7 {
    font-size: var(--app-font-size-sm) !important;
}

html.app-ui-tech body.app-home-body,
html.app-ui-tech body.app-login-body {
    position: relative;
    background-color: var(--app-bg);
    background-image:
        radial-gradient(ellipse 120% 80% at 100% 0%, rgba(0, 200, 255, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 80% 60% at 0% 100%, rgba(91, 141, 239, 0.1) 0%, transparent 45%),
        linear-gradient(var(--app-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--app-grid) 1px, transparent 1px);
    background-size: auto, auto, 28px 28px, 28px 28px;
    background-attachment: fixed;
}

html.app-ui-tech[data-bs-theme="dark"] body.app-home-body,
html.app-ui-tech[data-bs-theme="dark"] body.app-login-body {
    background-image:
        radial-gradient(ellipse 100% 70% at 90% 10%, rgba(0, 200, 255, 0.15) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 5% 95%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
        linear-gradient(var(--app-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--app-grid) 1px, transparent 1px);
}

html.app-ui-tech .app-home-shell,
html.app-ui-tech .app-home-main,
html.app-ui-tech #kt_app_root {
    position: relative;
    /* 勿设 z-index，否则页面内 modal 会困在底层，被 .modal-backdrop 挡住无法点击 */
}

/* Bootstrap 弹窗须高于侧栏/移动底栏与自定义 backdrop */
html.app-ui-tech .modal-backdrop {
    z-index: 1040 !important;
}

html.app-ui-tech .modal {
    z-index: 1055 !important;
}

html.app-ui-tech .app-home-sidebar {
    background: var(--app-surface);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid var(--app-border);
    box-shadow: 4px 0 32px var(--app-shadow), inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

html.app-ui-tech .app-home-sidebar-brand span {
    font-family: var(--app-font-sans);
    font-weight: 700;
    font-size: var(--app-font-size-sm);
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--app-primary), var(--app-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

html.app-ui-tech .app-home-nav-link {
    border: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

html.app-ui-tech .app-home-nav-link:hover {
    background: var(--app-nav-hover-bg);
    box-shadow: none;
}

html.app-ui-tech .app-home-nav-link.active {
    background: linear-gradient(90deg, var(--app-nav-active-bg), transparent);
    box-shadow: inset 3px 0 0 var(--app-primary);
}

html.app-ui-tech .app-home-nav-section-toggle,
html.app-ui-tech .app-home-nav-section-toggle:hover,
html.app-ui-tech .app-home-nav-section-toggle:focus,
html.app-ui-tech .app-home-nav-section-toggle:active {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: normal;
    min-height: 0;
}

html.app-ui-tech .app-home-nav-section-toggle:hover {
    background: var(--app-nav-hover-bg) !important;
}

html.app-ui-tech .app-home-nav-section + .app-home-nav-section {
    border-top-color: var(--app-border);
}

html.app-ui-tech .app-home-header {
    background: var(--app-surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--app-border);
    box-shadow: 0 4px 24px var(--app-shadow);
}

html.app-ui-tech .app-home-header h1 {
    font-family: var(--app-font-sans);
    font-size: var(--app-font-size-lg) !important;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--app-text) !important;
}

html.app-ui-tech .text-gray-900,
html.app-ui-tech .text-gray-800 {
    color: var(--app-text) !important;
}

html.app-ui-tech .text-gray-600,
html.app-ui-tech .text-gray-500,
html.app-ui-tech .text-muted {
    color: var(--app-text-muted) !important;
}

html.app-ui-tech .card,
html.app-ui-tech .dash-kpi-card,
html.app-ui-tech .dash-chart-card,
html.app-ui-tech .dash-hero-card,
html.app-ui-tech .matrix-wrap-card {
    background: var(--app-surface) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--app-border) !important;
    box-shadow: 0 8px 32px var(--app-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
}

html.app-ui-tech .dash-kpi-card:hover,
html.app-ui-tech .dash-chart-card:hover {
    border-color: rgba(0, 200, 255, 0.28) !important;
    box-shadow: 0 12px 40px var(--app-shadow), 0 0 24px var(--app-glow);
}

html.app-ui-tech .dash-hero-card {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.12) 0%, var(--app-surface) 45%, var(--app-surface) 100%) !important;
    border: 1px solid rgba(0, 200, 255, 0.2) !important;
}

html.app-ui-tech[data-bs-theme="dark"] .dash-hero-card {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.14) 0%, rgba(12, 20, 38, 0.9) 50%, rgba(8, 14, 28, 0.95) 100%) !important;
}

html.app-ui-tech .dash-kpi-total .dash-kpi-icon {
    background: rgba(0, 200, 255, 0.18);
    color: var(--app-primary);
    box-shadow: 0 0 16px var(--app-glow);
}

html.app-ui-tech .dash-kpi-fixed .dash-kpi-icon {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

html.app-ui-tech .dash-kpi-variable .dash-kpi-icon {
    background: rgba(167, 139, 250, 0.16);
    color: var(--app-accent);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.2);
}

html.app-ui-tech .dash-kpi-budget .dash-kpi-icon {
    background: rgba(251, 191, 36, 0.16);
    color: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.18);
}

html.app-ui-tech .dash-kpi-value {
    font-family: var(--app-font-mono);
    font-weight: 600;
}

html.app-ui-tech .dash-kpi-progress > span {
    background: linear-gradient(90deg, var(--app-primary), #50cd89, var(--app-accent));
    box-shadow: 0 0 8px var(--app-glow);
}

html.app-ui-tech .card-title,
html.app-ui-tech .dash-section-label {
    font-family: var(--app-font-sans);
    font-weight: 700;
    letter-spacing: 0.01em;
}

html.app-ui-tech .btn-primary {
    background: linear-gradient(135deg, var(--app-primary) 0%, var(--app-accent) 100%);
    border: 1px solid rgba(0, 200, 255, 0.35);
    color: #fff;
    box-shadow: 0 4px 20px var(--app-glow);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}

html.app-ui-tech .btn-primary:hover,
html.app-ui-tech .btn-primary:focus {
    background: linear-gradient(135deg, #00d4ff 0%, #9b7cff 100%);
    border-color: rgba(0, 200, 255, 0.45);
    color: #fff;
    box-shadow: 0 6px 28px var(--app-glow);
    transform: translateY(-1px);
}

html.app-ui-tech .btn-light-primary {
    background: rgba(0, 200, 255, 0.1);
    border: 1px solid rgba(0, 200, 255, 0.22);
    color: var(--app-primary);
}

html.app-ui-tech .btn-light-primary:hover,
html.app-ui-tech .btn-light-primary:focus {
    background: rgba(0, 200, 255, 0.16);
    border-color: rgba(0, 200, 255, 0.32);
    color: var(--app-primary);
}

html.app-ui-tech a:not(.btn):not(.app-home-nav-link):not(.nav-link) {
    color: var(--app-primary);
}

html.app-ui-tech a:not(.btn):hover {
    color: var(--app-accent);
}

html.app-ui-tech .text-primary {
    color: var(--app-primary) !important;
}

html.app-ui-tech .page-link.active,
html.app-ui-tech .active > .page-link {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

html.app-ui-tech .form-control,
html.app-ui-tech .form-select {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--app-border);
    transition: border-color 0.2s, box-shadow 0.2s;
}

html.app-ui-tech[data-bs-theme="light"] .form-control,
html.app-ui-tech[data-bs-theme="light"] .form-select {
    background: rgba(255, 255, 255, 0.7);
}

html.app-ui-tech .form-control:focus,
html.app-ui-tech .form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px var(--app-glow);
}

html.app-ui-tech .badge-light-primary {
    background: rgba(0, 200, 255, 0.12);
    color: var(--app-primary);
    border: 1px solid rgba(0, 200, 255, 0.2);
}

html.app-ui-tech .table thead th {
    font-family: var(--app-font-sans);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: var(--app-font-size-xs);
    color: var(--app-text-muted);
}

html.app-ui-tech .matrix-sheet-table th.matrix-th-fixed,
html.app-ui-tech .matrix-badge-projected {
    color: var(--app-primary);
    text-shadow: 0 0 12px var(--app-glow);
}

html.app-ui-tech .matrix-sheet-table th.matrix-th-projected:not(.matrix-th-fixed) {
    color: #1b567f;
    text-shadow: none;
}

html.app-ui-tech .app-mobile-bottom-nav {
    background: var(--app-surface);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--app-border);
    box-shadow: 0 -4px 24px var(--app-shadow);
}

html.app-ui-tech .app-mobile-bottom-nav a.active {
    color: var(--app-primary);
    text-shadow: 0 0 12px var(--app-glow);
}

/* Login */
.login-quick-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    margin-bottom: 0.25rem;
}

.login-quick-divider {
    width: 1px;
    height: 1.1rem;
    background: var(--app-border);
    opacity: 0.65;
}

.login-lang-link {
    font-size: var(--app-font-size-sm);
    font-weight: 600;
    color: var(--app-text-muted);
    text-decoration: none;
    padding: 0.15rem 0.25rem;
    line-height: 1.2;
}

.login-lang-link:hover,
.login-lang-link.active {
    color: var(--app-primary);
}

html.app-ui-tech .login-mobile-box {
    background: var(--app-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    box-shadow: 0 24px 64px var(--app-shadow), 0 0 40px var(--app-glow);
}

html.app-ui-tech .login-mobile-box h1 {
    font-family: var(--app-font-sans);
    font-size: var(--app-font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--app-text) !important;
}

html.app-ui-tech .login-mobile-box .form-label,
html.app-ui-tech .login-mobile-box label.form-label {
    color: var(--app-text) !important;
    font-weight: 600;
}

html.app-ui-tech .login-mobile-box .text-gray-500,
html.app-ui-tech .login-mobile-box .text-gray-900 {
    color: var(--app-text-muted) !important;
}

html.app-ui-tech .login-mobile-box .text-gray-900.fw-bolder {
    color: var(--app-text) !important;
}

html.app-ui-tech .login-mobile-box {
    color: var(--app-text);
}

html.app-ui-tech .login-auth-bg {
    background-image: none !important;
    background:
        radial-gradient(circle at 30% 20%, rgba(0, 200, 255, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(124, 58, 237, 0.25) 0%, transparent 50%),
        linear-gradient(160deg, #030610 0%, #0a1628 40%, #061018 100%) !important;
    position: relative;
    overflow: hidden;
}

html.app-ui-tech .login-auth-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(0, 200, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 200, 255, 0.06) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: app-tech-grid-drift 24s linear infinite;
}

html.app-ui-tech .login-auth-bg-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

html.app-ui-tech .login-auth-bg h2 {
    font-family: var(--app-font-sans);
    font-size: var(--app-font-size-3xl);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0 0 30px rgba(0, 200, 255, 0.6);
}

html.app-ui-tech .login-auth-tagline {
    max-width: 22rem;
    letter-spacing: 0.06em;
    text-shadow: 0 0 16px rgba(0, 200, 255, 0.35);
}

/* SVG tech orbit — login panel + in-app ambient */
html.app-ui-tech .app-tech-orbit-panel {
    position: relative;
    overflow: hidden;
}

html.app-ui-tech .app-tech-orbit-svg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

html.app-ui-tech .app-tech-orbit-svg--login .app-tech-orbit-art {
    width: min(92vmin, 540px);
    height: min(92vmin, 540px);
    filter: drop-shadow(0 0 28px rgba(0, 200, 255, 0.45)) drop-shadow(0 0 60px rgba(91, 141, 239, 0.25));
    animation: app-tech-orbit-float 8s ease-in-out infinite;
}

html.app-ui-tech .app-tech-orbit-bg {
    position: fixed;
    top: 0;
    right: 0;
    width: min(62vw, 780px);
    height: min(62vw, 780px);
    transform: translate(18%, -12%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.42;
}

html.app-ui-tech[data-bs-theme="light"] .app-tech-orbit-bg {
    opacity: 0.28;
}

html.app-ui-tech .app-tech-orbit-svg--app .app-tech-orbit-art {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 20px rgba(0, 200, 255, 0.25));
}

html.app-ui-tech .app-tech-orbit-pulse {
    animation: app-tech-orbit-pulse 3s ease-in-out infinite;
}

@keyframes app-tech-orbit-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.02); }
}

@keyframes app-tech-orbit-pulse {
    0%, 100% { stroke-opacity: 0.35; r: 28; }
    50% { stroke-opacity: 0.75; r: 32; }
}

@keyframes app-tech-grid-drift {
    0% { background-position: 0 0, 0 0; }
    100% { background-position: 40px 40px, 40px 40px; }
}

/* Invoice sheets in app */
html.app-ui-tech .invoice-sheet {
    background: var(--app-surface-solid, var(--app-surface));
    border: 1px solid var(--app-border);
    box-shadow: 0 12px 40px var(--app-shadow);
}

html.app-ui-tech .invoice-brand {
    text-shadow: 0 0 20px var(--app-glow);
}

/* Toastr / modals */
html.app-ui-tech .modal-content {
    background: var(--app-surface-solid, var(--app-surface));
    backdrop-filter: blur(16px);
    border: 1px solid var(--app-border);
    box-shadow: 0 20px 60px var(--app-shadow), 0 0 32px var(--app-glow);
}

html.app-ui-tech #toast-container > .toast {
    backdrop-filter: blur(12px);
    border: 1px solid var(--app-border);
    box-shadow: 0 8px 32px var(--app-shadow);
}

/* DataTables */
html.app-ui-tech table.dataTable tbody tr:hover {
    background: rgba(0, 200, 255, 0.06) !important;
}

@media (prefers-reduced-motion: reduce) {
    html.app-ui-tech .login-auth-bg::before {
        animation: none;
    }
    html.app-ui-tech .app-tech-orbit-svg--login .app-tech-orbit-art {
        animation: none;
    }
    html.app-ui-tech .app-tech-orbit-pulse {
        animation: none;
    }
    html.app-ui-tech .app-tech-orbit-ring animateTransform,
    html.app-ui-tech .app-tech-orbit-ticks animateTransform,
    html.app-ui-tech .app-tech-orbit-art animate,
    html.app-ui-tech .app-tech-orbit-art animateTransform {
        animation: none !important;
    }
    html.app-ui-tech .btn-primary:hover {
        transform: none;
    }
}

@media (max-width: 991.98px) {
    html.app-ui-tech .app-tech-orbit-bg {
        display: none;
    }
}

/* ===== iPhone / iOS 触控与视口 ===== */
@supports (-webkit-touch-callout: none) {
    html.app-ui-tech body.app-home-body,
    html.app-ui-tech body.app-login-body {
        min-height: -webkit-fill-available;
    }
}

@media (max-width: 991.98px) {
    html.app-ui-tech {
        font-size: 15px;
        -webkit-text-size-adjust: 100%;
    }

    html.app-ui-tech {
        --app-font-size-xs: 0.84375rem;
        --app-font-size-sm: 0.90625rem;
    }

    html.app-ui-tech body.app-home-body,
    html.app-ui-tech body.app-login-body {
        max-width: 100vw;
    }

    html.app-ui-tech body.app-home-body {
        overflow-x: clip;
    }

    /* iOS 输入框 <16px 会触发自动放大 */
    html.app-ui-tech .form-control,
    html.app-ui-tech .form-select,
    html.app-ui-tech input[type="text"],
    html.app-ui-tech input[type="password"],
    html.app-ui-tech input[type="number"],
    html.app-ui-tech input[type="email"],
    html.app-ui-tech input[type="tel"],
    html.app-ui-tech input[type="search"],
    html.app-ui-tech textarea {
        font-size: 16px !important;
    }

    html.app-ui-tech .btn,
    html.app-ui-tech .app-home-nav-link,
    html.app-ui-tech .app-home-nav-section-toggle,
    html.app-ui-tech .app-mobile-bottom-nav a,
    html.app-ui-tech .app-mobile-bottom-nav button {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    html.app-ui-tech .btn,
    html.app-ui-tech .card-header .card-toolbar .btn {
        min-height: var(--app-touch-min);
    }

    html.app-ui-tech .modal-dialog {
        margin-top: max(0.5rem, var(--app-safe-top));
        margin-bottom: max(0.5rem, var(--app-safe-bottom));
    }

    html.app-ui-tech .dash-chart-card .card-title {
        font-size: var(--app-font-size-sm);
        line-height: 1.4;
    }

    html.app-ui-tech .dash-kpi-card .text-muted.fs-7 {
        font-size: var(--app-font-size-sm) !important;
    }
}

/* 登录页 — 手机全屏 + 背景圆环 */
body.app-login-body #kt_app_root {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: calc(var(--app-vh, 1vh) * 100);
}

body.app-login-body .login-mobile-wrap {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: calc(var(--app-vh, 1vh) * 100);
    padding-top: max(1.25rem, var(--app-safe-top)) !important;
    padding-bottom: max(1.25rem, var(--app-safe-bottom)) !important;
    padding-left: max(1rem, var(--app-safe-left)) !important;
    padding-right: max(1rem, var(--app-safe-right)) !important;
    overflow: hidden;
}

body.app-login-body .login-mobile-inner,
body.app-login-body .login-mobile-box {
    position: relative;
    z-index: 2;
}

html.app-ui-tech .app-tech-orbit-login-mobile {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: 0.45;
}

html.app-ui-tech .app-tech-orbit-svg--login-mobile {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.app-ui-tech .app-tech-orbit-svg--login-mobile .app-tech-orbit-art {
    width: min(115vw, 420px);
    height: min(115vw, 420px);
    max-width: none;
    filter: drop-shadow(0 0 24px rgba(0, 200, 255, 0.35));
    animation: none;
}

html.app-ui-tech[data-bs-theme="light"] .app-tech-orbit-login-mobile {
    opacity: 0.28;
}

@media (max-width: 575.98px) {
    body.app-login-body .login-mobile-box {
        padding: 1.15rem !important;
    }

    html.app-ui-tech .login-mobile-box h1 {
        font-size: var(--app-font-size-xl);
    }

    .app-mobile-bottom-nav a span,
    .app-mobile-bottom-nav button span {
        font-size: 0.6875rem;
        letter-spacing: -0.02em;
    }

    .dash-filter-inline {
        grid-template-columns: 1fr 1fr;
    }

    .dash-hero-card {
        padding: 1rem 1.1rem;
    }

    .dash-kpi-card .card-body {
        padding: 1rem 1.1rem;
    }
}

/* User-adjustable font family (persisted in localStorage) */
html[data-app-font-family="default"],
html:not([data-app-font-family]) {
    --app-font-sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-app-font-family="noto"] {
    --app-font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-app-font-family="inter"] {
    --app-font-sans: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-app-font-family="nunito"] {
    --app-font-sans: "Nunito", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-app-font-family="source"] {
    --app-font-sans: "Source Sans 3", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-app-font-family="serif"] {
    --app-font-sans: "Noto Serif SC", Georgia, "Songti SC", serif;
}

html[data-app-font-family="system"] {
    --app-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-display-prefs .app-font-family-select {
    width: auto;
    min-width: 7.5rem;
    max-width: 11rem;
    font-size: var(--app-font-size-xs);
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* User-adjustable font scale (persisted in localStorage) */
html[data-app-font-scale="sm"] {
    --app-font-size: 0.8125rem;
    --app-font-size-sm: 0.75rem;
    --app-font-size-xs: 0.6875rem;
    --app-font-size-lg: 0.9375rem;
    --app-font-size-xl: 1.0625rem;
    --app-font-size-2xl: 1.25rem;
    --app-font-size-3xl: 1.5rem;
}

html[data-app-font-scale="lg"] {
    --app-font-size: 1.0625rem;
    --app-font-size-sm: 1rem;
    --app-font-size-xs: 0.9375rem;
    --app-font-size-lg: 1.1875rem;
    --app-font-size-xl: 1.375rem;
    --app-font-size-2xl: 1.625rem;
    --app-font-size-3xl: 1.875rem;
}

html[data-app-font-scale="xl"] {
    --app-font-size: 1.1875rem;
    --app-font-size-sm: 1.0625rem;
    --app-font-size-xs: 1rem;
    --app-font-size-lg: 1.3125rem;
    --app-font-size-xl: 1.5rem;
    --app-font-size-2xl: 1.75rem;
    --app-font-size-3xl: 2rem;
}

/* User-adjustable table density */
html[data-app-table-density="compact"] .table > :not(caption) > * > *,
html[data-app-table-density="compact"] table.dataTable tbody td,
html[data-app-table-density="compact"] table.dataTable thead th,
html[data-app-table-density="compact"] .matrix-sheet-table td,
html[data-app-table-density="compact"] .matrix-sheet-table th {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
    font-size: var(--app-font-size-sm);
    line-height: 1.35;
}

html[data-app-table-density="comfortable"] .table > :not(caption) > * > *,
html[data-app-table-density="comfortable"] table.dataTable tbody td,
html[data-app-table-density="comfortable"] table.dataTable thead th,
html[data-app-table-density="comfortable"] .matrix-sheet-table td,
html[data-app-table-density="comfortable"] .matrix-sheet-table th {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    line-height: 1.6;
}

.app-display-prefs .btn {
    min-width: 2.1rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
    font-size: var(--app-font-size-xs);
}

/* iPhone 12–17 Pro Max：标准机型 390px、Plus/Pro Max ≥428px */
@media (min-width: 428px) and (max-width: 991.98px) {
    html[data-device-tier="pro-max"] .app-home-content,
    html[data-device-tier="pro-max"] .app-home-header {
        padding-left: max(1rem, var(--app-safe-left));
        padding-right: max(1rem, var(--app-safe-right));
    }

    html[data-device-tier="pro-max"] .app-mobile-bottom-nav a span,
    html[data-device-tier="pro-max"] .app-mobile-bottom-nav button span {
        font-size: var(--app-font-size-xs);
        max-width: 4.75rem;
    }

    html[data-device-tier="pro-max"] .matrix-sheet-table {
        font-size: var(--app-font-size-sm);
    }
}

@media (max-width: 389.98px) {
    .app-home-header .btn-group .btn,
    .app-home-header a.btn-sm {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
        font-size: 0.75rem;
    }

    .app-display-prefs .app-table-density-switch {
        display: none;
    }

    .app-display-prefs .app-font-family-select {
        min-width: 6.5rem;
        max-width: 8.5rem;
    }

    .dash-quick-links {
        flex-direction: column;
    }

    .dash-quick-links a {
        width: 100%;
    }
}

/* WhatsApp invoice preview modal */
.app-wa-preview-modal .app-wa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
}

.app-wa-preview-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 767.98px) {
    .app-wa-preview-layout {
        grid-template-columns: 1fr;
    }
}

.app-wa-chat-panel {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--app-border);
    background: #e5ddd5;
    box-shadow: 0 4px 16px var(--app-shadow);
}

.app-wa-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #075e54;
    color: #fff;
}

.app-wa-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.app-wa-chat-body {
    padding: 1rem;
    min-height: 120px;
    background:
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.app-wa-bubble {
    max-width: 100%;
    border-radius: 8px 8px 2px 8px;
    padding: 0.65rem 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.app-wa-bubble-out {
    background: #dcf8c6;
    margin-left: auto;
    max-width: 92%;
}

.app-wa-bubble-text {
    font-family: inherit;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
    border: 0;
    color: #111b21;
    max-height: 200px;
    overflow: auto;
}

.app-wa-bubble-meta {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.875rem;
    font-weight: 700;
    color: #075e54;
}

.app-wa-card-panel {
    min-width: 0;
}

.app-wa-card-capture-wrap {
    background: #f8fafc;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 0.75rem;
    max-height: 420px;
    overflow: auto;
}

.app-wa-card-capture {
    max-width: 560px;
    margin: 0 auto;
}

.app-wa-card-capture table {
    max-width: 100% !important;
}

#invoice_email_preview_modal .modal-body iframe {
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--app-border);
}
