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

:root {
  --bg: #FBF7F2;
  --surface: #FFFFFF;
  --ink: #1C1A17;
  --muted: #6F6A62;
  --line: #ECE5DB;
  --brand: #E2552B;
  --brand-ink: #FFFFFF;
  --brand-soft: #FDEBE4;
  --ok: #1F8A5B;
  --ok-soft: #E3F4EC;
  --warn: #B7791F;
  --warn-soft: #FDF3DF;
  --bad: #C53030;
  --bad-soft: #FDE8E8;
  --info: #2B6CB0;
  --info-soft: #E6F0FA;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,26,23,.06), 0 6px 20px rgba(28,26,23,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(251,247,242,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); font-size: 1.1rem; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  padding: 10px 16px; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .05s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: #d9cfc2; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #cc4822; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 11px; font-size: .875rem; border-radius: 9px; }
.btn.lg { padding: 14px 20px; font-size: 1.05rem; border-radius: 13px; }
.btn.block { width: 100%; }

/* forms */
label.field { display: block; }
label.field > span { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: #3c3833; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #F1ECE5; color: #4a453f; }
.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); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: 20px; }
.tab { padding: 12px 14px; font-weight: 600; color: var(--muted); border: 0; background: none; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); border-bottom-color: var(--brand); }

/* toasts */
#toasts { position: fixed; bottom: 20px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; transition: opacity .4s, transform .4s; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(28,26,23,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; }

/* table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.num { font-variant-numeric: tabular-nums; }
