
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }


:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a8a;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #4ade80;
    --success-bg: #052e16;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --warning: #fbbf24;
    --warning-bg: #451a03;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body {
    font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}


::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    transition: background var(--transition), border-color var(--transition);
}
.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    padding: 0 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.nav-brand {
    font-size: 19px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    padding: 10px 0;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: opacity var(--transition);
}
.nav-brand:hover { opacity: 1; }
.nav-links {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all var(--transition);
    white-space: nowrap;
    font-weight: 500;
}
.nav-links a:hover,
.nav-links a:active {
    color: var(--text);
    background: var(--primary-light);
}
.nav-actions { display: flex; align-items: center; gap: 8px; }


.theme-toggle {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle-inner {
    position: relative;
    width: 20px;
    height: 20px;
}
.theme-toggle svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    transform-origin: center center;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle .moon-icon,
.theme-fab .moon-icon { opacity: 1; transform: scale(1); }
.theme-toggle .sun-icon,
.theme-fab .sun-icon  { opacity: 0; transform: scale(0.2); }

[data-theme="dark"] .theme-toggle .moon-icon,
[data-theme="dark"] .theme-fab .moon-icon { opacity: 0; transform: scale(0.2); }
[data-theme="dark"] .theme-toggle .sun-icon,
[data-theme="dark"] .theme-fab .sun-icon  { opacity: 1; transform: scale(1); }
.theme-toggle-label { font-size: 14px; font-weight: 500; display: none; }



.theme-fab {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.theme-fab:hover { color: var(--primary); border-color: var(--primary); }
.theme-fab .theme-toggle-inner { position: relative; width: 18px; height: 18px; }
.theme-fab svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    transform-origin: center center;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}


.steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.steps-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.steps-list li:last-child { border-bottom: none; }
.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.step-text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    padding-top: 3px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
    width: 100%;
    animation: fadeInUp 0.4s ease-out;
}


.home-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}


.hero {
    text-align: left;
    padding: 56px 0 32px;
    animation: fadeInUp 0.5s ease-out;
}
.hero h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 14px;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    color: var(--text-muted);
    font-size: 17px;
    margin-bottom: 28px;
    max-width: 600px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}


.card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    animation: fadeInUp 0.4s ease-out backwards;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}


.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.4s ease-out backwards;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:hover {
    box-shadow: var(--shadow-sm);
}
.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
    word-break: break-word;
    transition: color var(--transition);
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 500;
}


.balance-num {
    display: inline-block;
    transition: transform 0.3s ease, color 0.3s ease;
}
.balance-num.flash {
    animation: pulse 0.6s ease;
}


.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    min-height: 46px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    min-height: auto;
    padding: 0;
    margin-right: 6px;
    appearance: auto;
    -webkit-appearance: auto;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 22px;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
    text-align: center;
    line-height: 1.2;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover { background: #b91c1c; }
.btn-secondary {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }
.btn-block { width: 100%; }



.kv-list {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.kv-row {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    align-items: flex-start;
}
.kv-row:last-child { border-bottom: none; }
.kv-key {
    flex-shrink: 0;
    width: 90px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    padding-top: 1px;
}
.kv-value {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}
.kv-value.break-all { word-break: break-all; }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
    border-radius: 10px;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}
th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    white-space: nowrap;
}
th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    position: sticky;
    top: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
tr {
    transition: background var(--transition);
}
tr:hover td { background: transparent; }
td.wrap { white-space: normal; word-break: break-word; min-width: 180px; max-width: 320px; }


.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    transition: all var(--transition);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }


.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
    animation: shake 0.4s ease;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }


pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
    line-height: 1.55;
    margin: 8px 0;
    word-break: normal;
    box-shadow: var(--shadow-md);
}
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
pre code { background: none; padding: 0; }
code.inline {
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--primary);
    word-break: break-word;
    display: inline-block;
    max-width: 100%;
    font-weight: 500;
}


.api-key-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    word-break: break-all;
    flex-wrap: wrap;
    transition: border-color var(--transition);
}
.api-key-box:hover { border-color: var(--border); }
.api-key-box .key-text {
    flex: 1;
    min-width: 200px;
    padding: 4px 0;
}
.api-key-box .btn { flex-shrink: 0; }


