/* صفوف — shared design system */
@font-face { font-family: "Sufoof Sans"; font-weight: 400; font-display: swap; src: local("IBM Plex Sans Arabic"), local("IBMPlexSansArabic-Regular"), url(/fonts/plex-arabic-400.woff2) format("woff2"); }
@font-face { font-family: "Sufoof Sans"; font-weight: 500; font-display: swap; src: local("IBM Plex Sans Arabic Medium"), local("IBMPlexSansArabic-Medium"), url(/fonts/plex-arabic-500.woff2) format("woff2"); }
@font-face { font-family: "Sufoof Sans"; font-weight: 700; font-display: swap; src: local("IBM Plex Sans Arabic Bold"), local("IBMPlexSansArabic-Bold"), url(/fonts/plex-arabic-700.woff2) format("woff2"); }

:root {
  --font: "Sufoof Sans", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  --num: "SF Pro Rounded", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --bg: #F7F4F0;
  --surface: #FFFFFF;
  --surface-2: #F2EEE9;
  --surface-3: #E9E3DC;
  --ink: #1E1A16;
  --ink-2: #5C544C;
  --ink-3: #958B80;
  --line: #E6DFD7;
  --brand: #E8613C;
  --brand-2: #C94B29;
  --brand-soft: #FDEBE4;
  --brand-ink: #FFFFFF;
  --ok: #18946A;
  --ok-soft: #DDF4EA;
  --warn: #C98A00;
  --warn-soft: #FFF2D1;
  --bad: #D13F3F;
  --bad-soft: #FCE4E2;
  --info: #2D6CDF;
  --info-soft: #E3ECFC;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --sh-1: 0 1px 2px rgba(30, 26, 22, .06), 0 1px 3px rgba(30, 26, 22, .05);
  --sh-2: 0 4px 14px rgba(30, 26, 22, .08), 0 1px 3px rgba(30, 26, 22, .06);
  --sh-3: 0 18px 50px rgba(30, 26, 22, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12110F;
  --surface: #1C1A17;
  --surface-2: #26231F;
  --surface-3: #312D28;
  --ink: #F4EFE9;
  --ink-2: #BDB4A9;
  --ink-3: #82786D;
  --line: #34302A;
  --brand-soft: #3A2219;
  --ok-soft: #12352A;
  --warn-soft: #3A2E0E;
  --bad-soft: #3D1818;
  --info-soft: #172A4A;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 4px 14px rgba(0, 0, 0, .4);
  --sh-3: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface-2); --b-ink: var(--ink); --b-line: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid var(--b-line); background: var(--b-bg); color: var(--b-ink);
  font-weight: 600; font-size: 15px; cursor: pointer; user-select: none; white-space: nowrap; text-decoration: none !important;
  transition: transform .12s var(--ease), background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn.primary { --b-bg: var(--brand); --b-ink: var(--brand-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.ok { --b-bg: var(--ok); --b-ink: #fff; }
.btn.danger { --b-bg: var(--bad); --b-ink: #fff; }
.btn.soft-danger { --b-bg: var(--bad-soft); --b-ink: var(--bad); }
.btn.outline { --b-bg: transparent; --b-line: var(--line); }
.btn.ghost { --b-bg: transparent; }
.btn.ghost:hover { --b-bg: var(--surface-2); filter: none; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn.lg { min-height: 54px; padding: 0 22px; font-size: 17px; border-radius: var(--r-lg); }
.btn.xl { min-height: 64px; padding: 0 26px; font-size: 19px; border-radius: var(--r-lg); }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 42px; }
.btn.icon.sm { width: 34px; }
.btn .ic { width: 20px; height: 20px; flex: none; }
.btn.sm .ic { width: 17px; height: 17px; }
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: var(--r); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s; appearance: none;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.5; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23958B80' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-position: 12px 50%; background-size: 16px; background-repeat: no-repeat; padding-left: 36px; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.invalid { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }

.switch { position: relative; display: inline-flex; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .22s var(--ease); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(-20px); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.setting-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .grow > b { display: block; font-weight: 600; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-1); border: 1px solid var(--line); }
.card.pad { padding: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { margin: 0; font-size: 16px; }
.card-b { padding: 18px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; user-select: none; transition: all .15s; }
.chip:hover { border-color: var(--ink-3); }
.chip.on, .chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: blink 1s infinite; }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
@keyframes blink { 50% { opacity: .3; } }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--ink); }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }
.notice .ic { margin-top: 2px; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .ic { width: 44px; height: 44px; margin: 0 auto 10px; stroke-width: 1.5; }

.spinner { width: 22px; height: 22px; border: 3px solid color-mix(in srgb, currentColor 20%, transparent); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader { min-height: 60vh; display: grid; place-items: center; color: var(--brand); }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-weight: 600; color: var(--ink-3); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---------- toast ---------- */
.toasts { position: fixed; inset-inline: 0; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: var(--surface); box-shadow: var(--sh-3); font-weight: 500; animation: toastIn .3s var(--ease); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast .btn { --b-bg: rgba(255,255,255,.16); --b-ink: inherit; min-height: 32px; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { transform: translateY(16px) scale(.96); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(20, 16, 12, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fadeIn .2s; }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); animation: popIn .28s var(--ease); }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-h h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-b { padding: 12px 20px 20px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .overlay.sheet-on-mobile { align-items: end; padding: 0; }
  .overlay.sheet-on-mobile .modal { width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheetIn .3s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(.94) translateY(8px); opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(100%); } }

/* ---------- misc ---------- */
.logo-mark { width: 36px; height: 36px; border-radius: 10px; flex: none; object-fit: cover; background: var(--brand-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--brand-soft); color: var(--brand-2); flex: none; }
.kbd { display: inline-block; padding: 0 6px; border-radius: 5px; border: 1px solid var(--line); border-bottom-width: 2px; font-size: 12px; font-family: var(--num); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.copy-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 6px; border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--surface-2); }
.copy-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; font-size: 13px; padding: 0 8px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.flip { transform: scaleX(-1); }
