:root {
    --sidebar-width: 256px;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --sidebar-bg: #0f172a;
    --sidebar-muted: #94a3b8;
}

body {
    background-color: #f4f6fb;
    color: #1e293b;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #111c33 0%, var(--sidebar-bg) 100%);
    color: #e2e8f0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.15rem 1.25rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(148, 163, 184, .12);
}

.sidebar-brand .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sidebar-nav {
    padding: .85rem .75rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.sidebar-section-title {
    padding: .9rem .75rem .35rem;
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #64748b;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    margin-bottom: 2px;
    border-radius: .55rem;
    color: var(--sidebar-muted);
    font-size: .92rem;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar .nav-link:hover {
    color: #f8fafc;
    background: rgba(148, 163, 184, .1);
}

.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(99, 102, 241, .95), rgba(139, 92, 246, .75));
    box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .9);
}

.sidebar .nav-link i.bi {
    font-size: 1rem;
    width: 1.15rem;
    text-align: center;
}

.sidebar .subnav {
    margin: 0 0 .25rem .6rem;
    padding-left: .85rem;
    border-left: 1px solid rgba(148, 163, 184, .18);
}

.sidebar .subnav .nav-link {
    padding: .4rem .65rem;
    font-size: .86rem;
}

.sidebar-footer {
    padding: .9rem 1.25rem;
    font-size: .75rem;
    color: #64748b;
    border-top: 1px solid rgba(148, 163, 184, .12);
}

.sidebar-backdrop {
    display: none;
}

/* ---------- 主内容 ---------- */
.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e9f2;
    padding: .7rem 1.5rem;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

.sidebar-toggle {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1035;
    }

    .content-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}

/* ---------- 卡片与统计 ---------- */
.card {
    border: 1px solid #e8ecf4;
    border-radius: .85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eef1f7;
    padding: .9rem 1.1rem;
    font-weight: 600;
}

.form-section-header {
    background: linear-gradient(90deg, #0f766e, #0d9488);
    color: #fff;
    border-bottom: 0;
    font-weight: 600;
}

.form-section-toggle {
    padding: .1rem .45rem;
    border: 0;
    border-radius: .3rem;
    background: #fff;
    color: #0f766e;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.2;
}

.form-section-toggle:hover,
.form-section-toggle:focus {
    background: #ecfdf5;
    color: #0f766e;
}

.form-section-toggle .bi-plus-lg {
    display: none;
}

.form-section-toggle.collapsed .bi-dash-lg {
    display: none;
}

.form-section-toggle.collapsed .bi-plus-lg {
    display: inline;
}

html {
    scroll-behavior: smooth;
}

.anchor-section {
    scroll-margin-top: 90px;
}

.anchor-nav {
    position: sticky;
    top: 90px;
}

.anchor-nav .list-group-item {
    border-left: 0;
    border-right: 0;
    padding: .8rem 1.1rem;
    color: #475569;
    font-size: .92rem;
}

.anchor-nav .list-group-item i {
    width: 1.2rem;
    text-align: center;
    color: #64748b;
}

.anchor-nav .list-group-item:hover {
    color: var(--brand-dark);
    background: #f8faff;
}

.anchor-nav .list-group-item.active {
    color: var(--brand-dark);
    background: #f1f5ff;
    font-weight: 600;
    border-color: #eef1f7;
}

.anchor-nav .list-group-item.active i {
    color: var(--brand);
}

/* ---------- 投诉调解 ---------- */
.complaint-form-header {
    background: #f2b600;
    color: #212529;
    border-bottom: 0;
    font-weight: 600;
}

.complaint-form-close {
    color: #212529;
    text-decoration: none;
    opacity: .75;
}

.complaint-form-close:hover {
    color: #000;
    opacity: 1;
}

.mediation-form-header {
    background: #17a2b8;
    color: #fff;
    border-bottom: 0;
    font-weight: 600;
}

.mediation-form-close {
    color: #fff;
    text-decoration: none;
    opacity: .8;
}

.mediation-form-close:hover {
    color: #fff;
    opacity: 1;
}

.safety-form-header {
    background: #f2b600;
    color: #212529;
    border-bottom: 0;
    font-weight: 600;
}

.safety-form-close {
    color: #212529;
    text-decoration: none;
    opacity: .75;
}

.safety-form-close:hover {
    color: #000;
    opacity: 1;
}

.notification-form-header {
    background: #f2b600;
    color: #212529;
    border-bottom: 0;
    font-weight: 600;
}

.notification-form-close {
    color: #212529;
    text-decoration: none;
    opacity: .75;
}

.notification-form-close:hover {
    color: #000;
    opacity: 1;
}

#notificationEditor .ql-editor img {
    max-width: 100%;
    height: auto;
}

.complaint-attachment-panel {
    background: #fff;
}

.complaint-attachment-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem 0;
    border-bottom: 1px solid #eef1f7;
}

.complaint-attachment-row:last-child {
    border-bottom: 0;
}

