/* =============================================================================
   style.css — نظام التصميم بتاع Aroma Cloudflare
   -----------------------------------------------------------------------------
   الاتجاه (من ui-ux-pro-max، والتفاصيل في docs/DESIGN.md):
     • الستايل: Minimalism & Swiss + Flat. مناسب للوحات التحكم والـ SaaS، وبيدعم RTL بالكامل.
     • الألوان: B2B Navy/Slate + برتقالي البراند للأكشن الأساسي بس.
     • الخط: IBM Plex Sans Arabic، متحمّل من السيرفر نفسه (مفيش طلبات برة).
     • كل الألوان tokens في :root. ممنوع أي hex جوه الكومبوننتس.
     • كل التباينات محسوبة: النص 4.5:1 على الأقل، والأيقونات والحدود 3:1.
   ========================================================================== */

/* ---------------------------------------------------------------- الخط */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }

/* ---------------------------------------------------------------- Tokens: الوضع الفاتح */
:root {
  /* البراند */
  --brand: #f38020;            /* للشعار والزينة بس، مش للنص */
  --primary: #c2410c;          /* الأزرار الأساسية: أبيض عليه = 5.2:1 */
  --primary-hover: #9a3412;
  --on-primary: #ffffff;
  --primary-soft: #fff7ed;
  --primary-border: #fdba74;

  /* الأسطح */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* النص */
  --text: #0f172a;
  --text-2: #334155;
  --muted: #475569;            /* 7.5:1 على الأبيض */

  /* الحالات (لون + خلفية، وكلهم ≥ 4.5:1) */
  --ok: #15803d;   --ok-bg: #f0fdf4;   --ok-border: #bbf7d0;
  --warn: #854d0e; --warn-bg: #fefce8; --warn-border: #fde68a;
  --info: #1d4ed8; --info-bg: #eff6ff; --info-border: #bfdbfe;
  --err: #b91c1c;  --err-bg: #fef2f2;  --err-border: #fecaca;

  /* الشريط الجانبي (غامق في الوضعين) */
  --side-bg: #0f172a;
  --side-text: #cbd5e1;
  --side-muted: #94a3b8;
  --side-hover: #1e293b;
  --side-active: #1e293b;
  --side-border: #1e293b;

  --ring: #c2410c;
  --overlay: rgb(15 23 42 / .55);

  /* المسافات (كل 4px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* الحواف والظلال (Flat: ظل خفيف جداً بس) */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / .16);

  /* الحركة */
  --dur-fast: 120ms; --dur: 200ms; --dur-slow: 280ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);

  /* الطبقات */
  --z-sticky: 20; --z-dropdown: 40; --z-drawer: 60; --z-modal: 100; --z-toast: 200;

  --icon-sm: 16px; --icon-md: 20px;

  color-scheme: light;
}

/* ---------------------------------------------------------------- Tokens: الوضع الغامق */
/* ألوان أفتح ومش مشبّعة، مش مجرد عكس للألوان، والتباين اتحسب لوحده */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #fb923c;          /* نص غامق عليه = 8.6:1 */
    --primary-hover: #fdba74;
    --on-primary: #1c0a00;
    --primary-soft: rgb(251 146 60 / .1);
    --primary-border: rgb(251 146 60 / .45);

    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --surface-hover: #172033;
    --border: #1f2937;
    --border-strong: #334155;

    --text: #f1f5f9;
    --text-2: #cbd5e1;
    --muted: #94a3b8;            /* 6.9:1 على surface */

    --ok: #4ade80;   --ok-bg: rgb(74 222 128 / .1);   --ok-border: rgb(74 222 128 / .3);
    --warn: #facc15; --warn-bg: rgb(250 204 21 / .1); --warn-border: rgb(250 204 21 / .3);
    --info: #93c5fd; --info-bg: rgb(147 197 253 / .1); --info-border: rgb(147 197 253 / .3);
    --err: #f87171;  --err-bg: rgb(248 113 113 / .1); --err-border: rgb(248 113 113 / .3);

    --side-bg: #060a14;
    --side-hover: #111827;
    --side-active: #111827;
    --side-border: #111827;

    --ring: #fb923c;
    --overlay: rgb(0 0 0 / .65);
    --shadow-sm: none;
    --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- الأساسيات */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: "Plex Arabic", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.3; text-wrap: balance; }
