:root {
    /* OPPO Inspired Palette */
    --bg-color: #F2F4F7;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --surface-white: #FFFFFF;
    
    /* Brand Colors */
    --primary: #2AD181;
    --primary-dark: #20BA72;
    --primary-gradient: linear-gradient(135deg, #2AD181 0%, #10B981 100%);
    
    /* Text Colors */
    --text-main: #1F1F1F;
    --text-sub: #757575;
    --text-light: #BFBFBF;
    
    /* Status */
    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --warning: #FF9800;
    --warning-bg: #FFF3E0;
    --danger: #D32F2F;
    --danger-bg: #FFEBEE;
    
    /* Dimensions & Spacing */
    --sidebar-width: 260px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.03);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Layout Structure */
.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    transition: var(--transition);
}

.logo-area {
    padding: 10px 0 40px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, #1D1D1F, #454545);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: var(--success-bg);
    color: var(--success);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-sub);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: rgba(0,0,0,0.03);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 16px rgba(42, 209, 129, 0.25);
}

.sidebar-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-top: 20px;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Top Bar */
.top-bar {
    height: 80px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(242, 244, 247, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.api-key-widget {
    display: flex;
    align-items: center;
    background: var(--surface-white);
    padding: 6px;
    border-radius: 50px;
    box-shadow: var(--shadow-card);
    width: 400px;
    border: 1px solid rgba(0,0,0,0.03);
    transition: var(--transition);
}

.api-key-widget:focus-within {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(42, 209, 129, 0.1);
}

.api-key-widget input {
    flex: 1;
    border: none;
    padding: 8px 16px;
    font-size: 0.95rem;
    outline: none;
    background: transparent;
}

.btn-connect {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-connect:hover {
    background: #000;
    transform: scale(1.05);
}

/* Scroll Area */
.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* Tabs Logic */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.full-width {
    grid-column: 1 / -1;
}

.card {
    background: var(--surface-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255,255,255,0.6);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Forms & Inputs */
.action-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

input, select {
    background: #FAFAFA;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    color: var(--text-main);
}

input:focus, select:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(42, 209, 129, 0.1);
}

.input-sm { width: 100px; }
.input-md { width: 200px; }
.input-lg { flex: 1; min-width: 200px; }

/* Buttons */
button { cursor: pointer; font-family: inherit; }

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(42, 209, 129, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #F5F5F5;
    color: var(--text-sub);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: #EEEEEE;
    color: var(--text-main);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-text:hover {
    text-decoration: underline;
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
}

.btn-success:hover { background: #D0E8D4; }

.btn-warning {
    background: var(--warning-bg);
    color: #E65100;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
}

.btn-warning:hover { background: #FFE0B2; }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
}

.btn-danger:hover { background: #FFCDD2; }

.btn-group {
    display: flex;
    gap: 8px;
}

.block { width: 100%; }

/* Results Box */
.result-box {
    margin-top: 20px;
    padding: 16px;
    background: #F8F9FA;
    border-radius: var(--radius-md);
    font-family: 'Menlo', monospace;
    font-size: 0.85rem;
    color: #555;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid transparent;
    max-height: 400px;
    overflow-y: auto;
}

.result-box:empty { display: none; }

.result-box.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(46, 125, 50, 0.1);
}

.result-box.error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(211, 47, 47, 0.1);
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 300px;
    border-left: 4px solid transparent;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DDD; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #CCC; }

/* Mobile & Responsive Design (OPPO Style) */
@media (max-width: 768px) {
    /* Structure */
    .app-wrapper {
        flex-direction: column;
        height: 100vh;
        overflow: hidden; /* Prevent body scroll, use content scroll */
    }

    /* Bottom Navigation (Sidebar transformed) */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 8px 12px 24px 12px; /* Extra padding for safe area */
        border-right: none;
        border-top: 1px solid rgba(0,0,0,0.05);
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        justify-content: space-around;
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
    }

    .logo-area, .sidebar-footer {
        display: none;
    }

    .nav-menu {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        gap: 0;
    }

    .nav-item {
        flex-direction: column;
        padding: 6px 0;
        gap: 4px;
        font-size: 0.7rem;
        color: var(--text-sub);
        flex: 1;
        justify-content: center;
        border-radius: 8px;
    }

    .nav-item .icon {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }

    .nav-item:hover {
        background: transparent;
        transform: none;
    }

    .nav-item.active {
        background: transparent;
        color: var(--primary);
        box-shadow: none;
    }
    
    .nav-item.active .icon {
        transform: translateY(-2px);
        transition: var(--transition);
    }

    /* Main Content */
    .main-content {
        height: 100%;
        padding-bottom: 80px; /* Space for bottom nav */
    }

    /* Top Bar */
    .top-bar {
        height: auto;
        padding: 16px 20px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        background: rgba(242, 244, 247, 0.85);
        position: sticky;
        top: 0;
    }

    .page-title {
        font-size: 1.2rem;
        text-align: center;
    }

    .api-key-widget {
        width: 100%;
        padding: 4px 6px;
        margin: 0;
    }
    
    .api-key-widget input {
        font-size: 0.9rem;
    }

    /* Scroll Area */
    .content-scroll-area {
        padding: 16px 16px 100px 16px; /* Bottom padding for scroll end */
    }

    /* Components */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .card {
        padding: 20px;
        border-radius: 16px;
    }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .form-stack {
        gap: 12px;
    }

    .input-sm, .input-md, .input-lg {
        width: 100%;
    }

    button, input, select {
        min-height: 44px; /* Touch friendly */
    }
    
    .btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }
    
    .btn-text {
        padding: 8px;
    }

    /* Toast Mobile Position */
    .toast-container {
        top: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 90%;
        align-items: center;
    }
    
    .toast {
        width: 100%;
        min-width: auto;
        justify-content: center;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* =========================================
   NEW COMPACT DASHBOARD STYLES (OPPO Style)
   ========================================= */

/* 移除旧版 result-box 的滚动条和高度限制 */
.result-box {
    max-height: none !important;
    overflow: visible !important;
    margin-top: 0 !important;
    padding: 0 !important;
}

/* 新的概览容器：横向布局，无缝衔接 */
.overview-dashboard {
    display: grid;
    grid-template-columns: 350px 1fr; /* 左侧余额定宽，右侧详情自适应 */
    gap: 24px;
    margin-bottom: 24px;
    align-items: stretch;
}

/* 通用面板样式 */
.dashboard-panel {
    background: var(--surface-white);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-subtle);
    border: 1px solid rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    height: 100%; /* 等高 */
    min-height: 220px;
}

.dashboard-panel:hover {
    box-shadow: var(--shadow-float);
    transform: translateY(-2px);
}

/* 左侧：余额面板 (微渐变) */
.balance-panel {
    background: linear-gradient(145deg, #FFFFFF 0%, #F5F9F7 100%);
    position: relative;
    overflow: hidden;
}

.balance-panel::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(42, 209, 129, 0.08) 0%, transparent 70%);
    z-index: 0;
}

.balance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-big-num {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
    letter-spacing: -1px;
}

.balance-symbol {
    font-size: 1.2rem;
    color: var(--text-sub);
    margin-right: 4px;
    font-weight: 600;
}

/* 迷你状态条 (Compact Stats) */
.mini-stats-row {
    display: flex;
    gap: 12px;
    margin-top: auto;
    position: relative;
    z-index: 1;
}

.mini-stat {
    background: rgba(255,255,255,0.8);
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.04);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mini-stat-label { font-size: 0.75rem; color: var(--text-sub); margin-bottom: 2px; }
.mini-stat-val { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }

/* 右侧：详情面板 (网格布局) */
.info-grid-panel {
    display: flex;
    flex-direction: column;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px 32px;
    margin-top: 8px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-sub);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1.05rem;
    color: var(--text-main);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    word-break: break-all;
}

.info-value.mono {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #F5F7FA;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--primary-dark);
    width: fit-content;
}

/* 移动端适配修正 */
@media (max-width: 1024px) {
    .overview-dashboard {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .balance-big-num { font-size: 2.4rem; }
}

/* =========================================
   DATA TABLE & LOGS STYLES
   ========================================= */

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: #F5F7FA;
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
}

.filter-tab {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-tab.active {
    background: white;
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.filter-tab:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255,255,255,0.5);
}

/* Data Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.03);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table th {
    text-align: left;
    padding: 16px 24px;
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 600;
    background: #FAFAFA;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    white-space: nowrap;
}

.data-table td {
    padding: 16px 24px;
    font-size: 0.95rem;
    color: var(--text-main);
    border-bottom: 1px solid rgba(0,0,0,0.03);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: #F8F9FB;
}

/* Amounts */
.amount-plus { color: var(--success); font-weight: 700; }
.amount-minus { color: var(--text-main); font-weight: 700; }

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
    background: white;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: #F5F7FA;
    border-color: rgba(0,0,0,0.1);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-sub);
    font-weight: 500;
}

/* 充值二维码卡片 */
.recharge-result-panel {
    margin-top: 24px;
    animation: slideDown 0.4s ease;
}

.qr-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.05);
    max-width: 400px;
    margin: 0 auto;
}

.qr-title { font-size: 1.2rem; font-weight: 700; color: var(--success); margin-bottom: 4px; }
.qr-subtitle { font-size: 0.9rem; color: var(--text-sub); margin-bottom: 24px; }

.qr-code-box {
    background: white;
    padding: 10px;
    display: inline-block;
    border-radius: 12px;
    margin-bottom: 24px;
    /* qrcode.js 会在这里插入 img */
}
.qr-code-box img { display: block; }

.order-info {
    background: #F5F7FA;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.order-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-sub);
}
.order-row:last-child { margin-bottom: 0; }

.order-amount { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.order-no { font-family: monospace; }

.qr-footer { display: flex; gap: 12px; justify-content: center; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