.complaint-attachment-panel .min-w-0 {
    min-width: 0;
}

.recipient-pick-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e8ecf4;
    border-radius: .5rem;
    padding: .35rem;
}

.recipient-pick-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .55rem;
    border-radius: .4rem;
    cursor: pointer;
    margin: 0;
}

.recipient-pick-item:hover {
    background: #f8faff;
}

.recipient-pick-item input {
    margin-top: 0;
}

/* ---------- 小区档案：收费 ---------- */
.fee-list {
    border: 1px solid #e8ecf4;
    border-radius: .5rem;
    overflow: hidden;
    background: #fff;
}

.fee-list-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid #eef1f7;
}

.fee-list-row:nth-child(odd) {
    background: #f8fafc;
}

.fee-list-title {
    flex: 1;
    color: #334155;
}

.fee-list-amount {
    color: #334155;
    text-align: right;
    white-space: nowrap;
}

.fee-list-remove {
    visibility: hidden;
    opacity: 0;
    transition: opacity .12s ease;
}

.fee-list-row:hover .fee-list-remove,
.fee-list-row:focus-within .fee-list-remove {
    visibility: visible;
    opacity: 1;
}

.fee-list-empty {
    padding: 1rem;
    text-align: center;
    color: #94a3b8;
}

.fee-list-form {
    padding: .85rem 1rem;
    background: #f8fafc;
}

.fee-year-input {
    width: 110px;
}

.fee-type-select {
    width: 190px;
}

.fee-other-input {
    width: 180px;
}

.fee-amount-input {
    width: 220px;
}

@media (hover: none) {
    .fee-list-remove {
        visibility: visible;
        opacity: 1;
    }
}

/* ---------- 小区档案：费用支付方 ---------- */
.payer-group-item + .payer-group-item {
    margin-top: .9rem;
}

.payer-details {
    margin: .4rem 0 0 1.75rem;
}

.payer-details .form-check + .form-check {
    margin-top: .35rem;
}

.payer-other-input {
    display: inline-block;
    width: 520px;
    max-width: calc(100% - 5.5rem);
    margin: .25rem 0 .25rem .75rem;
    vertical-align: middle;
}

/* ---------- 小区档案：其他管房单位 ---------- */
.company-picker-panel {
    background: #fff;
    overflow: hidden;
}

.company-picker-toolbar {
    border-bottom: 1px solid #e8ecf4;
}

.company-picker-count {
    display: inline-flex;
    align-items: center;
    padding: .3rem .65rem;
    border: 1px solid #cbd5e1;
    border-radius: .35rem;
    background: #fff;
    color: #2563eb;
    font-size: .875rem;
    line-height: 1.2;
}

.company-picker-table {
    max-height: 420px;
    overflow-y: auto;
}

.company-picker-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.company-picker-row .company-row-actions {
    visibility: hidden;
    opacity: 0;
    transition: opacity .12s ease;
}

.company-picker-row:hover .company-row-actions,
.company-picker-row:focus-within .company-row-actions {
    visibility: visible;
    opacity: 1;
}

@media (hover: none) {
    .company-picker-row .company-row-actions {
        visibility: visible;
        opacity: 1;
    }
}

.company-picker .table > :not(caption) > * > * {
    padding: .55rem .75rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: .7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    color: #64748b;
    font-size: .82rem;
}

.table > :not(caption) > * > * {
    padding: .7rem .85rem;
    vertical-align: middle;
}

.table thead th {
    color: #64748b;
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: #f8fafc;
    border-bottom: 1px solid #e8ecf4;
}

.table-hover > tbody > tr:hover > * {
    background-color: #f8faff;
}