.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 10px 18px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    margin-bottom: -2px;
}
.tab:hover { color: var(--text-muted); }
.tab.active {
    color: var(--primary);
    border-bottom-color: transparent;
}


.mcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 20px;
}
.mcard {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.4s ease-out backwards;
}
.mcard:hover {
    border-color: var(--border);
    box-shadow: none;
    transform: translateY(0);
}
.mcard:active { transform: translateY(0); }
.mcard:focus-visible {
    border-color: var(--border);
    box-shadow: none;
}
.mcard.copied {
    border-color: var(--border);
    background: var(--card-bg);
    animation: none;
}
.mcard-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.mcard-id {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 8px;
    transition: background var(--transition);
}
.mcard:hover .mcard-id { background: var(--bg); }
.mcard.copied .mcard-id { background: var(--bg); }
.mcard-id code {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--primary);
    word-break: break-all;
    background: none;
    padding: 0;
    line-height: 1.3;
    min-width: 0;
}
.mcard-id svg {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition);
}
.mcard:hover .mcard-id svg { color: var(--text-muted); }
.mcard.copied .mcard-id svg { color: var(--success); }
.mcard-prices {
    display: flex;
    gap: 6px;
    font-size: 11.5px;
}
.mcard-price {
    flex: 1;
    text-align: center;
    padding: 4px 6px;
    background: var(--bg);
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 600;
    transition: background var(--transition);
}
.mcard-price:first-child { color: var(--success); }
.mcard-price:last-child { color: var(--warning); }


.search-box {
    position: relative;
    margin: 16px 0 8px;
}
.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: var(--card-bg);
    color: var(--text);
    transition: all var(--transition);
    min-height: 48px;
}
.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.search-box svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}


.copy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    max-width: 90vw;
    text-align: center;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 8px;
}
.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


.usage-chart {
    margin-top: 12px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding: 8px 0;
}
.usage-bar {
    flex: 1;
    background: linear-gradient(180deg, var(--primary), var(--primary-hover));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}
.usage-bar:hover {
    filter: none;
    transform: none;
}
.usage-bar.empty { background: var(--border); }


.recharge-box {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.recharge-box input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    background: var(--card-bg);
    color: var(--text);
    min-height: 46px;
    transition: all var(--transition);
}
.recharge-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}


.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}


.app-body { display: block; }
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-header { flex-shrink: 0; }
.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}
.sidebar-footer { flex-shrink: 0; }
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    min-height: 60px;
    flex-shrink: 0;
}
.sidebar-brand {
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
}
.sidebar-close:hover { color: var(--text); background: var(--primary-light); }
.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.sidebar .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .nav-item:hover {
    color: var(--text);
    background: var(--primary-light);
}
.sidebar .nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-footer .theme-toggle {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    color: var(--text-muted);
}
.sidebar-footer .theme-toggle:hover {
    background: var(--primary-light);
    color: var(--text);
    border-color: transparent;
}
.sidebar-footer .theme-toggle .theme-toggle-inner { width: 18px; height: 18px; }
.sidebar-footer .theme-toggle svg { width: 18px; height: 18px; }
.sidebar-footer .theme-toggle-label { display: inline; }

.app-main {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-topbar { display: none; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }
.mobile-menu-btn { display: none; }
body.sidebar-open { overflow: hidden; }


.sidebar-collapse-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
}
.sidebar-expand-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 180;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.sidebar-expand-btn:hover { color: var(--primary); border-color: var(--primary); }
@media (min-width: 769px) {
    .sidebar-collapse-btn { display: inline-flex; }
    .sidebar-collapse-btn:hover { color: var(--text); background: var(--primary-light); }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .app-main { margin-left: 0; }
    body.sidebar-collapsed .sidebar-expand-btn { display: inline-flex; }
    
    .home-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 32px;
    }
    .home-left { flex: 1; min-width: 0; }
    .home-right { width: 340px; flex-shrink: 0; }
}


.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.flex-center { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }


.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}


@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}