a { color: var(--primary); text-underline-offset: 3px; }
code, .mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  direction: ltr; unicode-bidi: isolate; font-size: .93em;
}
.domain-name { overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* الأيقونات (Lucide، stroke 2) */
.i { width: var(--icon-md); height: var(--icon-md); flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: var(--icon-sm); height: var(--icon-sm); }
.i-flip { transform: scaleX(-1); } /* الأسهم في RTL */

/* Focus ظاهر وواضح (3:1) لكل اللي بيتضغط من الكيبورد */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-sm); }

.skip-link {
  position: absolute; inset-inline-start: var(--s4); top: -100px; z-index: var(--z-toast);
  background: var(--primary); color: var(--on-primary); padding: var(--s2) var(--s4); border-radius: var(--r-md); font-weight: 600;
}
.skip-link:focus { top: var(--s4); }

/* ---------------------------------------------------------------- الشعار */
.brand { display: flex; align-items: center; gap: var(--s3); font-weight: 700; font-size: 16px; }
.brand .logo { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--brand); display: grid; place-items: center; flex: none; }
.brand .logo svg { width: 22px; height: 22px; fill: #fff; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--side-muted); }

/* ---------------------------------------------------------------- الدخول */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--s8); box-shadow: var(--shadow-sm); }
.login-card .brand { flex-direction: column; text-align: center; margin-bottom: var(--s8); gap: var(--s3); font-size: 20px; }
.login-card .brand .logo { width: 52px; height: 52px; border-radius: var(--r-lg); }
.login-card .brand .logo svg { width: 30px; height: 30px; }
.login-card .brand small { color: var(--muted); font-size: 14px; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin-top: var(--s6); color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- الهيكل */
.layout { display: flex; min-height: 100dvh; }
.sidebar {
  width: 256px; flex: none; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: var(--s5) var(--s3); position: sticky; top: 0; height: 100dvh;
}
.sidebar .brand { color: #fff; padding: 0 var(--s2) var(--s5); margin-bottom: var(--s3); border-bottom: 1px solid var(--side-border); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  position: relative; color: var(--side-text); text-decoration: none; padding: 0 var(--s3); min-height: 42px; border-radius: var(--r-md);
  display: flex; align-items: center; gap: var(--s3); font-weight: 500; transition: background var(--dur-fast), color var(--dur-fast);
}
.nav a .i { color: var(--side-muted); transition: color var(--dur-fast); }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; }
.nav a[aria-current="page"] .i { color: var(--brand); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; inset-inline-start: calc(-1 * var(--s3)); top: 10px; bottom: 10px; width: 3px;
  background: var(--brand); border-start-end-radius: 3px; border-end-end-radius: 3px;
}
.nav-sep { font-size: 12px; font-weight: 600; color: var(--side-muted); padding: var(--s5) var(--s3) var(--s2); }
.userbox { border-top: 1px solid var(--side-border); padding: var(--s4) var(--s2) 0; display: flex; align-items: center; gap: var(--s3); }
.avatar {
  width: 36px; height: 36px; border-radius: var(--r-full); background: var(--side-hover); color: #fff; display: grid; place-items: center;
  font-weight: 600; flex: none;
}
.userbox .who { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; }
.userbox .who b { color: #fff; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .who span { color: var(--side-muted); }
.side-btn { background: none; border: 0; color: var(--side-muted); width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; cursor: pointer; }
.side-btn:hover { background: var(--side-hover); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s8); min-height: 64px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; }
.topbar h1:focus { outline: none; }
.menu-btn { display: none; }
#view { padding: var(--s8); max-width: 1200px; width: 100%; }
.drawer-backdrop { display: none; }

.mock-banner { display: flex; align-items: center; gap: var(--s2); background: var(--warn-bg); color: var(--warn); padding: var(--s2) var(--s8); font-size: 13px; border-bottom: 1px solid var(--warn-border); }

