@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f1b2d;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e3e8ef;
  --primary: #4f3477;
  --primary-600: #36145e;
  --primary-50: #f1ecf7;
  --accent: #7a5f97;
  --accent-50: #f3eef9;
  --success: #12805c;
  --success-50: #e7f6ef;
  --danger: #c0392b;
  --danger-50: #fdecea;
  --warn: #b7791f;
  --warn-50: #fdf5e6;
  --info: #2563eb;
  --info-50: #eaf1fe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
  --shadow: 0 1px 3px rgba(15, 27, 45, .06), 0 8px 24px -12px rgba(15, 27, 45, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 27, 45, .35);
  --font: 'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .02em; }
.pre { white-space: pre-wrap; }

/* ---------- الأزرار ---------- */
.btn {
  --b: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--b); background: var(--b); color: #fff;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--b); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-50); color: var(--primary); border-color: transparent; }
.btn.danger { --b: var(--danger); }
.btn.success { --b: var(--success); }
.btn.accent { --b: var(--accent); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 50px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); font: inherit; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: 15px var(--font); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.7; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(54, 20, 94, .12); }
.input[dir=ltr] { text-align: right; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 16px; }
.card-b { padding: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.spacer { flex: 1; }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.draft { color: var(--muted); }
.badge.scheduled { color: var(--info); background: var(--info-50); border-color: transparent; }
.badge.open { color: var(--success); background: var(--success-50); border-color: transparent; }
.badge.open::before { animation: pulse 1.6s infinite; }
.badge.closed { color: var(--ink-2); background: #eef1f5; border-color: transparent; }
.badge.approved { color: var(--success); background: var(--success-50); border-color: transparent; }
.badge.rejected { color: var(--danger); background: var(--danger-50); border-color: transparent; }
.badge.no_quorum, .badge.warn { color: var(--warn); background: var(--warn-50); border-color: transparent; }
.badge.pending { color: var(--info); background: var(--info-50); border-color: transparent; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; font-weight: 600; font-size: 12.5px; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { font-size: 34px; margin-bottom: 8px; opacity: .6; }

/* ---------- التقدم ---------- */
.progress { height: 8px; background: #edf1f6; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #6b4b96); border-radius: 99px; transition: width .4s ease; }
.stacked { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #edf1f6; }
.stacked > span { height: 100%; transition: width .4s ease; }
.stacked .a { background: var(--success); }
.stacked .r { background: var(--danger); }
.stacked .x { background: #a0aec0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }

/* ---------- النوافذ والتنبيهات ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; animation: fade .15s ease; }
.modal { width: 100%; max-width: 620px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); animation: rise .2s ease; }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { font-size: 17px; }
.modal-b { padding: 22px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-start; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s ease; display: flex; gap: 10px; align-items: flex-start; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.alert { padding: 12px 16px; border-radius: 12px; font-size: 14px; display: block; }
.alert.info { background: var(--info-50); color: #1e3a8a; }
.alert.warn { background: var(--warn-50); color: #7c4a03; }
.alert.error { background: var(--danger-50); color: #7f1d1d; }
.alert.success { background: var(--success-50); color: #064e3b; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 12px 16px; border: 0; background: none; font: 600 14px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-right: 6px; border-radius: 99px; background: var(--surface-2); font-size: 12px; }

.skeleton { background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 50%, #eef1f5 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media print {
  .no-print, .sidebar, .topbar, .toasts { display: none !important; }
  body { background: #fff; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