.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    animation: fadeIn 0.4s ease;
}
.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    opacity: 0.4;
}


@media (max-width: 1024px) {
    .nav-container { max-width: 100%; padding: 0 16px; }
    .container { max-width: 100%; padding: 24px 16px; }
    .hero h1 { font-size: 30px; }
    .hero { padding: 40px 12px 30px; }
    .card { padding: 20px; }
}


@media (max-width: 768px) {
    
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .app-main { margin-left: 0; }
    .app-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 100;
        min-height: 52px;
    }
    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text);
        cursor: pointer;
        padding: 6px;
        border-radius: 8px;
    }
    .mobile-menu-btn:hover { background: var(--primary-light); color: var(--primary); }
    .app-topbar-brand {
        font-size: 17px;
        font-weight: 800;
        text-decoration: none;
        background: linear-gradient(135deg, var(--primary), var(--primary-hover));
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .container { padding: 16px 12px; }
    .card {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 14px;
    }
    .card-title { margin-bottom: 12px; font-size: 16px; }

    .hero { padding: 32px 12px 24px; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 15px; margin-bottom: 22px; }
    .hero-actions .btn { flex: 1; min-width: 140px; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }
    .stat-card { padding: 14px 12px; }
    .stat-value { font-size: 24px; }
    .stat-label { font-size: 12px; margin-top: 4px; }

    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .form-group { margin-bottom: 14px; }
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 16px;
        min-height: 48px;
    }
    .btn { min-height: 46px; }

    
    .table-wrap { padding: 0; }
    
    .kv-key { width: 72px; font-size: 12px; }
    .kv-row { padding: 10px 12px; font-size: 13px; }
    table, thead, tbody, th, td, tr { display: block; }
    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 4px 0;
        background: var(--card-bg);
    }
    th { display: none; }
    td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 14px;
        border-bottom: 1px dashed var(--border);
        white-space: normal;
        font-size: 13px;
    }
    td:last-child { border-bottom: none; }
    td.wrap { min-width: 0; max-width: 100%; }
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 12px;
        flex-shrink: 0;
        min-width: 64px;
        padding-top: 2px;
    }
    td > * { text-align: right; }
    td .btn, td form { text-align: right; }
    td form { display: inline-block; }
    td.wrap::before { align-self: flex-start; padding-top: 4px; }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -12px 20px;
        padding: 0 12px;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { padding: 10px 14px; font-size: 13px; }

    .api-key-box {
        flex-direction: column;
        align-items: stretch;
    }
    .api-key-box .key-text { min-width: 0; }
    .api-key-box .btn { width: 100%; }

    .mcard-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .mcard { padding: 12px; gap: 8px; }
    .mcard-name { font-size: 14px; }
    .mcard-id { padding: 5px 8px; }
    .mcard-id code { font-size: 11px; }
    .mcard-price { font-size: 10.5px; padding: 3px 4px; }

    pre { font-size: 12px; padding: 12px; }
    code.inline { font-size: 12px; }

    .recharge-box { flex-direction: column; }
    .recharge-box input { width: 100%; }
    .recharge-box .btn { width: 100%; }

    .copy-toast { bottom: 20px; padding: 10px 16px; font-size: 13px; }
}


@media (max-width: 420px) {
    .hero h1 { font-size: 22px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 26px; }
    .hero-actions { flex-direction: column; }
    .hero-actions .btn { width: 100%; min-width: 0; }
    .flex-between { flex-direction: column; align-items: flex-start; }
    .nav-links a { padding: 7px 8px; font-size: 12.5px; }
    .mcard-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .mcard { padding: 10px; }
}


@media (max-height: 500px) and (orientation: landscape) {
    .hero { padding: 24px 16px; }
    .hero h1 { font-size: 26px; }
    .navbar { position: static; }
}


@media (min-width: 1440px) {
    .nav-container { max-width: 1440px; }
    .container { max-width: 1440px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .mcard-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}


@supports (-webkit-touch-callout: none) {
    .form-group input,
    .form-group select,
    .form-group textarea,
    .search-box input,
    .recharge-box input {
        font-size: 16px;
    }
}


@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
