/* ======================= 根变量 & 基础 ======================= */
:root {
    --bg-deep: #0a0e17;
    --bg-card: rgba(16, 24, 40, 0.85);
    --bg-card-hover: rgba(22, 34, 56, 0.9);
    --bg-input: rgba(10, 16, 30, 0.75);
    --border: rgba(56, 200, 255, 0.15);
    --border-active: rgba(56, 200, 255, 0.5);
    --cyan: #38c8ff;
    --cyan-dim: rgba(56, 200, 255, 0.35);
    --cyan-bright: #5dd8ff;
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.35);
    --green: #22d3a0;
    --red: #f87171;
    --orange: #fb923c;
    --text: #e2e8f0;
    --text-dim: #8899aa;
    --text-bright: #f1f5f9;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-glow: 0 0 40px rgba(56, 200, 255, 0.08), 0 0 80px rgba(168, 85, 247, 0.04);
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* 亮色主题 */
body.light {
    --bg-deep: #f0f4f8;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-input: rgba(240, 244, 248, 0.9);
    --border: rgba(56, 120, 200, 0.15);
    --border-active: rgba(56, 120, 200, 0.5);
    --cyan: #2563eb;
    --cyan-dim: rgba(37, 99, 235, 0.3);
    --cyan-bright: #1d4ed8;
    --purple: #7c3aed;
    --purple-dim: rgba(124, 58, 237, 0.3);
    --green: #059669;
    --red: #dc2626;
    --text: #1e293b;
    --text-dim: #64748b;
    --text-bright: #0f172a;
    --shadow-glow: 0 0 40px rgba(37, 99, 235, 0.08), 0 0 80px rgba(124, 58, 237, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg-deep);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ======================= 背景特效 ======================= */
.bg-grid {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(56, 200, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 200, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 50% 50% at 50% 0%, black 30%, transparent 70%);
}
body.light .bg-grid {
    background-image:
        linear-gradient(rgba(100, 140, 200, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 140, 200, 0.06) 1px, transparent 1px);
}
.bg-particles {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56, 200, 255, 0.04) 0%, transparent 60%),
                radial-gradient(ellipse 60% 40% at 80% 80%, rgba(168, 85, 247, 0.04) 0%, transparent 60%);
}
body.light .bg-particles {
    background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.04) 0%, transparent 60%),
                radial-gradient(ellipse 60% 40% at 80% 80%, rgba(124, 58, 237, 0.04) 0%, transparent 60%);
}

/* ======================= 头部导航 ======================= */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
body.light .header {
    background: rgba(255, 255, 255, 0.85);
}
.header-inner {
    max-width: 1400px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; filter: drop-shadow(0 0 10px rgba(56, 200, 255, 0.5)); }
.logo-text {
    font-size: 20px; font-weight: 700; letter-spacing: 1px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 10px; }

/* ======================= 按钮 ======================= */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; border: none;
    transition: all 0.25s ease; text-decoration: none;
    font-family: inherit; white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--cyan), #0ea5e9);
    color: #fff; box-shadow: 0 0 20px rgba(56, 200, 255, 0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(56, 200, 255, 0.45);
}
.btn-outline {
    background: transparent; color: var(--cyan);
    border: 1px solid var(--cyan-dim);
}
.btn-outline:hover {
    background: rgba(56, 200, 255, 0.08);
    border-color: var(--border-active);
}
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.btn-icon {
    background: none; border: none; cursor: pointer;
    font-size: 18px; padding: 4px 8px; border-radius: var(--radius-xs);
    transition: all 0.2s; color: var(--text-dim);
}
.btn-icon:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-icon.danger:hover { color: var(--red); background: rgba(248,113,113,0.1); }

/* ======================= 主容器 ======================= */
.main-container {
    position: relative; z-index: 1;
    max-width: 1400px; margin: 0 auto; padding: 28px 24px 48px;
}

