/* ==========================================================================
   App theme — plain CSS (no build step). The same design as the React/Tailwind kit:
   RTL-first Arabic UI, glass surfaces, dark by default with [data-theme="light"].
   Works in ASP.NET Web Forms / MVC / static HTML. Pair with theme.js and icons.svg.
   ========================================================================== */

/* ---- Tokens: dark (default) ---- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --font-sans: "Cairo", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: #6366f14d;

  --success: #10b981; --success-bg: #10b9811f;
  --warning: #f59e0b; --warning-bg: #f59e0b1f;
  --danger:  #ef4444; --danger-bg:  #ef44441f;
  --info:    #3b82f6; --info-bg:    #3b82f61f;

  --bg: #0a0e1a;
  --bg-secondary: #111827;
  --surface: #1a1f35;
  --surface-2: #252b45;
  --surface-hover: #1e2540;
  --input-bg: #1e2540;
  --border: #94a3b81a;
  --ring: #6366f1;
  --border-focus: #6366f180;

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-accent: #818cf8;

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px;
  --shadow-sm: 0 2px 8px #0000004d;
  --shadow-md: 0 4px 16px #0006;
  --shadow-lg: 0 8px 32px #00000080;
  --shadow-glow: 0 0 20px var(--primary-glow);
  --transition-fast: .15s cubic-bezier(.4,0,.2,1);
  --transition-normal: .25s cubic-bezier(.4,0,.2,1);

  --sidebar-width: 280px;
  --sidebar-collapsed: 76px;

  --dur-fast: .15s;
  --dur: .25s;
  --dur-slow: .4s;
  --dur-slower: .7s;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --glass: color-mix(in oklab, var(--surface) 72%, transparent);
  --glass-strong: color-mix(in oklab, var(--surface) 88%, transparent);
  --glass-blur: 14px;

  --success-border: #10b98159;
  --warning-border: #f59e0b59;
  --danger-border:  #ef444459;
  --info-border:    #3b82f659;

  --aurora-1: #6366f12e;
  --aurora-2: #06b6d41f;
}

/* ---- Tokens: light ---- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-secondary: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-hover: #f1f5f9;
  --input-bg: #f8fafc;
  --border: #0f172a14;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --text-accent: #4f46e5;
  --shadow-sm: 0 2px 8px #0000000f;
  --shadow-md: 0 4px 16px #00000014;
  --shadow-lg: 0 8px 32px #0000001f;
  --glass: color-mix(in oklab, var(--surface) 82%, transparent);
  --glass-strong: color-mix(in oklab, var(--surface) 94%, transparent);
  --aurora-1: #6366f11f;
  --aurora-2: #06b6d414;
}

/* ---- Base (a small reset so browser defaults don't fight the design) ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-normal), color var(--transition-normal);
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul.plain, ol.plain { list-style: none; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ---- Icons (icons.svg sprite): <svg class="i"><use href="icons.svg#name"/></svg> ---- */
.i { width: 18px; height: 18px; flex: none; }
.i-xs { width: 12px; height: 12px; } .i-sm { width: 15px; height: 15px; } .i-md { width: 20px; height: 20px; }
.i-lg { width: 22px; height: 22px; } .i-xl { width: 28px; height: 28px; }

