/* ===== المكونات ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.25rem; }

.kpi { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.kpi-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.kpi-label { color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.kpi-trend { font-size: .78rem; font-weight: 700; }
.tone-green { background: #dcfce7; color: #15803d; } .tone-blue { background: #dbeafe; color: #1d4ed8; }
.tone-amber { background: #fef3c7; color: #b45309; } .tone-red { background: #fee2e2; color: #b91c1c; }
.tone-teal { background: #ccfbf1; color: #0f766e; } .tone-purple { background: #ede9fe; color: #6d28d9; }
:root[data-theme="dark"] [class^="tone-"], :root[data-theme="dark"] [class*=" tone-"] { filter: brightness(.9) saturate(.9); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1.1rem; border-radius: var(--radius-sm);
  font-weight: 700; border: 1px solid transparent; transition: var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-outline { border-color: var(--border); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.input, select.input, textarea.input {
  width: 100%; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none; transition: var(--transition);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.input.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: .2rem; }

.table-wrap { overflow-x: auto; }
.table th { text-align: start; padding: .75rem 1rem; font-size: .8rem; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; cursor: pointer; user-select: none; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table tbody tr:hover { background: var(--surface-2); }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.success { background: #dcfce7; color: #15803d; } .badge.danger { background: #fee2e2; color: #b91c1c; }
.badge.warning { background: #fef3c7; color: #b45309; } .badge.info { background: #dbeafe; color: #1d4ed8; }

.table-tools { display: flex; gap: .5rem; flex-wrap: wrap; padding: 1rem 1.25rem; align-items: center; }
.pagination { display: flex; gap: .3rem; justify-content: center; padding: 1rem; }
.pagination button { min-width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* نافذة منبثقة */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,6,23,.55); display: grid; place-items: center; z-index: 100; padding: 1rem; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 800; }
.modal-body { padding: 1.25rem; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

/* إشعارات Toast */
.toasts { position: fixed; bottom: 1.2rem; inset-inline-start: 1.2rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--text); color: var(--bg); padding: .75rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow-lg); animation: slide .25s; min-width: 220px; }
.toast.success { background: var(--success); color: #fff; } .toast.error { background: var(--danger); color: #fff; }

/* حالة تحميل */
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 3rem auto; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty i { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }

.chart-box { position: relative; height: 280px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button { padding: .3rem .8rem; border-radius: 8px; font-weight: 600; font-size: .85rem; color: var(--text-muted); }
.segmented button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.alert-item { display: flex; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); align-items: flex-start; }
.alert-item:last-child { border: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
