:root {
    --m-primary: #2563eb;
    --m-primary-dark: #1d4ed8;
    --m-primary-soft: #dbeafe;
    --m-bg: #f1f5f9;
    --m-card: #ffffff;
    --m-text: #0f172a;
    --m-muted: #64748b;
    --m-border: #e2e8f0;
    --m-success: #10b981;
    --m-warning: #f59e0b;
    --m-danger: #ef4444;
    --m-radius: 14px;
    --m-header-h: 52px;
    --m-tab-h: 56px;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-safe-t: env(safe-area-inset-top, 0px);
    --m-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    color: var(--m-text);
    background: var(--m-bg);
    line-height: 1.5;
}

a { color: var(--m-primary); text-decoration: none; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

/* App shell */
.m-app {
    min-height: 100%;
    padding-top: calc(var(--m-header-h) + var(--m-safe-t));
    padding-bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 12px);
}

.m-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: calc(var(--m-header-h) + var(--m-safe-t));
    padding: var(--m-safe-t) 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    background: rgba(255, 255, 255, .96);
    /* 微信 X5 对 backdrop-filter 支持差，容易导致子元素背景丢失 */
    border-bottom: 1px solid var(--m-border);
}

.m-header-title {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.02em;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-header-back {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin-left: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--m-text);
    border-radius: 10px;
    font-size: 22px;
    line-height: 1;
}

.m-header-back:active { background: #f1f5f9; }

.m-header-action {
    flex-shrink: 0;
    color: var(--m-primary);
    font-size: 15px;
    font-weight: 600;
    padding: 6px 4px;
}

.m-header-fab {
    flex-shrink: 0;
    box-sizing: border-box;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    /* 微信 X5：避免仅用 CSS 变量 background，且勿依赖 backdrop-filter 叠层 */
    background-color: #2563eb;
    background-color: var(--m-primary, #2563eb);
    background-image: none;
    color: #fff !important;
    text-decoration: none !important;
    -webkit-appearance: none;
    appearance: none;
    display: -webkit-inline-box;
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 400;
    line-height: 34px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    position: relative;
    z-index: 2;
}

.m-header-fab:link,
.m-header-fab:visited,
.m-header-fab:hover,
.m-header-fab:active {
    color: #fff !important;
    text-decoration: none !important;
    background-color: #2563eb;
    background-color: var(--m-primary, #2563eb);
}

.m-header-fab:active {
    background-color: #1d4ed8;
    background-color: var(--m-primary-dark, #1d4ed8);
    -webkit-transform: translateZ(0) scale(.96);
    transform: translateZ(0) scale(.96);
}

.m-main {
    padding: 12px 14px 24px;
}

/* Tabbar */
.m-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    height: calc(var(--m-tab-h) + var(--m-safe-b));
    padding-bottom: var(--m-safe-b);
    display: flex;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--m-border);
}

.m-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--m-muted);
    font-size: 11px;
    font-weight: 500;
    min-width: 0;
}

.m-tab-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
}

.m-tab.active { color: var(--m-primary); }
.m-tab.active .m-tab-icon {
    background: var(--m-primary-soft);
    color: var(--m-primary);
}

/* Home hero */
.m-hero {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
    color: #fff;
    border-radius: 18px;
    padding: 20px 18px;
    margin-bottom: 14px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .28);
}

.m-hero-hello {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.m-hero-sub {
    margin-top: 6px;
    font-size: 13px;
    opacity: .85;
}

/* Stats */
.m-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.m-stat {
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 14px 14px 12px;
    box-shadow: var(--m-shadow);
    color: inherit;
    display: block;
}

.m-stat strong {
    display: block;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--m-primary);
    line-height: 1.2;
}

.m-stat strong small {
    margin-left: 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--m-muted);
    letter-spacing: 0;
}

.m-stat span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--m-muted);
}

.m-stat.warn strong { color: var(--m-danger); }
.m-stat.mute strong { color: var(--m-muted); }

.m-weight {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.m-weight-card {
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 14px 14px 12px;
    box-shadow: var(--m-shadow);
}

.m-weight-head {
    font-size: 12px;
    color: var(--m-muted);
}

.m-weight-total {
    margin-top: 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--m-primary);
    line-height: 1.2;
}

.m-weight-total small,
.m-weight-channel strong small {
    margin-left: 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--m-muted);
    letter-spacing: 0;
}

.m-weight-channels {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--m-border);
}

