:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --primary-light: #E8F0FE;
    --success: #52C41A;
    --danger: #FF4D4F;
    --warning: #FAAD14;
    --text: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --bg: #F5F7FA;
    --bg-white: #FFFFFF;
    --border: #E8E8E8;
    --border-light: #F0F0F0;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-sm: 4px;
    --font-size: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: var(--font-size);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size);
    cursor: pointer;
    transition: all 0.2s;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; border: none; color: var(--text-secondary); }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,144,217,0.1); }
.form-input.has-error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Card */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.card-header {
    font-size: 16px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
}

/* Badge/Tag */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}
.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-success { background: #F6FFED; color: var(--success); }
.tag-danger { background: #FFF2F0; color: var(--danger); }
.tag-warning { background: #FFFBE6; color: var(--warning); }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* Loading & Toast */
.spinner {
    display: inline-block;
    width: 40px; height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius);
    color: #fff;
    z-index: 9999;
    animation: toastIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; } }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__text { font-size: 14px; }

/* Tab Switch Detection Warning Bar */
#tab-warning-bar {
    position: fixed;
    top: 0; left: 0; width: 100%;
    background: var(--warning);
    color: #fff;
    text-align: center;
    padding: 6px;
    font-size: 13px;
    z-index: 9998;
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
