/* ===== CARDS ===== */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light);
}
.card-header h3 { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.card-flush { padding: 0; }
.card-flush .card-header { padding: 20px 24px 14px; margin-bottom: 0; }

/* ===== KPI CARDS ===== */
.kpi-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.22s;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.kpi-corner {
    position: absolute; top: 0; right: 0;
    width: 64px; height: 64px;
    border-bottom-left-radius: 100%;
}
.kpi-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.kpi-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.kpi-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
}
.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* KPI color variants */
.kpi-corner-indigo { background: #eef2ff; }
.kpi-corner-emerald { background: #ecfdf5; }
.kpi-corner-amber { background: #fffbeb; }
.kpi-corner-red { background: #fef2f2; }
.kpi-corner-purple { background: #faf5ff; }
.kpi-corner-sky { background: #f0f9ff; }

.kpi-icon-indigo { background: #e0e7ff; }
.kpi-icon-indigo svg { stroke: #6366f1; }
.kpi-icon-emerald { background: #d1fae5; }
.kpi-icon-emerald svg { stroke: #10b981; }
.kpi-icon-amber { background: #fef3c7; }
.kpi-icon-amber svg { stroke: #f59e0b; }
.kpi-icon-red { background: #fee2e2; }
.kpi-icon-red svg { stroke: #ef4444; }
.kpi-icon-purple { background: #ede9fe; }
.kpi-icon-purple svg { stroke: #8b5cf6; }
.kpi-icon-sky { background: #e0f2fe; }
.kpi-icon-sky svg { stroke: #0ea5e9; }

.text-indigo { color: #6366f1; }
.text-emerald { color: #10b981; }
.text-amber { color: #f59e0b; }
.text-red { color: #ef4444; }
.text-purple { color: #8b5cf6; }
.text-sky { color: #0ea5e9; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius);
    font-weight: 600; font-size: 0.88rem;
    border: 1px solid transparent; cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: var(--accent); color: white;
    box-shadow: 0 1px 2px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
    transform: translateY(-1px);
    color: white;
}
.btn-secondary { background: var(--bg-primary); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--border-light); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: var(--radius); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%; border-collapse: collapse;
    font-size: 0.88rem;
}
.table th {
    text-align: left; padding: 12px 16px;
    font-size: 0.72rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    position: sticky; top: 0;
}
.table td {
    padding: 14px 16px; border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg-tertiary); }
.table tbody tr.clickable { cursor: pointer; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block; margin-bottom: 6px;
    font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
}
.form-input, .form-textarea, .form-select {
    width: 100%; padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary);
    transition: all var(--transition);
    outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input::placeholder { color: var(--text-muted); }
.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent);
    border-radius: 4px; cursor: pointer;
}

/* ===== AVATAR ===== */
.avatar {
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full); font-weight: 600;
    font-size: 0.8rem; flex-shrink: 0;
    background: var(--accent-light); color: var(--accent);
}
.avatar-sm { width: 34px; height: 34px; font-size: 0.72rem; }
.avatar-md { width: 42px; height: 42px; }
.avatar-lg { width: 52px; height: 52px; font-size: 1rem; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    padding: 14px 20px; border-radius: var(--radius);
    background: var(--bg-primary); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    max-width: 380px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px;
    color: var(--text-secondary); text-align: center;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state-text { font-size: 0.95rem; }

/* ===== TABS ===== */
.tabs {
    display: flex; gap: 4px; margin-bottom: 24px;
    border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tab {
    padding: 10px 20px; font-size: 0.88rem; font-weight: 500;
    color: var(--text-secondary); background: none; border: none;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all var(--transition); margin-bottom: -1px;
    text-decoration: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== LOADING ===== */
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 60px; width: 100%;
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
    position: fixed; top: 0; right: -480px; width: 480px;
    height: 100vh; background: var(--bg-primary);
    border-left: 1px solid var(--border);
    z-index: 100; transition: right var(--transition-slow);
    overflow-y: auto; box-shadow: var(--shadow-lg);
}
.detail-panel.open { right: 0; }
.detail-panel-header {
    position: sticky; top: 0; background: var(--bg-primary);
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    z-index: 1;
}
.detail-panel-header h3 { font-size: 1rem; font-weight: 700; }
.detail-panel-body { padding: 24px; }
.detail-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); z-index: 99;
    opacity: 0; visibility: hidden; transition: all var(--transition-slow);
    backdrop-filter: blur(2px);
}
.detail-overlay.open { opacity: 1; visibility: visible; }

.detail-section { margin-bottom: 20px; }
.detail-label {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.detail-value { font-size: 0.92rem; line-height: 1.6; color: var(--text-primary); }
.detail-message {
    white-space: pre-wrap; background: var(--bg-tertiary);
    padding: 12px 16px; border-radius: var(--radius);
    font-size: 0.85rem; line-height: 1.6;
}
.detail-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}

/* ===== ESCALATION CLIENT ===== */
.escalation-client { display: flex; align-items: center; gap: 10px; }
.escalation-msg { font-size: 0.85rem; }
