:root {
    --primary-color: #0070f3;
    --primary-hover: #0051a2;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #1a202c;
    --text-secondary: #718096;
    --error-color: #e53e3e;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.6;
}

/* Index 页面居中布局 */
body.index-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
    margin: 0;
    animation: fadeInUp 0.5s ease;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 1.25rem;
    position: relative;
}

input {
    width: 100%;
    padding: 0.875rem 1rem;
    margin-bottom: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    box-sizing: border-box;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #fafbfc;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.1);
    transform: translateY(-1px);
}

button {
    width: 100%;
    padding: 0.875rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0051a2 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 112, 243, 0.3);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.message {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.message.error {
    color: var(--error-color);
    background: #fff0f0;
    border-color: #fc8181;
}

.message.success {
    color: #22543d;
    background: #c6f6d5;
    border-color: #68d391;
}

.result-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    border-radius: var(--radius);
    border: 2px solid #c6e2ff;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.result-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--success-color);
    margin: 0.5rem 0;
}

.result-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem 0;
}

.token-display {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border: 2px dashed var(--primary-color);
    border-radius: var(--radius);
    font-family: 'Courier New', 'Monaco', monospace;
    word-break: break-all;
    font-size: 0.95rem;
    color: var(--text-color);
    position: relative;
    transition: all 0.3s ease;
}

.token-display:hover {
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(0, 112, 243, 0.15);
}

.btn-copy {
    margin-top: 1rem;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-copy:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.3);
}

.result-tip {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    font-style: italic;
}

/* ========== Login Page ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.login-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.login-form input {
    margin-bottom: 1.25rem;
    font-size: 1rem;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.3s ease;
    background: #fafbfc;
    width: 100%;
    box-sizing: border-box;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.1);
    transform: translateY(-1px);
}

/* ========== Dashboard ========== */
.dashboard-container {
    min-height: 100vh;
    padding: 0;
}

.dashboard-header {
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: nowrap;
    position: relative;
}

.header-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    margin-right: auto;
    padding-right: 1rem;
}

.header-title h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: calc(100% - 100px);
}

.header-subtitle {
    margin: 0.25rem 0 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: calc(100% - 100px);
}

.btn-logout {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: auto;
    width: auto;
    margin-left: auto;
    z-index: 10;
}

.btn-logout::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-logout:hover::before {
    left: 100%;
}

.btn-logout:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-logout:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.btn-logout span {
    position: relative;
    z-index: 1;
}

.dashboard-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

/* ========== Action Cards ========== */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.action-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.action-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-color);
}

.action-card p {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.btn-card {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-card:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 112, 243, 0.3);
}

.btn-card:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.key-result {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: #f7fafc;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
}

.key-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.key-value {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-color);
    word-break: break-all;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
}

.btn-copy-key {
    width: 100%;
    padding: 0.625rem;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-copy-key:hover {
    background: #38a169;
}

/* ========== Table Section ========== */
.table-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
}

.table-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.table-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color);
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: #f7fafc;
}

.table-header h2 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-color);
    white-space: nowrap;
    display: inline-block;
}

.btn-refresh {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: #f7fafc;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.data-table tbody tr {
    transition: all 0.2s ease;
}

.data-table tbody tr:hover {
    background: #f7fafc;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.empty-state.error {
    color: var(--error-color);
}

/* ========== Status Badges ========== */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-unused {
    background: #c6f6d5;
    color: #22543d;
}

.status-used {
    background: #fed7d7;
    color: #742a2a;
}

.status-expired {
    background: #feebc8;
    color: #7c2d12;
}

.status-active {
    background: #c6f6d5;
    color: #22543d;
}

.status-disabled {
    background: #e2e8f0;
    color: #4a5568;
}

/* ========== Usage Info ========== */
.usage-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.usage-text {
    font-weight: 500;
    min-width: 50px;
}

.usage-text.usage-normal {
    color: var(--success-color);
}

.usage-text.usage-warning {
    color: var(--warning-color);
}

.usage-text.usage-full {
    color: var(--error-color);
}

.usage-bar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    max-width: 100px;
}

.usage-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.usage-fill.usage-normal {
    background: var(--success-color);
}

.usage-fill.usage-warning {
    background: var(--warning-color);
}

.usage-fill.usage-full {
    background: var(--error-color);
}

/* ========== Code Display ========== */
code, .key-code {
    font-family: 'Courier New', 'Monaco', monospace;
    background: #f7fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #2d3748;
}

.token-cell code {
    display: block;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Textarea ========== */
textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.875rem;
    margin-bottom: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    resize: vertical;
    transition: all 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.1);
}

/* ========== Buttons ========== */
button {
    font-family: inherit;
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 112, 243, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== Messages ========== */
.message {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.error {
    color: var(--error-color);
    background: #fed7d7;
    border: 1px solid #fc8181;
}

.message.success {
    color: #22543d;
    background: #c6f6d5;
    border: 1px solid #68d391;
}

/* ========== Pagination ========== */
.pagination {
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--border-color);
    background: #f7fafc;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-width: 100px;
    text-align: center;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .dashboard-main {
        padding: 0 1rem 1rem;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .table-section {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .header-title h1 {
        font-size: 1.25rem;
    }

    .btn-logout {
        padding: 0.625rem 1.25rem;
        font-size: 0.8125rem;
    }
}
