/* ==============================================================================
   HKVPN 控制台 · 现代 SaaS 风格
   ============================================================================== */

/* ===== 重置 + 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: #f5f7fb;
    color: #1a1d24;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== CSS 变量 ===== */
:root {
    --c-info: #2a6fb5;
    --c-info-light: #e6f1fb;
    --c-info-dark: #1d5a99;
    --c-success: #137333;
    --c-success-light: #e6f4ea;
    --c-warning: #b86e00;
    --c-warning-light: #fef3e0;
    --c-danger: #c5221f;
    --c-danger-light: #fce8e6;
    --c-text: #1a1d24;
    --c-text-secondary: #5f6368;
    --c-text-tertiary: #8a8d92;
    --c-border: #e4e7ec;
    --c-border-strong: #c8ccd2;
    --c-surface: #ffffff;
    --c-bg: #f5f7fb;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* ===== 顶部 nav ===== */
.topnav {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
}
.logo-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2a6fb5 0%, #1d5a99 100%);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px;
    box-shadow: var(--shadow-sm);
}
.brand-text { letter-spacing: -0.01em; }
.nav-tabs {
    display: flex; gap: 4px;
    flex: 1;
    margin-left: 8px;
}
.nav-tab {
    padding: 20px 14px;
    font-size: 13px;
    color: var(--c-text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--c-text); }
.nav-tab.active {
    color: var(--c-info);
    border-bottom-color: var(--c-info);
    font-weight: 500;
}
.user-menu {
    display: flex; gap: 12px; align-items: center;
    font-size: 13px;
    color: var(--c-text-secondary);
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #2a6fb5, #534ab7);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 500;
}
.logout {
    color: var(--c-text-tertiary);
    cursor: pointer;
    transition: color 0.15s;
}
.logout:hover { color: var(--c-danger); }

/* ===== Main 区域 ===== */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 28px 60px;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== 页面头 ===== */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}
.page-title {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}
.page-sub {
    font-size: 13px;
    color: var(--c-text-secondary);
    margin: 0;
}

/* ===== 统计卡片 ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 32px;
}
.stat {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    border: 1px solid var(--c-border);
    transition: box-shadow 0.15s;
}
.stat:hover { box-shadow: var(--shadow-sm); }
.stat-label {
    font-size: 12px;
    color: var(--c-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-value {
    font-size: 28px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.02em;
}
.stat-hint {
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin-top: 6px;
}

/* ===== 章节标题 ===== */
.section-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 14px;
    color: var(--c-text-secondary);
}

