/* ==================== 基础重置与变量 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-code: #f8fafc;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ==================== 顶部栏（居中） ==================== */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    width: 100%;
    max-width: 1400px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-brand span { color: var(--accent); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ==================== 标签页导航（居中） ==================== */
.tabs-wrap {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 56px;
    z-index: 90;
    display: flex;
    justify-content: center;
}

.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 1400px;
    width: 100%;
    justify-content: center;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 12px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text-2); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

@media (min-width: 1280px) {
    .topbar {
        justify-content: flex-start;
        padding-left: 24px;
        padding-right: 24px;
    }

    .topbar-inner {
        max-width: none;
    }

    .tabs-wrap {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 220px;
        padding: 16px 12px;
        border-right: 1px solid var(--border);
        border-bottom: none;
        align-items: flex-start;
        justify-content: flex-start;
        background: #ffffff;
    }

    .tabs {
        width: 100%;
        max-width: none;
        flex-direction: column;
        gap: 6px;
        overflow: visible;
        justify-content: flex-start;
    }

    .tab {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid transparent;
        border-radius: 8px;
        margin-bottom: 0;
        text-align: left;
        color: var(--text-2);
        background: transparent;
    }

    .tab:hover {
        background: var(--bg-hover);
        color: var(--text);
    }

    .tab.active {
        background: var(--accent-light);
        border-color: rgba(37,99,235,0.22);
        color: var(--accent);
    }

    .container {
        margin-left: 220px;
        max-width: none;
        padding: 18px 20px;
    }

    .card {
        scroll-margin-top: 72px;
    }

    .preview-panel-wrapper {
        top: 74px;
    }

    .node-list,
    #group-list,
    #rule-list {
        max-height: 70vh;
    }

    #sec-nodes,
    #sec-rules {
        min-height: 360px;
    }
}

/* ==================== 按钮 ==================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.25); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

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

.btn-secondary { background: var(--bg-hover); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 0.82rem; }

.btn-group { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }

/* ==================== 主布局 ==================== */
.container { padding: 20px 24px; max-width: 1680px; margin: 0 auto; }

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 520px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .main-grid { grid-template-columns: 1fr; }
    .tabs { justify-content: flex-start; }
}

/* ==================== 左侧编辑区 ==================== */
.editor-panel { display: flex; flex-direction: column; gap: 20px; }

@media (min-width: 1280px) {
    .editor-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        align-items: start;
    }

    .stats-bar,
    #sec-nodes,
    #sec-rules {
        grid-column: 1 / -1;
    }
}

/* ==================== 右侧预览区（sticky） ==================== */
.preview-panel-wrapper {
    position: sticky;
    top: 108px;
}

@media (max-width: 1100px) {
    .preview-panel-wrapper { position: static; }
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    scroll-margin-top: 116px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
}

/* ==================== 统计栏 ==================== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
}
.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; }
.stat-icon.green { background: #f0fdf4; }
.stat-icon.orange { background: #fffbeb; }

.stat-info .value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-info .label { font-size: 0.78rem; color: var(--text-3); }

/* ==================== 表单元素 ==================== */
.form-group { margin-bottom: 14px; }

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 9px 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.92rem;
    transition: all 0.2s;
    outline: none;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea {
    min-height: 110px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

.help-text { font-size: 0.78rem; color: var(--text-3); margin-top: 4px; }

/* ==================== 节点列表 ==================== */
.node-list { max-height: 620px; overflow-y: auto; padding-right: 4px; }

.node-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.node-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.node-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.node-name {
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
    word-break: break-all;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.node-type {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid rgba(37,99,235,0.15);
    font-weight: 600;
    flex-shrink: 0;
}

.node-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-2);
}

.node-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }

