/* ============================================================
   للمونتاج — RTL Arabic dashboard, slate-charcoal dark, violet accent
   Based on reference design (styles.css). Body is the grid container
   because PHP outputs <aside> and <div.dash-layout> as siblings.
   ============================================================ */

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

/* =========== Design tokens =========== */
:root {
  --accent:      #8b6dff;
  --accent-2:    #a98bff;
  --accent-soft: rgba(139,109,255,0.14);
  --accent-ring: rgba(139,109,255,0.35);

  --bg:          #0f1115;
  --bg-2:        #14171d;
  --surface:     #181b22;
  --surface-2:   #1d2129;
  --surface-3:   #232833;
  --line:        rgba(255,255,255,0.06);
  --line-strong: rgba(255,255,255,0.10);

  --fg:     #e8eaf0;
  --fg-2:   #c7cad3;
  --muted:  #8a8f9c;
  --muted-2:#6a6f7c;

  /* Status colours */
  --status-new:      #6aa6ff;
  --status-progress: #b18bff;
  --status-review:   #f5b454;
  --status-edit:     #ff8a8a;
  --status-done:     #5fd49a;
  --status-late:     #ff6b7a;

  /* Short aliases used in PHP templates */
  --green:  #5fd49a;
  --yellow: #f5b454;
  --red:    #ff6b7a;
  --blue:   #6aa6ff;
  --purple: #b18bff;

  /* Legacy */
  --accent2: var(--accent-2);
  --dark:    var(--bg);
  --border:  var(--line);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow:    0 8px 30px rgba(0,0,0,0.35);

  --side-w: 268px;
  --top-h:  68px;
}

/* =========== Reset =========== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
h1,h2,h3,h4,h5,h6 { margin: 0; }
p { margin: 0; }

/* =========== Base =========== */
html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", Tahoma, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { display: block; }

/* Ambient gradient */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 500px at 90% -10%, color-mix(in oklab,var(--accent) 12%,transparent), transparent 60%),
    radial-gradient(800px 600px at -10% 110%, color-mix(in oklab,var(--accent) 7%,transparent), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   DASHBOARD LAYOUT
   PHP outputs:
     <body class="dash-body">
       <aside class="dash-sidebar">…</aside>
       <div class="dash-layout">
         <div class="dash-main">…</div>
       </div>
     </body>

   We make body.dash-body a grid with two columns.
   In RTL, column-1 is visually on the RIGHT → sidebar.
   Column-2 is on the LEFT → main content.
   ============================================================ */

body.dash-body {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* =========== Sidebar =========== */
.dash-sidebar, .sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 22px 18px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
}

/* =========== Main =========== */
.dash-layout, .app {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.dash-main, .main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.dash-content, .content {
  padding: 28px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =========== Brand =========== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab,var(--accent) 60%,#000));
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 6px 20px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.18);
  position: relative;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 6px;
  border: 1.5px solid rgba(255,255,255,0.55);
  border-radius: 6px;
  clip-path: polygon(0 0, 60% 0, 100% 50%, 60% 100%, 0 100%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15.5px; letter-spacing: 0.01em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

/* =========== Sidebar nav sections =========== */
.side-section { display: flex; flex-direction: column; gap: 4px; }
.side-title {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--muted-2);
  padding: 10px 10px 4px;
  text-transform: uppercase;
}

/* nav items — supports both <a> and <div> */
.nav-item, .side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 120ms, color 120ms, border-color 120ms;
  text-decoration: none;
}
.nav-item:hover, .side-link:hover { background: var(--surface); color: var(--fg); }
.nav-item .ico, .side-link .side-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
}
.nav-item:hover .ico, .side-link:hover .side-icon { color: var(--fg-2); }
.nav-item .count, .side-link .side-badge {
  margin-left: auto;                       /* push to far left in RTL flex row */
  font-size: 11px; color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 999px;
}
.nav-item.active, .side-link.active {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: color-mix(in oklab,var(--accent) 25%,transparent);
}
.nav-item.active .ico, .side-link.active .side-icon { color: var(--accent-2); }
.nav-item.active .count, .side-link.active .side-badge {
  background: color-mix(in oklab,var(--accent) 22%,var(--surface-2));
  border-color: color-mix(in oklab,var(--accent) 30%,var(--line));
  color: var(--fg);
}