/* ===== 设备卡片网格 ===== */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.device-card {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: 20px;
    border: 1px solid var(--c-border);
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.device-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: var(--c-border-strong);
}
.device-head {
    display: flex; justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
.device-name {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
}
.device-meta {
    font-size: 11px;
    color: var(--c-text-secondary);
    margin-top: 3px;
}
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}
.pill .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.p-active { background: var(--c-success-light); color: var(--c-success); }
.p-amber { background: var(--c-warning-light); color: var(--c-warning); }
.p-gray { background: #f0f1f3; color: var(--c-text-secondary); }
.p-red { background: var(--c-danger-light); color: var(--c-danger); }

.device-stat {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 16px;
}
.ds-block { text-align: center; }
.ds-label {
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ds-value {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text);
}
.ds-value.empty { color: var(--c-text-tertiary); }

.device-foot {
    display: flex;
    gap: 8px;
}
.device-foot .btn { { padding-left: 12px; padding-right: 12px; } }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
    background: var(--c-surface);
    color: var(--c-text);
    line-height: 1;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.b-primary {
    background: var(--c-info);
    color: white;
}
.b-primary:hover { background: var(--c-info-dark); }

.b-ghost {
    background: var(--c-bg);
    color: var(--c-text);
    border: 1px solid var(--c-border);
}
.b-ghost:hover { background: #eef1f7; }

.b-danger {
    background: var(--c-danger-light);
    color: var(--c-danger);
    border: 1px solid transparent;
}
.b-danger:hover { background: #f7d3d0; }

.b-block { width: 100%; padding: 10px; }

/* ===== 待批准 ===== */
.pending-section {
    margin-bottom: 28px;
}
.pending-card {
    background: var(--c-warning-light);
    border: 1px solid #fdd663;
    border-radius: var(--r-lg);
    padding: 16px 20px;
    display: flex; justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.pending-info { flex: 1; }
.pending-title { font-size: 13px; font-weight: 500; }
.pending-desc {
    font-size: 12px;
    color: var(--c-text-secondary);
    margin-top: 4px;
}
.pending-code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 14px;
    background: white;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid #fdd663;
    letter-spacing: 0.05em;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--c-text-tertiary);
    font-size: 13px;
    grid-column: 1 / -1;
}

/* ===== 筛选 chip ===== */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.chip {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--c-text); }
.chip.active {
    background: var(--c-info-light);
    color: var(--c-info);
    border-color: var(--c-info);
}

/* ===== 表格 ===== */
.log-table-wrap {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--c-border);
    overflow: hidden;
}
.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.log-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--c-text-secondary);
    background: #fafbfc;
    border-bottom: 1px solid var(--c-border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.log-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border);
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover { background: #fafbfc; }
.mono {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}
.muted { color: var(--c-text-tertiary); }

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.b-green { background: var(--c-success-light); color: var(--c-success); }
.b-amber { background: var(--c-warning-light); color: var(--c-warning); }
.b-red { background: var(--c-danger-light); color: var(--c-danger); }
.b-blue { background: var(--c-info-light); color: var(--c-info); }
.b-gray { background: #f0f1f3; color: var(--c-text-secondary); }

/* ===== 账户页 ===== */
.account-card {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--c-border);
    padding: 24px;
    max-width: 560px;
}
.card-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--c-text);
}
.field input {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
    outline: none;
    border-color: var(--c-info);
    box-shadow: 0 0 0 3px rgba(42, 111, 181, 0.12);
}
.field .hint {
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin-top: 4px;
}
.actions {
    display: flex; gap: 12px; align-items: center;
    margin-top: 16px;
}
.msg { flex: 1; font-size: 12px; }
.msg .ok { color: var(--c-success); }
.msg .err { color: var(--c-danger); }

.info-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px 16px;
    font-size: 13px;
}
.info-grid dt { color: var(--c-text-secondary); }
.info-grid dd { color: var(--c-text); font-family: "SF Mono", monospace; }

/* ===== 登录页 ===== */
.login-body {
    background: linear-gradient(135deg, #f5f7fb 0%, #e8eef6 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
    background: var(--c-surface);
    border-radius: 16px;
    padding: 36px 32px;
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .logo-mark {
    width: 52px; height: 52px;
    margin: 0 auto 16px;
    font-size: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}
.login-title {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.01em;
}
.login-sub {
    font-size: 13px;
    color: var(--c-text-secondary);
    margin-top: 6px;
}
.login-card .field { margin-bottom: 16px; }
.login-foot {
    text-align: center;
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin-top: 20px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.dot-muted {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--c-success);
    display: inline-block;
}

/* ===== Alert ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--r-md);
    margin-bottom: 16px;
    font-size: 12px;
}
.alert-error {
    background: var(--c-danger-light);
    color: var(--c-danger);
    border: 1px solid #f4c0c0;
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: 24px;
    width: 420px;
    max-width: calc(100vw - 40px);
    box-shadow: var(--shadow-lg);
}
.modal h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}
.modal p {
    font-size: 13px;
    color: var(--c-text-secondary);
    margin-bottom: 20px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .device-grid { grid-template-columns: 1fr; }
    main { padding: 20px 16px; }
    .topnav { padding: 0 16px; gap: 12px; }
    .nav-tabs { gap: 0; }
    .nav-tab { padding: 20px 10px; font-size: 12px; }
    .user-menu span:not(.logout) { display: none; }
}

/* ===== 隐藏 sr-only ===== */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}