.lms-overlay {
    --lms-accent: #ff4d6a;
    --lms-text: #24242b;
    --lms-muted: #777985;
    --lms-line: #ebecef;
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    background: rgba(18, 19, 25, .58);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: lms-fade-in .18s ease-out;
}

.lms-overlay * { box-sizing: border-box; }

.lms-panel {
    width: min(820px, 100%);
    max-height: min(90vh, 880px);
    max-height: min(90dvh, 880px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .65);
    border-radius: 22px;
    background: #f8f8fa;
    color: var(--lms-text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .26);
    animation: lms-rise-in .22s cubic-bezier(.2, .8, .2, 1);
}

.lms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px 17px;
    border-bottom: 1px solid var(--lms-line);
    background: rgba(255, 255, 255, .94);
}

.lms-header h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.lms-header p { margin: 5px 0 0; color: var(--lms-muted); font-size: 13px; }

.lms-icon-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f1f4;
    color: #777;
    font-size: 25px;
    line-height: 42px;
    cursor: pointer;
}

.lms-body { min-height: 0; padding: 18px 20px 22px; overflow: auto; }

.lms-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.lms-toolbar-grid { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(112px, auto)); }
.lms-schedule-toolbar { grid-template-columns: minmax(220px, 1fr) 130px 130px auto; }
.lms-grow { flex: 1 1 auto; }

.lms-search {
    min-width: 0;
    height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid #dedfe4;
    border-radius: 12px;
    background: #fff;
    color: #9a9ca5;
}

.lms-search:focus-within { border-color: rgba(255, 77, 106, .55); box-shadow: 0 0 0 3px rgba(255, 77, 106, .09); }
.lms-search input { min-width: 0; width: 100%; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--lms-text); font-size: 14px; }

.lms-overlay select,
.lms-overlay button:not(.lms-icon-button) {
    min-height: 40px;
    border: 1px solid #dedfe4;
    border-radius: 10px;
    background: #fff;
    color: #4f515b;
    font: inherit;
    font-size: 13px;
}