.icon-btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.icon-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-btn.edit:hover { background: var(--warning); color: #fff; border-color: var(--warning); }

/* ==================== 预览面板 ==================== */
.preview-panel {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    height: calc(100vh - 160px);
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
}

.preview-panel .key { color: #2563eb; }
.preview-panel .string { color: #16a34a; }
.preview-panel .number { color: #dc2626; }
.preview-panel .boolean { color: #9333ea; }
.preview-panel .comment { color: var(--text-3); }

@media (max-width: 1100px) {
    .preview-panel { height: 350px; }
}

/* ==================== 快速操作 ==================== */
.quick-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.quick-tag {
    padding: 5px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    font-weight: 500;
}

.quick-tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.list-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 8px;
    padding: 10px 0 12px;
    margin-bottom: 4px;
    background: var(--bg-card);
}

.list-toolbar input,
.list-toolbar select {
    height: 36px;
    font-size: 0.86rem;
}

/* ==================== 开关 ==================== */
.switch-wrapper { display: flex; align-items: center; gap: 10px; }

.switch {
    position: relative;
    width: 42px; height: 24px;
    background: #cbd5e1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.switch.active { background: var(--accent); }

.switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.switch.active::after { left: 20px; }

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15,23,42,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title { font-size: 1.15rem; color: var(--text); font-weight: 700; }

.close-btn {
    background: none; border: none;
    color: var(--text-3);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ==================== 历史记录项 ==================== */
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.history-item:hover { border-color: var(--accent); background: var(--accent-light); }

.history-info { flex: 1; min-width: 0; }

.history-name {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

.history-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ==================== 订阅区域 ==================== */
.subscribe-box, .sub-link-box {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 14px;
}

.subscribe-url, .sub-link-url {
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    word-break: break-all;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin: 10px 0;
    border: 1px solid var(--border);
}

.subscription-format-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    margin: 4px 0 16px;
    color: var(--text-2);
    background: #f4f8f6;
    border: 1px solid #dce8e1;
    border-radius: var(--radius-sm);
}

.subscription-format-note > .ui-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--success);
}

.subscription-format-note strong,
.subscription-format-note span {
    display: block;
}

.subscription-format-note strong {
    margin-bottom: 3px;
    color: var(--text-1);
    font-size: 0.9rem;
}

.subscription-format-note span {
    font-size: 0.8rem;
    line-height: 1.55;
}

.obfuscation-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0;
}

.option-card {
    background: var(--bg-hover);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.option-card:hover { border-color: var(--accent); }

.option-card.selected { border-color: var(--success); background: #f0fdf4; }

.option-icon { font-size: 1.8rem; margin-bottom: 6px; }

.option-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; }

.option-desc { font-size: 0.78rem; color: var(--text-3); }

/* ==================== DNS 行 ==================== */
.dns-row {
    display: grid;
    grid-template-columns: 1fr 100px 36px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

/* ==================== 上传区域 ==================== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-hover);
    margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-light); }

.upload-zone svg { width: 44px; height: 44px; margin-bottom: 10px; color: var(--text-3); }

.upload-zone p { color: var(--text-2); font-size: 0.88rem; }

/* ==================== 服务器文件列表 ==================== */
.server-file-list { max-height: 280px; overflow-y: auto; }

.server-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.server-file-item:hover { border-color: var(--accent); background: var(--accent-light); }

.server-file-item .file-info { flex: 1; min-width: 0; }

.server-file-item .file-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }

.server-file-item .file-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

.server-file-item .file-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ==================== 徽章 ==================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-success { background: #f0fdf4; color: var(--success); }

.badge-warning { background: #fffbeb; color: var(--warning); }

/* ==================== 分割线 ==================== */
.section-divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ==================== 输入组 ==================== */
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.input-group .btn { white-space: nowrap; }

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show { transform: translateY(0); opacity: 1; }

.toast-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 0.8rem; flex-shrink: 0;
}

.toast-success .toast-icon { background: var(--success); color: #fff; }
.toast-error .toast-icon { background: var(--danger); color: #fff; }

/* ==================== 规则项 ==================== */
.rule-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 9px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: all 0.2s;
}

#group-list,
#rule-list {
    max-height: 620px;
    overflow-y: auto;
    padding-right: 4px;
}

.rule-item:hover { border-color: var(--accent); }

.rule-type {
    background: var(--bg-hover);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--accent);
    min-width: 108px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.rule-value {
    flex: 1;
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
    min-width: 0;
    color: var(--text-2);
}

.rule-proxy {
    background: #f0fdf4;
    color: var(--success);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    border: 1px solid #bbf7d0;
}

.rule-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-3);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }

/* ==================== 游客提示 ==================== */
.guest-tip {
    background: var(--accent-light);
    border: 1px solid rgba(37,99,235,0.15);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    color: var(--text-2);
}

.guest-tip a { color: var(--accent); text-decoration: none; font-weight: 600; }
.guest-tip a:hover { text-decoration: underline; }

/* ==================== 加载动画 ==================== */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 登录/注册页面 ==================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
}

.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { font-size: 1.4rem; color: var(--text); margin-bottom: 6px; }
.auth-header p { color: var(--text-2); font-size: 0.88rem; }

.auth-footer { text-align: center; margin-top: 18px; color: var(--text-2); font-size: 0.85rem; }
.auth-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

.auth-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.85rem;
}

.auth-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.85rem;
}