/* Sidebar footer */
.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg,#2c3140,#1a1d24);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  font-size: 13px; color: var(--fg); font-weight: 600;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
.side-foot .who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.side-foot .who b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-size: 11.5px; color: var(--muted); }
.side-foot .menu-btn {
  margin-left: auto;
  width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); display: grid; place-items: center;
}
.side-foot .menu-btn:hover { color: var(--fg); border-color: var(--line-strong); }

/* =========== Topbar =========== */
.dash-topbar, .topbar {
  position: sticky;
  top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: color-mix(in oklab,var(--bg) 80%,transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.topbar-title, .page-title {
  display: flex; flex-direction: column; line-height: 1.15;
}
.topbar-title h1, .topbar-title h2, .page-title h1 {
  margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.01em;
}
.crumbs, .topbar-title .crumbs {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--fg); }

.topbar-spacer, .tb-spacer { flex: 1; }

/* Search in topbar */
.topbar-search, .search {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  min-width: 200px; max-width: 340px;
  transition: border-color 120ms, box-shadow 120ms;
}
.topbar-search:focus-within, .search:focus-within {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-search .s-ico, .search .s-ico { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.topbar-search input, .search input {
  background: none; border: 0; outline: none;
  color: var(--fg); font-size: 13px; width: 100%; font-family: inherit;
}
.topbar-search input::placeholder, .search input::placeholder { color: var(--muted-2); }
.topbar-search .s-kbd, .search .kbd, .kbd {
  font-size: 11px; color: var(--muted-2);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 5px; white-space: nowrap;
}

/* Notification bell */
.notif-bell, .notif-btn, .icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--fg-2); display: grid; place-items: center;
  cursor: pointer; font-size: 18px;
  position: relative;
  transition: background 120ms, border-color 120ms, color 120ms;
  text-decoration: none;
}
.notif-bell:hover, .notif-btn:hover, .icon-btn:hover {
  background: var(--surface-2); color: var(--fg); border-color: var(--line-strong);
}
.notif-badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 17px; height: 17px; border-radius: 999px;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center; padding: 0 4px;
  border: 2px solid var(--bg);
}
.notif-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--bg);
}

