:root {
    --bg: #eef1f6;
    --bg-tint: #f4f6fc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border: #e8edf3;
    --border-light: #f1f5f9;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-border: #dbeafe;
    --success: #15803d;
    --success-soft: #ecfdf5;
    --success-border: #bbf7d0;
    --accent: #b45309;
    --accent-soft: #fffbeb;
    --accent-border: #fde68a;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
    --nav-h: 44px;
    --bar-h: 46px;
    --pager-h: 44px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: "Inter", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .wx-card:hover {
        transform: none;
    }
}

/* ── Dashboard: 固定一屏、不滚动；间距不变，超出走分页 ── */
.app-page-dashboard {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, var(--bg-tint) 0%, var(--bg) 42%, #e8edf4 100%);
}

.app-page-dashboard > .container-fluid {
    flex-shrink: 0;
}

.app-page-dashboard .alert {
    flex-shrink: 0;
    margin: 0.35rem 1rem 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
}

.app-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem 0.6rem;
    gap: 0.55rem;
    overflow: hidden;
}

.workbench-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.55rem;
    overflow: hidden;
}

.card-grid-scroll {
    min-height: 0;
    overflow: hidden;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: max-content;
    align-content: start;
    gap: 0.65rem 0.9rem;
}

/* Navbar */
.app-navbar {
    flex-shrink: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: none;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
    flex-shrink: 0;
    min-height: var(--nav-h);
    backdrop-filter: blur(10px);
}

.app-navbar .container-fluid {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.navbar-brand {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem !important;
}

.nav-link.active {
    color: var(--primary);
    font-weight: 600;
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
}
.nav-link:hover { color: var(--primary); }

/* Page bar */
.page-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.85rem;
    min-height: var(--bar-h);
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-bar-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    border: none;
    font-size: 0.8125rem;
    line-height: 1.2;
}

.stat-chip-label {
    color: inherit;
    opacity: 0.82;
    font-weight: 500;
    white-space: nowrap;
}

.stat-chip strong {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: inherit;
}

.stat-chip-time {
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.6rem;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.stat-chip-neutral {
    background: var(--primary-soft);
    color: #1e40af;
}

.stat-chip-success {
    background: var(--success-soft);
    color: var(--success);
}

.stat-chip-muted {
    background: #eef2f6;
    color: var(--text-muted);
}

.stat-chip-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

.live-clock {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--primary);
}

.live-clock::before {
    content: "·";
    margin-right: 0.35rem;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-add {
    padding: 0.3rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.wx-card {
    position: relative;
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 0.65rem 0.45rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    height: auto;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.wx-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.wx-card-priority {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1), var(--shadow);
}

.wx-card-priority::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius) 0 0 var(--radius);
    background: linear-gradient(180deg, #3b82f6, #6366f1);
}

.wx-card-disabled {
    opacity: 0.68;
    background: #fafbfc;
}

.wx-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
}

.wx-card-title {
    min-width: 0;
    flex: 1;
}

.wx-card-id {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.wx-card-remark {
    margin-top: 0.1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wx-card-badges {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.badge-pill {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.1rem 0.38rem;
    border-radius: 999px;
    line-height: 1.35;
    white-space: nowrap;
}

.badge-rank {
    background: linear-gradient(135deg, var(--primary-soft), #e0e7ff);
    color: #1d4ed8;
}
.badge-on {
    background: var(--success-soft);
    color: var(--success);
}
.badge-off { background: var(--border-light); color: var(--text-muted); }

/* 分流次数 */
.wx-card-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0.32rem 0.5rem;
    background: linear-gradient(135deg, #fff8eb 0%, #fffdf7 100%);
    border: none;
    border-radius: var(--radius-sm);
}

.wx-card-stat-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.wx-card-stat-label {
    font-size: 0.75rem;
    color: #92400e;
    font-weight: 600;
    white-space: nowrap;
}

.wx-card-stat .count-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    flex-shrink: 0;
}

.wx-card-stat-edit {
    flex-shrink: 0;
    border: none;
    background: rgba(255, 255, 255, 0.65);
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #b45309;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.wx-card-stat-edit:hover {
    background: #fff;
}

.wx-card-stat-edit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* 主操作：图标 + 文字 */
.wx-card-actions {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 0.35rem;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 30px;
    padding: 0.25rem 0.4rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--border-light);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
    background: #e8edf3;
    color: var(--text);
}

.action-btn:active:not(:disabled) {
    transform: scale(0.97);
}

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

.action-btn-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.action-btn-primary:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
}

.action-btn .icon {
    width: 14px;
    height: 14px;
}

.action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* 底部管理链接 */
.wx-card-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.35rem;
    margin-top: 0.1rem;
    padding-top: 0.32rem;
    border-top: 1px solid var(--border);
}

.wx-card-footer form {
    display: inline;
    margin: 0;
}

.footer-link {
    border: none;
    background: transparent;
    padding: 0.15rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
}

.footer-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.footer-link-danger:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.footer-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Icon buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover:not(:disabled) {
    background: var(--border-light);
    border-color: #cbd5e1;
    color: var(--text);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.94);
}

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

.icon-btn-primary {
    background: var(--primary-soft);
    border-color: #bfdbfe;
    color: var(--primary);
}

.icon-btn-primary:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.icon-btn-danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}

.icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.28);
}

/* Tooltips */
.tooltip { font-size: 0.75rem; }

