:root {
    --msg-ink: #202b27;
    --msg-muted: #87938f;
    --msg-primary: #20bd8e;
    --msg-primary-dark: #128161;
    --msg-primary-soft: #e9f8f3;
    --msg-danger: #ff5268;
    --msg-border: #e7ecea;
    --msg-page: #f5f7f6;
}

.messages-page,
.messages-page * { box-sizing: border-box; }

.messages-page {
    width: 100%;
    max-width: 680px;
    min-height: calc(100vh - 58px);
    margin: 0 auto;
    padding: 10px 8px 88px;
    color: var(--msg-ink);
    background: var(--msg-page);
}

.messages-toolbar {
    margin: 0 0 8px;
    padding: 9px;
    border: 1px solid var(--msg-border);
    border-radius: 10px;
    background: #fff;
}

.messages-toolbar-head { display: flex; min-width: 0; align-items: center; gap: 8px; }

.messages-status-tabs {
    display: grid;
    min-width: 0;
    flex: 1 1 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    background: #f0f3f2;
}

.messages-status-tab {
    display: flex;
    min-width: 0;
    height: 34px;
    padding: 0 5px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #66736f !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.messages-status-tab.is-active {
    color: var(--msg-primary-dark) !important;
    background: #fff;
    box-shadow: 0 1px 5px rgba(31, 60, 51, .1);
}