.badge-soft-primary { background: #eef2ff; color: #4338ca; }
.badge-soft-success { background: #ecfdf5; color: #047857; }
.badge-soft-info { background: #eff6ff; color: #1d4ed8; }
.badge-soft-warning { background: #fffbeb; color: #b45309; }
.badge-soft-danger { background: #fef2f2; color: #b91c1c; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }
.badge-soft-dark { background: #e2e8f0; color: #1e293b; }

.badge-soft-primary,
.badge-soft-success,
.badge-soft-info,
.badge-soft-warning,
.badge-soft-danger,
.badge-soft-secondary,
.badge-soft-dark {
    font-weight: 500;
    padding: .35em .6em;
}

.text-muted-sm {
    color: #94a3b8;
    font-size: .78rem;
}

/* ---------- 问卷 ---------- */
.question-card {
    border-left: 4px solid var(--brand);
}

.question-title {
    font-weight: 600;
    font-size: 1rem;
}

.question-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--brand-dark);
    font-size: .78rem;
    font-weight: 700;
}

.required-mark {
    color: #dc2626;
    margin-left: 3px;
}

.rating-group .btn-check:checked + label {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.rating-group label {
    min-width: 46px;
}

.option-list .form-check {
    padding: .45rem .45rem .45rem 1.9rem;
    border-radius: .5rem;
}

.option-list .form-check:hover {
    background: #f8faff;
}

.survey-hero {
    background: linear-gradient(120deg, #4338ca 0%, #6d28d9 60%, #7c3aed 100%);
    color: #fff;
    border-radius: 1rem;
    padding: 1.6rem;
    box-shadow: 0 18px 40px -22px rgba(67, 56, 202, .8);
}

.survey-hero .text-white-50 {
    color: rgba(255, 255, 255, .72) !important;
}

/* ---------- 消息 ---------- */
.message-item {
    display: flex;
    gap: .9rem;
    padding: .95rem 1.1rem;
    border-bottom: 1px solid #eef1f7;
    color: inherit;
    text-decoration: none;
    transition: background .15s ease;
}

.message-item:hover {
    background: #f8faff;
}

.message-item.unread {
    background: #f5f7ff;
}

.message-item.unread .message-subject {
    font-weight: 700;
}

.message-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    flex: 0 0 auto;
    margin-top: 7px;
}

.message-body {
    white-space: pre-wrap;
    line-height: 1.8;
    color: #334155;
}

/* ---------- 登录 ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #312e81 0%, #0f172a 55%, #020617 100%);
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border: 0;
    border-radius: 1.1rem;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .7);
}

.auth-brand {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* ---------- 权限树 ---------- */
.permission-group {
    border: 1px solid #e8ecf4;
    border-radius: .7rem;
    padding: .85rem 1rem;
    height: 100%;
}

.permission-group .group-title {
    font-weight: 600;
    margin-bottom: .5rem;
}

.permission-group .form-check {
    font-size: .88rem;
}

.scroll-check-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e8ecf4;
    border-radius: .6rem;
    padding: .5rem .75rem;
}

.chart-box {
    position: relative;
    height: 280px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2.4rem;
    display: block;
    margin-bottom: .6rem;
}

@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }

    .content-wrapper {
        margin: 0;
    }

    .card {
        box-shadow: none;
        break-inside: avoid;
    }
}

/* ---------- 投诉 / 调解详情 ---------- */
.case-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .case-layout {
        grid-template-columns: 1fr;
    }
}

.case-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #e8f0ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 600;
}

.case-info-row {
    display: flex;
    gap: .75rem;
    padding: .35rem 0;
    border-bottom: 1px dashed #eef1f6;
    font-size: .875rem;
}

.case-info-row:last-child {
    border-bottom: 0;
}

.case-info-label {
    color: #8a94a6;
    min-width: 72px;
    flex: 0 0 auto;
    font-size: .8rem;
}

.case-info-value {
    color: #303a4d;
    word-break: break-word;
}

.case-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.case-timeline::before {
    content: "";
    position: absolute;
    left: .55rem;
    top: .4rem;
    bottom: .4rem;
    width: 2px;
    background: #e8ecf4;
}

.case-timeline-item {
    position: relative;
    margin-bottom: 1.1rem;
}

.case-timeline-item:last-child {
    margin-bottom: 0;
}

.case-date-badge {
    position: absolute;
    left: -1.5rem;
    top: 0;
    width: 2.6rem;
    background: #ef4444;
    color: #fff;
    border-radius: .45rem;
    text-align: center;
    padding: .15rem 0;
    line-height: 1.1;
}

.case-date-badge .day {
    display: block;
    font-size: 1rem;
    font-weight: 700;
}

.case-date-badge .month {
    display: block;
    font-size: .6rem;
    opacity: .9;
}

.case-timeline-icon {
    position: absolute;
    left: -1.45rem;
    top: .1rem;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
}

.case-timeline-icon.is-follow-up {
    background: #f59e0b;
}

.case-timeline-icon.is-reply {
    background: #10b981;
}

.case-timeline-item:has(.case-date-badge) .case-timeline-body {
    padding-left: 1.6rem;
}

.case-timeline-body {
    padding-left: 1.6rem;
}

.case-description {
    white-space: pre-line;
    color: #3c4658;
    font-size: .9rem;
}

.case-recipient-chip {
    display: inline-block;
    background: #f4f6fb;
    border-radius: 999px;
    padding: .1rem .55rem;
    margin: 0 .35rem .35rem 0;
    font-size: .8rem;
}

.case-community-list {
    line-height: 1.9;
}

/* 小区详情页功能块：flex 子项内文字截断需要消除最小宽度 */
.minw-0 {
    min-width: 0;
}

/* ---------- 弹窗表单内部滚动 ----------
 * 功能块弹窗把 <form> 包在 modal-header/body/footer 外层，
 * Bootstrap 的 modal-dialog-scrollable 滚动约束（作用于 .modal-content > .modal-body）
 * 会因此失效，内容超高时底部被裁切且无法滚动。
 * 这里把滚动约束转移到 form 自身，与 Bootstrap 原生结构等效。 */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden;
}

.modal-dialog-scrollable .modal-content > form > .modal-body {
    overflow-y: auto;
}