.notif-panel, .notif-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: 360px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 100; overflow: hidden; display: none;
}
.notif-panel.open, .notif-dropdown.open { display: block; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.notif-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; cursor: pointer; transition: background 100ms;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in oklab,var(--accent) 5%,var(--surface)); }
.notif-item .n-body { flex: 1; min-width: 0; }
.notif-item .n-title { font-weight: 500; color: var(--fg); margin-bottom: 2px; }
.notif-item .n-msg { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item .n-time { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.notif-footer { padding: 10px 16px; font-size: 12px; text-align: center; color: var(--muted); }

/* =========== Section header =========== */
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.005em; }
.section-head .sub { color: var(--muted); font-size: 12.5px; }

/* =========== Cards =========== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }

/* =========== Stat cards =========== */
.stats-grid, .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px;
}
.stat-card, .stat {
  position: relative;
  padding: 20px 22px;
  background: linear-gradient(180deg,var(--surface),var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; align-items: flex-start; gap: 14px;
}
.stat-card::before, .stat::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(220px 80px at 100% 0%,var(--accent-soft),transparent 60%);
  opacity: 0.6;
  pointer-events: none;
}
.stat-icon, .stat .lbl {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
  position: relative; z-index: 1;
}
.stat-icon.green { background: rgba(95,212,154,.12); border-color: rgba(95,212,154,.25); }
.stat-icon.yellow { background: rgba(245,180,84,.12); border-color: rgba(245,180,84,.25); }
.stat-icon.red { background: rgba(255,107,122,.12); border-color: rgba(255,107,122,.25); }
.stat-icon.blue { background: rgba(106,166,255,.12); border-color: rgba(106,166,255,.25); }
.stat-icon.purple { background: rgba(177,139,255,.12); border-color: rgba(177,139,255,.25); }
.stat-icon.accent, .stat.accent .lbl {
  background: var(--accent-soft);
  border-color: color-mix(in oklab,var(--accent) 30%,transparent);
}
.stat-info, .stat .lbl { display: flex; flex-direction: column; gap: 4px; position: relative; z-index: 1; background: none; border: none; width: auto; height: auto; }
.stat-value, .stat .val {
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-label, .stat .lbl-text { font-size: 12.5px; color: var(--muted); }
.stat .delta {
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--status-done);
}
.stat .delta.down { color: var(--status-edit); }
.stat .delta .pill {
  background: color-mix(in oklab,currentColor 15%,transparent);
  padding: 1px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* =========== Tables =========== */
.table-wrap { overflow: hidden; overflow-x: auto; border-radius: var(--radius); }
table, .table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
thead th {
  text-align: start;
  font-weight: 500; font-size: 11.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  padding: 14px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--fg-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 100ms; cursor: pointer; }
tbody tr:hover { background: color-mix(in oklab,var(--surface-2) 60%,transparent); }
.table .id, td.id {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; color: var(--muted);
}
.table .name, td.name { color: var(--fg); font-weight: 500; }

/* =========== Status cell with progress bar =========== */
.status-cell, .status {
  display: inline-flex; flex-direction: column; gap: 5px; min-width: 130px;
}
.status-cell .s-row,
.status .row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px;
}
.status-cell .s-label,
.status .label {
  display: inline-flex; align-items: center; gap: 6px; color: var(--fg-2);
}
.status-cell .s-dot, .status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); display: inline-block; flex-shrink: 0;
}
.status-cell .s-pct, .status .pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.status-cell .s-bar, .status .bar {
  height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden;
}
.status-cell .s-bar > span, .status .bar > span {
  display: block; height: 100%; border-radius: 999px; background: var(--accent);
}

/* Status colour variants */
.status-cell[data-s="new"] .s-dot,
.status-cell[data-s="new"] .s-bar > span,
.status[data-s="new"] .dot,
.status[data-s="new"] .bar > span        { background: var(--status-new); }

.status-cell[data-s="in_progress"] .s-dot,
.status-cell[data-s="in_progress"] .s-bar > span,
.status[data-s="progress"] .dot,
.status[data-s="progress"] .bar > span  { background: var(--status-progress); }

.status-cell[data-s="review"] .s-dot,
.status-cell[data-s="review"] .s-bar > span,
.status[data-s="review"] .dot,
.status[data-s="review"] .bar > span    { background: var(--status-review); }

.status-cell[data-s="completed"] .s-dot,
.status-cell[data-s="completed"] .s-bar > span,
.status[data-s="done"] .dot,
.status[data-s="done"] .bar > span      { background: var(--status-done); }

.status-cell[data-s="cancelled"] .s-dot,
.status-cell[data-s="cancelled"] .s-bar > span  { background: var(--muted-2); }

.status[data-s="edit"] .dot,
.status[data-s="edit"] .bar > span      { background: var(--status-edit); }
.status[data-s="late"] .dot,
.status[data-s="late"] .bar > span      { background: var(--status-late); }

/* =========== Who cell =========== */
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .av {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 12px; color: var(--fg); font-weight: 600; flex-shrink: 0;
}
.who-cell .who-info { display: flex; flex-direction: column; line-height: 1.2; }
.who-cell .who-info b { color: var(--fg); font-weight: 500; font-size: 13.5px; }
.who-cell .who-info span { color: var(--muted); font-size: 11.5px; }