/* ======================= 统计卡片 ======================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex; align-items: center; gap: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    opacity: 0; transition: opacity 0.3s;
}
.stat-card:hover {
    border-color: var(--border-active);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}
.stat-card:hover::before { opacity: 1; }
.stat-icon { font-size: 36px; flex-shrink: 0; }
.stat-info { min-width: 0; }
.stat-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
.stat-value {
    display: block; font-size: 22px; font-weight: 700;
    font-family: var(--font-mono);
    background: linear-gradient(135deg, var(--text-bright), var(--cyan-bright));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-sub { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ======================= 筛选栏 ======================= */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px; margin-bottom: 20px;
    backdrop-filter: blur(10px);
}
.filter-row {
    display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.filter-actions { flex-direction: row; gap: 8px; align-items: flex-end; padding-bottom: 2px; }

/* ======================= 表单控件 ======================= */
input, select, textarea {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.25s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(56, 200, 255, 0.1);
}
input::placeholder, textarea::placeholder { color: rgba(136, 153, 170, 0.5); }
select option { background: #111827; color: var(--text); }
body.light select option { background: #fff; color: #1e293b; }
textarea { resize: vertical; min-height: 70px; }

/* ======================= 表格区域 ======================= */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    overflow: hidden;
}
.table-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.table-header h3 { font-size: 16px; font-weight: 600; }
.table-count { font-size: 13px; color: var(--text-dim); }
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%; border-collapse: collapse;
    font-size: 14px;
}
.data-table thead { background: rgba(10, 16, 30, 0.5); }
.data-table th {
    padding: 14px 16px; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 14px 16px; border-bottom: 1px solid rgba(56, 200, 255, 0.05);
}
.data-table tbody tr {
    transition: background 0.2s;
}
.data-table tbody tr:hover { background: rgba(56, 200, 255, 0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }

.seller-tag {
    display: inline-block; padding: 3px 12px;
    border-radius: 20px; font-size: 12px; font-weight: 600;
    background: rgba(56, 200, 255, 0.1);
    border: 1px solid rgba(56, 200, 255, 0.2);
    color: var(--cyan-bright);
}
.num-cell { font-family: var(--font-mono); text-align: right; }
.highlight { color: var(--green); font-weight: 600; }
.notes-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.actions-cell { white-space: nowrap; }
.empty-cell { text-align: center; color: var(--text-dim); padding: 48px 16px !important; }

/* ======================= 分页 ======================= */
.pagination {
    display: flex; justify-content: center; gap: 6px;
    padding: 20px 24px; border-top: 1px solid var(--border);
}
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 12px;
    border-radius: var(--radius-xs); font-size: 14px;
    color: var(--text-dim); text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.page-link:hover { color: var(--cyan); border-color: var(--border); }
.page-link.active {
    background: linear-gradient(135deg, rgba(56, 200, 255, 0.15), rgba(168, 85, 247, 0.15));
    border-color: var(--border-active); color: var(--cyan-bright);
    font-weight: 600;
}

/* ======================= 弹窗 ======================= */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
    padding: 24px;
}
.modal-overlay.active { display: flex; }
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    position: relative;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-glow), 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-glow {
    position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
    background: radial-gradient(ellipse at top, rgba(56, 200, 255, 0.06) 0%, transparent 70%);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    position: relative; z-index: 1;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none; border: none; color: var(--text-dim);
    font-size: 20px; cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-xs); transition: all 0.2s;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.05); }

#recordForm { padding: 24px; position: relative; z-index: 1; }
#recordForm .input-row { display: flex; gap: 12px; }
#recordForm .input-group { flex: 1; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
#recordForm .input-group.short { flex: 0 0 100px; }
#recordForm .input-group label { font-size: 13px; color: var(--text-dim); }
.required { color: var(--red); }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 8px;
}

/* ======================= Toast ======================= */
.toast-container {
    position: fixed; top: 80px; right: 24px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 14px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; color: #fff;
    animation: toastIn 0.35s ease; min-width: 200px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.toast.success { background: linear-gradient(135deg, #059669, #10b981); }
.toast.error   { background: linear-gradient(135deg, #dc2626, #ef4444); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ======================= 安装页面 ======================= */
.install-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at center, rgba(56,200,255,0.04) 0%, transparent 60%),
                var(--bg-deep);
}
body.light .install-wrapper {
    background: radial-gradient(ellipse at center, rgba(37,99,235,0.04) 0%, transparent 60%),
                var(--bg-deep);
}
.install-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%; max-width: 600px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-glow);
}
.install-card .card-glow {
    position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at 50% 0%, rgba(56,200,255,0.08) 0%, transparent 70%);
}
.install-card h1 {
    font-size: 28px; text-align: center;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}
