/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: #e6e6e6;
    min-height: 100vh;
    line-height: 1.5;
}

.app { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }

/* ===== 顶栏 ===== */
.topbar { margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 32px; }
.brand h1 { font-size: 22px; font-weight: 600; color: #fff; }
.subtitle { font-size: 13px; color: #888; margin-top: 2px; }

/* ===== 通知条 ===== */
.notice {
    background: rgba(74, 142, 255, 0.1);
    border: 1px solid rgba(74, 142, 255, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #b3c7f0;
    margin-bottom: 20px;
}
.notice strong { color: #fff; }

/* ===== 布局 ===== */
.main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.speed-test-panel, .ip-panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 22px;
    backdrop-filter: blur(8px);
}
.speed-test-panel h2, .ip-panel h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 18px;
    color: #fff;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea,
#ipSearch,
#regionFilter {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e6e6e6;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
#ipSearch:focus,
#regionFilter:focus { border-color: #4a8eff; }
.form-group .hint { display: block; font-size: 11px; color: #666; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== 按钮 ===== */
.action-buttons { display: flex; gap: 8px; margin-top: 8px; }
.btn-primary, .btn-secondary {
    padding: 9px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(135deg, #4a8eff 0%, #2d6cd9 100%);
    color: white;
    flex: 1;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 142, 255, 0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 进度 ===== */
.progress-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 6px;
}
.progress-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a8eff 0%, #00d4ff 100%);
    width: 0;
    transition: width 0.3s;
    border-radius: 3px;
}

/* ===== 实时测速结果 ===== */
.live-result { margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.live-result h3 { font-size: 13px; color: #aaa; margin-bottom: 12px; font-weight: 500; }
.live-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.live-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 14px;
}
.live-card.best {
    background: linear-gradient(135deg, rgba(74, 142, 255, 0.15) 0%, rgba(0, 212, 255, 0.1) 100%);
    border-color: rgba(74, 142, 255, 0.3);
}
.lc-label { font-size: 11px; color: #888; margin-bottom: 6px; }
.lc-value { font-size: 18px; font-weight: 600; color: #fff; font-family: 'SF Mono', Menlo, monospace; }
.lc-detail { font-size: 11px; color: #888; margin-top: 4px; }

/* ===== IP 库表 ===== */
.ip-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.ip-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ip-actions #ipSearch { width: 220px; }
.ip-actions #regionFilter { width: auto; min-width: 120px; }

.muted { color: #888; font-weight: normal; font-size: 13px; }

.ip-table-container {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    max-height: 600px;
    overflow-y: auto;
}
.ip-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ip-table thead { background: rgba(0, 0, 0, 0.3); position: sticky; top: 0; z-index: 1; }
.ip-table th {
    padding: 12px 14px;
    text-align: left;
    color: #aaa;
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ip-table td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ip-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.ip-table tbody tr.empty-row td { text-align: center; color: #666; padding: 40px; }
.ip-table tbody tr.measured { background: rgba(74, 142, 255, 0.06); }
.ip-table tbody tr.recommended::before { content: '★ '; color: #ffa500; }
.ip-table tbody tr.recommended { background: linear-gradient(90deg, rgba(255, 165, 0, 0.08) 0%, transparent 100%); }

.ip-cell { font-family: 'SF Mono', Menlo, monospace; font-weight: 500; }
.location-cell { color: #aaa; font-size: 12px; }
.colo-cell { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: #c9a0ff; }
.tier-cell { font-size: 11px; }
.tier-1 { color: #4caf50; }
.tier-2 { color: #ffa500; }
.tier-3 { color: #888; }
.metric-cell { font-family: 'SF Mono', Menlo, monospace; }
.metric-good { color: #4caf50; }
.metric-medium { color: #ffa500; }
.metric-bad { color: #f44336; }
.metric-pending { color: #555; }
.action-cell { white-space: nowrap; }
.action-cell button {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    margin-right: 4px;
}
.action-cell button:hover { background: rgba(74, 142, 255, 0.2); border-color: #4a8eff; }
.action-cell button.copied { background: #4caf50; border-color: #4caf50; color: white; }

/* ===== 页脚 ===== */
.footer {
    margin-top: 24px;
    text-align: center;
    color: #666;
    font-size: 12px;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.footer a { color: #4a8eff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer p { margin: 4px 0; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(74, 142, 255, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
}
.toast.show { opacity: 1; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .live-cards { grid-template-columns: repeat(2, 1fr); }
    .ip-actions { flex-direction: column; align-items: stretch; }
    .ip-actions #ipSearch { width: 100%; }
}
