:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    max-width: 480px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.card.wide {
    max-width: 900px;
    margin: 0 auto;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.form-container {
    padding: 2rem;
}

.form-container h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary);
    color: white;
    width: auto;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: auto;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: #c33;
    font-size: 0.9rem;
    display: none;
}

.error-message.show {
    display: block;
}

.toggle-form {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.toggle-form a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.toggle-form a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.footer {
    background: var(--bg);
    padding: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.footer p {
    margin: 0.25rem 0;
}

.muted {
    opacity: 0.7;
}

/* Dashboard specific */
.section {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section h2 {
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.info-item .label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.info-item .value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.form-inline {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.input-inline {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.key-created {
    padding: 1rem;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.key-created .warning {
    color: #92400e;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.key-display {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.key-display code {
    flex: 1;
    padding: 0.75rem;
    background: white;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

.keys-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.key-info {
    flex: 1;
}

.key-prefix {
    font-family: 'Monaco', 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.95rem;
}

.key-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.usage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-card {
    padding: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.loading {
    color: var(--text-muted);
    font-style: italic;
}

.docs {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.docs h3 {
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.1rem;
}

.docs h3:first-child {
    margin-top: 0;
}

.docs ol, .docs ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.docs li {
    margin: 0.5rem 0;
}

.docs code {
    background: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

@media (max-width: 640px) {
    body {
        padding: 1rem 0.5rem;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .form-container {
        padding: 1.5rem;
    }

    .section {
        padding: 1.5rem;
    }

    .form-inline {
        flex-direction: column;
    }

    .header-flex {
        flex-direction: column;
        gap: 1rem;
    }
}