/* =========== Badges =========== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--fg-2);
  white-space: nowrap; font-weight: 500;
}
.badge-green  { background: rgba(95,212,154,.15);  border-color: rgba(95,212,154,.3);  color: #5fd49a; }
.badge-yellow { background: rgba(245,180,84,.15);  border-color: rgba(245,180,84,.3);  color: #f5b454; }
.badge-red    { background: rgba(255,107,122,.15); border-color: rgba(255,107,122,.3); color: #ff6b7a; }
.badge-blue   { background: rgba(106,166,255,.15); border-color: rgba(106,166,255,.3); color: #6aa6ff; }
.badge-purple { background: rgba(177,139,255,.15); border-color: rgba(177,139,255,.3); color: #b18bff; }
.badge-orange { background: rgba(255,159,67,.15);  border-color: rgba(255,159,67,.3);  color: #ff9f43; }
.badge-gray   { background: var(--surface-3); border-color: var(--line); color: var(--muted); }

/* =========== Tag =========== */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--fg-2);
}
.tag.accent {
  background: var(--accent-soft);
  border-color: color-mix(in oklab,var(--accent) 25%,transparent);
  color: var(--accent-2);
}

/* =========== Buttons =========== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg); font: inherit; font-size: 14px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, filter 120ms;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary, .btn.primary {
  background: linear-gradient(180deg,var(--accent),color-mix(in oklab,var(--accent) 78%,#000));
  border-color: color-mix(in oklab,var(--accent) 60%,transparent);
  color: white;
  box-shadow: 0 6px 18px var(--accent-soft);
}
.btn-primary:hover, .btn.primary:hover { filter: brightness(1.08); }
.btn-secondary, .btn.secondary { background: var(--surface-2); }
.btn-ghost, .btn.ghost { background: transparent; }
.btn-danger { background: rgba(255,107,122,.15); border-color: rgba(255,107,122,.3); color: #ff6b7a; }
.btn-danger:hover { background: rgba(255,107,122,.25); }
.btn-sm, .btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* =========== Forms =========== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--fg);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.form-control:focus {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--muted-2); }
select.form-control { appearance: none; -webkit-appearance: none; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* =========== Filter bar / chips =========== */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--fg-2); font-size: 12.5px; cursor: pointer; text-decoration: none;
  transition: background 120ms, color 120ms, border-color 120ms;
  white-space: nowrap;
}
.chip:hover { color: var(--fg); border-color: var(--line-strong); }
.chip.active {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: color-mix(in oklab,var(--accent) 30%,transparent);
}
.chip .count {
  font-size: 11px; background: var(--surface-2);
  padding: 1px 7px; border-radius: 999px;
  color: var(--muted); border: 1px solid var(--line);
}
.chip.active .count {
  background: color-mix(in oklab,var(--accent) 22%,transparent);
  color: var(--fg); border-color: transparent;
}

/* =========== Alerts / Flash =========== */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13.5px; color: var(--fg-2);
}
.alert-success, .alert-ok {
  background: rgba(95,212,154,.1); border-color: rgba(95,212,154,.3); color: #5fd49a;
}
.alert-error, .alert-danger {
  background: rgba(255,107,122,.1); border-color: rgba(255,107,122,.3); color: #ff6b7a;
}
.alert-warning {
  background: rgba(245,180,84,.1); border-color: rgba(245,180,84,.3); color: #f5b454;
}
.alert-info {
  background: rgba(106,166,255,.1); border-color: rgba(106,166,255,.3); color: #6aa6ff;
}

/* =========== Pagination =========== */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 18px; border-top: 1px solid var(--line);
  background: var(--surface-2); font-size: 12.5px; color: var(--muted);
}
.pagination .pages { display: flex; gap: 4px; margin-left: auto; }
.page-item {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--fg-2); display: grid; place-items: center;
  cursor: pointer; font-size: 12.5px;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.page-item a { display: grid; place-items: center; width: 100%; height: 100%; color: inherit; }