.lms-overlay select { height: 42px; padding: 0 30px 0 11px; }
.lms-overlay button:not(.lms-icon-button) { padding: 8px 12px; cursor: pointer; }
.lms-overlay button:not(.lms-icon-button):hover { border-color: #c9cad1; background: #f9f9fb; }
.lms-overlay .lms-primary { border-color: var(--lms-accent) !important; background: var(--lms-accent) !important; color: #fff !important; }
.lms-overlay .lms-danger,
.lms-overlay .lms-danger-text { color: #d63c50 !important; }
.lms-overlay .lms-danger { border-color: #d63c50 !important; background: #d63c50 !important; color: #fff !important; }
.lms-overlay .lms-danger-text { border-color: #f0cdd3 !important; background: #fff7f8 !important; }

.lms-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 2px 2px 11px;
    color: var(--lms-muted);
    font-size: 12px;
}

.lms-list-head strong { color: #4c4e57; font-size: 14px; }
.lms-list-head > div { display: flex; align-items: center; gap: 12px; }
.lms-overlay .lms-link-button { min-height: auto !important; padding: 2px !important; border: 0 !important; background: transparent !important; color: var(--lms-accent) !important; }

.lms-record-list,
.lms-ledger-list { display: grid; gap: 10px; }

.lms-record-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 15px 16px;
    border: 1px solid var(--lms-line);
    border-radius: 15px;
    background: #fff;
}

.lms-record-main { min-width: 0; flex: 1; }
.lms-record-heading { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lms-record-heading h3 { min-width: 0; margin: 0 0 0 2px; overflow: hidden; color: #262730; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.lms-badge { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: #f0f1f4; color: #73757f; font-size: 10px; font-weight: 650; }
.lms-badge-accent { background: #fff0f3; color: #e8425f; }
.lms-badge-warn { background: #fff5e4; color: #be7922; }
.lms-record-sub { margin: 7px 0 0; color: var(--lms-muted); font-size: 12px; }
.lms-record-summary { display: -webkit-box; margin: 8px 0 0; overflow: hidden; color: #555862; font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.lms-metrics { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 9px; color: #9698a0; font-size: 11px; }
.lms-record-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; max-width: 185px; }

.lms-empty { min-height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #a0a2aa; text-align: center; }
.lms-empty span { font-size: 32px; transform: rotate(-20deg); }
.lms-empty p { margin: 8px 0 0; font-size: 13px; }

.lms-private-grid { min-height: 420px; display: grid; grid-template-columns: 220px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--lms-line); border-radius: 16px; background: #fff; }
.lms-peer-list { overflow: auto; border-right: 1px solid var(--lms-line); background: #fbfbfc; }
.lms-overlay .lms-chat-peer { width: 100%; min-height: 66px !important; display: flex; align-items: center; gap: 9px; padding: 10px !important; border: 0 !important; border-bottom: 1px solid #f0f0f2 !important; border-radius: 0 !important; background: transparent !important; text-align: left; }
.lms-overlay .lms-chat-peer.active { background: #fff0f3 !important; }
.lms-avatar { width: 35px; height: 35px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #ff7c92, #e94562); color: #fff; font-weight: 700; }
.lms-chat-peer-main { min-width: 0; flex: 1; }
.lms-chat-peer-main b { display: flex; align-items: center; gap: 6px; overflow: hidden; color: #33343b; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lms-chat-peer-main small { display: block; margin-top: 4px; overflow: hidden; color: #999ba4; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lms-chat-peer em { color: #aaa; font-size: 10px; font-style: normal; }
.lms-unread { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--lms-accent); }
.lms-chat-detail { min-width: 0; display: flex; flex-direction: column; }
.lms-chat-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--lms-line); }
.lms-chat-detail-head h3 { margin: 0; font-size: 15px; }
.lms-chat-detail-head span { display: block; margin-top: 3px; color: var(--lms-muted); font-size: 10px; }
.lms-inline-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.lms-inline-actions button { min-height: 30px !important; padding: 5px 8px !important; font-size: 11px !important; }
.lms-message-list { min-height: 0; flex: 1; overflow: auto; padding: 14px; background: #f6f6f8; }
.lms-message-row { width: min(82%, 440px); margin: 0 0 13px; }
.lms-message-row.mine { margin-left: auto; }
.lms-message-meta { display: flex; justify-content: space-between; gap: 10px; margin: 0 3px 4px; color: #92949d; font-size: 10px; }
.lms-message-row.mine .lms-message-meta { flex-direction: row-reverse; }
.lms-message-bubble { padding: 9px 11px; border-radius: 5px 13px 13px 13px; background: #fff; color: #41434b; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; box-shadow: 0 1px 4px rgba(0, 0, 0, .04); }
.lms-message-row.mine .lms-message-bubble { border-radius: 13px 5px 13px 13px; background: #ffdce3; }
.lms-message-actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 3px; opacity: .2; transition: opacity .15s; }
.lms-message-row.mine .lms-message-actions { justify-content: flex-end; }
.lms-message-row:hover .lms-message-actions { opacity: 1; }
.lms-message-actions button { min-height: 22px !important; padding: 1px 4px !important; border: 0 !important; background: transparent !important; color: #858791 !important; font-size: 10px !important; }
.lms-compact-label { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; color: var(--lms-muted); font-size: 12px; white-space: nowrap; }

.lms-stat-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.lms-stat-card { min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; padding: 15px; border: 1px solid var(--lms-line); border-radius: 16px; background: #fff; }
.lms-stat-card span { color: var(--lms-muted); font-size: 12px; }
.lms-stat-card strong { color: #34353d; font-size: 25px; }
.lms-stat-balance { background: linear-gradient(140deg, #343640, #202129); }
.lms-stat-balance span { color: rgba(255, 255, 255, .66); }
.lms-stat-balance strong { color: #ffd977; }
.lms-stat-income strong { color: #1f9c69; }
.lms-stat-expense strong { color: #db5164; }
.lms-ledger-toolbar { justify-content: space-between; }
.lms-segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: #ebecf0; }
.lms-segmented button { min-height: 31px !important; padding: 5px 15px !important; border: 0 !important; background: transparent !important; }
.lms-segmented button.active { background: #fff !important; color: #222 !important; box-shadow: 0 1px 5px rgba(0, 0, 0, .08); }
.lms-cleanup { display: flex; gap: 7px; }
.lms-cleanup select { height: 44px; }
.lms-ledger-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--lms-line); border-radius: 13px; background: #fff; }
.lms-ledger-icon { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; font-size: 18px; font-weight: 500; }
.lms-ledger-icon.income { background: #e9f8f1; color: #159463; }
.lms-ledger-icon.expense { background: #fff0f2; color: #d8475c; }
.lms-ledger-main { min-width: 0; flex: 1; }
.lms-ledger-main h3 { margin: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.lms-ledger-main p { margin: 5px 0 0; color: var(--lms-muted); font-size: 11px; }
.lms-ledger-value { flex: 0 0 auto; text-align: right; }

/* 手机触控与键盘操作：管理页所有动作保留足够热区 */
.lms-overlay .lms-inline-actions button,
.lms-overlay .lms-message-actions button,
.lms-overlay .lms-segmented button,
.lms-overlay .lms-cleanup button { min-width:40px !important; min-height:40px !important; }
.lms-overlay button:focus-visible,.lms-overlay select:focus-visible,.lms-overlay input:focus-visible { outline:2px solid #e94562; outline-offset:2px; }
.lms-ledger-value strong { display: block; font-size: 15px; }
.lms-ledger-value small { display: block; margin-top: 3px; color: #9a9ca4; font-size: 10px; }
.lms-ledger-value.income strong { color: #159463; }
.lms-ledger-value.expense strong { color: #d8475c; }

.lms-date-tile { width: 47px; height: 50px; display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; border: 1px solid #ffd4dc; border-radius: 11px; background: #fff7f8; color: #db4260; }
.lms-date-tile strong { font-size: 19px; line-height: 1; }
.lms-date-tile span { margin-top: 4px; font-size: 10px; }
.lms-schedule-card.is-expired { opacity: .75; }

.lms-confirm { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 20px; border-radius: inherit; background: rgba(18, 19, 25, .44); }
.lms-confirm-card { width: min(360px, 100%); padding: 20px; border-radius: 16px; background: #fff; box-shadow: 0 18px 50px rgba(0, 0, 0, .2); }
.lms-confirm-card h3 { margin: 0; font-size: 17px; }
.lms-confirm-card p { margin: 10px 0 18px; color: var(--lms-muted); font-size: 13px; line-height: 1.6; }
.lms-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 700px) {
    .lms-overlay { align-items: flex-end; padding: 0; }
    .lms-panel { width: 100%; max-height: 94vh; max-height: 94dvh; border-width: 1px 0 0; border-radius: 22px 22px 0 0; }
    .lms-header { padding: 17px 16px 14px; }
    .lms-body { padding: 14px 13px max(18px, env(safe-area-inset-bottom)); }
    .lms-toolbar-grid,
    .lms-schedule-toolbar { grid-template-columns: 1fr 1fr; }
    .lms-toolbar-grid .lms-search,
    .lms-schedule-toolbar .lms-search { grid-column: 1 / -1; }
    .lms-record-card { align-items: flex-start; flex-wrap: wrap; gap: 11px; padding: 13px; }
    .lms-record-card > .lms-record-main { flex-basis: calc(100% - 64px); }
    .lms-record-actions { width: 100%; max-width: none; justify-content: flex-end; }
    .lms-record-heading { flex-wrap: wrap; }
    .lms-record-heading h3 { flex-basis: 100%; margin-top: 2px; }
    .lms-private-grid { min-height: 500px; grid-template-columns: 1fr; grid-template-rows: minmax(86px, 120px) minmax(0, 1fr); }
    .lms-peer-list { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--lms-line); }
    .lms-overlay .lms-chat-peer { width: 164px; min-width: 164px; border-right: 1px solid #f0f0f2 !important; border-bottom: 0 !important; }
    .lms-chat-detail-head { align-items: flex-start; flex-direction: column; }
    .lms-inline-actions { justify-content: flex-start; }
    .lms-toolbar:not(.lms-toolbar-grid) { align-items: stretch; flex-wrap: wrap; }
    .lms-toolbar:not(.lms-toolbar-grid) .lms-search { flex-basis: 100%; }
    .lms-stat-grid { grid-template-columns: 1fr 1fr; }
    .lms-stat-balance { grid-column: 1 / -1; }
    .lms-ledger-toolbar { align-items: stretch; flex-direction: column; }
    .lms-cleanup { justify-content: space-between; }
}

@media (max-width: 410px) {
    .lms-toolbar-grid,
    .lms-schedule-toolbar { grid-template-columns: 1fr; }
    .lms-toolbar-grid .lms-search,
    .lms-schedule-toolbar .lms-search { grid-column: auto; }
    .lms-message-row { width: 90%; }
    .lms-stat-card { min-height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
    .lms-overlay,
    .lms-panel { animation: none; }
}

@keyframes lms-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lms-rise-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