.m-weight-channel {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.m-weight-channel span {
    font-size: 12px;
    color: var(--m-muted);
}

.m-weight-channel strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--m-text);
    letter-spacing: -.02em;
    line-height: 1.2;
    text-align: right;
}

/* Sections / cards */
.m-section { margin-bottom: 18px; }

.m-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 2px;
}

.m-section-head h3 {
    font-size: 15px;
    font-weight: 650;
}

.m-section-head a {
    font-size: 13px;
    color: var(--m-muted);
}

.m-card {
    display: block;
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--m-shadow);
    color: inherit;
}

.m-card-body {
    display: block;
    color: inherit;
}

.m-card-body:active { opacity: .85; }

.m-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.m-card-row strong {
    font-size: 15px;
    font-weight: 650;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.m-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--m-muted);
}

.m-card-meta a { font-weight: 600; }

.m-card-text {
    margin-top: 8px;
    font-size: 14px;
    color: var(--m-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.m-card-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.m-muted { color: var(--m-muted); font-size: 12px; }

.m-empty {
    text-align: center;
    color: var(--m-muted);
    padding: 36px 16px;
    font-size: 14px;
    background: var(--m-card);
    border-radius: var(--m-radius);
}

/* Tags */
.m-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    background: #f1f5f9;
    color: var(--m-muted);
}

.m-tag.green { background: #d1fae5; color: #047857; }
.m-tag.red { background: #fee2e2; color: #b91c1c; }
.m-tag.blue { background: var(--m-primary-soft); color: var(--m-primary-dark); }
.m-tag.gray { background: #e2e8f0; color: #475569; }
.m-tag.orange { background: #ffedd5; color: #c2410c; }

/* Search */
.m-search {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    margin-bottom: 12px;
    align-items: stretch;
}

.m-search-filters {
    grid-template-columns: 1fr 1fr;
}

.m-search-filters input[type="search"] {
    grid-column: 1 / -1;
}

.m-search-filters .m-btn {
    grid-column: 1 / -1;
}

.m-search input,
.m-search select {
    height: 40px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 0 12px;
    background: #fff;
    outline: none;
    min-width: 0;
}

.m-search input:focus,
.m-search select:focus {
    border-color: var(--m-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.m-search select { max-width: 110px; }

.m-search-filters select { max-width: none; }

/* Buttons */
.m-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.m-btn-primary {
    background: var(--m-primary);
    color: #fff;
}

.m-btn-primary:active { background: var(--m-primary-dark); }

.m-btn-ghost {
    background: #fff;
    color: var(--m-text);
    border: 1px solid var(--m-border);
}

.m-btn-ghost:active { background: #f8fafc; }

.m-btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 10px;
}

.m-btn-block {
    width: 100%;
    height: 46px;
    font-size: 16px;
}

.m-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* Detail */
.m-detail-hero {
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 18px 16px;
    margin-bottom: 12px;
    box-shadow: var(--m-shadow);
}

.m-detail-title-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.m-detail-avatar {
    flex: 0 0 30%;
    width: 30%;
    max-width: 30%;
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--m-border);
    background: #f8fafc;
    line-height: 0;
    align-self: flex-start;
}

.m-detail-avatar img {
    display: block;
    width: 100%;
    height: auto;
}

.m-detail-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    background: linear-gradient(145deg, #e2e8f0, #f1f5f9);
    color: #64748b;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.m-detail-title-main {
    flex: 1 1 auto;
    min-width: 0;
}

.m-detail-hero h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
    word-break: break-word;
}

.m-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.m-panel {
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 4px 16px;
    margin-bottom: 12px;
    box-shadow: var(--m-shadow);
}

.m-panel-title {
    font-size: 14px;
    font-weight: 650;
    padding: 14px 0 6px;
}

.m-kv {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.m-kv:last-child { border-bottom: none; }

.m-kv > span {
    color: var(--m-muted);
    flex-shrink: 0;
}

.m-kv em {
    font-style: normal;
    text-align: right;
    word-break: break-word;
}

.m-kv a { font-weight: 650; }

.m-remark {
    padding: 0 0 14px;
    font-size: 14px;
    color: var(--m-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.m-bottom-actions {
    padding: 8px 0 4px;
}

.m-bottom-actions--split {
    display: flex;
    gap: 10px;
}

.m-bottom-actions--split .m-bottom-action-form,
.m-bottom-actions--split .m-btn {
    flex: 1;
    min-width: 0;
}

.m-bottom-actions--split .m-bottom-action-form {
    margin: 0;
}

/* Form */
.m-form {
    background: var(--m-card);
    border-radius: var(--m-radius);
    padding: 8px 16px 16px;
    box-shadow: var(--m-shadow);
}

.m-field {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.m-field:last-of-type { border-bottom: none; }

.m-field > span {
    display: block;
    font-size: 13px;
    color: var(--m-muted);
    margin-bottom: 8px;
}

.m-field input,
.m-field select,
.m-field textarea {
    width: 100%;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    outline: none;
}

.m-field textarea { resize: vertical; min-height: 120px; }

.m-field input:focus,
.m-field select:focus,
.m-field textarea:focus {
    border-color: var(--m-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.m-form .m-btn-block { margin-top: 16px; }

/* Member picker */
.m-member-picker { position: relative; }

.m-member-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    background: #f8fafc;
}

.m-member-selected em {
    font-style: normal;
    font-size: 14px;
    word-break: break-word;
}

.m-member-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    max-height: 220px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    box-shadow: var(--m-shadow);
}

.m-member-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
}

.m-member-item:last-child { border-bottom: none; }
.m-member-item:active { background: #f8fafc; }

.m-member-empty {
    padding: 16px 12px;
    color: var(--m-muted);
    font-size: 13px;
    text-align: center;
}

/* Door photo upload */
.m-upload {
    position: relative;
}

.m-upload-file,
.m-field .m-upload-file {
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    opacity: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.m-upload-pick {
    margin-bottom: 0;
}

.m-upload-preview {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.m-upload-preview img {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--m-border);
    background: #f8fafc;
}

.m-upload-preview-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.m-upload-tip {
    margin-top: 8px;
    font-size: 12px;
    color: var(--m-muted);
}

.m-door-photo {
    padding: 0 0 14px;
}

.m-door-photo a {
    display: block;
}

.m-door-photo img {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--m-border);
    background: #f8fafc;
}

/* Legacy mobile pager alias */
.m-pager,
.m-pager-actions {
    display: none;
}

/* FAB */
.m-fab {
    position: fixed;
    right: 18px;
    bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 18px);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--m-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 400;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
    z-index: 90;
}

.m-fab:active { transform: scale(.96); }

/* Login / result */
.m-login-body {
    min-height: 100%;
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(37, 99, 235, .22), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, rgba(59, 130, 246, .18), transparent 55%),
        var(--m-bg);
}

.m-login {
    max-width: 420px;
    margin: 0 auto;
    padding: 56px 24px 40px;
}

.m-login-brand { margin-bottom: 28px; }

.m-login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
    font-weight: 800;
    letter-spacing: .04em;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .3);
}

.m-login-brand h1 {
    margin-top: 16px;
    font-size: 26px;
    font-weight: 750;
    letter-spacing: -.03em;
}

.m-login-brand p {
    margin-top: 6px;
    color: var(--m-muted);
    font-size: 14px;
}

.m-login-form {
    background: var(--m-card);
    border-radius: 18px;
    padding: 20px 18px;
    box-shadow: var(--m-shadow);
}

.m-login-form label {
    display: block;
    margin-bottom: 14px;
}

.m-login-form label span {
    display: block;
    font-size: 13px;
    color: var(--m-muted);
    margin-bottom: 8px;
}

.m-login-form input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    padding: 0 12px;
    background: #f8fafc;
    outline: none;
}

.m-login-form input:focus {
    border-color: var(--m-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.m-login-form .m-btn-block { margin-top: 8px; }

.m-login-pc {
    display: block;
    text-align: center;
    margin-top: 18px;
    color: var(--m-muted);
    font-size: 13px;
}

.m-result {
    max-width: 420px;
    margin: 0 auto;
    padding: 80px 24px;
    text-align: center;
}

.m-result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.m-result-icon.ok {
    background: #d1fae5;
    color: #047857;
}

.m-result-icon.err {
    background: #fee2e2;
    color: #b91c1c;
}

.m-result-msg {
    font-size: 16px;
    margin-bottom: 20px;
    word-break: break-word;
}

/* Call action strip */
.m-call-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.m-call-bar .m-btn { flex: 1; }

@media (max-width: 360px) {
    .m-search { grid-template-columns: 1fr; }
    .m-search select { max-width: none; }
}