.page-item:hover { background: var(--surface-2); color: var(--fg); border-color: var(--line-strong); }
.page-item.active {
  background: var(--accent-soft);
  border-color: color-mix(in oklab,var(--accent) 30%,transparent);
  color: var(--fg);
}

/* =========== Empty state =========== */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; color: var(--fg-2); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; }

/* =========== Timeline =========== */
.timeline {
  position: relative;
  padding-right: 20px;
  display: flex; flex-direction: column; gap: 18px;
}
.timeline::before {
  content: ""; position: absolute;
  top: 4px; bottom: 4px; right: 6px;
  width: 1px; background: var(--line-strong);
}
.tl-item { position: relative; }
.tl-item::before {
  content: ""; position: absolute;
  right: -19px; top: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.tl-item .meta {
  display: flex; gap: 8px; align-items: baseline;
  color: var(--muted); font-size: 12px; margin-bottom: 2px;
}
.tl-item .meta b { color: var(--fg); font-weight: 500; font-size: 13px; }
.tl-item .body { color: var(--fg-2); font-size: 13.5px; }

/* =========== Detail grid =========== */
.detail-grid {
  display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: start;
}
.kv { display: grid; grid-template-columns: 140px 1fr; row-gap: 14px; column-gap: 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--fg); }

.rail { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--top-h) + 16px); }

/* =========== Action list =========== */
.action-list { display: flex; flex-direction: column; gap: 8px; }
.action {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; color: var(--fg-2); font-size: 13.5px;
  transition: background 120ms, color 120ms;
  text-decoration: none; width: 100%;
}
.action:hover { color: var(--fg); background: var(--surface-3); }
.action .ico { color: var(--muted); }
.action.primary {
  background: var(--accent-soft);
  border-color: color-mix(in oklab,var(--accent) 30%,transparent);
  color: var(--fg);
}
.action.primary .ico { color: var(--accent-2); }

/* =========== Link list =========== */
.link-list { display: flex; flex-direction: column; gap: 10px; }
.link-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px;
}
.link-row .l-ico {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--surface-3); display: grid; place-items: center;
  color: var(--fg-2); border: 1px solid var(--line); flex-shrink: 0;
}
.link-row .l-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.link-row .l-meta b { color: var(--fg); font-size: 13.5px; font-weight: 500; }
.link-row .l-meta span {
  color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
  direction: ltr; text-align: end;
}
.link-row .l-act { margin-left: auto; display: flex; gap: 6px; }

/* =========== KV mini =========== */
.kv-mini { display: flex; flex-direction: column; gap: 12px; }
.kv-mini .row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.kv-mini .row span { color: var(--muted); }
.kv-mini .row b { color: var(--fg); font-weight: 500; }