.messages-mark-all {
    display: inline-flex;
    flex: 0 0 auto;
    height: 40px;
    padding: 0 10px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    border-radius: 8px;
    color: var(--msg-primary-dark);
    background: var(--msg-primary-soft);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.messages-mark-all .layui-icon { font-size: 14px; }
.messages-mark-all:disabled { cursor: wait; opacity: .65; }

.messages-category-strip {
    display: flex;
    min-width: 0;
    margin-top: 10px;
    gap: 6px;
    overflow-x: auto;
    padding: 1px 1px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.messages-category-strip::-webkit-scrollbar { display: none; }

.messages-category-chip {
    --category-color: #20a77e;
    --category-bg: #e8f8f2;
    display: flex;
    flex: 0 0 60px;
    width: 60px;
    padding: 3px 1px 1px;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #687570 !important;
    background: transparent;
    font-size: 10px;
    line-height: 1.35;
    white-space: nowrap;
    text-decoration: none;
}

.messages-category-icon {
    display: flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--category-color);
    background: var(--category-bg);
}

.messages-category-icon .layui-icon { font-size: 20px; }
.messages-category-chip.is-active { border-color: #bce9da; color: var(--msg-primary-dark) !important; background: #f0fbf7; }
.category-all { --category-color: #66736f; --category-bg: #eef2f0; }
.category-maintenance { --category-color: #696bd2; --category-bg: #eeeefe; }
.category-benefit { --category-color: #e88824; --category-bg: #fff2e2; }
.category-security { --category-color: #df5063; --category-bg: #ffedf0; }
.category-service { --category-color: #3288bc; --category-bg: #e8f4fa; }
.category-other { --category-color: #74817c; --category-bg: #eef2f0; }

.message-list { display: flex; flex-direction: column; gap: 8px; }

.message-item {
    --category-color: #20a77e;
    --category-bg: #e8f8f2;
    overflow: hidden;
    border: 1px solid var(--msg-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 9px rgba(31, 62, 52, .04);
}

.message-item.is-read { background: #fbfcfc; }

.message-item-link {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 96px;
    padding: 13px 10px 12px 12px;
    align-items: flex-start;
    gap: 10px;
    color: inherit !important;
    text-decoration: none;
}

.message-item-icon {
    display: flex;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    align-self: center;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    color: var(--category-color);
    background: var(--category-bg);
}

.message-item-icon .layui-icon { font-size: 24px; }
.message-item-body { display: flex; min-width: 0; flex: 1 1 auto; flex-direction: column; }

.message-item-heading {
    display: flex;
    min-width: 0;
    height: 23px;
    align-items: center;
    gap: 5px;
}

.message-item-heading strong {
    min-width: 0;
    overflow: hidden;
    color: #26312e;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.is-read .message-item-heading strong { color: #53605c; font-weight: 600; }

.message-read-state,
.message-pin {
    display: inline-flex;
    flex: 0 0 auto;
    height: 20px;
    padding: 0 5px;
    align-items: center;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1;
}

.message-read-state { color: #fff; background: var(--msg-danger); }
.is-read .message-read-state { color: var(--msg-primary-dark); background: #dff7ee; }
.message-pin { color: #a35a12; background: #fff0d8; }

.message-item-summary {
    display: block;
    min-width: 0;
    height: 18px;
    margin-top: 3px;
    overflow: hidden;
    color: #8a9692;
    font-size: 12px;
    line-height: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-item time { margin-top: 5px; color: #adb5b2; font-size: 10px; line-height: 1.2; }
.message-unread-dot { flex: 0 0 auto; width: 7px; height: 7px; margin: 7px 1px 0 0; border-radius: 50%; background: var(--msg-danger); box-shadow: 0 0 0 3px #ffe9ed; }
.message-item-arrow { flex: 0 0 auto; margin-top: 4px; color: #c0c8c5; font-size: 13px; }

.messages-state {
    padding: 42px 20px;
    border: 1px solid var(--msg-border);
    border-radius: 10px;
    background: #fff;
    text-align: center;
}

.messages-state-icon { color: var(--msg-primary); font-size: 34px; line-height: 1; }
.messages-state-icon .layui-icon { font-size: 34px; }
.messages-state h3 { margin: 11px 0 5px; font-size: 16px; }
.messages-state p { margin: 0; color: var(--msg-muted); font-size: 12px; line-height: 1.65; }
.messages-state a { display: inline-flex; min-height: 38px; margin-top: 15px; padding: 0 17px; align-items: center; border-radius: 8px; color: #fff !important; background: var(--msg-primary); text-decoration: none; }

.messages-pagination { display: flex; margin-top: 16px; justify-content: center; gap: 6px; }
.messages-page-link { min-width: 36px; height: 36px; border: 1px solid var(--msg-border); border-radius: 7px; color: #60706a !important; background: #fff; line-height: 34px; text-align: center; text-decoration: none; }
.messages-page-link.is-current { border-color: var(--msg-primary); color: #fff !important; background: var(--msg-primary); }

/* 消息详情 */
.message-detail-page { padding-top: 0; background: #fff; }

.message-detail-nav {
    position: sticky;
    z-index: 5;
    top: 0;
    display: grid;
    height: 58px;
    margin: 0 -8px;
    padding: 0 10px;
    align-items: center;
    grid-template-columns: 42px 1fr 42px;
    border-bottom: 1px solid #edf0ef;
    background: rgba(255, 255, 255, .96);
}

.message-detail-nav h1 { margin: 0; font-size: 17px; font-weight: 650; text-align: center; }
.message-detail-back,
.message-detail-home { display: flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 9px; color: #53605c !important; text-decoration: none; }
.message-detail-home { justify-self: end; }
.message-detail-back .layui-icon,
.message-detail-home .layui-icon { font-size: 19px; }

.message-detail {
    --category-color: #20a77e;
    --category-bg: #e8f8f2;
    padding: 28px 18px 38px;
}

.message-detail-category { color: var(--category-color); font-size: 12px; line-height: 1.4; font-weight: 650; }
.message-detail h2 { margin: 6px 0 10px; color: #17201d; font-size: 24px; line-height: 1.45; font-weight: 750; word-break: break-word; }
.message-detail-meta { display: flex; align-items: center; gap: 8px; color: #9ba5a1; font-size: 11px; }
.message-detail-meta span { padding: 2px 6px; border-radius: 4px; color: #a35a12; background: #fff0d8; }
.message-detail-divider { width: 34px; height: 3px; margin: 20px 0; border-radius: 2px; background: var(--category-color); }
.message-detail-content { color: #36423e; font-size: 15px; line-height: 1.95; word-break: break-word; overflow-wrap: anywhere; }
.message-detail-content img { max-width: 100%; height: auto; }
.message-detail-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.message-detail-content p:first-child { margin-top: 0; }
.message-detail-action { display: flex; width: 100%; min-height: 44px; margin-top: 28px; padding: 0 16px; align-items: center; justify-content: center; gap: 5px; border-radius: 9px; color: #fff !important; background: var(--category-color); font-size: 14px; font-weight: 650; text-decoration: none; }
.message-detail-state { margin-top: 14px; }

.messages-status-tab:focus-visible,
.messages-category-chip:focus-visible,
.messages-mark-all:focus-visible,
.message-item-link:focus-visible,
.messages-page-link:focus-visible,
.message-detail-back:focus-visible,
.message-detail-home:focus-visible,
.message-detail-action:focus-visible { outline: 3px solid rgba(32, 189, 142, .25); outline-offset: 2px; }

@media (max-width: 350px) {
    .messages-mark-all { padding-right: 8px; padding-left: 8px; }
    .message-item-link { padding-left: 10px; gap: 8px; }
    .message-item-icon { flex-basis: 42px; width: 42px; height: 42px; }
    .message-item-arrow { display: none; }
    .message-detail h2 { font-size: 21px; }
}

@media (min-width: 680px) {
    .messages-page { padding-right: 14px; padding-left: 14px; }
    .message-detail-nav { margin-right: -14px; margin-left: -14px; }
    .message-detail { padding-right: 30px; padding-left: 30px; }
}