/* ---------------------------------------------------------------- زرار أيقونة */
.icon-btn {
  position: relative; background: none; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }

/* ---------------------------------------------------------------- التنبيهات */
.bell-wrap { position: relative; }
.bell .count {
  position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; border-radius: var(--r-full);
  background: var(--err); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 5px; text-align: center;
  border: 2px solid var(--surface); box-sizing: content-box; font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .bell .count { color: #1c0505; } }
.bell.ring .i { animation: ring 700ms var(--ease-out) 2; transform-origin: 50% 10%; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }

.notif-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + var(--s2)); width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  max-height: min(480px, 70dvh); overflow: auto; z-index: var(--z-dropdown);
  animation: pop var(--dur) var(--ease-out);
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.notif-item { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); font-size: 14px; }
.notif-item:last-child { border-bottom: 0; }
.notif-item .dot { width: 8px; height: 8px; border-radius: var(--r-full); background: transparent; margin-top: 8px; flex: none; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item.unread .dot { background: var(--primary); }
.notif-empty { padding: var(--s10) var(--s4); text-align: center; color: var(--muted); display: grid; justify-items: center; gap: var(--s2); }

/* ---------------------------------------------------------------- الأزرار */
.btn {
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  min-height: 40px; padding: 0 var(--s4); border-radius: var(--r-md); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); text-decoration: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--border); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.is-busy { cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--err); border-color: var(--err-border); }
.btn.danger:hover { background: var(--err-bg); }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger-solid { color: #1c0505; } }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 0 var(--s3); font-size: 13px; }
.btn.block { width: 100%; min-height: 44px; }
.spin { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- الفورم */
label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: var(--s2); color: var(--text); }
.req { color: var(--err); margin-inline-start: 2px; }
.field { margin-bottom: var(--s5); }
.hint { font-weight: 400; font-size: 13px; color: var(--muted); margin-top: var(--s2); }
input, select {
  font: inherit; font-size: 15px; width: 100%; min-height: 44px; padding: 0 var(--s3);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), 0 0 0 1px var(--primary); }
input[dir="ltr"] { text-align: left; }
input[aria-invalid="true"] { border-color: var(--err); }
.row { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: flex-start; }
.row > .field { flex: 1 1 200px; }
.row > .btn { margin-top: 30px; }
.input-wrap { position: relative; }
.input-wrap .i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: var(--s3); color: var(--muted); pointer-events: none; }
.input-wrap input { padding-inline-start: 40px; }
.input-group { display: flex; gap: var(--s2); }
.pass-wrap { position: relative; }
.pass-wrap input { padding-inline-end: 48px; }
.pass-toggle { position: absolute; top: 2px; inset-inline-end: 2px; }
.alert {
  display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md);
  margin-bottom: var(--s5); font-size: 14px; border: 1px solid;
}
.alert .i { margin-top: 2px; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.alert ul, .alert ol { margin: var(--s1) 0 0; padding-inline-start: var(--s5); }
.alert a { color: inherit; font-weight: 600; }

/* ---------------------------------------------------------------- الكروت */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: var(--s6); margin-bottom: var(--s6); }
.card h2 { font-size: 16px; font-weight: 700; margin: 0 0 var(--s4); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.card-head h2 { margin: 0; }
.card-sub { color: var(--muted); font-size: 14px; margin: calc(-1 * var(--s3)) 0 var(--s5); }
.narrow { max-width: 600px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5);
  display: flex; gap: var(--s4); align-items: center; text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast);
}
a.stat:hover { border-color: var(--border-strong); }
.stat .ico { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat.warn .ico { background: var(--warn-bg); color: var(--warn); }
.stat.info .ico { background: var(--info-bg); color: var(--info); }
.stat.ok .ico   { background: var(--ok-bg); color: var(--ok); }
.stat.err .ico  { background: var(--err-bg); color: var(--err); }

/* ---------------------------------------------------------------- الجداول */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s6)) calc(-1 * var(--s6)); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: var(--s3) var(--s4); text-align: start; border-top: 1px solid var(--border); vertical-align: middle; }
th:first-child, td:first-child { padding-inline-start: var(--s6); }
th:last-child, td:last-child { padding-inline-end: var(--s6); }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
tbody tr { transition: background var(--dur-fast); }
tbody tr:hover { background: var(--surface-hover); }
tr.highlight { background: var(--info-bg); }
tr.highlight:hover { background: var(--info-bg); }
td .actions { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
td.domain { font-weight: 600; }
/* الخانات القصيرة متتكسرش على سطرين على الديسكتوب (على الموبايل الجدول بيبقى كروت) */
@media (min-width: 768px) {
  td.domain .domain-name, td[data-label="السيرفر"], td[data-label="تاريخ الإضافة"], td[data-label="الوقت"], td[data-label="IP"] { white-space: nowrap; overflow-wrap: normal; }
}
.err-text { display: flex; gap: var(--s1); align-items: flex-start; color: var(--err); font-size: 13px; margin-top: var(--s1); max-width: 320px; }

/* الشارات: لون + أيقونة + نص (مش بنعتمد على اللون لوحده) */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid;
}
.badge .i { width: 14px; height: 14px; }
.badge.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-border); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge.err  { background: var(--err-bg);  color: var(--err);  border-color: var(--err-border); }
.badge.muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