/* =========== Grid helpers =========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }

/* =========== Wallet card =========== */
.wallet-card {
  position: relative;
  padding: 24px 26px;
  background: linear-gradient(135deg, #1a1730 0%, #12101c 100%);
  border: 1px solid color-mix(in oklab,var(--accent) 30%,transparent);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.wallet-card::before {
  content: "";
  position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  pointer-events: none;
}
.wallet-label { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; position: relative; z-index: 1; }
.wallet-amount { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; color: var(--fg); position: relative; z-index: 1; }
.wallet-footer {
  display: flex; align-items: center; gap: 20px; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid rgba(255,255,255,.07);
  position: relative; z-index: 1;
}
.wallet-mini { display: flex; flex-direction: column; gap: 2px; }
.wallet-mini .wl { font-size: 11.5px; color: var(--muted); }
.wallet-mini .wv { font-size: 14.5px; font-weight: 600; color: var(--fg); }

/* =========== Toast container =========== */
.toast-container {
  position: fixed; bottom: 24px; left: 24px;
  z-index: 999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 360px;
  padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--fg);
  box-shadow: var(--shadow); pointer-events: all;
  animation: slideIn .2s ease;
}
.toast.success { border-color: rgba(95,212,154,.3); background: color-mix(in oklab,rgba(95,212,154,.1),var(--surface-2)); }
.toast.error   { border-color: rgba(255,107,122,.3); background: color-mix(in oklab,rgba(255,107,122,.1),var(--surface-2)); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =========== Modal =========== */
.modal-backdrop,
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop.open,
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 520px;
  animation: modalIn .2s ease;
}
.modal-head, .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  font-size: 16px; font-weight: 600;
}
.modal-body { padding: 22px; }
.modal-foot, .modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; padding: 0 4px;
  line-height: 1; transition: color 120ms;
}
.modal-close:hover { color: var(--fg); }
@keyframes modalIn { from { transform: scale(0.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========== Loading spinner =========== */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========== Misc / Utility =========== */
.hr, hr { height: 1px; background: var(--line); border: 0; margin: 8px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 22px; }
.text-muted  { color: var(--muted); }
.text-small  { font-size: 12.5px; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }

/* =========== Public pages =========== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 64px; display: flex; align-items: center; padding: 0 5%;
  background: color-mix(in oklab,var(--bg) 80%,transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.nav-brand { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; }
.nav-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg,var(--accent),color-mix(in oklab,var(--accent) 60%,#000));
  display: grid; place-items: center; color: white; font-size: 16px;
}
.nav-spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { padding: 7px 14px; border-radius: 8px; font-size: 14px; color: var(--fg-2); transition: background 120ms, color 120ms; }
.nav-links a:hover { background: var(--surface); color: var(--fg); }

.hero {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 100px 5% 60px;
  position: relative; z-index: 1;
}
.hero h1 { font-size: clamp(2.4rem,5vw,4.2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 20px; }
.grad-text { background: linear-gradient(135deg,var(--accent),var(--accent-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { font-size: 1.1rem; color: var(--fg-2); max-width: 520px; margin: 0 auto 36px; }
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.section { padding: 80px 5%; position: relative; z-index: 1; }
.section-container { max-width: 1200px; margin: 0 auto; }
.section-header { text-align: center; margin-bottom: 52px; }
.section-header h2 { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; }
.section-header p { color: var(--fg-2); font-size: 1.05rem; max-width: 480px; margin: 0 auto; }

.features-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 20px; }
.feature-card {
  padding: 26px 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color 200ms, transform 200ms;
}
.feature-card:hover { border-color: var(--accent-ring); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 14px; }
.feature-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--fg-2); font-size: 13.5px; line-height: 1.65; }

.auth-wrap, .auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; gap: 0;
  position: relative; z-index: 1;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
/* header داخل الكارد */
.auth-head, .auth-logo {
  padding: 28px 30px 22px; border-bottom: 1px solid var(--line); text-align: center;
}
.auth-head .mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg,var(--accent),color-mix(in oklab,var(--accent) 65%,#000));
  display: grid; place-items: center; color: white; font-size: 24px;
  margin: 0 auto 14px; box-shadow: 0 8px 24px var(--accent-soft);
}
.auth-head h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-head p, .auth-logo p { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
/* body داخل الكارد: form مباشر أو auth-body */
.auth-body, .auth-card > form { padding: 24px 30px 28px; }
.auth-card > .alert { margin: 14px 30px 0; }
/* footer داخل الكارد */
.auth-footer {
  padding: 14px 30px 20px; text-align: center;
  font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--line);
}
.auth-footer a { color: var(--accent-2); }

.site-footer {
  position: relative; z-index: 1;
  padding: 28px 5%; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 12px;
}

/* =========== Responsive =========== */
@media (max-width: 1180px) {
  .stats-grid, .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .rail { position: static; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body.dash-body {
    grid-template-columns: 1fr;
  }
  .dash-sidebar, .sidebar {
    display: none;
  }
  .stats-grid, .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .features-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
}
