* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: #2916f6;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:hover {
    opacity: 0.9;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

/* Cards */
.feature-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-card-full {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-bottom: 1rem;
}

.stat-card h3, .stat-card-full h3 {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Tables */
.data-table table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* Upstream Usage Sections */
.upstream-key-section {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.upstream-key-section h3 {
    margin: 0 0 16px 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.data-table th {
    background-color: #f1f5f9;
    font-weight: 600;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Login */
.login-box {
    max-width: 400px;
    margin: 100px auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    font-size: 16px; /* Prevent iOS zoom on focus */
}

.error {
    color: var(--danger-color);
    margin-top: 1rem;
    text-align: center;
}

/* Remember me checkbox */
.remember-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remember-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}

.remember-group label {
    display: inline;
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

/* Sections */
main section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-box input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    width: 200px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* API Keys */
.apikey-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.apikey-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.apikey-info code {
    font-family: monospace;
    font-size: 0.875rem;
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Status */
.status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status.active {
    background: #dcfce7;
    color: var(--success-color);
}

.status.inactive {
    background: #fee2e2;
    color: var(--danger-color);
}

/* Usage */
.usage-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.usage-item .model {
    font-weight: 600;
}

.usage-item .time {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

/* Empty state */
.empty {
    text-align: center;
    color: var(--secondary-color);
    padding: 2rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--secondary-color);
}

/* Tagline */
.tagline {
    color: var(--secondary-color);
    font-size: 1.125rem;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Main content */
main {
    padding: 2rem 0;
}

/* Progress bar */
.progress-bar {
    width: 100px;
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

/* Table wrapper for horizontal scroll */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */
@media (max-width: 768px) {
    /* Container */
    .container {
        padding: 0 12px;
    }

    /* Header */
    header {
        padding: 0.75rem 0;
        margin-bottom: 1rem;
    }

    .navbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .navbar h1 {
        font-size: 1.25rem;
    }

    .nav-links {
        gap: 0.5rem;
    }

    #adminUsername {
        font-size: 0.875rem;
    }

    /* Main */
    main {
        padding: 1rem 0;
    }

    /* Section Header */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    .section-header .btn {
        width: 100%;
        text-align: center;
    }

    /* Tabs - Horizontal scroll on mobile */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.25rem;
        padding-bottom: 0.5rem;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Stats Grid - Single column on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Tables - Horizontal scroll wrapper */
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table table {
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Button sizing on mobile */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .btn-copy {
        margin-left: 0.25rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .pagination span {
        font-size: 0.875rem;
        width: 100%;
        text-align: center;
        order: -1;
    }

    /* Modal - Full screen on mobile */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 5% auto;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Forms */
    .form-group input {
        padding: 0.625rem;
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    /* Login box - mobile responsive */
    .login-box {
        margin: 60px auto;
        padding: 1.5rem;
        width: 90%;
        max-width: none;
    }

    .login-box h1 {
        font-size: 1.5rem;
    }

    .remember-group {
        justify-content: flex-start;
    }

    .remember-group input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .remember-group label {
        font-size: 0.95rem;
    }

    /* Progress bar */
    .progress-bar {
        width: 60px;
    }

    /* Status badges */
    .status {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }

    /* API Key display */
    .data-table code {
        display: block;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .navbar h1 {
        font-size: 1.1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: space-between;
    }

    #adminUsername {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tab {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
    }

    .stat-card {
        padding: 0.875rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .modal-content {
        padding: 1rem;
        margin: 2% auto;
    }

    .close {
        right: 0.75rem;
        top: 0.75rem;
        font-size: 1.25rem;
    }
}




/* 1. 进度条外层容器（背景轨道） */
.progress-container {
    width: 80%;           /* 宽度 */
    max-width: 600px;     /* 最大宽度 */
    background-color: #e0e0e0; /* 背景色：浅灰色 */
    border-radius: 25px;  /* 圆角 */
    height: 30px;         /* 高度 */
    position: relative;   /* 为了定位内部的文字 */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2); /* 内阴影增加立体感 */
    overflow: hidden;     /* 防止内部进度条溢出圆角 */
}

/* 2. 进度条内层填充（蓝色部分） */
.progress-bar {
    height: 100%;
    width: 0%;            /* 初始宽度为 0 */
    background-color: #3498db; /* 主题色：蓝色 */
    border-radius: 25px;
    text-align: right;    /* 文字靠右 */
    
    /* 关键：添加过渡动画，让进度变化更平滑 */
    transition: width 0.6s ease; 
    
    /* 如果文字放在蓝色条内部，使用 Flex 布局 */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    box-sizing: border-box;
}

        /* 3. 百分比文字样式 */
        .progress-text {
            color: white;
            font-size: 14px;
            font-weight: bold;
            white-space: nowrap; /* 防止文字换行 */
        }