:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #1e293b;
        --text: #f1f5f9;
        --text-light: #94a3b8;
        --border: #334155;
    }
}

.toast { position: fixed; top: 20px; right: 20px; background: var(--card); border-radius: 12px; padding: 16px 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); z-index: 9999; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 400px; animation: slideIn 0.3s ease; border-left: 4px solid var(--primary); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast-icon { font-size: 24px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.toast-message { font-size: 14px; color: var(--text-light); }

@keyframes slideIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.2s; }
.modal-content { background: var(--card); border-radius: 16px; padding: 24px; max-width: 400px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: scaleIn 0.2s; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.modal-message { color: var(--text-light); margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions button { flex: 1; }
.form-modal .modal-content { max-width: 500px; }
.form-modal input { margin-bottom: 12px; }
.form-modal .form-row { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.form-modal .oauth-steps { background: rgba(59,130,246,0.1); padding: 16px; border-radius: 8px; margin-bottom: 16px; border: 2px solid var(--info); }
.form-modal .oauth-steps p { margin-bottom: 8px; font-size: 14px; }
.form-modal .oauth-steps p:last-child { margin-bottom: 0; }

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

.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 9999; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,0.2); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-text { color: white; font-size: 16px; font-weight: 500; }
.help-tip { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--info); color: white; font-size: 12px; font-weight: 600; cursor: help; margin-left: 6px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-state-text { font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.empty-state-hint { font-size: 14px; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; transition: background 0.3s; min-height: 100vh; }
.container { max-width: 1400px; margin: 0 auto; padding: 1rem; height: 100vh; display: flex; align-items: center; justify-content: center; }

.login-form { background: var(--card); border-radius: 1.5rem; box-shadow: var(--shadow); max-width: 480px; width: 100%; padding: 3rem; }
.login-form h2 { text-align: center; margin-bottom: 2.5rem; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-size: 2rem; font-weight: 700; }
.form-group { margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 0.75rem; font-weight: 600; color: var(--text); font-size: 0.95rem; }
input { width: 100%; min-height: 48px; padding: 0.875rem 1rem; border: 2px solid var(--border); border-radius: 0.75rem; font-size: 0.95rem; line-height: 1.5; background: var(--card); color: var(--text); transition: all 0.2s; text-indent: 0.25rem; -webkit-appearance: none; }
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,0.1); }
input::placeholder { color: var(--text-light); opacity: 0.6; }

button { width: 100%; min-height: 52px; padding: 1rem; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border: none; border-radius: 0.75rem; cursor: pointer; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.5px; transition: all 0.2s; box-shadow: 0 4px 12px rgba(99,102,241,0.2); position: relative; }
button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99,102,241,0.35); }
button:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px rgba(99,102,241,0.25); }
button:disabled { opacity: 0.7; cursor: not-allowed; }
button.loading::after { content: ''; position: absolute; width: 16px; height: 16px; margin-left: 10px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.main-content { background: var(--card); border-radius: 1.5rem; box-shadow: var(--shadow); width: 100%; max-width: 1400px; height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 2rem; border-bottom: 2px solid var(--border); flex-shrink: 0; }
.header h1 { font-size: 1.75rem; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-weight: 700; }
.header button { width: auto; padding: 0.625rem 1.5rem; font-size: 0.9rem; }
.tabs { display: flex; gap: 0.5rem; }
.tab { background: transparent; color: var(--text-light); border: none; padding: 0.625rem 1.25rem; border-radius: 0.5rem; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.3); }
.content { padding: 2rem; flex: 1; overflow-y: auto; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-track { background: var(--bg); border-radius: 4px; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.content::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

.add-form { background: var(--bg); padding: 1.5rem; border-radius: 1rem; margin-bottom: 2rem; border: 2px solid var(--border); }
.add-form h3 { margin-bottom: 1.25rem; font-size: 1.25rem; font-weight: 600; }
.btn-group { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.btn-group .btn { width: auto; flex: 1; min-width: 140px; }
.oauth-box { background: rgba(251,191,36,0.1); padding: 1.5rem; border-radius: 1rem; margin-bottom: 1.25rem; border: 2px solid var(--warning); }
.oauth-box p { margin-bottom: 1rem; color: var(--text); font-size: 0.95rem; }
.form-row { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 200px; }

.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.25rem; }
.token-card { background: var(--bg); border: 2px solid var(--border); border-radius: 1rem; padding: 1.5rem; transition: all 0.3s; position: relative; overflow: hidden; }
.token-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); opacity: 0; transition: opacity 0.3s; }
.token-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.token-card:hover::before { opacity: 1; }
.token-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.token-id { font-size: 0.75rem; color: var(--text-light); font-family: monospace; }
.token-info { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }
.info-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.info-label { color: var(--text-light); min-width: 80px; font-weight: 500; }
.info-value { color: var(--text); font-family: monospace; font-size: 0.8rem; }
.token-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.btn { padding: 0.625rem 1rem; border: none; border-radius: 0.5rem; cursor: pointer; font-size: 0.875rem; font-weight: 600; transition: all 0.2s; white-space: nowrap; text-align: center; }
.btn:hover { transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: #6b7280; color: white; }

.hidden { display: none; }
.status { padding: 0.375rem 0.875rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.25rem; }
.status.enabled { background: rgba(16,185,129,0.15); color: var(--success); }
.status.disabled { background: rgba(239,68,68,0.15); color: var(--danger); }

.stats { display: flex; gap: 1.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 150px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); padding: 1.25rem; border-radius: 1rem; color: white; }
.stat-value { font-size: 2rem; font-weight: 700; margin-bottom: 0.25rem; }
.stat-label { font-size: 0.875rem; opacity: 0.9; }

.config-form { max-width: 800px; }
.config-form h3 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.config-section { background: var(--bg); padding: 1.5rem; border-radius: 1rem; margin-bottom: 1.5rem; border: 2px solid var(--border); }
.config-section h4 { margin-bottom: 1rem; color: var(--primary); font-size: 1.1rem; }
.config-form .form-group { margin-bottom: 1rem; }
.config-form label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.config-form input, .config-form select, .config-form textarea { width: 100%; padding: 0.75rem; border: 2px solid var(--border); border-radius: 0.5rem; background: var(--card); color: var(--text); font-size: 0.9rem; }
.config-form textarea { resize: vertical; font-family: inherit; }
.config-form button[type="submit"] { margin-top: 1rem; }

@media (max-width: 768px) {
    .container { padding: 0; height: 100vh; }
    .login-form { margin: 1rem; padding: 2rem; border-radius: 1rem; }
    .login-form h2 { font-size: 1.5rem; }
    .main-content { height: 100vh; border-radius: 0; }
    .header { padding: 1rem; flex-wrap: wrap; gap: 1rem; }
    .header h1 { font-size: 1.25rem; }
    .tabs { width: 100%; }
    .tab { flex: 1; }
    .content { padding: 1rem; }
    .token-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-row input { min-width: 100%; }
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }
    .stats { flex-direction: column; }
    .toast { right: 10px; left: 10px; min-width: auto; max-width: none; }
    .modal { padding: 10px; }
}
