:root {
    --bg: #f4f7f5;
    --panel: #ffffff;
    --ink: #1f2329;
    --muted: #6b7570;
    --muted-2: #8f959e;
    --line: #e4ebe7;
    --line-soft: #f0f4f1;
    --brand: #2f9e77;
    --brand-dark: #268565;
    --brand-soft: #e8f3ee;
    --danger: #e05a4f;
    --danger-soft: #fdecea;
    --warn: #c98a1f;
    --warn-soft: #fdf6e3;
    --info: #4c7597;
    --info-soft: #eef4f9;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(31, 35, 41, 0.04), 0 8px 24px rgba(31, 35, 41, 0.05);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: 14px;
    color: inherit;
}

.hidden {
    display: none !important;
}

/* ==================== 登录 ==================== */

.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(47, 158, 119, 0.12), transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(47, 158, 119, 0.1), transparent 45%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 32px 28px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3cb187, #268565);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
}

.logo-sm {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 18px;
}

.login-brand h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.login-brand p {
    margin: 2px 0 0;
    color: var(--muted-2);
    font-size: 12px;
    letter-spacing: 1px;
}

.field {
    display: block;
    margin-bottom: 16px;
}

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

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f9fbfa;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(47, 158, 119, 0.12);
}

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

.login-error {
    min-height: 20px;
    margin: 0 0 10px;
    color: var(--danger);
    font-size: 13px;
}

.login-hint {
    margin: 18px 0 0;
    color: var(--muted-2);
    font-size: 12px;
    text-align: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f4f7f5;
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn:hover {
    background: #eaf0ec;
}

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

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

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-ghost {
    border-color: var(--line);
    background: #fff;
}

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

.btn-danger:hover {
    background: #cf4a3f;
}

.btn-danger-ghost {
    border-color: #f3cdc8;
    background: #fff;
    color: var(--danger);
}

.btn-danger-ghost:hover {
    background: var(--danger-soft);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
}

/* ==================== 布局 ==================== */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    flex: 0 0 232px;
    width: 232px;
    height: 100vh;
    padding: 20px 14px;
    border-right: 1px solid var(--line);
    background: var(--panel);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
}

.brand-text strong {
    display: block;
    font-size: 15px;
    line-height: 1.3;
}

.brand-text small {
    color: var(--muted-2);
    font-size: 11px;
    letter-spacing: 1px;
}

.nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    padding-top: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: #f4f7f5;
    color: var(--ink);
}

.nav-item.active {
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 600;
}

.nav-icon {
    width: 18px;
    font-size: 15px;
    text-align: center;
}

.nav-sep {
    margin: 10px 12px 6px;
    color: var(--muted-2);
    font-size: 11px;
    letter-spacing: 1px;
}

.sidebar-foot {
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.me {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.avatar {
    display: flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 14px;
    font-weight: 600;
}

.me-info strong {
    display: block;
    font-size: 13px;
    line-height: 1.3;
}

.me-info small {
    color: var(--muted-2);
    font-size: 11px;
}

.main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 32px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(6px);
}

.topbar h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted-2);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    padding-top: 4px;
}

.content {
    flex: 1;
    padding: 24px 32px 40px;
}

/* ==================== 卡片 / 统计 ==================== */

.card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 18px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.stat-sub {
    margin-top: 4px;
    color: var(--muted-2);
    font-size: 12px;
}

.stat-value.accent {
    color: var(--brand);
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.panel-title p {
    margin: 2px 0 0;
    color: var(--muted-2);
    font-size: 12px;
}

.hint-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px;
}

.hint-list li + li {
    margin-top: 6px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.quick-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdfc;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.quick-item:hover {
    border-color: #bfe0d2;
    background: var(--brand-soft);
    transform: translateY(-1px);
}

.quick-item strong {
    font-size: 14px;
}

.quick-item span {
    color: var(--muted-2);
    font-size: 12px;
}

/* ==================== 工具栏 / 表格 ==================== */

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

.toolbar .search {
    position: relative;
    display: flex;
    align-items: center;
}

.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select {
    min-width: 150px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    outline: none;
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(47, 158, 119, 0.1);
}

.toolbar .spacer {
    flex: 1;
}

.toolbar .count {
    color: var(--muted-2);
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.table th {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #fafcfb;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

table.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

table.table tr:last-child td {
    border-bottom: none;
}

table.table tbody tr:hover {
    background: #fafcfb;
}

td.actions {
    white-space: nowrap;
}

td.actions .btn + .btn {
    margin-left: 6px;
}

.cell-main {
    font-weight: 600;
    color: var(--ink);
}

.cell-sub {
    display: block;
    margin-top: 2px;
    color: var(--muted-2);
    font-size: 12px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-num {
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 9px;
    border-radius: 999px;
    background: #f0f4f1;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
    white-space: nowrap;
}

.badge-admin {
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 600;
}

.badge-user {
    background: #f2f4f5;
    color: var(--muted);
}

.badge-wechat {
    background: var(--info-soft);
    color: var(--info);
}

.badge-public {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-done {
    background: #f2f4f5;
    color: var(--muted-2);
}

.badge-open {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.badge-pending {
    background: var(--warn-soft);
    color: var(--warn);
    font-weight: 600;
}

.badge-replied {
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 600;
}

.badge-ignored {
    background: #f2f4f5;
    color: var(--muted);
}

.badge-p0 {
    background: #f2f6fa;
    color: #6f93b3;
}

.badge-p1 {
    background: #f2f4f5;
    color: var(--muted);
}

.badge-p2 {
    background: var(--danger-soft);
    color: var(--danger);
}

.empty {
    padding: 56px 20px;
    color: var(--muted-2);
    text-align: center;
}

.empty-icon {
    display: block;
    margin-bottom: 8px;
    font-size: 30px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 12.5px;
}

/* ==================== 弹层 ==================== */

.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 26, 23, 0.45);
    animation: fade-in 0.15s ease-out;
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(20, 26, 23, 0.24);
    animation: pop-in 0.18s ease-out;
}

.modal.modal-sm {
    max-width: 420px;
}

.modal.modal-lg {
    max-width: 720px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
}

.modal-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: #f4f7f5;
    color: var(--ink);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 24px 8px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.form-grid .field-full {
    grid-column: 1 / -1;
}

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.check-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.check-pill input {
    margin: 0;
    accent-color: var(--brand);
}

.check-pill:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.form-error {
    min-height: 18px;
    color: var(--danger);
    font-size: 12.5px;
}

.view-content {
    max-height: 46vh;
    overflow-y: auto;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdfc;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.75;
}

.view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--muted-2);
    font-size: 12.5px;
}

.confirm-text {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.7;
}

.confirm-text strong {
    color: var(--danger);
}

/* ==================== 提示 ==================== */

.toast-root {
    position: fixed;
    top: 22px;
    left: 50%;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(31, 35, 41, 0.92);
    color: #fff;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(20, 26, 23, 0.2);
    animation: toast-in 0.2s ease-out;
}

.toast.err {
    background: rgba(200, 62, 51, 0.95);
}

.toast.ok {
    background: rgba(38, 133, 101, 0.95);
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 响应式 ==================== */

@media (max-width: 900px) {
    .sidebar {
        flex: 0 0 72px;
        width: 72px;
        padding: 16px 10px;
    }

    .brand-text,
    .nav-item span.nav-text,
    .nav-sep,
    .me-info,
    .sidebar-foot .btn {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 11px 0;
    }

    .topbar,
    .content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}