/* ---------------------------------------------------------------- الفلاتر */
.toolbar { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; margin-bottom: var(--s5); }
.toolbar .spacer { flex: 1; }
.tabs { display: flex; gap: var(--s1); flex-wrap: wrap; background: var(--surface-2); padding: var(--s1); border-radius: var(--r-md); }
.tab {
  font: inherit; font-size: 13px; font-weight: 600; min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-sm); border: 0;
  background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tab:hover { color: var(--text); }
.tab[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .c { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toolbar .input-wrap { width: 260px; }

/* ---------------------------------------------------------------- الحالات الفاضية والتحميل */
.empty { padding: var(--s10) var(--s4); text-align: center; color: var(--muted); display: grid; justify-items: center; gap: var(--s2); }
.empty .ico { width: 48px; height: 48px; border-radius: var(--r-full); background: var(--surface-2); display: grid; place-items: center; color: var(--muted); margin-bottom: var(--s2); }
.empty b { color: var(--text); font-size: 15px; }
.skeleton { display: grid; gap: var(--s3); }
.skeleton div { height: 44px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton div:first-child { height: 28px; width: 40%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- الـ Nameservers */
.ns-list { display: grid; gap: var(--s3); margin: var(--s5) 0; }
.ns-item {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--primary-soft); border: 1px solid var(--primary-border);
}
.ns-item .ns-n { font-weight: 700; color: var(--primary); font-size: 12px; min-width: 32px; }
.ns-item code { flex: 1; font-size: 16px; font-weight: 600; text-align: left; overflow-wrap: anywhere; color: var(--text); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 var(--s2); display: grid; gap: var(--s3); }
.steps li { counter-increment: s; display: flex; gap: var(--s3); align-items: flex-start; font-size: 14px; color: var(--text-2); }
.steps li::before {
  content: counter(s); flex: none; width: 24px; height: 24px; border-radius: var(--r-full); background: var(--surface-2);
  color: var(--text); font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- التحقق بخطوتين */
/* خانة الكود: أرقام كبيرة ومتباعدة علشان تتقري بسهولة وهو بيبص على الموبايل */
.otp-input { text-align: center !important; font-family: ui-monospace, Consolas, monospace; font-size: 24px; letter-spacing: .3em; min-height: 52px; font-variant-numeric: tabular-nums; }
.otp-input::placeholder { letter-spacing: .3em; }
.login-links { display: flex; justify-content: space-between; gap: var(--s2); margin-top: var(--s4); flex-wrap: wrap; }
.tfa-steps { margin: var(--s4) 0; }
/* الـ QR لازم يفضل أسود على أبيض حتى في الوضع الغامق، وإلا الكاميرا مش هتقراه */
.qr-box { background: #ffffff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s3); width: max-content; margin: 0 auto var(--s4); }
.qr-box img { display: block; width: 200px; height: 200px; }
.manual-key { margin-bottom: var(--s4); }
.manual-key summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14px; padding: var(--s2) 0; width: max-content; }
.manual-key .ns-item { margin-top: var(--s2); }
.manual-key code { font-size: 15px; letter-spacing: .05em; }
.codes-grid { list-style: none; padding: var(--s4); margin: var(--s5) 0 var(--s4); display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2) var(--s4); background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); }
.codes-grid code { font-size: 15px; font-weight: 600; color: var(--text); }
.check-row { display: flex; align-items: center; gap: var(--s3); font-weight: 500; margin: var(--s5) 0 0; cursor: pointer; min-height: 44px; }
.check-row input { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); flex: none; cursor: pointer; }

/* ---------------------------------------------------------------- النوافذ */
#modal-root .backdrop {
  position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: var(--s4); z-index: var(--z-modal);
  animation: fade var(--dur) var(--ease-out);
}
.modal {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  width: 100%; max-width: 560px; padding: var(--s6); box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - 32px); overflow: auto; animation: pop var(--dur-slow) var(--ease-out);
}
.modal h2 { margin: 0 0 var(--s2); font-size: 19px; font-weight: 700; padding-inline-end: var(--s10); }
.modal-close { position: absolute; top: var(--s4); inset-inline-end: var(--s4); }
.modal-actions { display: flex; gap: var(--s3); margin-top: var(--s6); flex-wrap: wrap; }
.modal-icon { width: 56px; height: 56px; border-radius: var(--r-full); display: grid; place-items: center; margin: 0 auto var(--s4); }
.modal-icon .i { width: 28px; height: 28px; }
.modal-icon.ok { background: var(--ok-bg); color: var(--ok); }
.modal-icon.err { background: var(--err-bg); color: var(--err); }
.modal.activated { text-align: center; }
.modal.activated h2 { padding: 0; }
.modal.activated form { text-align: start; margin-top: var(--s5); }
.modal.activated .modal-actions { justify-content: center; }
.modal.activated .modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------------------------------------------------------------- Toast */
#toasts { position: fixed; bottom: var(--s4); inset-inline-start: var(--s4); display: flex; flex-direction: column; gap: var(--s2); z-index: var(--z-toast); }
.toast {
  display: flex; align-items: center; gap: var(--s3); background: var(--text); color: var(--surface);
  padding: var(--s3) var(--s4); border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  max-width: min(400px, calc(100vw - 32px)); animation: pop var(--dur) var(--ease-out);
}
.toast.err { background: var(--err); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.err { color: #1c0505; } }
.toast.leaving { opacity: 0; transition: opacity var(--dur-fast) var(--ease-in); }

.boot { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* ---------------------------------------------------------------- الموبايل والتابلت */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-drawer);
    transform: translateX(100%); transition: transform var(--dur-slow) var(--ease-out); visibility: hidden;
  }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .drawer-backdrop.open { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-drawer) - 1); animation: fade var(--dur) var(--ease-out); }
  .menu-btn { display: grid; }
  .topbar { padding: 0 var(--s4); }
  .mock-banner { padding: var(--s2) var(--s4); }
  #view { padding: var(--s5) var(--s4); }
}

@media (max-width: 767px) {
  body { font-size: 16px; }
  .card { padding: var(--s4); }
  .table-wrap { margin: 0 calc(-1 * var(--s4)) calc(-1 * var(--s4)); }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .toolbar .input-wrap { width: 100%; }
  .row > .btn { margin-top: 0; width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
  .stat { flex-direction: column; align-items: flex-start; gap: var(--s3); padding: var(--s4); }

  /* الجداول بتتحول لكروت على الموبايل علشان مفيش Scroll بالعرض */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
  table.responsive td { border: 0; padding: var(--s1) 0 !important; display: flex; justify-content: space-between; gap: var(--s3); align-items: center; }
  table.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 500; flex: none; }
  table.responsive td.domain { font-size: 16px; padding-bottom: var(--s2) !important; }
  table.responsive td .actions { justify-content: flex-start; padding-top: var(--s2); width: 100%; }
  table.responsive td .actions .btn { flex: 1 1 auto; }
  .err-text { max-width: none; }
}

/* ---------------------------------------------------------------- تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .spin { animation: none !important; }
}