/* ---- Small helpers ---- */
.muted { color: var(--text-muted); } .faint { color: var(--text-faint); }
.danger-text { color: var(--danger); }
.tabular { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; } .text-left { text-align: left; } .text-end { text-align: end; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.text-xs { font-size: .75rem; line-height: 1rem; } .text-sm { font-size: .875rem; line-height: 1.25rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.grid { display: grid; gap: 1rem; }
.mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mb-4 { margin-bottom: 1rem; }
.p-5 { padding: 1.25rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sm\:span-2 { grid-column: span 2; } }
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:span-2 { grid-column: span 2; }
}
@media (min-width: 640px) and (max-width: 1023px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.only-mobile { display: inline-flex; } @media (min-width: 768px) { .only-mobile { display: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Tones: one vocabulary for badges, tiles, stats, bars, alerts ---- */
.tone-brand { --fg: var(--primary);    --tbg: var(--primary-glow); --tborder: color-mix(in oklab, var(--primary) 45%, transparent); }
.tone-green { --fg: var(--success);    --tbg: var(--success-bg);   --tborder: var(--success-border); }
.tone-amber { --fg: var(--warning);    --tbg: var(--warning-bg);   --tborder: var(--warning-border); }
.tone-red   { --fg: var(--danger);     --tbg: var(--danger-bg);    --tborder: var(--danger-border); }
.tone-info  { --fg: var(--info);       --tbg: var(--info-bg);      --tborder: var(--info-border); }
.tone-slate { --fg: var(--text-muted); --tbg: var(--surface-2);    --tborder: var(--border); }

/* ---- Core components ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-normal);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: var(--radius-md); padding: .55rem 1.1rem; font-weight: 600; font-size: .9rem; line-height: 1.5;
  cursor: pointer; border: 1px solid transparent; transition: all var(--transition-fast);
  white-space: nowrap; background: none; color: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--border-focus); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-glow); filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #b91c1c); color: #fff; box-shadow: 0 4px 12px var(--danger-bg); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-block { width: 100%; }
.btn-sm { height: 2rem; padding: 0 .75rem; font-size: .75rem; }
.btn-icon { padding: 0; width: 36px; height: 36px; flex: none; background: transparent; color: var(--text); border-color: var(--border); }
.btn-icon:hover:not(:disabled) { background: var(--surface-2); }
.btn-icon + .btn-icon { margin-inline-start: .5rem; }
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover:not(:disabled) { background: var(--danger-bg); }
@media (pointer: coarse) { .btn-icon { width: 44px; height: 44px; } }

.input {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: .55rem .8rem; font-size: .9rem; font-family: inherit; line-height: 1.5; outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px var(--border-focus); }
.label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
.check { display: inline-flex; width: fit-content; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }
.field-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .field-grid > .full { grid-column: span 2; } }

.chip, .badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1rem;
}
.badge { background: var(--tbg); color: var(--fg); border: 1px solid var(--tborder); }
.badge:not([class*="tone-"]) { --fg: var(--text-muted); --tbg: var(--surface-2); --tborder: var(--border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.spinner {
  display: inline-block; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 1s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon tile — the one icon container */
.icon-tile {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: .75rem;
  color: var(--fg, var(--primary)); background: var(--tbg, var(--primary-glow));
  border: 1px solid var(--tborder, color-mix(in oklab, var(--primary) 45%, transparent));
}
.icon-tile.sz-34 { width: 34px; height: 34px; } .icon-tile.sz-40 { width: 40px; height: 40px; } .icon-tile.sz-44 { width: 44px; height: 44px; }
.icon-tile.gradient { color: #fff; border: 0; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 4px 12px var(--primary-glow); }

/* Headers */
.page-header { margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; }
.page-header .head { display: flex; align-items: center; gap: .75rem; }
.page-header h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
.page-header p { margin-top: .25rem; font-size: .875rem; color: var(--text-muted); }
.section-header { margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.section-header .head { display: flex; align-items: center; gap: .625rem; }
.section-header h2 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 700; }
.section-header p { font-size: .75rem; color: var(--text-muted); }

/* Stat card */
.stat-card { position: relative; overflow: hidden; padding: 1.25rem; }
.stat-card::before {
  content: ""; position: absolute; top: -2.5rem; inset-inline-start: -2.5rem; width: 7rem; height: 7rem;
  border-radius: 50%; opacity: .6; background: var(--tbg); filter: blur(28px); pointer-events: none;
}
.stat-card .body { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.stat-card .label-text { font-size: .875rem; font-weight: 500; color: var(--text-muted); }
.stat-card .value { margin-top: .5rem; font-size: 1.875rem; line-height: 2.25rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card .hint { margin-top: .25rem; font-size: .75rem; color: var(--text-muted); }

/* Progress + gauge */
.progress { width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--fg); transition: width var(--dur-slower) var(--ease-out); }
.progress.tone-brand > span, .progress:not([class*="tone-"]) > span { background: linear-gradient(90deg, var(--primary), var(--primary-hover)); }
.gauge { position: relative; display: grid; place-items: center; }
.gauge svg { transform: rotate(-90deg); }
.gauge .track { stroke: var(--surface-2); }
.gauge .arc { stroke: var(--fg, var(--primary)); transition: stroke-dashoffset var(--dur-slower) var(--ease-out); }
.gauge .center { position: absolute; text-align: center; }
.gauge .num { font-size: 1.5rem; line-height: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fg, var(--primary)); }
.gauge .cap { font-size: 11px; color: var(--text-muted); }

/* States */
.empty-state, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem;
  border-radius: 1rem; padding: 3rem; text-align: center;
}
.empty-state { border: 1px dashed var(--border); background: color-mix(in oklab, var(--surface) 60%, transparent); }
.empty-state .art { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 1rem; font-size: 1.875rem; background: var(--surface-2); border: 1px solid var(--border); }
.empty-state .title, .error-state .title { font-size: 1.125rem; font-weight: 600; }
.empty-state .hint, .error-state .hint { max-width: 24rem; font-size: .875rem; color: var(--text-muted); }
.error-state { padding: 2.5rem; border: 1px solid var(--danger-border); background: var(--danger-bg); }
.error-state .title { color: var(--danger); }
.error-state .art { font-size: 1.875rem; }

/* Inline alert (form error / warning / note) */
.alert {
  margin-top: .75rem; display: flex; align-items: flex-start; gap: .5rem;
  border-radius: .75rem; padding: .5rem .75rem; font-size: .875rem;
  background: var(--tbg); color: var(--fg); border: 1px solid var(--tborder);
  animation: scaleIn var(--dur) var(--ease-spring) both;
}
.alert:not([class*="tone-"]) { --fg: var(--danger); --tbg: var(--danger-bg); --tborder: var(--danger-border); }
.alert > .body { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table-modern { width: 100%; font-size: .875rem; border-collapse: collapse; }
.table-modern thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; padding: .75rem; text-align: start; white-space: nowrap;
}
.table-modern thead th.text-center { text-align: center; }
.table-modern thead th.text-left { text-align: left; }
.table-modern thead th.text-end { text-align: end; }
.table-modern tbody tr { border-top: 1px solid var(--border); transition: background var(--dur-fast) ease; }
.table-modern tbody tr:hover { background: var(--surface-2); }
.table-modern td { padding: .75rem; }
.table-modern tbody tr { animation: fadeIn var(--dur) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 22ms); }
.card > .table-modern:first-child thead th:first-child { border-start-start-radius: var(--radius-lg); }
.card > .table-modern:first-child thead th:last-child { border-start-end-radius: var(--radius-lg); }

/* Theme switch (☀️/🌙 pill) */
.theme-toggle {
  position: relative; display: inline-flex; align-items: center; width: 52px; height: 28px; padding: 0;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); transition: all var(--transition-fast);
}
.theme-toggle .knob {
  position: absolute; inset-inline-start: 3px; display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 1px 4px #0006;
  transition: all .15s cubic-bezier(.4,0,.2,1);
}
:root[data-theme="light"] .theme-toggle .knob { inset-inline-start: 26px; }
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: none; align-items: flex-start; justify-content: center; padding: 0 1rem;
  background: color-mix(in oklab, #020617 62%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal-backdrop.is-open { display: flex; animation: fadeIn var(--dur-fast) ease-out; }
.modal {
  margin-top: 1rem; display: flex; flex-direction: column; width: 100%; max-width: 42rem;
  max-height: calc(100dvh - 2rem); padding: 0; box-shadow: var(--shadow-lg); animation: modalIn .16s ease-out;
}
@media (min-width: 640px) { .modal { margin-top: 8vh; max-height: 84vh; } }
.modal-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.modal-head .head { display: flex; min-width: 0; align-items: center; gap: .625rem; }
.modal-head h3 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 700; overflow-wrap: anywhere; }
.modal-body { min-height: 0; overflow-y: auto; padding: 1.25rem; }
.confirm { padding: .25rem; text-align: center; }
.confirm .art { margin: 0 auto 1rem; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 1rem; font-size: 1.875rem; background: var(--danger-bg); border: 1px solid var(--danger-border); }
.confirm .msg { margin-bottom: 1.5rem; font-size: .875rem; line-height: 1.75rem; color: var(--text-muted); }
.confirm .actions { display: flex; justify-content: center; gap: .75rem; }

/* Toasts */
.toast-stack { pointer-events: none; position: fixed; inset-inline: 0; top: 1rem; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 0 1rem; }
.toast {
  pointer-events: auto; display: flex; width: 100%; max-width: 28rem; align-items: flex-start; gap: .75rem;
  border-radius: 1rem; border: 1px solid var(--tborder); padding: .75rem; box-shadow: var(--shadow-lg);
  background: linear-gradient(180deg, var(--tbg), var(--glass));
  backdrop-filter: blur(var(--glass-blur)) saturate(140%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  animation: toastIn var(--dur) var(--ease-spring);
}
.toast.leaving { animation: toastOut 220ms var(--ease-out) forwards; }
.toast > .i { margin-top: 2px; color: var(--fg); }
.toast p { flex: 1; font-size: .875rem; line-height: 1.5rem; }
.toast button { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border: 0; border-radius: .5rem; background: none; color: var(--text-muted); transition: background var(--transition-fast); }
.toast button:hover { background: var(--surface-2); }

/* ==========================================================================
   App shell: glass sidebar + top bar
   ========================================================================== */
.app-shell { position: relative; display: flex; min-height: 100vh; }
.appside {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; height: 100vh; width: 280px;
  display: flex; flex-direction: column; flex-shrink: 0; padding: .75rem;
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  transform: translateX(100%);
  transition: width var(--transition-normal), transform var(--transition-normal);
}
@media (max-width: 767px) { [dir="ltr"] .appside:not(.is-open) { transform: translateX(-100%); } }
.appside.is-open { transform: none; }
@media (min-width: 768px) {
  .appside { position: sticky; top: .75rem; margin: .75rem; height: calc(100vh - 24px); border-radius: 1rem; transform: none; }
  .appside[data-collapsed="true"] { width: var(--sidebar-collapsed); }
  .appside[data-collapsed="true"] .side-hide { display: none; }
  .appside[data-collapsed="true"] .nav-item { justify-content: center; padding-inline: 0; }
  .appside[data-collapsed="true"] .side-brand { justify-content: center; padding-inline: 0; gap: 0; }
  .appside[data-collapsed="true"] .side-head { padding-inline: 0; }
}
.side-overlay { position: fixed; inset: 0; z-index: 30; display: none; background: rgba(2,6,23,.6); backdrop-filter: blur(3px); }
.side-overlay.is-open { display: block; animation: fadeIn var(--dur-fast) ease-out; }
@media (min-width: 768px) { .side-overlay { display: none !important; } }

.side-head { margin-bottom: 1.25rem; display: flex; align-items: center; gap: .5rem; padding: 0 .25rem; }
.side-brand {
  display: flex; flex: 1; align-items: center; gap: .75rem; border: 0; border-radius: .75rem; padding: .25rem;
  background: none; text-align: start; transition: background var(--transition-fast);
}
.side-brand:hover { background: var(--surface-2); }
.brand-logo {
  display: flex; width: 44px; height: 44px; flex: none; align-items: center; justify-content: center; border-radius: .75rem; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 4px 12px var(--primary-glow);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.side-brand:hover .brand-logo { transform: rotate(6deg) scale(1.05); }
.brand-name { font-size: .875rem; line-height: 1.25; font-weight: 800; }
.brand-tag { font-size: .75rem; color: var(--text-muted); }

.side-nav { display: flex; flex: 1; flex-direction: column; gap: .25rem; overflow-y: auto; }
.nav-item {
  --tone: var(--primary);
  position: relative; display: flex; align-items: center; gap: .75rem; border-radius: .75rem;
  padding: .625rem .75rem; font-size: .875rem; line-height: 1.25rem; font-weight: 600; color: var(--text);
  transition: background .2s, color .2s, transform .2s;
}
.nav-item:not(.is-active):hover { transform: translateX(-2px); background: var(--surface-2); }
[dir="ltr"] .nav-item:not(.is-active):hover { transform: translateX(2px); }
.nav-item > .i { position: relative; color: var(--tone); transition: transform .2s; }
.nav-item:hover > .i { transform: scale(1.1); }
.nav-item > span { position: relative; }
.nav-item.is-active { color: #fff; }
.nav-item.is-active > .i { color: #fff; }
.nav-item.is-active::before {
  content: ""; position: absolute; inset: 0; border-radius: .75rem;
  background: linear-gradient(135deg, var(--tone), color-mix(in oklab, var(--tone) 62%, #000));
  box-shadow: 0 4px 14px color-mix(in oklab, var(--tone) 45%, transparent);
  animation: scaleIn var(--dur) var(--ease-spring);
}
.nav-divider { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }

.side-foot { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: 0 .25rem .5rem; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  font-size: .875rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #06b6d4);
}
.user-chip .name { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { font-size: .75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { width: 100%; justify-content: flex-start; color: var(--danger); }
.logout:hover:not(:disabled) { background: var(--danger-bg); }

.app-main { position: relative; z-index: 10; min-width: 0; flex: 1; padding: .75rem; }
@media (min-width: 768px) { .app-main { padding: 1.5rem; } }
.topbar {
  margin: 0 auto 1.25rem; max-width: 72rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  border: 1px solid var(--border); border-radius: 1rem; padding: .625rem .75rem;
}
.topbar .who { display: flex; min-width: 0; align-items: center; gap: .5rem; }
.topbar .hello { font-size: .875rem; line-height: 1.25rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .date { font-size: .75rem; line-height: 1rem; color: var(--text-muted); }
.topbar .tools { display: flex; flex-shrink: 0; align-items: center; gap: .5rem; }
.topbar .tools .caption { display: none; font-size: .75rem; color: var(--text-muted); }
@media (min-width: 640px) { .topbar .tools .caption { display: inline; } }
.page { margin: 0 auto; max-width: 72rem; }

/* ==========================================================================
   Motion system — entrances decelerate, pops overshoot, all off under reduced motion
   ========================================================================== */
@keyframes modalIn    { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fadeUp     { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn    { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes skeletonSweep { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes auroraDrift {
  0% { transform: translate3d(0,0,0) scale(1); } 33% { transform: translate3d(4%,-3%,0) scale(1.08); }
  66% { transform: translate3d(-3%,4%,0) scale(.96); } 100% { transform: translate3d(0,0,0) scale(1); }
}
@keyframes pulseGlow  { 0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); } 50% { box-shadow: 0 0 18px 4px var(--primary-glow); } }
@keyframes toastIn    { from { opacity: 0; transform: translateY(-12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut   { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

.page-enter { animation: fadeUp var(--dur-slow) var(--ease-out) both; }
.reveal     { animation: fadeUp var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.reveal-pop { animation: scaleIn var(--dur) var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 45ms); }

.card-hover { transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
.glass {
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
}
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora::before, .aurora::after { content: ""; position: absolute; width: 70vw; height: 70vw; border-radius: 50%; filter: blur(90px); will-change: transform; }
.aurora::before { background: var(--aurora-1); top: -22vw; inset-inline-end: -14vw; animation: auroraDrift 26s ease-in-out infinite; }
.aurora::after  { background: var(--aurora-2); bottom: -26vw; inset-inline-start: -16vw; animation: auroraDrift 34s ease-in-out infinite reverse; }
.skeleton {
  display: block; border-radius: var(--radius-md);
  background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in oklab, var(--surface-2) 60%, var(--text-muted)) 50%, var(--surface-2) 70%);
  background-size: 200% 100%; animation: skeletonSweep 1.4s ease-in-out infinite;
}
.gradient-text {
  background: linear-gradient(120deg, var(--text), var(--primary-hover) 60%, var(--text));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.glow-pulse { animation: pulseGlow 2.6s ease-in-out infinite; }
.login-cta { position: relative; overflow: hidden; }
.login-cta::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform var(--dur-slower) var(--ease-out);
}
.login-cta:hover:not(:disabled)::after { transform: translateX(120%); }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-page { position: relative; min-height: 100vh; overflow: hidden; background: var(--bg); }
.login-glow {
  pointer-events: none; position: absolute; inset: 0;
  background:
    radial-gradient(900px 520px at 88% -8%, color-mix(in oklab, var(--primary) 26%, transparent), transparent 62%),
    radial-gradient(760px 460px at 4% 108%, color-mix(in oklab, #06b6d4 20%, transparent), transparent 58%);
}
.login-toggle { position: absolute; top: 1rem; inset-inline-end: 1rem; z-index: 20; }
.login-wrap { position: relative; z-index: 10; margin: 0 auto; display: flex; min-height: 100vh; max-width: 72rem; align-items: center; padding: 2.5rem 1.25rem; }
.login-grid { display: grid; width: 100%; align-items: center; gap: 2.5rem; }
@media (min-width: 1024px) { .login-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.login-brand { display: none; }
@media (min-width: 1024px) { .login-brand { display: block; } .login-compact { display: none !important; } }
.brand-row { display: flex; align-items: center; gap: .75rem; }
.brand-mark {
  display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 1rem; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: var(--shadow-glow);
}
.brand-row h1 { font-size: 1.875rem; line-height: 1.25; font-weight: 800; }
.brand-row p, .login-compact p { font-size: .875rem; color: var(--text-muted); }
.feature-list { margin-top: 2.25rem; display: flex; flex-direction: column; gap: .75rem; list-style: none; padding: 0; }
.feature-list li { display: flex; align-items: flex-start; gap: .75rem; border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; }
.feature-list .tile { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: .75rem; background: var(--primary-glow); color: var(--primary); }
.feature-list .t { font-weight: 700; }
.feature-list .d { font-size: .875rem; color: var(--text-muted); }
.login-side { margin: 0 auto; width: 100%; max-width: 28rem; }
.login-compact { margin-bottom: 1.5rem; display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-compact .brand-mark { margin-bottom: .75rem; width: 64px; height: 64px; }
.login-compact h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 800; }
.login-compact p { margin-top: .25rem; }
.login-card { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 1rem; padding: 1.5rem; box-shadow: var(--shadow-lg); }
@media (min-width: 640px) { .login-card { padding: 1.75rem; } }
.login-card::before { content: ""; pointer-events: none; position: absolute; inset-inline: 1.5rem; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--primary), transparent); }
.login-card h2 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 700; }
.login-card .sub { margin: .25rem 0 1.25rem; font-size: .875rem; color: var(--text-muted); }
.login-card .label + .field { margin-bottom: 0; }
.login-card .field + .label { margin-top: 1rem; }
.login-card .submit { margin-top: 1.5rem; height: 3rem; width: 100%; font-size: 1rem; }
.login-card .foot { margin-top: 1.25rem; text-align: center; font-size: .75rem; color: var(--text-faint); }
/* Input with a leading icon (inline start: right in RTL) and an optional trailing button (inline end) */
.field { position: relative; }
.field > .lead { pointer-events: none; position: absolute; inset-block: 0; inset-inline-start: .75rem; display: grid; place-items: center; color: var(--text-muted); }
.field > .input { padding-inline-start: 2.5rem; }
.field.has-trail > .input { padding-inline-end: 2.75rem; }
.field > .trail {
  position: absolute; inset-block: 0; inset-inline-end: .25rem; margin: auto 0; display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: .5rem; background: none; color: var(--text-muted); transition: background var(--transition-fast);
}
.field > .trail:hover { background: var(--surface-2); }
.field > .trail .off { display: none; }
.field > .trail[aria-pressed="true"] .on { display: none; }
.field > .trail[aria-pressed="true"] .off { display: block; }

/* ==========================================================================
   «حول» page — full-screen storm (always dark, independent of the theme)
   ========================================================================== */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes aboutReveal { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ringspin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% center; } 100% { background-position: -200% center; } }

.about-page { position: fixed; inset: 0; z-index: 100; overflow-x: hidden; overflow-y: auto; background: #05070c; color: #fff; font-family: var(--font-sans); }
.about-bg { position: fixed; inset: 0; pointer-events: none; opacity: .2; background: center / cover no-repeat; filter: contrast(1.2) brightness(.2); }
.about-rain { position: fixed; inset: 0; z-index: 20; pointer-events: none; mix-blend-mode: screen; opacity: .9; }
.about-rain canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.about-veil {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  background: radial-gradient(1200px 800px at 50% 0%, rgba(99,102,241,.14), transparent 60%), linear-gradient(180deg, rgba(5,7,12,.35), rgba(5,7,12,.78));
}
.about-controls { position: fixed; top: 0; inset-inline: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; padding: 1.25rem; pointer-events: none; }
@media (min-width: 640px) { .about-controls { padding: 1.5rem; } }
.about-controls .left { display: flex; align-items: center; gap: .75rem; }
.frost {
  pointer-events: auto; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 8px 32px rgba(0,0,0,.3);
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.frost:hover { background: rgba(255,255,255,.2); }
.about-sound { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.about-sound:hover { transform: scale(1.1); }
.about-sound .off { display: none; color: rgba(255,255,255,.6); }
.about-sound[aria-pressed="false"] .on, .about-sound.is-error .on { display: none; }
.about-sound[aria-pressed="false"] .off, .about-sound.is-error .off { display: block; }
.about-hint {
  display: none; border-radius: 999px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.1);
  padding: .375rem .875rem; font-size: .75rem; font-weight: 600; color: rgba(255,255,255,.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.about-hint.is-visible { display: inline-block; animation: aboutReveal .8s cubic-bezier(.2,.7,.2,1) both; }
.about-back { display: flex; align-items: center; gap: .625rem; border-radius: 999px; padding: .625rem 1.25rem; font-size: .875rem; font-weight: 700; }
.about-back:hover { transform: scale(1.05); }
.about-back.lg { padding: .75rem 1.5rem; }

.about-main { position: relative; z-index: 30; margin: 0 auto; width: 100%; max-width: 64rem; padding: 7rem 1.25rem 6rem; }
@media (min-width: 640px) { .about-main { padding-inline: 2rem; } }
.about-hero { display: flex; min-height: 78vh; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.about-org {
  margin-bottom: 1.5rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.05);
  padding: .375rem 1rem; font-size: .75rem; font-weight: 600; letter-spacing: .025em; color: rgba(255,255,255,.8);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.about-hero h1 { font-size: 2.25rem; line-height: 1.25; font-weight: 800; }
@media (min-width: 640px) { .about-hero h1 { font-size: 3.75rem; } }
.about-lead { margin-top: 1.25rem; max-width: 42rem; font-size: 1rem; line-height: 2rem; color: rgba(255,255,255,.7); }
@media (min-width: 640px) { .about-lead { font-size: 1.125rem; } }
.about-stats { margin-top: 3rem; display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (min-width: 640px) { .about-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.about-stats > div { border-radius: 1rem; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); padding: 1rem; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.about-stats dt { font-size: 1.5rem; line-height: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .about-stats dt { font-size: 1.875rem; line-height: 2.25rem; } }
.about-stats dd { margin-top: .25rem; font-size: .75rem; color: rgba(255,255,255,.6); }
.about-down { margin-top: 3.5rem; color: rgba(255,255,255,.35); }

.about-section { margin-top: 6rem; }
.about-kicker { font-size: .75rem; font-weight: 700; letter-spacing: .2em; color: rgba(255,255,255,.4); }
.about-section h2 { margin: .5rem 0 1.5rem; font-size: 1.5rem; line-height: 2rem; font-weight: 800; }
@media (min-width: 640px) { .about-section h2 { font-size: 1.875rem; line-height: 2.25rem; } }
.about-caps { display: grid; gap: 1rem; }
@media (min-width: 640px) { .about-caps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.about-panel {
  display: flex; align-items: flex-start; gap: 1rem; border-radius: 1rem; border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.35); padding: 1.25rem; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: border-color 250ms, background 250ms;
}
.about-panel:hover { border-color: rgba(255,255,255,.25); background: rgba(0,0,0,.45); }
.about-panel .tile { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: .75rem; border: 1px solid rgba(255,255,255,.1); }
.about-panel h3 { font-weight: 700; }
.about-panel p { margin-top: .25rem; font-size: .875rem; line-height: 1.75rem; color: rgba(255,255,255,.6); }
.about-box { border-radius: 1rem; border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.4); padding: 1.5rem; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
@media (min-width: 640px) { .about-box { padding: 2rem; } }
.about-dev { display: flex; flex-direction: column; align-items: center; gap: 1.75rem; }
@media (min-width: 640px) { .about-dev { flex-direction: row; align-items: flex-start; } }
.about-ring { position: relative; flex: none; border-radius: 50%; }
.about-ring::before {
  content: ""; position: absolute; inset: -3px; border-radius: inherit; padding: 3px;
  background: conic-gradient(from 0deg, var(--primary), #06b6d4, #a855f7, var(--primary));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: ringspin 6s linear infinite;
}
.about-ring img { position: relative; width: 160px; height: 160px; border-radius: 50%; border: 3px solid rgba(255,255,255,.1); object-fit: cover; box-shadow: 0 25px 50px -12px rgba(0,0,0,.25); }
.about-dev .info { min-width: 0; flex: 1; text-align: center; }
@media (min-width: 640px) { .about-dev .info { text-align: right; } }
.about-dev .name { font-size: 1.875rem; line-height: 2.25rem; font-weight: 800; }
.about-dev .role { margin-top: .25rem; font-size: .875rem; font-weight: 600; color: #a5b4fc; }
.about-degrees { margin-top: .75rem; display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; list-style: none; padding: 0; }
@media (min-width: 640px) { .about-degrees { justify-content: flex-start; } }
.about-degrees li {
  display: flex; align-items: center; gap: .5rem; border-radius: 999px; border: 1px solid rgba(252,211,77,.25);
  background: rgba(252,211,77,.1); padding: .375rem .875rem; font-size: .75rem; font-weight: 600; color: #fef3c7;
}
.about-degrees .i { color: #fcd34d; }
.about-bio { margin-top: 1rem; font-size: .875rem; line-height: 2rem; color: rgba(255,255,255,.7); }
.about-contacts { margin-top: 1.5rem; display: grid; gap: .75rem; }
@media (min-width: 640px) { .about-contacts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.about-contacts a {
  display: flex; min-height: 3rem; align-items: center; justify-content: space-between; gap: .75rem;
  border-radius: 1rem; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  padding: .875rem 1.25rem; font-size: .875rem; font-weight: 500; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: all .15s cubic-bezier(.4,0,.2,1);
}
.about-contacts a:hover { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.1); }
.about-contacts .v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,.85); }
.about-contacts .k { display: flex; flex-shrink: 0; align-items: center; gap: .5rem; color: rgba(255,255,255,.5); transition: color .15s; }
.about-contacts .k span { font-size: .75rem; }
.about-contacts .k .i { transition: transform .15s; }
.about-contacts a:hover .k { color: var(--contact-hover); }
.about-contacts a:hover .k .i { transform: scale(1.1); }
.about-legal { display: flex; align-items: flex-start; gap: 1rem; }
.about-legal .tile { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: .75rem; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); color: rgba(255,255,255,.7); }
.about-legal p { font-size: .875rem; line-height: 2rem; color: rgba(255,255,255,.7); }
.about-legal b { color: #fff; }
.about-footer { margin-top: 4rem; display: flex; flex-direction: column; align-items: center; gap: .75rem; text-align: center; }
.about-footer .ver { font-size: .75rem; color: rgba(255,255,255,.35); }
.about-footer .credits { max-width: 36rem; font-size: 11px; line-height: 1.5rem; color: rgba(255,255,255,.3); }

.about-reveal { opacity: 0; animation: aboutReveal .8s cubic-bezier(.2,.7,.2,1) forwards; }
.about-wait { opacity: 0; }              /* until scrolled into view (theme.js) */
.about-float { animation: float 5s ease-in-out infinite; }
.about-shimmer {
  background: linear-gradient(100deg, var(--text) 30%, var(--primary-hover) 50%, var(--text) 70%);
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 4s linear infinite;
}
.about-page .about-shimmer { --text: #f1f5f9; }

/* ---- Reduced motion: everything lands on its final frame ---- */
@media (prefers-reduced-motion: reduce) {
  .page-enter, .reveal, .reveal-pop, .skeleton, .glow-pulse, .aurora::before, .aurora::after,
  .table-modern tbody tr, .alert, .toast, .modal, .nav-item.is-active::before {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
  .card-hover:hover { transform: none; }
  .login-cta::after { display: none; }
  .about-reveal, .about-float, .about-ring::before, .about-shimmer { animation: none; }
  .about-reveal, .about-wait { opacity: 1; }
  * { transition: none !important; }
}