.install-card .subtitle { text-align: center; color: var(--text-dim); margin-bottom: 30px; }

.install-form { position: relative; z-index: 1; }
.install-form .form-section {
    background: rgba(10, 16, 30, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px; margin-bottom: 16px;
}
.install-form .form-section h3 { font-size: 15px; margin-bottom: 16px; color: var(--cyan); }
.install-form .input-row { display: flex; gap: 12px; }
.install-form .input-group { flex: 1; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.install-form .input-group.short { flex: 0 0 120px; }
.install-form .input-group label { font-size: 13px; color: var(--text-dim); }
.install-form .input-group input,
.install-form .input-group select {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 14px; font-size: 14px;
    width: 100%;
}
.install-form .input-group input:focus { border-color: var(--border-active); outline: none; }

.msg { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.msg-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }

/* ======================= 主题切换按钮 ======================= */
.theme-toggle {
    position: fixed; bottom: 24px; right: 24px; z-index: 150;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.theme-toggle:hover {
    transform: scale(1.1);
    border-color: var(--border-active);
    box-shadow: 0 4px 30px rgba(56,200,255,0.2);
}

/* ======================= 响应式 ======================= */

/* ---------- 平板 / 小屏电脑 ---------- */
@media (max-width: 1024px) {
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .modal-card { max-width: 90vw; }
}

/* ---------- 手机横屏 / 小平板 ---------- */
@media (max-width: 768px) {
    .header-inner { flex-direction: column; height: auto; padding: 12px 16px; gap: 10px; }
    .logo-text { font-size: 18px; }
    .header-actions { width: 100%; justify-content: center; }
    .main-container { padding: 14px 10px 32px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 18px; }
    .stat-icon { font-size: 28px; }
    .filter-bar { padding: 14px 16px; }
    .filter-row { flex-direction: column; }
    .filter-group { width: 100%; }
    .filter-actions { flex-direction: row; }
    .install-card { padding: 24px 20px; }
    .install-card h1 { font-size: 22px; }
    .install-form .input-row { flex-direction: column; }
    .install-form .input-group.short { flex: 1; }
    #recordForm .input-row { flex-direction: column; }
    #recordForm .input-group.short { flex: 1; }
    .modal-card { max-width: 95vw; max-height: 85vh; }
    #recordForm { padding: 16px; }
    .table-header { flex-direction: column; gap: 6px; align-items: flex-start; }
    .pagination { flex-wrap: wrap; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 10px 8px; }
}

/* ---------- 手机竖屏 ---------- */
@media (max-width: 480px) {
    .header-inner { padding: 10px 8px; }
    .logo-icon { font-size: 22px; }
    .logo-text { font-size: 15px; letter-spacing: 0; }
    .header-actions { gap: 6px; }
    .header-actions .btn { padding: 6px 10px; font-size: 12px; }
    .main-container { padding: 10px 6px 24px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { font-size: 24px; }
    .stat-value { font-size: 16px; }
    .stat-label { font-size: 11px; }
    .stat-sub { font-size: 11px; }
    .filter-bar { padding: 12px; border-radius: var(--radius-sm); }
    .table-section { border-radius: var(--radius-sm); }
    .table-header { padding: 12px; }
    .table-header h3 { font-size: 14px; }
    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 8px 6px; }
    .data-table th { font-size: 10px; letter-spacing: 0; }
    /* 隐藏桌面端不重要的列，手机端只显示关键列 */
    .data-table th:nth-child(7),
    .data-table td:nth-child(7),
    .data-table th:nth-child(9),
    .data-table td:nth-child(9) { display: none; }
    .modal-card { max-width: 100vw; border-radius: var(--radius-sm); margin: 0 4px; }
    #recordForm { padding: 12px; }
    .modal-header { padding: 14px 16px; }
    .modal-header h3 { font-size: 16px; }
    .install-card { padding: 20px 14px; }
    .install-card h1 { font-size: 18px; }
    .install-form .form-section { padding: 14px; }
    .page-link { min-width: 32px; height: 32px; font-size: 12px; padding: 0 8px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }
    .toast-container { left: 8px; right: 8px; top: 60px; }
    .toast { min-width: auto; font-size: 13px; }
}