/* ==================== 算术验证码 ==================== */
.math-captcha {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    margin-left: 4px;
    letter-spacing: 1px;
    user-select: none;
}

/* ==================== 路由模板 ==================== */
.rt-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.rt-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}
.rt-card-info { flex: 1; min-width: 0; }
.rt-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 2px;
}
.rt-card-count {
    font-size: 0.82rem;
    color: var(--text-3);
}
.rt-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* 路由模板编辑内联区域 */
#route-template-editor {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.rt-edit-rule {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}
.rt-edit-rule:last-child { border-bottom: none; }
.rt-edit-rule select {
    width: auto;
    min-width: 110px;
    padding: 6px 8px;
    font-size: 0.85rem;
}
.rt-edit-rule input {
    flex: 1;
    min-width: 80px;
    padding: 6px 8px;
    font-size: 0.85rem;
}
.rt-edit-rule .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
}

/* ==================== 代理组多选列表 ==================== */
.proxy-select-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--bg);
}
.proxy-select-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.9rem;
}
.proxy-select-item:hover {
    background: var(--bg-hover);
}
.proxy-select-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.proxy-select-item span {
    color: var(--text);
}
.proxy-select-item .proxy-tag {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-left: auto;
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ==================== 响应式微调 ==================== */
@media (max-width: 640px) {
    .topbar { padding: 0 14px; height: 52px; }
    .topbar-brand { font-size: 1rem; }
    .tabs-wrap { padding: 0 14px; top: 52px; }
    .tab { padding: 10px 12px; font-size: 0.85rem; }
    .container { padding: 12px 14px; }
    .stats-bar { grid-template-columns: 1fr; }
    .card { padding: 14px; }
    .node-actions { opacity: 1; }
    .node-details > div { font-size: 0.72rem; }
    .obfuscation-options { grid-template-columns: 1fr; }
    .btn-group { justify-content: stretch; }
    .btn-group .btn { flex: 1; }
    .rule-item { flex-wrap: wrap; }
    .rule-type { min-width: auto; }
    .modal-content { padding: 18px; }
    .preview-panel { height: 300px; }
}

/* ==================== 2026 产品界面重构 ==================== */
:root {
    --bg: #f4f7fb;
    --bg-card: #ffffff;
    --bg-hover: #f7f9fc;
    --bg-code: #fbfcfe;
    --text: #111827;
    --text-2: #475569;
    --text-3: #8994a7;
    --accent: #1769ff;
    --accent-hover: #0f55d8;
    --accent-light: #edf4ff;
    --success: #0a9f58;
    --warning: #b7791f;
    --danger: #d14343;
    --border: #dfe5ee;
    --border-strong: #cbd4e1;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --radius: 10px;
    --radius-sm: 7px;
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.ui-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.inline-icon-text,
.account-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.topbar {
    height: 64px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: none;
}

.topbar-brand {
    gap: 11px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.brand-mark .ui-icon { width: 28px; height: 28px; stroke-width: 2; }
.account-name { color: var(--text-2); font-size: 13px; font-weight: 550; }

.tabs-wrap { background: #fff; }
.tab {
    font-family: inherit;
    letter-spacing: -0.01em;
}

@media (min-width: 1280px) {
    .tabs-wrap {
        top: 64px;
        width: 220px;
        padding: 18px 12px;
    }

    .tabs { gap: 4px; }

    .tab {
        position: relative;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 44px;
        padding: 10px 14px;
        border: 0;
        border-radius: 7px;
        font-size: 14px;
        font-weight: 520;
    }

    .tab .ui-icon { color: #5e6b7f; }

    .tab.active {
        border: 0;
        background: var(--accent-light);
        color: var(--accent);
        font-weight: 650;
    }

    .tab.active::before {
        content: "";
        position: absolute;
        left: 0;
        top: 8px;
        bottom: 8px;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: var(--accent);
    }

    .tab.active .ui-icon { color: var(--accent); }

    .container {
        margin-left: 220px;
        padding: 20px 24px 40px;
    }

    .preview-panel-wrapper { top: 84px; }
    .card { scroll-margin-top: 84px; }
}

.main-grid {
    grid-template-columns: minmax(620px, 1fr) minmax(430px, 520px);
    gap: 16px;
}

.editor-panel {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 14px;
    min-width: 0;
}

.editor-panel > .card,
.editor-panel > .stats-bar {
    width: 100%;
    grid-column: auto;
}

.stats-bar {
    min-height: 74px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 4px 2px 8px;
}

.workspace-heading {
    flex: 1 1 auto;
    min-width: 240px;
}

.workspace-heading h1 {
    margin: 0;
    color: var(--text);
    font-size: 26px;
    line-height: 1.2;
    font-weight: 730;
    letter-spacing: -0.04em;
}

.workspace-heading p {
    margin-top: 6px;
    color: var(--text-2);
    font-size: 14px;
}

.stat-card {
    min-width: 92px;
    padding: 6px 8px;
    gap: 9px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.stat-card:hover { border-color: transparent; box-shadow: none; }

.stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 0;
    color: #526176;
    background: transparent !important;
}

.stat-icon .ui-icon { width: 22px; height: 22px; }
.stat-info .value { font-size: 18px; font-weight: 720; line-height: 1.1; }
.stat-info .label { margin-top: 3px; color: var(--text-2); font-size: 12px; white-space: nowrap; }

.card {
    padding: 18px;
    border-color: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    margin-bottom: 14px;
    align-items: center;
}

.card-title {
    gap: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.card-title::before { display: none; }

.btn {
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: -0.01em;
    box-shadow: none;
}

.btn-sm { min-height: 34px; padding: 7px 12px; font-size: 13px; }
.btn-primary:hover { transform: none; box-shadow: none; }
.btn-success { background: var(--success); }
.btn-secondary { background: #fff; color: #465469; border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    min-height: 38px;
    padding: 8px 12px;
    border-color: var(--border);
    border-radius: 7px;
    font-family: inherit;
    font-size: 13px;
}

textarea { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.11); }

.quick-actions { margin-bottom: 10px; gap: 6px; }
.quick-tag {
    padding: 5px 10px;
    border-radius: 6px;
    background: #fff;
    color: #536176;
    font-size: 12px;
    font-weight: 550;
}

.list-toolbar {
    grid-template-columns: minmax(0, 1fr) 170px;
    padding: 6px 0 12px;
}

.node-list { max-height: 600px; padding-right: 0; }
.node-table-head,
.node-table-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.15fr) minmax(140px, 1.3fr) 64px 92px 82px 72px;
    gap: 12px;
    align-items: center;
}

.node-table-head {
    padding: 10px 12px;
    color: #64748b;
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: 7px 7px 0 0;
    font-size: 12px;
    font-weight: 650;
}

.node-item {
    margin: -1px 0 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.node-item:last-child { border-radius: 0 0 7px 7px; }
.node-item:hover { border-color: var(--border-strong); box-shadow: none; background: #fbfdff; }
.node-table-row { min-height: 54px; padding: 10px 12px; }
.node-name { font-size: 13px; font-weight: 650; }
.node-endpoint { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-port { color: var(--text-2); font-variant-numeric: tabular-nums; }
.node-type {
    display: inline-flex;
    padding: 3px 7px;
    border: 1px solid #c9dafe;
    border-radius: 5px;
    background: #f4f7ff;
    color: #2456b8;
    font-size: 10px;
    letter-spacing: 0.03em;
}

.node-status { display: flex; align-items: center; gap: 6px; color: #087a45; font-size: 12px; }
.node-status > span { width: 7px; height: 7px; border-radius: 50%; background: #14a765; }
.node-actions { justify-content: flex-end; }
.node-detail-row {
    padding: 0 12px 10px;
    gap: 8px;
    border-top: 1px solid #f0f3f7;
}

.node-meta {
    gap: 5px;
    margin-top: 8px;
    padding: 2px 7px;
    border: 0;
    border-radius: 4px;
    background: #f4f6f9;
    color: #64748b;
    font-size: 11px;
}

.node-meta .ui-icon { width: 13px; height: 13px; }
.node-meta-warning { color: var(--warning); background: #fff8e8; }

.icon-btn {
    width: 30px;
    height: 30px;
    color: #64748b;
    border-radius: 6px;
}

.icon-btn .ui-icon { width: 15px; height: 15px; }
.icon-btn:hover { background: #fff1f1; color: var(--danger); border-color: #f1caca; }
.icon-btn.edit:hover { background: var(--accent-light); color: var(--accent); border-color: #c9dafe; }

.preview-panel-wrapper > .card {
    padding: 14px;
    height: calc(100vh - 104px) !important;
}

.preview-panel-wrapper .card-header { margin-bottom: 12px; }
.preview-panel-wrapper .card-title { font-size: 16px; }
.preview-panel {
    height: auto;
    flex: 1 1 auto;
    padding: 10px 0;
    border-radius: 7px;
    background: var(--bg-code);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.72;
    white-space: normal;
    word-break: normal;
}

.preview-line { display: grid; grid-template-columns: 46px minmax(0, 1fr); min-height: 20px; }
.preview-line:hover { background: #f2f6fb; }
.line-number {
    padding-right: 12px;
    color: #a1acbb;
    text-align: right;
    user-select: none;
    border-right: 1px solid #e6eaf0;
}
.line-code { padding-left: 12px; white-space: pre-wrap; word-break: break-all; }

.close-btn {
    position: relative;
    font-size: 0;
}
.close-btn::before,
.close-btn::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 1.5px;
    background: currentColor;
}
.close-btn::before { transform: rotate(45deg); }
.close-btn::after { transform: rotate(-45deg); }

.option-card {
    border-width: 1px;
    border-radius: 8px;
    background: #fff;
    text-align: left;
}
.option-card.selected { border-color: var(--accent); background: var(--accent-light); }
.option-icon { margin-bottom: 8px; color: var(--accent); }
.option-icon .ui-icon { width: 24px; height: 24px; }

.modal { background: rgba(15, 23, 42, 0.38); backdrop-filter: blur(2px); }
.modal-content { border-radius: 10px; box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2); }

@media (max-width: 1279px) {
    .topbar { height: 58px; }
    .tabs-wrap { top: 58px; }
    .tab { display: inline-flex; align-items: center; gap: 7px; }
    .tab .ui-icon { width: 16px; height: 16px; }
}

@media (max-width: 1100px) {
    .main-grid { grid-template-columns: 1fr; }
    .preview-panel-wrapper > .card { height: 560px !important; }
}

@media (max-width: 760px) {
    .topbar { padding: 0 14px; }
    .topbar-brand { font-size: 15px; }
    .brand-mark { width: 26px; height: 26px; }
    .brand-mark .ui-icon { width: 24px; height: 24px; }
    .tabs-wrap { padding: 0 10px; }
    .tab { padding: 10px 11px; font-size: 12px; }
    .tab .ui-icon { display: none; }
    .container { padding: 14px 12px 32px; }
    .stats-bar { align-items: flex-start; flex-wrap: wrap; gap: 8px 12px; }
    .workspace-heading { flex-basis: 100%; }
    .workspace-heading h1 { font-size: 22px; }
    .stat-card { min-width: 82px; padding-left: 0; }
    .card { padding: 14px; }
    .card-header { align-items: flex-start; }
    .list-toolbar { grid-template-columns: 1fr; }
    .node-table-head { display: none; }
    .node-item { margin-bottom: 8px; padding: 12px; border-radius: 8px; }
    .node-table-row { grid-template-columns: 1fr auto; gap: 7px 12px; padding: 0; }
    .node-name { grid-column: 1; }
    .node-endpoint { grid-column: 1; }
    .node-port { display: none; }
    .node-table-row > div:nth-child(4) { grid-column: 2; grid-row: 1; }
    .node-status { grid-column: 1; }
    .node-actions { grid-column: 2; grid-row: 2 / span 2; }
    .node-detail-row { padding: 8px 0 0; margin-top: 8px; }
    .preview-panel-wrapper > .card { height: 480px !important; }
    .preview-panel-wrapper .card-header > div:last-child { width: 100%; }
    .preview-panel-wrapper .card-header .btn { flex: 1 1 auto; }
}
