/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #0a0a0f;
    height: 100vh;
    overflow: hidden;
    color: #e0e0e0;
}

/* ===== 背景磨砂层 ===== */
.app-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(30, 60, 120, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(80, 30, 120, 0.2) 0%, transparent 60%),
        #0a0a0f;
    z-index: 0;
}

/* ===== 主容器 ===== */
.app-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(40px) saturate(1.2);
    -webkit-backdrop-filter: blur(40px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 32px;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

/* 登录态尺寸：800x650 */
.app-container:not(.is-logged-in) {
    width: 600px;
    height: 450px;
}

/* 登录后尺寸：1600x900（响应式） */
.app-container.is-logged-in {
    width: min(1600px, 92vw);
    height: min(900px, 88vh);
}

/* ===== 登录卡片 ===== */
.login-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px 48px;
}

.login-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.login-icon {
    font-size: 28px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 300;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.85);
    text-transform: lowercase;
}

.login-form {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.3);
}

.input-group input {
    height: 44px;
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    transition: border-color 0.3s;
    outline: none;
}

.input-group input:focus {
    border-color: rgba(99, 226, 183, 0.4);
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.login-btn {
    height: 44px;
    margin-top: 6px;
    background: linear-gradient(135deg, #63e2b7, #3b9e8a);
    border: none;
    border-radius: 12px;
    font-size: 14px; 
    font-weight: 600;
    color: #0a0a0f;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(99, 226, 183, 0.3);
}

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

.login-error {
    color: #f87171;
    font-size: 14px;
    text-align: center;
    margin-top: 4px;
    min-height: 24px;
}

/* ===== 主界面 ===== */
.main-panel {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px 28px;
}

/* 顶部导航 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.top-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
    transition: background 0.3s;
}

.status-dot.active {
    background: #63e2b7;
    box-shadow: 0 0 12px rgba(99, 226, 183, 0.4);
}

.status-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.logout-btn {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 70, 70, 0.15);
    border-color: rgba(255, 70, 70, 0.3);
    color: #f87171;
}

/* Tab 栏 */
.tab-bar {
    display: flex;
    gap: 32px;
    padding: 14px 0 12px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tab-item {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.3s, border-color 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-item:hover {
    color: rgba(255, 255, 255, 0.7);
}

.tab-item.active {
    color: #63e2b7;
    border-bottom-color: #63e2b7;
}

/* 内容区 */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding-top: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.content-area::-webkit-scrollbar {
    width: 4px;
}

.content-area::-webkit-scrollbar-track {
    background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.tab-content {
    height: 100%;
}

/* ===== 全局配置页 ===== */
.config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.metric-value {
    display: flex;
    align-items: center;
    gap: 12px;
}

.big-number {
    font-size: 28px;
    font-weight: 600;
    color: #fff;
}

.unit {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.3);
}

.digit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    color: #fff;
}

.sep {
    color: rgba(255, 255, 255, 0.15);
}

.status-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.3s;
}

.status-text.active {
    color: #63e2b7;
}

/* 开关 */
.switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: background 0.3s;
}

.switch .slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #1a1a24;
    border-radius: 50%;
    transition: transform 0.3s;
}

.switch input:checked+.slider {
    background: #63e2b7;
}

.switch input:checked+.slider::before {
    transform: translateX(20px);
    background: #0a0a0f;
}

.switch.small {
    width: 32px;
    height: 18px;
}

.switch.small .slider::before {
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
}

.switch.small input:checked+.slider::before {
    transform: translateX(14px);
}

/* 展开详情 */
.detail-collapse {
    padding: 12px 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s;
}

.detail-collapse:hover {
    color: rgba(255, 255, 255, 0.6);
}

.detail-panel {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.detail-panel .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-panel .form-row label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.25);
}

.detail-panel .form-row input,
.detail-panel .form-row select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.detail-panel .form-row input:focus,
.detail-panel .form-row select:focus {
    border-color: rgba(99, 226, 183, 0.3);
}

.save-btn {
    grid-column: 1 / -1;
    padding: 10px 24px;
    background: linear-gradient(135deg, #63e2b7, #3b9e8a);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #0a0a0f;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 4px;
}

.save-btn:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 16px rgba(99, 226, 183, 0.25);
}

/* ===== 隧道列表页 ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-left button {
    padding: 8px 18px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.toolbar-left button:hover {
    background: rgba(255, 255, 255, 0.06);
}

.btn-import:hover {
    border-color: rgba(99, 226, 183, 0.3);
    color: #63e2b7;
}
.btn-export:hover {
    border-color: rgba(99, 150, 255, 0.3);
    color: #6a9fff;
}
.btn-add {
    background: rgba(99, 226, 183, 0.12) !important;
    border-color: rgba(99, 226, 183, 0.2) !important;
    color: #63e2b7 !important;
}
.btn-add:hover {
    background: rgba(99, 226, 183, 0.2) !important;
}

.toolbar-right .search-input {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #fff;
    font-size: 13px;
    outline: none;
    width: 200px;
    transition: border-color 0.3s;
}

.toolbar-right .search-input:focus {
    border-color: rgba(99, 226, 183, 0.3);
}

.toolbar-right .search-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* 隧道卡片列表 */
.proxy-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.proxy-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 12px 18px;
    transition: border-color 0.3s;
}

.proxy-card:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.proxy-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.proxy-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #333;
    transition: background 0.3s;
}

.status-dot.active {
    background: #63e2b7;
    box-shadow: 0 0 10px rgba(99, 226, 183, 0.3);
}

.proxy-name {
    font-size: 15px;
    font-weight: 500;
    color: #fff;
}

.proxy-addr {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    font-family: 'JetBrains Mono', monospace;
}

.proxy-tag {
    font-size: 10px;
    padding: 2px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.proxy-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.remote-port {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
}

.icon-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    transition: color 0.2s;
    border-radius: 6px;
}

.icon-btn:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.04);
}

.icon-btn.danger:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.proxy-footer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.2);
}

.empty-state {
    padding: 48px 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.15);
    font-size: 14px;
}

/* ===== 弹窗 ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dialog-card {
    background: #1a1a24;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 28px 32px;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6);
}

.dialog-card h3 {
    font-size: 18px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 20px;
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dialog-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dialog-form .form-row label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

.dialog-form .form-row input,
.dialog-form .form-row select {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.dialog-form .form-row input:focus,
.dialog-form .form-row select:focus {
    border-color: rgba(99, 226, 183, 0.3);
}

.dialog-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.dialog-actions button {
    padding: 8px 24px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.5);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-confirm {
    background: linear-gradient(135deg, #63e2b7, #3b9e8a);
    color: #0a0a0f;
    font-weight: 600;
}

.btn-confirm:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(99, 226, 183, 0.2);
}

/* ===== 旋转圈过渡 ===== */
.loading-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.04);
    border-top: 3px solid #63e2b7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 5;
}

.loading-ring.visible {
    opacity: 1;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* 主内容默认透明，登录后淡入 */
.main-panel {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.main-panel.visible {
    opacity: 1;
}