/* Pagination */
.pagination-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: var(--pager-h);
    padding: 0.35rem 0.85rem;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pagination-info {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.pagination-spaced {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.pagination-spaced .page-item { margin: 0; }

.pagination-spaced .page-link {
    margin-left: 0;
    color: var(--text-secondary);
    border: none;
    background: var(--border-light);
    padding: 0.28rem 0.65rem;
    font-size: 0.8125rem;
    font-weight: 500;
    min-width: 2.25rem;
    text-align: center;
    border-radius: var(--radius-sm);
}

.pagination-spaced .page-link:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.pagination-spaced .page-item.active .page-link {
    background: var(--primary);
    color: #fff;
}

.pagination-spaced .page-item.disabled .page-link {
    color: var(--text-muted);
    background: #eef2f6;
    opacity: 0.7;
}

/* Modals */
.modal-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 0.9375rem;
    font-weight: 600;
}

.modal-body { padding: 1rem; }
.modal-footer {
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--border);
}

.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.form-label-sm {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.count-modal-target {
    font-size: 0.875rem;
    padding: 0.5rem 0.65rem;
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary-border);
}

.count-modal-target strong {
    display: block;
    margin-top: 0.15rem;
    word-break: break-all;
    color: var(--text);
}

.count-modal-hint {
    margin: -0.15rem 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.count-modal-editor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.count-modal-editor .form-control {
    flex: 1;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.count-modal-editor .btn {
    width: 2.25rem;
    padding: 0;
    flex-shrink: 0;
}

/* Buttons global */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
}

.btn, .form-control, .form-select, .page-link {
    border-radius: var(--radius-sm);
}

.form-control.form-control-locked,
.form-control.form-control-locked:read-only {
    background: var(--border-light);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-text-sm {
    font-size: 0.8125rem;
    margin-top: 0.35rem;
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Login */
.login-page {
    min-height: 100dvh;
    background: #f1f5f9;
}

.login-shell {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 820px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.login-aside {
    position: relative;
    padding: 2rem 1.75rem;
    background: linear-gradient(145deg, #eff6ff 0%, #e0e7ff 48%, #f8fafc 100%);
    border-bottom: 1px solid var(--primary-border);
    overflow: hidden;
}

.login-aside::before,
.login-aside::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.login-aside::before {
    width: 180px;
    height: 180px;
    top: -60px;
    right: -40px;
    background: rgba(37, 99, 235, 0.12);
}

.login-aside::after {
    width: 120px;
    height: 120px;
    bottom: -30px;
    left: -20px;
    background: rgba(99, 102, 241, 0.1);
}

.login-aside-inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 0.85rem;
    border-radius: 14px;
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary-border);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.login-mark .icon {
    width: 26px;
    height: 26px;
}

.login-title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.login-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 0.75rem;
    margin: 1.1rem 0 0;
    padding: 0;
    list-style: none;
}

.login-features li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.25rem 0.55rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
}

.login-feature-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.login-feature-dot-primary { background: var(--primary); }
.login-feature-dot-accent { background: var(--accent); }
.login-feature-dot-success { background: var(--success); }

.login-main {
    padding: 1.75rem 1.75rem 2rem;
}

.login-form-title {
    margin: 0 0 1.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.login-alert {
    font-size: 0.8125rem;
    border: none;
    border-radius: var(--radius-sm);
}

.login-form {
    display: grid;
    gap: 0.9rem;
}

.login-field {
    display: grid;
    gap: 0.35rem;
}

.login-input-wrap {
    position: relative;
}

.login-input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.login-input {
    min-height: 44px;
    padding: 0.45rem 0.75rem 0.45rem 2.35rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.login-input:focus {
    background: #fff;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-input::placeholder {
    color: #94a3b8;
}

.login-submit {
    margin-top: 0.35rem;
    min-height: 44px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    transition: background-color 0.15s ease;
}

.login-submit:hover {
    background: var(--primary-hover);
}

@media (min-width: 768px) {
    .login-card {
        flex-direction: row;
        min-height: 420px;
    }

    .login-aside {
        flex: 0 0 42%;
        display: flex;
        align-items: center;
        justify-content: center;
        border-bottom: none;
        border-right: 1px solid var(--primary-border);
    }

    .login-aside-inner {
        max-width: 280px;
    }

    .login-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 2.5rem 2.75rem;
    }
}

@media (max-width: 767.98px) {
    .login-shell {
        padding: 1rem;
    }

    .login-aside {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .login-features {
        margin-top: 0.85rem;
    }

    .login-main {
        padding: 1.35rem 1.25rem 1.5rem;
    }

    .login-form-title {
        margin-bottom: 1rem;
    }
}

/* Settings */
.settings-panel { max-width: 640px; }

.settings-panel .card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.app-main {
    max-width: 1480px;
    margin: 0 auto;
    padding: 1rem;
}

.template-editor {
    font-size: 0.9375rem;
    line-height: 1.65;
    min-height: 220px;
}

.template-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.template-hint code {
    font-size: 0.8125rem;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

/* Toast */
.app-toast-body {
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.alert {
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

/* Responsive grid columns */
@media (max-width: 1199.98px) {
    .card-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .card-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .app-shell {
        padding: 0.5rem 0.5rem 0.6rem;
    }

    .card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.7rem 0.7rem;
    }

    .page-bar {
        flex-wrap: wrap;
    }

    .btn-add { width: 100%; }
}

@media (max-width: 479.98px) {
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
