From bdb64769d495f97eebbe90378a3e964188da3717 Mon Sep 17 00:00:00 2001 From: ucmao <294323976@qq.com> Date: Tue, 8 Sep 2026 09:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=AA=92=E4=BD=93=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=B5=81=E7=A8=8B=E5=B9=B6=E5=AE=8C=E5=96=84=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db.py | 133 ++- src/web/admin.py | 2 +- src/web/portal.py | 2 +- static/css/console.css | 1780 +++++++++++++++++++++++++++---- templates/admin/dashboard.html | 107 +- templates/auth/login.html | 62 +- templates/auth/register.html | 61 +- templates/auth/setup.html | 60 +- templates/base_console.html | 94 +- templates/portal/dashboard.html | 118 +- 10 files changed, 2127 insertions(+), 292 deletions(-) diff --git a/src/db.py b/src/db.py index d457c86..9a41d6a 100644 --- a/src/db.py +++ b/src/db.py @@ -269,9 +269,99 @@ def get_daily_trend(user_id=None, days=7): for idx, item in enumerate(daily_stats): item["show_label"] = (idx % step == 0) or (idx == num_points - 1) - y_max = max_val if max_val > 0 else 10 - if y_max < 5: - y_max = 5 + def _calc_nice_ticks(mv, top_m=20, h=160): + if mv <= 0: + ym = 10 + raw_ticks = [10, 8, 6, 4, 2, 0] + elif mv <= 3: + ym = 3 + raw_ticks = [3, 2, 1, 0] + elif mv <= 5: + ym = 5 + raw_ticks = [5, 4, 3, 2, 1, 0] + elif mv <= 8: + ym = 8 + raw_ticks = [8, 6, 4, 2, 0] + elif mv <= 12: + ym = 12 + raw_ticks = [12, 9, 6, 3, 0] + elif mv <= 15: + ym = 15 + raw_ticks = [15, 12, 9, 6, 3, 0] + elif mv <= 20: + ym = 20 + raw_ticks = [20, 15, 10, 5, 0] + elif mv <= 30: + ym = 30 + raw_ticks = [30, 24, 18, 12, 6, 0] + elif mv <= 50: + ym = math.ceil(mv / 10) * 10 + step = 10 if ym <= 30 else (ym // 5) + raw_ticks = list(range(ym, -1, -step)) + if raw_ticks[-1] != 0: + raw_ticks.append(0) + elif mv <= 100: + ym = math.ceil(mv / 10) * 10 + step = max(10, ym // 5) + raw_ticks = list(range(ym, -1, -step)) + if raw_ticks[-1] != 0: + raw_ticks.append(0) + else: + mag = 10 ** math.floor(math.log10(mv)) + norm = mv / mag + if norm <= 1.5: + step = int(0.25 * mag) if mag >= 10 else 1 + ym = int(1.5 * mag) + elif norm <= 2.0: + step = int(0.4 * mag) if mag >= 10 else 1 + ym = int(2.0 * mag) + elif norm <= 5.0: + step = int(0.5 * mag) if mag >= 10 else 1 + ym = int(math.ceil(norm) * mag) + else: + step = int(1.0 * mag) if mag >= 10 else 1 + ym = int(math.ceil(norm / 2) * 2 * mag) + raw_ticks = list(range(ym, -1, -step)) + if raw_ticks[-1] != 0: + raw_ticks.append(0) + + ticks = [] + for v in raw_ticks: + y_pos = round(top_m + h * (1 - v / ym), 1) + ticks.append({ + "val": f"{v:,}", + "raw_val": v, + "y": y_pos, + }) + return ym, ticks + + def _points_to_bezier_path(coords, min_y=20, max_y=180, tension=0.2): + if not coords: + return "" + if len(coords) == 1: + return f"M {coords[0][0]:.1f} {coords[0][1]:.1f}" + if len(coords) == 2: + return f"M {coords[0][0]:.1f} {coords[0][1]:.1f} L {coords[1][0]:.1f} {coords[1][1]:.1f}" + + path = [f"M {coords[0][0]:.1f} {coords[0][1]:.1f}"] + n = len(coords) + for i in range(n - 1): + p0 = coords[max(0, i - 1)] + p1 = coords[i] + p2 = coords[i + 1] + p3 = coords[min(n - 1, i + 2)] + + if p1[1] == max_y and p2[1] == max_y: + path.append(f"L {p2[0]:.1f} {p2[1]:.1f}") + continue + + cp1x = p1[0] + (p2[0] - p0[0]) * tension + cp1y = max(min_y, min(max_y, p1[1] + (p2[1] - p0[1]) * tension)) + cp2x = p2[0] - (p3[0] - p1[0]) * tension + cp2y = max(min_y, min(max_y, p2[1] - (p3[1] - p1[1]) * tension)) + + path.append(f"C {cp1x:.1f} {cp1y:.1f}, {cp2x:.1f} {cp2y:.1f}, {p2[0]:.1f} {p2[1]:.1f}") + return " ".join(path) width = 620 height = 160 @@ -279,6 +369,10 @@ def get_daily_trend(user_id=None, days=7): top_margin = 20 bottom_y = top_margin + height + y_max, y_ticks = _calc_nice_ticks(max_val, top_margin, height) + + coords_calls = [] + coords_successes = [] points_calls = [] points_successes = [] @@ -289,14 +383,22 @@ def get_daily_trend(user_id=None, days=7): item["x"] = x item["y_calls"] = y_c item["y_successes"] = y_s + coords_calls.append((x, y_c)) + coords_successes.append((x, y_s)) points_calls.append(f"{x},{y_c}") points_successes.append(f"{x},{y_s}") - calls_line = " ".join(points_calls) - successes_line = " ".join(points_successes) + calls_path = _points_to_bezier_path(coords_calls, min_y=top_margin, max_y=bottom_y) + successes_path = _points_to_bezier_path(coords_successes, min_y=top_margin, max_y=bottom_y) first_x = daily_stats[0]["x"] last_x = daily_stats[-1]["x"] + + calls_area_path = f"{calls_path} L {last_x:.1f} {bottom_y:.1f} L {first_x:.1f} {bottom_y:.1f} Z" + successes_area_path = f"{successes_path} L {last_x:.1f} {bottom_y:.1f} L {first_x:.1f} {bottom_y:.1f} Z" + + calls_line = " ".join(points_calls) + successes_line = " ".join(points_successes) calls_area = f"{first_x},{bottom_y} {calls_line} {last_x},{bottom_y}" successes_area = f"{first_x},{bottom_y} {successes_line} {last_x},{bottom_y}" @@ -304,15 +406,15 @@ def get_daily_trend(user_id=None, days=7): "trend": daily_stats, "max_val": max_val, "y_max": y_max, + "calls_path": calls_path, + "successes_path": successes_path, + "calls_area_path": calls_area_path, + "successes_area_path": successes_area_path, "calls_line": calls_line, "successes_line": successes_line, "calls_area": calls_area, "successes_area": successes_area, - "y_ticks": [ - {"val": y_max, "y": top_margin}, - {"val": round(y_max / 2), "y": top_margin + height / 2}, - {"val": 0, "y": bottom_y}, - ], + "y_ticks": y_ticks, } @@ -343,13 +445,17 @@ def get_platform_distribution(user_id=None, days=7): PALETTE = [ "#4f46e5", "#10b981", "#f59e0b", "#ec4899", "#8b5cf6", "#06b6d4", "#ef4444", "#3b82f6", "#14b8a6", "#f97316", - "#64748b", "#84cc16", "#d946ef", "#6366f1" + "#6366f1", "#84cc16", "#d946ef", "#0284c7", "#e11d48", + "#7c3aed", "#059669", "#d97706", "#2563eb", "#db2777", + "#0891b2", "#ea580c", "#475569", "#65a30d", "#9333ea", + "#0d9488", "#c026d3", "#4338ca", "#16a34a", "#ca8a04", + "#e11d48", "#2563eb", "#7c2d12", "#4b5563", "#047857", "#b45309" ] items = [] if total_calls > 0: cx, cy = 100, 100 - r_out, r_in = 80, 50 + r_out, r_in = 86, 62 current_angle = 0.0 # radians for idx, row in enumerate(rows): @@ -390,6 +496,7 @@ def get_platform_distribution(user_id=None, days=7): items.append({ "platform": name, "calls": calls, + "calls_formatted": f"{calls:,}", "successes": successes, "percentage": percentage, "color": color, @@ -398,6 +505,8 @@ def get_platform_distribution(user_id=None, days=7): return { "total_calls": total_calls, + "total_calls_formatted": f"{total_calls:,}", + "platform_count": len(rows), "items": items, } diff --git a/src/web/admin.py b/src/web/admin.py index 9796dfc..2e89985 100644 --- a/src/web/admin.py +++ b/src/web/admin.py @@ -109,7 +109,7 @@ def export_logs(): def generate(): writer = csv.writer(_CsvRowBuffer()) yield "\ufeff" - yield writer.writerow(("时间(北京时间)", "客户", "Key Prefix", "平台", "请求路径", "脱敏 URL", "状态码", "耗时(毫秒)", "错误码")) + yield writer.writerow(("时间", "客户", "Key Prefix", "平台", "请求路径", "脱敏 URL", "状态码", "耗时(毫秒)", "错误码")) cursor = get_db().execute( "SELECT l.*, u.username, k.key_prefix FROM request_logs l " "LEFT JOIN users u ON u.id=l.user_id LEFT JOIN api_keys k ON k.id=l.api_key_id " diff --git a/src/web/portal.py b/src/web/portal.py index 86fbb04..ce1b89e 100644 --- a/src/web/portal.py +++ b/src/web/portal.py @@ -82,7 +82,7 @@ def export_logs(): def generate(): writer = csv.writer(_CsvRowBuffer()) yield "\ufeff" - yield writer.writerow(("时间(北京时间)", "平台", "请求路径", "脱敏 URL", "状态码", "耗时(毫秒)", "错误码")) + yield writer.writerow(("时间", "平台", "请求路径", "脱敏 URL", "状态码", "耗时(毫秒)", "错误码")) cursor = get_db().execute( "SELECT * FROM request_logs WHERE user_id=? ORDER BY id DESC", (g.user["id"],), diff --git a/static/css/console.css b/static/css/console.css index 414422b..57f77f3 100644 --- a/static/css/console.css +++ b/static/css/console.css @@ -1,206 +1,1626 @@ -:root { color-scheme: light; --ink:#182230; --muted:#667085; --line:#e4e7ec; --brand:#4f46e5; --brand-light:#eef2ff; --danger:#b42318; --sidebar-width:230px; } -* { box-sizing:border-box; } -body { margin:0; font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; color:var(--ink); background:#f8fafc; } -a { color:inherit; text-decoration:none; } +/* ========================================================================== + Media Parser Console - Enterprise Big-Tech Design System + Modern, Minimalist, Mainstream SaaS Design (Linear / Stripe / Vercel Aesthetic) + ========================================================================== */ -.console-app { display:flex; min-height:100vh; } +:root { + color-scheme: light; + + /* Brand Accent Colors (Refined Indigo & Electric Blue) */ + --brand: #4f46e5; + --brand-hover: #4338ca; + --brand-active: #3730a3; + --brand-light: #eef2ff; + --brand-light-hover: #e0e7ff; + --brand-border: #c7d2fe; + + /* Neutral / Slate Palette */ + --bg-app: #f8fafc; + --bg-card: #ffffff; + --bg-subtle: #f1f5f9; + --bg-muted: #e2e8f0; + + --ink: #0f172a; + --ink-secondary: #334155; + --ink-muted: #64748b; + --ink-subtle: #94a3b8; + + --line: #e2e8f0; + --line-subtle: #f1f5f9; + + /* Status Colors */ + --success: #059669; + --success-bg: #ecfdf5; + --success-border: #a7f3d0; + --success-text: #065f46; + + --danger: #dc2626; + --danger-hover: #b91c1c; + --danger-bg: #fef2f2; + --danger-border: #fecaca; + --danger-text: #991b1b; + + --warning: #d97706; + --warning-bg: #fffbeb; + --warning-border: #fde68a; + --warning-text: #92400e; + + --info: #0284c7; + --info-bg: #f0f9ff; + --info-border: #bae6fd; + --info-text: #075985; + + /* Layout Dimensions & Typography */ + --sidebar-width: 240px; + --topbar-height: 60px; + --radius-xs: 4px; + --radius-sm: 6px; + --radius-md: 8px; + --radius-lg: 12px; + --radius-xl: 16px; + --radius-2xl: 20px; + + /* Shadows */ + --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04); + --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04); + --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05); + --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04); + --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05); + + /* Transitions */ + --ease-out: cubic-bezier(0.16, 1, 0.3, 1); +} -.sidebar { width:var(--sidebar-width); background:#fff; border-right:1px solid var(--line); display:flex; flex-direction:column; justify-content:space-between; position:fixed; top:0; bottom:0; left:0; z-index:10; } -.sidebar-head { padding:20px 18px 16px; border-bottom:1px solid var(--line); } -.brand { display:flex; align-items:center; gap:10px; font-weight:800; font-size:16px; color:#0f172a; } -.brand img { width:32px; height:32px; border-radius:8px; } -.role-badge { display:inline-block; margin-top:6px; font-size:11px; font-weight:600; padding:2px 8px; border-radius:12px; background:var(--brand-light); color:var(--brand); } +*, *::before, *::after { + box-sizing: border-box; +} -.sidebar-nav { padding:16px 10px; flex:1; overflow-y:auto; } -.nav-group-title { font-size:11px; font-weight:700; color:#94a3b8; letter-spacing:.05em; text-transform:uppercase; padding:10px 10px 6px; } -.nav-group-title:not(:first-child) { margin-top:12px; } -.nav-item { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:8px; font-size:13.5px; font-weight:550; color:#475569; transition:all .15s ease; margin-bottom:3px; } -.nav-item:hover { background:#f1f5f9; color:#0f172a; } -.nav-item.active { background:var(--brand-light); color:var(--brand); font-weight:650; } -.nav-icon { width:18px; height:18px; display:inline-flex; align-items:center; justify-content:center; font-style:normal; } -.app-icon { width:1em; height:1em; display:block; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; } -.nav-icon .app-icon { width:18px; height:18px; } +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Inter, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + color: var(--ink); + background-color: var(--bg-app); + font-size: 14px; + line-height: 1.5; +} -.sidebar-foot { padding:14px 16px; border-top:1px solid var(--line); background:#fafafa; display:flex; align-items:center; justify-content:space-between; gap:10px; } -.user-card-inner { display:flex; align-items:center; gap:10px; flex:1; min-width:0; } -.user-avatar { width:34px; height:34px; border-radius:10px; background:#eef2ff; color:#4f46e5; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; border:1px solid #c7d2fe; flex-shrink:0; } -.user-meta { flex:1; min-width:0; } -.user-name { font-size:13.5px; font-weight:700; color:#0f172a; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } -.user-role { font-size:11px; color:#64748b; margin-top:1px; } +a { + color: inherit; + text-decoration: none; + transition: color 0.15s ease; +} -.logout-icon-btn { background:transparent; border:none; color:#64748b; width:34px; height:34px; border-radius:8px; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:all 0.15s ease; flex-shrink:0; padding:0; } -.logout-icon-btn:hover { background:#fef2f2; color:#ef4444; } -.sidebar-action-btn { background:transparent; border:none; color:#64748b; width:34px; height:34px; border-radius:8px; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:all 0.15s ease; flex-shrink:0; padding:0; } -.sidebar-action-btn:hover { background:#eef2ff; color:#4f46e5; } +/* Base App Layout */ +.console-app { + display: flex; + min-height: 100vh; +} -.main-wrapper { flex:1; margin-left:var(--sidebar-width); min-width:0; } -.main-topbar { height:60px; padding:0 32px; background:#fff; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:5; } -.page-title { font-size:18px; font-weight:700; margin:0; } +/* ========================================================================== + Sidebar Navigation (Left Rail) + ========================================================================== */ -.container { width:100%; max-width:1160px; padding:30px 32px 60px; margin:0 auto; } -.auth-wrap { min-height:calc(100vh - 64px); display:grid; place-items:center; padding:32px 16px; } -.auth-card { width:min(430px,100%); } +.sidebar { + width: var(--sidebar-width); + background: var(--bg-card); + border-right: 1px solid var(--line); + display: flex; + flex-direction: column; + justify-content: space-between; + position: fixed; + top: 0; + bottom: 0; + left: 0; + z-index: 20; + user-select: none; +} -.card { background:#fff; border:1px solid var(--line); border-radius:14px; padding:22px; box-shadow:0 1px 3px rgba(15,23,42,.03); scroll-margin-top:80px; } -.card + .card { margin-top:20px; } -.title { margin:0 0 7px; font-size:25px; letter-spacing:-.02em; } -.subtitle,.muted { color:var(--muted); } -.subtitle { margin:0 0 24px; line-height:1.6; } -.field { margin:15px 0; } -.field label { display:block; font-size:13px; font-weight:650; margin-bottom:7px; } -input,select { width:100%; height:40px; border:1px solid #cbd5e1; border-radius:8px; padding:0 12px; background:#fff; color:var(--ink); font-size:14px; } -input:focus { outline:3px solid #eef2ff; border-color:#818cf8; } -.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; height:38px; border:0; border-radius:8px; padding:0 14px; font-size:13.5px; font-weight:600; cursor:pointer; background:#f1f5f9; color:#334155; transition:background .15s ease; } -.btn:hover { background:#e2e8f0; } -.btn-primary { background:var(--brand); color:#fff; } -.btn-primary:hover { background:#4338ca; } -.btn-danger { background:#fef2f2; color:var(--danger); } -.btn-danger:hover { background:#fee2e2; } -.btn-small { height:32px; padding:0 10px; font-size:12px; } -.btn-block { width:100%; } -.flash { margin-bottom:16px; border-radius:10px; padding:12px 16px; font-size:14px; background:#ecfdf3; color:#027a48; border:1px solid #abf5d1; } -.flash.error { background:#fef3f2; color:var(--danger); border-color:#fecdca; } +.sidebar-head { + padding: 16px 16px 14px; + border-bottom: 1px solid var(--line); + display: flex; + flex-direction: column; + gap: 8px; +} -/* 浮动气泡卡片提示 (Toast Notification) */ -.toast-container { position:fixed; top:20px; left:calc(50% + var(--sidebar-width) / 2); transform:translateX(-50%); z-index:9999; display:flex; flex-direction:column; align-items:center; gap:10px; pointer-events:none; width:auto; max-width:min(520px, calc(100vw - 32px)); } -.toast-bubble { pointer-events:auto; display:flex; align-items:center; gap:12px; min-width:260px; max-width:100%; padding:12px 18px; border-radius:12px; font-size:14px; font-weight:550; line-height:1.4; background:#ffffff; box-shadow:0 10px 28px -4px rgba(15,23,42,0.12), 0 4px 10px -2px rgba(15,23,42,0.05); border:1px solid #e2e8f0; transition:opacity 0.25s ease, transform 0.25s ease; animation:toastSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; } -.toast-bubble.toast-hiding { opacity:0; transform:translateY(-16px) scale(0.95); pointer-events:none; } -@keyframes toastSlideIn { 0% { opacity:0; transform:translateY(-24px) scale(0.94); } 100% { opacity:1; transform:translateY(0) scale(1); } } -.toast-bubble.toast-success { background:#f0fdf4; border-color:#bbf7d0; color:#166534; } -.toast-bubble.toast-success .toast-icon { color:#16a34a; } -.toast-bubble.toast-error { background:#fef2f2; border-color:#fecaca; color:#991b1b; } -.toast-bubble.toast-error .toast-icon { color:#dc2626; } -.toast-bubble.toast-warning { background:#fffbeb; border-color:#fde68a; color:#92400e; } -.toast-bubble.toast-warning .toast-icon { color:#d97706; } -.toast-bubble.toast-info { background:#eef2ff; border-color:#c7d2fe; color:#3730a3; } -.toast-bubble.toast-info .toast-icon { color:#4f46e5; } -.toast-icon { flex-shrink:0; display:flex; align-items:center; justify-content:center; } -.toast-content { flex:1; word-break:break-word; } -.toast-close { flex-shrink:0; background:transparent; border:none; font-size:18px; line-height:1; width:22px; height:22px; cursor:pointer; color:currentColor; opacity:0.5; border-radius:50%; display:flex; align-items:center; justify-content:center; transition:opacity 0.15s, background 0.15s; margin-left:6px; } -.toast-close:hover { opacity:1; background:rgba(0,0,0,0.06); } +.brand { + display: flex; + align-items: center; + gap: 10px; + font-weight: 750; + font-size: 15px; + color: var(--ink); + letter-spacing: -0.02em; +} -/* 自定义确认弹窗 (Custom Confirmation Modal) */ -.modal-backdrop { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(15,23,42,0.5); backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px); z-index:10000; display:flex; align-items:center; justify-content:center; padding:20px; opacity:0; transition:opacity 0.2s ease; } -.modal-backdrop.modal-open { opacity:1; } -.modal-card { background:#ffffff; border-radius:16px; border:1px solid #e2e8f0; box-shadow:0 20px 30px -6px rgba(15,23,42,0.16), 0 10px 15px -4px rgba(15,23,42,0.08); width:100%; max-width:440px; padding:24px; transform:scale(0.94) translateY(8px); transition:transform 0.22s cubic-bezier(0.16, 1, 0.3, 1); } -.modal-backdrop.modal-open .modal-card { transform:scale(1) translateY(0); } -.modal-header { display:flex; align-items:flex-start; gap:16px; } -.modal-icon-wrap { width:44px; height:44px; border-radius:12px; flex-shrink:0; display:flex; align-items:center; justify-content:center; } -.modal-icon-wrap.danger { background:#fef2f2; color:#ef4444; border:1px solid #fecaca; } -.modal-icon-wrap.warning { background:#fffbeb; color:#f59e0b; border:1px solid #fde68a; } -.modal-icon-wrap.primary { background:#eef2ff; color:#4f46e5; border:1px solid #c7d2fe; } -.modal-title { margin:0 0 6px; font-size:17px; font-weight:700; color:#0f172a; } -.modal-desc { margin:0; font-size:14px; line-height:1.5; color:#64748b; } -.modal-footer { display:flex; align-items:center; justify-content:flex-end; gap:10px; margin-top:24px; } -.modal-footer .btn { min-width:80px; height:38px; padding:0 16px; font-size:14px; border-radius:8px; } -.btn-secondary { background:#f8fafc; border:1px solid #cbd5e1; color:#475569; } -.btn-secondary:hover { background:#f1f5f9; color:#0f172a; } +.brand img { + width: 28px; + height: 28px; + border-radius: var(--radius-md); + box-shadow: 0 2px 5px rgba(0,0,0,0.06); +} -.page-head { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:24px; } -.page-head h1 { margin:0 0 6px; font-size:26px; } -.stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:16px; margin-bottom:20px; align-items:stretch; } -.stats > .card, .grid-2 > .card, .dashboard-charts-grid > .card { margin-top:0; } -.stat { display:flex; flex-direction:column; justify-content:space-between; height:100%; } -.stat strong { display:block; font-size:28px; margin-top:8px; color:#0f172a; } -.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:stretch; } -.grid-2 > .card { display:flex; flex-direction:column; justify-content:flex-start; height:100%; } +.role-badge { + align-self: flex-start; + display: inline-flex; + align-items: center; + gap: 4px; + font-size: 11px; + font-weight: 600; + padding: 2px 8px; + border-radius: 9999px; + background: var(--brand-light); + color: var(--brand); + border: 1px solid var(--brand-border); +} -.card h2 { margin:0 0 5px; font-size:17px; } -.row { display:flex; align-items:center; gap:10px; } -.between { justify-content:space-between; } -.stack { display:flex; flex-direction:column; gap:10px; } -.key { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; background:#f1f5f9; border:1px solid #e2e8f0; border-radius:6px; padding:4px 10px; font-size:12.5px; color:#334155; display:inline-block; letter-spacing:0.03em; max-width:100%; vertical-align:middle; } -.secret { background:#0f172a; color:#f8fafc; padding:16px; border-radius:10px; overflow-wrap:anywhere; font-family:ui-monospace,SFMono-Regular,monospace; font-size:13px; } -.badge { display:inline-flex; padding:3px 9px; border-radius:20px; font-size:12px; font-weight:600; background:#ecfdf3; color:#027a48; } -.badge.off { background:#fef3f2; color:#b42318; } -.notice { padding:14px 16px; border:1px solid #fde68a; background:#fffbeb; color:#92400e; border-radius:10px; margin-bottom:20px; font-size:14px; } -.table-wrap { overflow:auto; } -table { width:100%; border-collapse:collapse; font-size:13.5px; table-layout:fixed; } -th,td { text-align:left; padding:12px 12px; border-bottom:1px solid #f1f5f9; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } -th { color:#64748b; font-weight:600; background:#f8fafc; } -.inline-form { display:flex; align-items:center; gap:7px; } -.inline-form input { width:auto; min-width:260px; height:34px; } -.inline-form input[type=number] { min-width:70px; width:80px; } -.inline-form input[type=date] { min-width:130px; width:140px; } -.inline-form input[type=checkbox] { min-width:auto; width:17px; height:17px; } -.code { margin:12px 0 0; background:#0f172a; color:#cbd5e1; padding:14px; border-radius:8px; overflow:auto; font:12.5px/1.6 ui-monospace,SFMono-Regular,monospace; } -.chart-container { position:relative; width:100%; } -.chart-tooltip { position:absolute; display:none; pointer-events:none; background:rgba(255,255,255,0.96); color:#0f172a; padding:10px 14px; border-radius:10px; font-size:12px; line-height:1.6; border:1px solid #e2e8f0; box-shadow:0 10px 25px -5px rgba(15,23,42,0.12),0 4px 10px -2px rgba(15,23,42,0.05); z-index:20; backdrop-filter:blur(8px); white-space:nowrap; transition:left 0.06s ease, top 0.06s ease, opacity 0.1s ease, transform 0.1s ease; opacity:0; transform:translateY(4px); } -.chart-tooltip.active { display:block; opacity:1; transform:translateY(0); } -.chart-tooltip .tt-title { font-weight:700; margin-bottom:5px; color:#475569; border-bottom:1px solid #f1f5f9; padding-bottom:4px; font-size:12.5px; } -.chart-tooltip .tt-row { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:3px; color:#475569; } -.chart-tooltip .tt-row strong { color:#0f172a; } -.chart-tooltip .tt-dot { width:8px; height:8px; border-radius:50%; display:inline-block; } -.point-circle { transition: r .15s ease, stroke-width .15s ease; } +.sidebar-nav { + padding: 14px 10px; + flex: 1; + overflow-y: auto; +} -/* 开关与配置列表布局 */ -.settings-list { display: flex; flex-direction: column; margin: 16px 0 24px 0; } -.setting-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); gap: 16px; } -.setting-item:last-child { border-bottom: none; } -.setting-info { display: flex; flex-direction: column; gap: 4px; } -.setting-title { font-size: 14.5px; font-weight: 600; color: var(--ink); } -.setting-desc { font-size: 13px; color: var(--muted); } -.setting-control { display: flex; align-items: center; gap: 10px; flex-shrink: 0; } +.sidebar-nav::-webkit-scrollbar { + width: 4px; +} +.sidebar-nav::-webkit-scrollbar-thumb { + background: #cbd5e1; + border-radius: 4px; +} -/* iOS 风格平滑切换开关 (Switch) */ -.switch { position: relative; display: inline-block; width: 46px; height: 24px; flex-shrink: 0; } -.switch input { opacity: 0; width: 0; height: 0; margin: 0; } -.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: background-color .2s ease, box-shadow .2s ease; border-radius: 24px; } -.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: #ffffff; transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 50%; box-shadow: 0 1px 3px rgba(15,23,42,0.2); } -.switch input:checked + .slider { background-color: var(--brand); } -.switch input:focus-visible + .slider { box-shadow: 0 0 0 2px var(--brand-light), 0 0 0 4px var(--brand); } -.switch input:checked + .slider:before { transform: translateX(22px); } +.nav-group-title { + font-size: 11px; + font-weight: 700; + color: var(--ink-subtle); + letter-spacing: 0.06em; + text-transform: uppercase; + padding: 10px 10px 4px; +} -/* 表格小尺寸开关 */ -.switch-sm { width: 38px; height: 20px; } -.switch-sm .slider:before { height: 14px; width: 14px; left: 3px; bottom: 3px; } -.switch-sm input:checked + .slider:before { transform: translateX(18px); } +.nav-group-title:not(:first-child) { + margin-top: 14px; +} +.nav-item { + display: flex; + align-items: center; + gap: 10px; + padding: 8px 12px; + border-radius: var(--radius-md); + font-size: 13.5px; + font-weight: 500; + color: var(--ink-secondary); + transition: all 0.15s ease; + margin-bottom: 2px; + position: relative; +} -/* 周期切换按钮组 */ -.period-tabs { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 3px; gap: 2px; border: 1px solid #e2e8f0; } -.period-tab { padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: #64748b; border-radius: 6px; text-decoration: none; transition: all .15s ease; cursor: pointer; border: none; background: transparent; } -.period-tab:hover { color: #0f172a; } -.period-tab.active { background: #ffffff; color: var(--brand); box-shadow: 0 1px 3px rgba(15,23,42,0.08); font-weight: 700; } +.nav-item:hover { + background: var(--bg-subtle); + color: var(--ink); +} -/* 动态图表网格双栏 */ -.dashboard-charts-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; } +.nav-item.active { + background: var(--brand-light); + color: var(--brand); + font-weight: 600; +} -/* 饼图样式 */ -.pie-wrapper { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; padding: 6px 0; } -.pie-svg-box { position: relative; width: 170px; height: 170px; flex-shrink: 0; } -.pie-center-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; } -.pie-center-val { font-size: 22px; font-weight: 800; color: #0f172a; line-height: 1; } -.pie-center-lbl { font-size: 11px; color: #64748b; margin-top: 3px; } +.nav-item.active::before { + content: ""; + position: absolute; + left: 0; + top: 6px; + bottom: 6px; + width: 3px; + background: var(--brand); + border-radius: 0 4px 4px 0; +} -.pie-slice { transition: opacity 0.2s ease, transform 0.2s ease; cursor: pointer; transform-origin: 100px 100px; } -.pie-slice:hover { opacity: 0.85; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15)); } +.nav-icon { + width: 18px; + height: 18px; + display: inline-flex; + align-items: center; + justify-content: center; + flex-shrink: 0; +} -/* 饼图下方平铺图例 (Pill Tags Legend Grid) */ -.pie-pill-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 12px; margin-top: 12px; width: 100%; max-height: 200px; overflow-y: auto; padding: 4px; } -.pie-pill-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #f8fafc; border: 1px solid #f1f5f9; transition: all .15s ease; } -.pie-pill-item:hover { background: #f1f5f9; border-color: #cbd5e1; } -.pie-pill-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; } -.pie-pill-name { font-weight: 550; color: #334155; } -.pie-pill-val { font-weight: 700; color: #0f172a; margin-left: 2px; } +.app-icon { + width: 1em; + height: 1em; + display: block; + fill: none; + stroke: currentColor; + stroke-width: 1.9; + stroke-linecap: round; + stroke-linejoin: round; +} -/* 柱状排行榜 (Top 10 Ranking Bars) */ -.ranking-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; } -.ranking-item { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; } -.ranking-head { display: flex; justify-content: space-between; align-items: center; } -.ranking-name { font-weight: 600; color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; } -.ranking-val { font-weight: 700; color: var(--brand); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; } -.ranking-bar-bg { width: 100%; height: 10px; background: #f1f5f9; border-radius: 6px; overflow: hidden; position: relative; } -.ranking-bar-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5); border-radius: 6px; transition: width 0.4s ease; } +.nav-icon .app-icon { + width: 18px; + height: 18px; +} -@media(max-width:840px){ - .console-app { flex-direction:column; } - .sidebar { width:100%; position:relative; height:auto; border-right:0; border-bottom:1px solid var(--line); } - .main-wrapper { margin-left:0; } - .main-topbar { padding:0 16px; } - .toast-container { left:50%; } - .stats,.grid-2 { grid-template-columns:1fr; } - .container { padding:16px; } +.sidebar-foot { + padding: 12px 14px; + border-top: 1px solid var(--line); + background: #fafafa; + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} + +.user-card-inner { + display: flex; + align-items: center; + gap: 10px; + flex: 1; + min-width: 0; +} + +.user-avatar { + width: 32px; + height: 32px; + border-radius: var(--radius-md); + background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%); + color: var(--brand); + display: flex; + align-items: center; + justify-content: center; + font-weight: 700; + font-size: 13.5px; + border: 1px solid var(--brand-border); + flex-shrink: 0; +} + +.user-meta { + flex: 1; + min-width: 0; +} + +.user-name { + font-size: 13px; + font-weight: 650; + color: var(--ink); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.user-role { + font-size: 11px; + color: var(--ink-muted); + margin-top: 1px; +} + +.sidebar-action-btn, .logout-icon-btn { + background: transparent; + border: none; + color: var(--ink-muted); + width: 32px; + height: 32px; + border-radius: var(--radius-md); + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: all 0.15s ease; + flex-shrink: 0; + padding: 0; +} + +.sidebar-action-btn:hover { + background: var(--brand-light); + color: var(--brand); +} + +.logout-icon-btn:hover { + background: var(--danger-bg); + color: var(--danger); +} + +/* ========================================================================== + Main Content Area & Topbar + ========================================================================== */ + +.main-wrapper { + flex: 1; + margin-left: var(--sidebar-width); + min-width: 0; + display: flex; + flex-direction: column; +} + +.main-topbar { + height: var(--topbar-height); + padding: 0 32px; + background: rgba(255, 255, 255, 0.88); + backdrop-filter: blur(12px); + -webkit-backdrop-filter: blur(12px); + border-bottom: 1px solid var(--line); + display: flex; + align-items: center; + justify-content: space-between; + position: sticky; + top: 0; + z-index: 10; +} + +.topbar-left { + display: flex; + align-items: center; + gap: 12px; +} + +.topbar-breadcrumb { + display: flex; + align-items: center; + gap: 6px; + font-size: 12.5px; + color: var(--ink-subtle); +} + +.topbar-breadcrumb a:hover { + color: var(--ink); +} + +.topbar-separator { + color: #cbd5e1; +} + +.page-title { + font-size: 16px; + font-weight: 700; + color: var(--ink); + margin: 0; + letter-spacing: -0.01em; +} + +.topbar-right { + display: flex; + align-items: center; + gap: 10px; +} + +.topbar-link { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 12.5px; + font-weight: 550; + color: var(--ink-secondary); + padding: 5px 12px; + border-radius: var(--radius-md); + border: 1px solid var(--line); + background: var(--bg-card); + transition: all 0.15s ease; +} + +.topbar-link:hover { + background: var(--bg-subtle); + border-color: #cbd5e1; + color: var(--ink); +} + +.status-pill { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 12px; + font-weight: 550; + padding: 4px 10px; + border-radius: 9999px; + background: var(--bg-subtle); + color: var(--ink-secondary); + border: 1px solid var(--line); +} + +.status-pill.online { + background: var(--success-bg); + color: var(--success-text); + border-color: var(--success-border); +} + +.status-pill.offline { + background: var(--danger-bg); + color: var(--danger-text); + border-color: var(--danger-border); +} + +.status-dot { + width: 7px; + height: 7px; + border-radius: 50%; + background: currentColor; +} + +.status-dot.pulse { + animation: pulseDot 2s infinite; +} + +@keyframes pulseDot { + 0% { opacity: 1; transform: scale(1); } + 50% { opacity: 0.4; transform: scale(0.85); } + 100% { opacity: 1; transform: scale(1); } +} + +.container { + width: 100%; + max-width: 1200px; + padding: 28px 32px 60px; + margin: 0 auto; +} + +/* ========================================================================== + Page Headers & Metric KPI Cards + ========================================================================== */ + +.page-head { + display: flex; + justify-content: space-between; + align-items: flex-start; + gap: 20px; + margin-bottom: 24px; +} + +.page-head h1 { + margin: 0 0 6px; + font-size: 22px; + font-weight: 800; + letter-spacing: -0.03em; + color: var(--ink); +} + +.card { + background: var(--bg-card); + border: 1px solid var(--line); + border-radius: var(--radius-xl); + padding: 22px 24px; + box-shadow: var(--shadow-xs); + transition: box-shadow 0.2s ease, border-color 0.2s ease; + scroll-margin-top: 80px; +} + +.card + .card { + margin-top: 20px; +} + +.card-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 16px; + gap: 12px; + flex-wrap: wrap; +} + +.card h2 { + margin: 0 0 4px; + font-size: 15px; + font-weight: 700; + color: var(--ink); + letter-spacing: -0.01em; +} + +.title { + margin: 0 0 8px; + font-size: 24px; + font-weight: 800; + letter-spacing: -0.03em; + color: var(--ink); +} + +.subtitle, .muted { + color: var(--ink-muted); +} + +.subtitle { + margin: 0 0 24px; + font-size: 13.5px; + line-height: 1.6; +} + +/* KPI Statistics Grid */ +.stats { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 16px; + margin-bottom: 24px; + align-items: stretch; +} + +.stats > .card, .grid-2 > .card, .dashboard-charts-grid > .card { + margin-top: 0; +} + +.stat { + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 18px 20px; + border-radius: var(--radius-lg); + background: var(--bg-card); + border: 1px solid var(--line); + box-shadow: var(--shadow-xs); + transition: all 0.2s ease; + position: relative; + overflow: hidden; + height: 100%; +} + +.stat:hover { + border-color: #cbd5e1; + box-shadow: var(--shadow-sm); + transform: translateY(-1px); +} + +.stat-head { + display: flex; + align-items: center; + justify-content: space-between; +} + +.stat-label { + font-size: 12.5px; + font-weight: 550; + color: var(--ink-muted); +} + +.stat-icon { + width: 28px; + height: 28px; + border-radius: var(--radius-sm); + background: var(--bg-subtle); + color: var(--ink-secondary); + display: flex; + align-items: center; + justify-content: center; +} + +.stat strong { + display: block; + font-size: 26px; + font-weight: 800; + letter-spacing: -0.03em; + color: var(--ink); + margin-top: 10px; + font-variant-numeric: tabular-nums; + line-height: 1.15; +} + +.stat-foot { + margin-top: 8px; + font-size: 11.5px; + color: var(--ink-subtle); +} + +/* Two-column responsive grid */ +.grid-2 { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 20px; + align-items: stretch; +} + +.grid-2 > .card { + display: flex; + flex-direction: column; + justify-content: flex-start; + height: 100%; +} + +.row { + display: flex; + align-items: center; + gap: 10px; +} + +.between { + justify-content: space-between; +} + +.stack { + display: flex; + flex-direction: column; + gap: 10px; +} + +/* ========================================================================== + Interactive Controls & Forms + ========================================================================== */ + +.field { + margin: 16px 0; +} + +.field label { + display: block; + font-size: 13px; + font-weight: 600; + color: var(--ink-secondary); + margin-bottom: 6px; +} + +input, select, textarea { + width: 100%; + height: 38px; + border: 1px solid #cbd5e1; + border-radius: var(--radius-md); + padding: 0 12px; + background: var(--bg-card); + color: var(--ink); + font-size: 13.5px; + font-family: inherit; + transition: all 0.15s ease; +} + +input:focus, select:focus, textarea:focus { + outline: none; + border-color: var(--brand); + box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); +} + +input::placeholder { + color: #94a3b8; +} + +/* Buttons */ +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + height: 36px; + border: 1px solid transparent; + border-radius: var(--radius-md); + padding: 0 14px; + font-size: 13px; + font-weight: 600; + font-family: inherit; + cursor: pointer; + background: var(--bg-subtle); + color: var(--ink-secondary); + transition: all 0.15s ease; + user-select: none; + white-space: nowrap; +} + +.btn:hover { + background: #e2e8f0; + color: var(--ink); +} + +.btn-primary { + background: var(--brand); + color: #ffffff; + border-color: var(--brand); + box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2); +} + +.btn-primary:hover { + background: var(--brand-hover); + border-color: var(--brand-hover); + box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25); +} + +.btn-secondary { + background: var(--bg-card); + border: 1px solid #cbd5e1; + color: var(--ink-secondary); + box-shadow: var(--shadow-xs); +} + +.btn-secondary:hover { + background: var(--bg-subtle); + border-color: #94a3b8; + color: var(--ink); +} + +.btn-danger { + background: var(--danger-bg); + border-color: var(--danger-border); + color: var(--danger); +} + +.btn-danger:hover { + background: #fee2e2; + border-color: #fca5a5; + color: var(--danger-hover); +} + +.btn-small { + height: 28px; + padding: 0 9px; + font-size: 12px; + border-radius: var(--radius-sm); +} + +.btn-block { + width: 100%; +} + +/* Badges & Tags */ +.badge { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 2px 8px; + border-radius: 9999px; + font-size: 11.5px; + font-weight: 600; + background: var(--success-bg); + color: var(--success-text); + border: 1px solid var(--success-border); +} + +.badge.off { + background: var(--danger-bg); + color: var(--danger-text); + border-color: var(--danger-border); +} + +.badge.brand { + background: var(--brand-light); + color: var(--brand); + border-color: var(--brand-border); +} + +.badge.neutral { + background: var(--bg-subtle); + color: var(--ink-secondary); + border-color: var(--line); +} + +.key { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + background: var(--bg-subtle); + border: 1px solid var(--line); + border-radius: var(--radius-sm); + padding: 3px 8px; + font-size: 12px; + color: var(--ink-secondary); + display: inline-block; + letter-spacing: 0.02em; +} + +.secret { + background: #0f172a; + color: #f8fafc; + padding: 16px; + border-radius: var(--radius-lg); + overflow-wrap: anywhere; + font-family: ui-monospace, SFMono-Regular, Menlo, monospace; + font-size: 13px; + line-height: 1.6; + border: 1px solid #1e293b; + box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); +} + +.notice { + padding: 14px 18px; + border: 1px solid var(--warning-border); + background: var(--warning-bg); + color: var(--warning-text); + border-radius: var(--radius-lg); + margin-bottom: 20px; + font-size: 13.5px; + display: flex; + align-items: center; + gap: 10px; +} + +.code { + margin: 12px 0 0; + background: #0f172a; + color: #e2e8f0; + padding: 16px 18px; + border-radius: var(--radius-lg); + overflow: auto; + font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + border: 1px solid #1e293b; +} + +/* ========================================================================== + Modern Enterprise Data Tables + ========================================================================== */ + +.table-wrap { + width: 100%; + overflow-x: auto; + border: 1px solid var(--line); + border-radius: var(--radius-lg); + background: var(--bg-card); + box-shadow: var(--shadow-xs); +} + +table { + width: 100%; + border-collapse: collapse; + font-size: 13px; + text-align: left; +} + +thead { + background: var(--bg-subtle); + border-bottom: 1px solid var(--line); +} + +th { + color: var(--ink-secondary); + font-weight: 650; + font-size: 12px; + padding: 11px 16px; + letter-spacing: 0.01em; + white-space: nowrap; +} + +td { + padding: 12px 16px; + border-bottom: 1px solid var(--line-subtle); + color: var(--ink); + vertical-align: middle; +} + +tbody tr { + transition: background-color 0.12s ease; +} + +tbody tr:hover { + background-color: #f8fafc; +} + +tbody tr:last-child td { + border-bottom: none; +} + +/* Table Inline Controls */ +table input[type="date"], +table input[type="number"], +table select { + height: 30px; + padding: 0 8px; + font-size: 12.5px; + border-radius: var(--radius-sm); + border: 1px solid #cbd5e1; + background: #ffffff; +} + +table input[type="number"] { + text-align: right; +} + +/* iOS Style Smooth Toggle Switch */ +.switch { + position: relative; + display: inline-block; + width: 42px; + height: 22px; + flex-shrink: 0; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; + margin: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #cbd5e1; + transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1); + border-radius: 9999px; +} + +.slider:before { + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 3px; + bottom: 3px; + background-color: #ffffff; + transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); + border-radius: 50%; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); +} + +.switch input:checked + .slider { + background-color: var(--brand); +} + +.switch input:focus-visible + .slider { + box-shadow: 0 0 0 2px var(--brand-light), 0 0 0 4px var(--brand); +} + +.switch input:checked + .slider:before { + transform: translateX(20px); +} + +.switch-sm { + width: 36px; + height: 19px; +} + +.switch-sm .slider:before { + height: 13px; + width: 13px; + left: 3px; + bottom: 3px; +} + +.switch-sm input:checked + .slider:before { + transform: translateX(17px); +} + +/* ========================================================================== + Segmented Controls & Modern Charts + ========================================================================== */ + +.period-tabs { + display: inline-flex; + background: var(--bg-subtle); + border-radius: var(--radius-md); + padding: 3px; + gap: 2px; + border: 1px solid var(--line); +} + +.period-tab { + padding: 5px 12px; + font-size: 12.5px; + font-weight: 550; + color: var(--ink-muted); + border-radius: var(--radius-sm); + text-decoration: none; + transition: all 0.15s ease; + cursor: pointer; + border: none; + background: transparent; + user-select: none; +} + +.period-tab:hover { + color: var(--ink); +} + +.period-tab.active { + background: #ffffff; + color: var(--brand); + box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); + font-weight: 650; +} + +.dashboard-charts-grid { + display: grid; + grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); + gap: 20px; + margin-top: 20px; + align-items: start; +} + +.chart-container { + position: relative; + width: 100%; +} + +.chart-tooltip { + position: absolute; + display: none; + pointer-events: none; + background: rgba(255, 255, 255, 0.95); + backdrop-filter: blur(12px); + -webkit-backdrop-filter: blur(12px); + color: var(--ink); + padding: 10px 14px; + border-radius: var(--radius-lg); + font-size: 12px; + line-height: 1.5; + border: 1px solid var(--line); + box-shadow: var(--shadow-lg); + z-index: 20; + white-space: nowrap; + transition: left 0.06s ease, top 0.06s ease, opacity 0.15s ease, transform 0.15s ease; + opacity: 0; + transform: translateY(4px); +} + +.chart-tooltip.active { + display: block; + opacity: 1; + transform: translateY(0); +} + +.chart-tooltip .tt-title { + font-weight: 700; + margin-bottom: 6px; + color: var(--ink-secondary); + border-bottom: 1px solid var(--line-subtle); + padding-bottom: 4px; + font-size: 12px; +} + +.chart-tooltip .tt-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; + margin-top: 3px; + color: var(--ink-secondary); +} + +.chart-tooltip .tt-row strong { + color: var(--ink); + font-variant-numeric: tabular-nums; +} + +.chart-tooltip .tt-dot { + width: 7px; + height: 7px; + border-radius: 50%; + display: inline-block; +} + +.chart-hover-dot { + transition: cx 0.06s ease, cy 0.06s ease; + filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.22)); +} + +/* Donut & Ranking Components */ +.pie-wrapper { + display: flex; + flex-direction: column; + gap: 16px; + align-items: center; + justify-content: center; + padding: 10px 0; +} + +.pie-svg-box { + position: relative; + width: 180px; + height: 180px; + flex-shrink: 0; +} + +.pie-center-text { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + text-align: center; + pointer-events: none; + width: 120px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 4px; +} + +.pie-center-lbl { + font-size: 12px; + color: var(--ink-muted); + white-space: nowrap; + line-height: 1; + transition: all 0.15s ease; +} + +.pie-center-val { + font-size: 21px; + font-weight: 800; + color: var(--ink); + line-height: 1.15; + font-variant-numeric: tabular-nums; + letter-spacing: -0.02em; + word-break: keep-all; + white-space: nowrap; + transition: all 0.15s ease; +} + +.pie-slice { + transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); + cursor: pointer; + transform-origin: 100px 100px; +} + +.pie-slice:hover, .pie-slice.active { + opacity: 0.95; + transform: scale(1.05); + filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2)); +} + +/* 50+ 平台紧凑居中图例 (完全对齐图片设计:圆点 + 平台名称) */ +.pie-pill-grid { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + gap: 8px 16px; + margin-top: 14px; + width: 100%; + max-height: 220px; + overflow-y: auto; + padding: 4px 8px; +} + +.pie-pill-grid::-webkit-scrollbar { + width: 4px; +} +.pie-pill-grid::-webkit-scrollbar-thumb { + background: #cbd5e1; + border-radius: 4px; +} + +.pie-pill-item { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 12.5px; + color: var(--ink-secondary); + cursor: pointer; + background: transparent; + border: none; + padding: 3px 6px; + border-radius: var(--radius-sm); + transition: all 0.15s ease; + user-select: none; +} + +.pie-pill-item:hover, .pie-pill-item.active { + color: var(--ink); + background: var(--bg-subtle); + transform: translateY(-1px); +} + +.pie-pill-dot { + width: 9px; + height: 9px; + border-radius: 50%; + flex-shrink: 0; +} + +.pie-pill-name { + font-weight: 500; + color: inherit; + white-space: nowrap; +} + +/* Ranking Bars */ +.ranking-list { + display: flex; + flex-direction: column; + gap: 12px; + margin-top: 8px; +} + +.ranking-item { + display: flex; + flex-direction: column; + gap: 5px; + font-size: 12.5px; +} + +.ranking-head { + display: flex; + justify-content: space-between; + align-items: center; +} + +.ranking-name { + font-weight: 600; + color: var(--ink-secondary); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 220px; + display: flex; + align-items: center; + gap: 6px; +} + +.ranking-badge { + display: inline-flex; + align-items: center; + justify-content: center; + width: 18px; + height: 18px; + border-radius: 4px; + font-size: 10.5px; + font-weight: 700; + background: var(--bg-subtle); + color: var(--ink-muted); +} + +.ranking-item:nth-child(1) .ranking-badge { + background: #fef3c7; + color: #b45309; +} +.ranking-item:nth-child(2) .ranking-badge { + background: #f1f5f9; + color: #475569; +} +.ranking-item:nth-child(3) .ranking-badge { + background: #ffedd5; + color: #c2410c; +} + +.ranking-val { + font-weight: 700; + color: var(--brand); + font-variant-numeric: tabular-nums; + font-size: 12px; +} + +.ranking-bar-bg { + width: 100%; + height: 8px; + background: var(--bg-subtle); + border-radius: 9999px; + overflow: hidden; + position: relative; +} + +.ranking-bar-fill { + height: 100%; + background: linear-gradient(90deg, #6366f1, #4f46e5); + border-radius: 9999px; + transition: width 0.4s ease; +} + +/* ========================================================================== + Settings Page Specifics + ========================================================================== */ + +.settings-list { + display: flex; + flex-direction: column; +} + +.setting-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px 0; + border-bottom: 1px solid var(--line-subtle); + gap: 20px; +} + +.setting-item:last-child { + border-bottom: none; +} + +.setting-info { + display: flex; + flex-direction: column; + gap: 3px; + flex: 1; +} + +.setting-title { + font-size: 14px; + font-weight: 600; + color: var(--ink); +} + +.setting-desc { + font-size: 12.5px; + color: var(--ink-muted); + line-height: 1.45; +} + +.setting-control { + display: flex; + align-items: center; + gap: 10px; + flex-shrink: 0; +} + +/* ========================================================================== + Toasts & Modal Windows + ========================================================================== */ + +.toast-container { + position: fixed; + top: 20px; + left: calc(50% + var(--sidebar-width) / 2); + transform: translateX(-50%); + z-index: 9999; + display: flex; + flex-direction: column; + align-items: center; + gap: 10px; + pointer-events: none; + width: auto; + max-width: min(520px, calc(100vw - 32px)); +} + +.toast-bubble { + pointer-events: auto; + display: flex; + align-items: center; + gap: 12px; + min-width: 280px; + max-width: 100%; + padding: 12px 18px; + border-radius: var(--radius-lg); + font-size: 13.5px; + font-weight: 550; + line-height: 1.45; + background: #ffffff; + box-shadow: var(--shadow-xl); + border: 1px solid var(--line); + transition: opacity 0.22s ease, transform 0.22s var(--ease-out); + animation: toastSlideIn 0.3s var(--ease-out) forwards; +} + +.toast-bubble.toast-hiding { + opacity: 0; + transform: translateY(-16px) scale(0.95); + pointer-events: none; +} + +@keyframes toastSlideIn { + 0% { opacity: 0; transform: translateY(-20px) scale(0.96); } + 100% { opacity: 1; transform: translateY(0) scale(1); } +} + +.toast-bubble.toast-success { + background: #ffffff; + border-color: var(--success-border); + color: var(--success-text); +} +.toast-bubble.toast-success .toast-icon { color: var(--success); } + +.toast-bubble.toast-error { + background: #ffffff; + border-color: var(--danger-border); + color: var(--danger-text); +} +.toast-bubble.toast-error .toast-icon { color: var(--danger); } + +.toast-bubble.toast-warning { + background: #ffffff; + border-color: var(--warning-border); + color: var(--warning-text); +} +.toast-bubble.toast-warning .toast-icon { color: var(--warning); } + +.toast-bubble.toast-info { + background: #ffffff; + border-color: var(--brand-border); + color: var(--brand-active); +} +.toast-bubble.toast-info .toast-icon { color: var(--brand); } + +.toast-icon { + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; +} + +.toast-content { + flex: 1; + word-break: break-word; +} + +.toast-close { + flex-shrink: 0; + background: transparent; + border: none; + font-size: 18px; + line-height: 1; + width: 22px; + height: 22px; + cursor: pointer; + color: currentColor; + opacity: 0.5; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + transition: opacity 0.15s, background 0.15s; +} + +.toast-close:hover { + opacity: 1; + background: rgba(0, 0, 0, 0.05); +} + +/* Modals */ +.modal-backdrop { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(15, 23, 42, 0.45); + backdrop-filter: blur(6px); + -webkit-backdrop-filter: blur(6px); + z-index: 10000; + display: flex; + align-items: center; + justify-content: center; + padding: 20px; + opacity: 0; + transition: opacity 0.2s ease; +} + +.modal-backdrop.modal-open { + opacity: 1; +} + +.modal-card { + background: #ffffff; + border-radius: var(--radius-xl); + border: 1px solid var(--line); + box-shadow: var(--shadow-xl); + width: 100%; + max-width: 460px; + padding: 24px; + transform: scale(0.96) translateY(6px); + transition: transform 0.22s var(--ease-out); +} + +.modal-backdrop.modal-open .modal-card { + transform: scale(1) translateY(0); +} + +.modal-header { + display: flex; + align-items: flex-start; + gap: 16px; +} + +.modal-icon-wrap { + width: 42px; + height: 42px; + border-radius: var(--radius-lg); + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; +} + +.modal-icon-wrap.danger { + background: var(--danger-bg); + color: var(--danger); + border: 1px solid var(--danger-border); +} + +.modal-icon-wrap.warning { + background: var(--warning-bg); + color: var(--warning); + border: 1px solid var(--warning-border); +} + +.modal-icon-wrap.primary { + background: var(--brand-light); + color: var(--brand); + border: 1px solid var(--brand-border); +} + +.modal-title { + margin: 0 0 4px; + font-size: 16px; + font-weight: 700; + color: var(--ink); +} + +.modal-desc { + margin: 0; + font-size: 13.5px; + line-height: 1.5; + color: var(--ink-muted); +} + +.modal-footer { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 10px; + margin-top: 24px; +} + +/* ========================================================================== + Auth Pages (Login / Register / Setup) + ========================================================================== */ + +.auth-wrap { + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: 32px 16px; + background: radial-gradient(circle at 50% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 70%), var(--bg-app); +} + +.auth-card { + width: min(420px, 100%); +} + +.auth-brand { + display: flex; + flex-direction: column; + align-items: center; + margin-bottom: 24px; + text-align: center; +} + +.auth-brand img { + width: 44px; + height: 44px; + border-radius: var(--radius-lg); + box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15); + margin-bottom: 12px; +} + +.auth-brand h2 { + margin: 0; + font-size: 18px; + font-weight: 800; + color: var(--ink); +} + +.flash { + margin-bottom: 16px; + border-radius: var(--radius-md); + padding: 10px 14px; + font-size: 13px; + background: var(--success-bg); + color: var(--success-text); + border: 1px solid var(--success-border); + display: flex; + align-items: center; + gap: 8px; +} + +.flash.error { + background: var(--danger-bg); + color: var(--danger-text); + border-color: var(--danger-border); +} + +/* ========================================================================== + Responsive Breakpoints + ========================================================================== */ + +@media (max-width: 860px) { + .console-app { + flex-direction: column; + } + .sidebar { + width: 100%; + position: relative; + height: auto; + border-right: none; + border-bottom: 1px solid var(--line); + } + .main-wrapper { + margin-left: 0; + } + .main-topbar { + padding: 0 16px; + } + .toast-container { + left: 50%; + } + .stats, .grid-2, .dashboard-charts-grid { + grid-template-columns: 1fr; + } + .container { + padding: 20px 16px; + } } diff --git a/templates/admin/dashboard.html b/templates/admin/dashboard.html index 7c0a14b..ec62048 100644 --- a/templates/admin/dashboard.html +++ b/templates/admin/dashboard.html @@ -14,12 +14,41 @@ 超级管理员