* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #2a2a4a;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.4rem;
    color: #00d4ff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-info {
    font-size: 0.9rem;
    color: #aaa;
}

#user-info .admin-badge {
    background: #ff6b35;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 6px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #00d4ff;
    color: #1a1a2e;
    font-weight: 600;
}

.btn-primary:hover {
    background: #00b8e6;
}

.btn-secondary {
    background: #2a2a4a;
    color: #e0e0e0;
    border: 1px solid #3a3a5a;
}

.btn-secondary:hover {
    background: #3a3a5a;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #2a2a4a;
    color: #e0e0e0;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    cursor: pointer;
}

.btn-small:hover {
    background: #3a3a5a;
}

.btn-danger {
    background: #6b2020;
    color: #ff6b6b;
    border: 1px solid #8a3030;
}

.btn-danger:hover {
    background: #8a2828;
}

/* Pages */
.page {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.3rem;
    color: #fff;
    flex: 1;
}

/* Auth */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: #16213e;
    padding: 32px;
    border-radius: 12px;
    border: 1px solid #2a2a4a;
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    margin-bottom: 20px;
    color: #fff;
    text-align: center;
}

.auth-switch {
    margin-top: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: #888;
}

.auth-switch a {
    color: #00d4ff;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #aaa;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #0f3460;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00d4ff;
}

.form-group textarea {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    resize: vertical;
}

/* Cards */
.card-list {
    display: grid;
    gap: 12px;
}

.card {
    background: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: #00d4ff;
}

.card-info h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 4px;
}

.card-info p {
    font-size: 0.85rem;
    color: #888;
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge {
    background: #0f3460;
    color: #00d4ff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Level Detail */
.level-meta {
    background: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.level-meta .meta-item {
    font-size: 0.85rem;
}

.level-meta .meta-item strong {
    color: #00d4ff;
    margin-right: 6px;
}

.json-viewer {
    background: #0d1117;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: #c9d1d9;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #fff;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

/* Error messages */
.error-message {
    background: #3d1a1a;
    border: 1px solid #6b2a2a;
    color: #ff6b6b;
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.success-message {
    background: #1a3d1a;
    border: 1px solid #2a6b2a;
    color: #6bff6b;
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.85rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .card-actions {
        width: 100%;
        justify-content: flex-end;
    }
}