@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e6e8f0;
  --text: #171a2c;
  --muted: #6b7088;
  --primary: #5b47e0;
  --primary-2: #7c6cf0;
  --primary-soft: #eeebfd;
  --accent: #ff4d6d;
  --accent-soft: #ffe8ec;
  --success: #10a765;
  --success-soft: #e3f7ee;
  --warn: #f59e0b;
  --warn-soft: #fef3dc;
  --danger: #e5484d;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(20, 22, 50, .05), 0 4px 16px rgba(20, 22, 50, .06);
  --shadow-lg: 0 20px 60px rgba(20, 22, 50, .22);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
label { font-size: 13px; color: var(--muted); font-weight: 500; display: block; margin-bottom: 6px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600;
  background: var(--surface); border: 1.5px solid var(--line); transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cfd3e2; background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 14px 22px; font-size: 17px; }
.icon { width: 20px; height: 20px; flex: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.chip.live { background: var(--success-soft); color: var(--success); }
.chip.scheduled { background: var(--warn-soft); color: #b56d00; }
.chip.expired, .chip.paused { background: #eef0f4; color: #80859a; }
.chip.offer { background: var(--accent-soft); color: var(--accent); }
.chip.primary { background: var(--primary-soft); color: var(--primary); }

/* modal */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 17, 40, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); width: 100%;
  max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; animation: pop .18s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px) } }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1b1d33; color: #fff; padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d5d8e3; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { right: 21px; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; flex: none; font-size: 15px;
}
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty svg { width: 56px; height: 56px; opacity: .35; margin-bottom: 8px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .modal { border-radius: 18px; }
}
