  :root {
    /* ---------- الهوية اللونية ---------- */
    --ink: #172233;
    --ink-soft: #4b5768;
    --muted: #8b93a3;
    --bg: #eef1f5;
    --surface: #ffffff;
    --line: #e1e5ec;

    /* ---------- كحلي (اللون الأساسي من اللوجو) ---------- */
    --brand-950: #0a1c33;
    --brand-900: #0f2745;
    --brand-800: #14315c;
    --brand-700: #1b3d6e;
    --brand-600: #234a82;
    --brand-500: #3568a8;
    --brand-300: #9cbedd;
    --brand-100: #e3ecf5;

    /* ---------- أخضر (لون التمييز من اللوجو) ---------- */
    --accent: #2e9e5b;
    --accent-dark: #1f7a45;
    --accent-soft: #e3f5ea;

    --stage-new: #3568a8;
    --stage-qualified: #c98a2e;
    --stage-booked: #7c5cbf;
    --stage-won: #2e9e5b;
    --stage-reject: #b24a41;

    --font-display: 'Cairo', Tahoma, Arial, sans-serif;
    --font-data: 'IBM Plex Mono', 'Courier New', monospace;

    /* ---------- مقياس الظلال (عشان كل الكروت والنوافذ تحس بنفس العمق) ---------- */
    --shadow-sm: 0 1px 3px rgba(23,34,51,.07);
    --shadow-md: 0 4px 14px rgba(23,34,51,.12);
    --shadow-lg: 0 14px 34px rgba(15,39,69,.18);
    --shadow-xl: 0 24px 60px rgba(15,39,69,.3);
  }

  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0; font-family: var(--font-display); background: var(--bg); color: var(--ink);
    height: 100vh; display: flex; overflow: hidden;
  }
  ::selection { background: var(--accent-soft); color: var(--brand-900); }

  /* أي حقل إدخال بعرض ثابت (inline أو من الكود) ميتعداش عرض الحاوية بتاعته */
  input, select, textarea, button { max-width: 100%; }

  /* ---------- قاعدة موحدة لكل حقول الإدخال (نص/إيميل/باسورد/رقم/تاريخ/select/textarea) ---------- */
  input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="date"], input[type="tel"], input[type="search"], select, textarea {
    padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px;
    font-family: var(--font-display); background: var(--surface); color: var(--ink);
    outline: none; transition: border-color .15s, box-shadow .15s;
  }
  input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="number"]:focus,
  input[type="date"]:focus, input[type="tel"]:focus, input[type="search"]:focus, select:focus, textarea:focus {
    border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(53,104,168,.15);
  }
  textarea {
    resize: vertical; line-height: 1.65; min-height: 62px;
    scrollbar-width: thin; scrollbar-color: var(--brand-300) transparent;
  }
  textarea::-webkit-scrollbar { width: 8px; }
  textarea::-webkit-scrollbar-track { background: transparent; }
  textarea::-webkit-scrollbar-thumb { background: var(--brand-300); border-radius: 8px; }
  textarea::-webkit-scrollbar-thumb:hover { background: var(--brand-500); }

  /* ---------- حالة تركيز موحدة للعناصر التفاعلية (كيبورد بالذات) ---------- */
  button:focus-visible, a:focus-visible, .nav-btn:focus-visible {
    outline: 2px solid var(--brand-500); outline-offset: 2px;
  }

  .table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 560px; }

  /* ================= تسجيل الدخول ================= */
  #login-screen {
    flex: 1; min-width: 0; display: flex; background: var(--brand-950);
    position: relative; overflow: hidden; min-height: 100dvh;
  }
  #login-screen::before {
    content: ""; position: absolute; inset: 0;
    background-image:
      radial-gradient(circle at 15% 20%, rgba(46,158,91,.10) 0, transparent 40%),
      repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 1px, transparent 1px 42px);
    pointer-events: none;
  }
  #login-brand {
    flex: 1.1; display: flex; flex-direction: column; justify-content: center;
    padding: 0 56px; color: #fff; position: relative; z-index: 1;
  }
  #login-brand .eyebrow {
    font-family: var(--font-data); font-size: 11px; letter-spacing: .16em; color: var(--accent);
    text-transform: uppercase; margin-bottom: 18px;
  }
  #login-brand h1 { font-size: 34px; font-weight: 800; margin: 0 0 14px; line-height: 1.3; }
  #login-brand p { font-size: 14px; color: rgba(255,255,255,.6); max-width: 340px; line-height: 1.9; margin: 0; }
  #login-brand .stat-strip { display: flex; gap: 28px; margin-top: 40px; }
  #login-brand .stat-strip div b { display: block; font-family: var(--font-data); font-size: 20px; color: var(--accent); }
  #login-brand .stat-strip div span { font-size: 11px; color: rgba(255,255,255,.5); }

  #login-panel {
    width: 400px; background: var(--surface); display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1; box-shadow: -30px 0 60px rgba(0,0,0,.25);
  }
  #login-box { width: min(300px, 100%); }
  #login-box h2 { margin: 0 0 4px; color: var(--brand-800); font-size: 20px; font-weight: 800; }
  #login-box .sub { font-size: 12px; color: var(--muted); margin-bottom: 26px; }
  #login-box label { display: block; font-size: 11px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 600; }
  #login-box input {
    width: 100%; padding: 11px 13px; margin-bottom: 16px; border: 1.5px solid var(--line);
    border-radius: 9px; font-size: 14px; font-family: var(--font-display); outline: none;
    transition: border-color .15s;
  }
  #login-box button {
    width: 100%; padding: 12px; background: var(--brand-700); color: #fff; border: none;
    border-radius: 9px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font-display);
    transition: background .15s, transform .05s;
  }
  #login-box button:hover { background: var(--brand-600); }
  #login-box button:active { transform: translateY(1px); }
  #login-error {
    color: #a53d34; background: #fbeae8; border-radius: 8px; padding: 9px 12px;
    font-size: 12px; margin-bottom: 14px; display: none; text-align: center;
  }

  /* ================= هيكل التطبيق ================= */
  #app { flex: 1; display: none; }
  #app.active { display: flex; width: 100%; }

  #sidebar {
    width: 224px; background: var(--brand-950); color: #fff; display: flex; flex-direction: column;
    flex-shrink: 0; transition: transform .2s ease;
  }
  #sidebar-overlay { display: none; }
  #sidebar-toggle-btn {
    display: none; background: none; border: 1.5px solid var(--line); border-radius: 8px; width: 36px; height: 36px;
    align-items: center; justify-content: center; cursor: pointer; color: var(--ink-soft); flex-shrink: 0;
  }
  #sidebar-toggle-btn svg { width: 18px; height: 18px; }
  #sidebar-header { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
  #sidebar-header .logo-row { display: flex; align-items: center; gap: 9px; }
  #sidebar-header .logo-mark {
    width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
    display: flex; align-items: center; justify-content: center; font-family: var(--font-data);
    font-weight: 700; font-size: 13px; color: var(--brand-950); flex-shrink: 0; overflow: hidden;
  }
  #sidebar-header .logo-mark img { width: 100%; height: 100%; object-fit: cover; }
  #sidebar-header h2 { margin: 0; font-size: 15px; font-weight: 800; }
  #sidebar-header .tagline { font-size: 10px; color: rgba(255,255,255,.4); margin-top: 1px; }
  #sidebar-header .sub {
    font-size: 11px; color: rgba(255,255,255,.55); margin-top: 14px; padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
  }

  #nav-list { flex: 1; padding: 14px 10px; }
  .nav-btn {
    width: 100%; background: none; border: none; color: rgba(255,255,255,.62); text-align: right;
    padding: 11px 13px; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; gap: 10px; font-family: var(--font-display);
    margin-bottom: 3px; transition: background .12s, color .12s;
  }
  .nav-btn svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
  .nav-btn:hover { background: rgba(255,255,255,.05); color: #fff; }
  .nav-btn.active { color: #fff; background: rgba(46,158,91,.16); }
  .nav-btn.active svg { opacity: 1; color: var(--accent); }
  .nav-btn.active { box-shadow: inset 3px 0 0 var(--accent); }
  .nav-badge {
    margin-right: auto; background: var(--stage-reject); color: #fff; font-size: 10px; font-weight: 800;
    border-radius: 20px; padding: 1px 7px; font-family: var(--font-data);
  }

  #logout-btn {
    margin: 12px; background: none; border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.7);
    border-radius: 8px; padding: 9px; font-size: 12px; cursor: pointer; font-family: var(--font-display);
    transition: border-color .15s, color .15s;
  }
  #logout-btn:hover { border-color: rgba(255,255,255,.4); color: #fff; }

  /* ================= المحتوى الرئيسي ================= */
  #main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

  /* ---------- الشريط العلوي (Topbar) ---------- */
  #topbar {
    height: 58px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 50;
  }
  #global-search { flex: 1; max-width: 380px; position: relative; }
  #global-search svg {
    position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--muted); pointer-events: none;
  }
  #global-search input {
    width: 100%; padding: 8px 36px 8px 12px; background: var(--bg);
    transition: border-color .15s, background .15s, box-shadow .15s;
  }
  #global-search input:focus { background: var(--surface); }
  #topbar-spacer { flex: 1; }
  #topbar-quick-add {
    background: var(--brand-700); color: #fff; border: none; border-radius: 8px; width: 34px; height: 34px;
    font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; flex-shrink: 0;
  }
  #topbar-quick-add:hover { background: var(--brand-600); }
  #topbar-bell {
    width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface);
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative;
  }
  #topbar-bell svg { width: 16px; height: 16px; color: var(--ink-soft); }
  #topbar-bell .ping { position: absolute; top: 7px; left: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

  .bell-dropdown {
    position: absolute; top: 44px; left: 0; width: 320px; max-height: 380px; overflow-y: auto;
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
    border: 1px solid var(--line); display: none; z-index: 100; padding: 8px;
  }
  .bell-dropdown.open { display: block; }
  .bell-dropdown .bd-title { font-size: 12px; font-weight: 800; color: var(--ink-soft); padding: 8px 10px 6px; }
  .bell-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .bell-item:hover { background: var(--bg); }
  .bell-item .b-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
  .bell-item .b-date { font-size: 10.5px; color: var(--stage-reject); font-family: var(--font-data); }
  .bell-item .b-date.today { color: var(--accent); }
  .bell-empty { padding: 20px 10px; text-align: center; color: var(--muted); font-size: 12px; }

  /* ---------- بوب أب التنبيهات ---------- */
  #toast-container {
    position: fixed; top: 20px; left: 20px; z-index: 99999; display: flex; flex-direction: column; gap: 10px;
    max-width: 320px;
  }
  .toast {
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
    border-right: 4px solid var(--accent); padding: 14px 16px; direction: rtl; position: relative;
    animation: toast-in .25s ease-out;
  }
  .toast.followup { border-right-color: var(--stage-new); }
  .toast .toast-title { font-size: 13px; font-weight: 800; color: var(--brand-900); margin-bottom: 4px; display:flex; align-items:center; gap:6px; padding-left: 18px; }
  .toast .toast-body { font-size: 12px; color: var(--ink-soft); }
  .toast-close {
    position: absolute; top: 8px; left: 8px; background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 13px; line-height: 1; width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; transition: background .12s, color .12s;
  }
  .toast-close:hover { color: var(--ink); background: var(--bg); }
  .toast-actions { display: flex; gap: 8px; margin-top: 10px; }
  .toast-actions button {
    border: none; border-radius: 16px; padding: 5px 12px; font-size: 11px; font-weight: 700;
    cursor: pointer; font-family: var(--font-display);
  }
  .toast-open-btn { background: var(--brand-700); color: #fff; }
  .toast-snooze-btn { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line) !important; }
  @keyframes toast-in {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
  }

  /* ---------- احتفال "تم القبول" ---------- */
  .celebrate-overlay {
    position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center;
    pointer-events: none;
  }
  .celebrate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  .celebrate-card {
    position: relative; z-index: 1; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-xl);
    padding: 26px 42px; text-align: center; direction: rtl;
    animation: celebrate-pop .45s cubic-bezier(.34,1.56,.64,1) both;
    transition: opacity .5s, transform .5s;
  }
  .celebrate-card.fade-out { opacity: 0; transform: scale(.92) translateY(-8px); }
  .celebrate-emoji { font-size: 44px; line-height: 1; margin-bottom: 6px; }
  .celebrate-title { font-size: 22px; font-weight: 800; color: var(--accent); }
  .celebrate-sub { font-size: 13.5px; color: var(--ink-soft); margin-top: 4px; }
  @keyframes celebrate-pop {
    0% { transform: scale(.4); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }
  .bell-footer {
    text-align: center; font-size: 11px; color: var(--brand-500); padding: 8px 6px 4px; cursor: pointer;
    border-top: 1px solid var(--line); margin-top: 4px; font-weight: 700;
  }
  .bell-footer:hover { color: var(--brand-700); }
  #user-chip {
    display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 20px;
    background: var(--bg); cursor: pointer; flex-shrink: 0; border: 1px solid var(--line);
  }
  #user-chip .name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
  #user-chip .role { font-size: 10px; color: var(--muted); display: block; margin-top: -2px; }

  /* ---------- الصورة الرمزية (Avatar) ---------- */
  .avatar {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    font-weight: 800; color: #fff; flex-shrink: 0; font-family: var(--font-display);
  }
  .avatar.sz-16 { width: 16px; height: 16px; font-size: 8.5px; }
  .avatar.sz-28 { width: 28px; height: 28px; font-size: 11.5px; }
  .avatar.sz-34 { width: 34px; height: 34px; font-size: 13px; }
  .name-cell { display: flex; align-items: center; gap: 10px; }

  /* ---------- فلاتر Pills ---------- */
  .filter-pills { display: flex; gap: 7px; flex-wrap: wrap; }
  .filter-pill {
    background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-soft); border-radius: 20px;
    padding: 7px 15px; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: var(--font-display);
    display: flex; align-items: center; gap: 6px; transition: all .12s;
  }
  .filter-pill:hover { border-color: var(--brand-300); }
  .filter-pill.active { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
  .filter-pill .n { opacity: .7; font-family: var(--font-data); font-size: 11px; }

  .view-header {
    padding: 22px 30px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: flex-end;
  }
  .view-header .eyebrow {
    font-family: var(--font-data); font-size: 10.5px; letter-spacing: .14em; color: var(--brand-500);
    text-transform: uppercase; font-weight: 600; margin-bottom: 6px; display: block;
  }
  .view-header h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--brand-900); }
  .view-body { padding: 24px 30px 40px; }

  .btn {
    background: var(--brand-700); color: #fff; border: none; border-radius: 8px; padding: 10px 18px;
    font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font-display);
    display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
    transition: background .15s, transform .05s, opacity .15s;
  }
  .btn:hover { background: var(--brand-600); }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
  .btn.secondary { background: var(--brand-100); color: var(--brand-800); }
  .btn.secondary:hover { background: #cfdcec; }
  .btn.danger { background: #fbeae8; color: #a53d34; }
  .btn.danger:hover { background: #f6d9d5; }
  .btn.sm { padding: 6px 13px; font-size: 11.5px; border-radius: 7px; }

  /* ---------- زرار أيقونة صغير (حذف/إغلاق) ---------- */
  .icon-btn-remove {
    background: none; border: none; color: #a53d34; cursor: pointer; font-size: 13px; line-height: 1;
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s;
  }
  .icon-btn-remove:hover { background: #fbeae8; }

  /* ---------- قائمة العملاء ---------- */
  #list-toolbar { display: flex; justify-content: space-between; margin-bottom: 18px; gap: 10px; flex-wrap: wrap; }
  #list-toolbar input { width: 230px; }
  table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
  th, td { padding: 12px 16px; text-align: right; font-size: 13px; border-bottom: 1px solid var(--line); }
  th { background: #f7f8f7; color: var(--ink-soft); font-weight: 700; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; }
  td:nth-child(5) { font-family: var(--font-data); font-weight: 600; }
  tr:hover td { background: #fafbfa; cursor: pointer; }
  .tag-empty { color: #b7bfba; }

  /* .stage-badge (مراحل العملاء) و .pill-badge (التذاكر) بيشتركوا في نفس الشكل الأساسي */
  .stage-badge, .pill-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 20px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  }
  .stage-badge { border: 1.4px solid transparent; }
  .stage-badge::before, .pill-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .stage-badge.new { color: var(--stage-new); background: var(--brand-100); }
  .stage-badge.qualified { color: var(--stage-qualified); background: #faf1e2; }
  .stage-badge.booked { color: var(--stage-booked); background: #f0eaf9; }
  .stage-badge.won { color: var(--stage-won); background: #e5f3ec; }
  .stage-badge.reject { color: var(--stage-reject); background: #fbeae8; }

  /* ---------- نافذة (Modal) ---------- */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(10,28,51,.55); display: none; align-items: center;
    justify-content: center; z-index: 9999; backdrop-filter: blur(2px);
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface); border-radius: 16px; padding: 30px; width: 500px; max-width: 92vw;
    max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-xl); font-size: 14.5px;
  }
  .modal h3 { margin: 0 0 20px; font-size: 20px; font-weight: 800; color: var(--brand-900); }
  .wa-btn {
    display: flex; align-items: center; gap: 6px; background: #25d366; color: #fff; text-decoration: none;
    border-radius: 20px; padding: 7px 16px; font-size: 13px; font-weight: 700; font-family: var(--font-display);
    margin-bottom: 14px;
  }
  .modal label { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; margin-top: 16px; }
  .modal input, .modal select, .modal textarea { width: 100%; padding: 11px 13px; font-size: 14.5px; border-radius: 9px; }
  .modal-actions { display: flex; gap: 10px; margin-top: 26px; justify-content: flex-end; flex-wrap: wrap; }
  .modal-actions .btn { padding: 11px 20px; font-size: 13.5px; }
  .field-row { display: flex; gap: 10px; }
  .field-row > div { flex: 1; }

  /* ---------- نافذة مقسّمة لأقسام واضحة (ستايل SaaS احترافي) ---------- */
  .modal.modal-structured {
    display: flex; flex-direction: column; padding: 0; width: 580px; max-height: 90vh;
  }
  .modal-structured .modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 30px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  }
  .modal-structured .modal-head h3 { margin: 0; }
  .modal-structured .modal-body { padding: 22px 30px; overflow-y: auto; flex: 1; }
  .modal-structured .modal-actions {
    margin: 0; padding: 16px 30px; border-top: 1px solid var(--line);
    background: var(--bg); border-radius: 0 0 16px 16px; flex-shrink: 0;
  }
  .modal-structured .modal-body > label:first-child { margin-top: 0; }
  .modal-body .settings-block:first-child { border-top: none; margin-top: 0; padding-top: 0; }
  .modal-structured input[type="text"], .modal-structured input[type="number"], .modal-structured input[type="tel"],
  .modal-structured input[type="date"], .modal-structured select, .modal-structured textarea {
    background: var(--bg); border-color: transparent;
  }
  .modal-structured input[type="text"]:focus, .modal-structured input[type="number"]:focus,
  .modal-structured input[type="tel"]:focus, .modal-structured input[type="date"]:focus,
  .modal-structured select:focus, .modal-structured textarea:focus {
    background: var(--surface); border-color: var(--brand-500);
  }

  .activity-item { background: #f7f8f7; border-radius: 8px; padding: 9px 11px; margin-bottom: 7px; font-size: 12px; border-right: 2.5px solid var(--brand-300); }
  .activity-item .time { color: var(--muted); font-size: 10px; margin-bottom: 3px; font-family: var(--font-data); }

  /* ---------- الكانبان ---------- */
  #kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
  .kanban-col {
    width: 262px; background: #e7ebf0; border-radius: 12px; padding: 4px; flex-shrink: 0;
    border-top: 3px solid var(--col-color, var(--brand-500));
  }
  .kanban-col h4 {
    margin: 10px 10px 12px; font-size: 12.5px; font-weight: 800; display: flex; justify-content: space-between;
    align-items: center; color: var(--ink);
  }
  .kanban-col h4 .count { color: var(--muted); font-weight: 600; font-size: 11px; font-family: var(--font-data); }
  .kanban-col h4 .stage-label-text { cursor: pointer; border-radius: 5px; padding: 2px 5px; margin: -2px -5px; transition: background .12s; }
  .kanban-col h4 .stage-label-text:hover { background: rgba(0,0,0,.05); }
  .kanban-col h4 .stage-label-text .edit-pencil { font-size: 10px; opacity: .5; }
  .kanban-col h4 .stage-label-input {
    font-size: 12.5px; font-weight: 800; color: var(--ink); font-family: var(--font-display);
    border: 1.5px solid var(--brand-500); border-radius: 5px; padding: 2px 5px; width: 110px; outline: none;
  }
  .worker-card {
    background: var(--surface); border-radius: 10px; padding: 13px 14px; margin: 0 8px 10px;
    box-shadow: var(--shadow-sm); cursor: grab; font-size: 13px; border: 1px solid var(--line);
    border-right: 3px solid var(--col-color, var(--brand-500));
    transition: box-shadow .15s, transform .1s, border-color .15s;
  }
  .worker-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
  .worker-card .title {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px;
  }
  .worker-card .title .name-wrap {
    display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; color: var(--brand-900);
  }
  .worker-card .title .name-wrap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .worker-card .owner-chip {
    display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--brand-600);
    font-weight: 700; margin-top: 6px;
  }
  .worker-card .owner-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .worker-card .price {
    color: var(--accent-dark); font-weight: 800; font-size: 11.5px; font-family: var(--font-data);
    background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; flex-shrink: 0; white-space: nowrap;
  }
  .worker-card .meta-row {
    display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 4px;
    margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  }
  .worker-card .meta { color: var(--ink-soft); font-size: 11px; display: flex; align-items: center; gap: 5px; }
  .worker-card .meta .m-icon { opacity: .55; font-size: 11px; }
  .worker-card .meta.reject-reason {
    color: var(--ink); font-weight: 400; margin-top: 9px;
    background: #fdf3f2; border: 1px solid #f3d2cc; border-right: 3px solid var(--stage-reject);
    border-radius: 8px; padding: 8px 10px; display: flex; align-items: flex-start; gap: 7px;
    line-height: 1.6; font-size: 11.5px;
  }
  .worker-card .meta.reject-reason .reject-icon {
    flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--stage-reject);
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px;
    margin-top: 1px;
  }
  .worker-card .meta.reject-reason b { color: var(--stage-reject); font-weight: 700; }

  /* ---------- Modal: سبب الرفض ---------- */
  #reject-reason-modal .modal { width: 380px; }
  #reject-reason-modal .rr-hint { font-size: 12px; color: var(--ink-soft); line-height: 1.8; margin: 0 0 14px; }
  #reject-reason-modal textarea { min-height: 80px; }
  #reject-reason-modal .rr-error {
    display: none; color: #a53d34; background: #fbeae8; border-radius: 8px;
    padding: 8px 11px; font-size: 12px; margin-top: 10px;
  }
  .kanban-col.drag-over { background: var(--brand-100); }

  .kanban-col[data-stage="new"] { --col-color: var(--stage-new); }
  .kanban-col[data-stage="qualified"] { --col-color: var(--stage-qualified); }
  .kanban-col[data-stage="booked"] { --col-color: var(--stage-booked); }
  .kanban-col[data-stage="won"] { --col-color: var(--stage-won); }
  .kanban-col[data-stage="reject"] { --col-color: var(--stage-reject); }

  /* ---------- لوحة القيادة ---------- */
  .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; margin-bottom: 30px; }
  .stat-card {
    background: var(--surface); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow-sm);
    border-right: 3px solid var(--brand-500); position: relative; overflow: hidden;
  }
  .stat-card .icon {
    position: absolute; left: 14px; top: 14px; width: 30px; height: 30px; border-radius: 8px;
    background: var(--brand-100); display: flex; align-items: center; justify-content: center;
  }
  .stat-card .icon svg { width: 16px; height: 16px; color: var(--brand-600); }
  .stat-card .num { font-size: 25px; font-weight: 800; color: var(--brand-900); font-family: var(--font-data); }
  .stat-card .lbl { font-size: 11.5px; color: var(--muted); margin-top: 5px; font-weight: 600; }
  .stat-card.gold { border-right-color: var(--accent); }
  .stat-card.gold .icon { background: var(--accent-soft); }
  .stat-card.gold .icon svg { color: var(--accent); }
  .stat-card.gold .num { color: var(--accent); }
  .stat-card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
  .stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

  .section-label { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; }

  /* ---------- التقارير ---------- */
  .reports-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 16px; margin-bottom: 16px; }
  .report-card { background: var(--surface); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow-sm); }
  /* حاوية بارتفاع ثابت لأي Chart.js — من غيرها الكانفاس بيدخل في حلقة تصغير/تكبير مستمرة لأن الحاوية بتاخد حجمها منه وهو بياخد حجمه منها */
  .chart-wrap { position: relative; width: 100%; }
  .stage-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; background: var(--surface); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-sm); }
  .stage-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .stage-row .name { width: 90px; font-size: 12.5px; font-weight: 600; }
  .stage-row .bar-bg { flex: 1; background: #eef0ee; border-radius: 6px; height: 9px; overflow: hidden; }
  .stage-row .bar-fill { height: 100%; border-radius: 6px; }
  .stage-row .num { width: 160px; text-align: left; font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-data); }

  /* ---------- نظام التذاكر ---------- */
  .pill-badge.p-low { color: var(--brand-500); background: var(--brand-100); }
  .pill-badge.p-medium { color: var(--stage-qualified); background: #faf1e2; }
  .pill-badge.p-high { color: #c05f42; background: #fbeee8; }
  .pill-badge.p-critical { color: var(--stage-reject); background: #fbeae8; }
  .pill-badge.t-request { color: var(--stage-new); background: var(--brand-100); }
  .pill-badge.t-complaint { color: var(--stage-reject); background: #fbeae8; }
  .pill-badge.t-followup { color: var(--stage-qualified); background: #faf1e2; }
  .pill-badge.s-new { color: var(--stage-new); background: var(--brand-100); }
  .pill-badge.s-received { color: var(--brand-500); background: var(--brand-100); }
  .pill-badge.s-in_progress { color: var(--accent); background: var(--accent-soft); }
  .pill-badge.s-waiting_reply { color: var(--stage-qualified); background: #faf1e2; }
  .pill-badge.s-done { color: var(--stage-won); background: #e5f3ec; }
  .pill-badge.s-closed { color: var(--ink-soft); background: #eef0ee; }
  .pill-badge.s-cancelled { color: var(--stage-reject); background: #fbeae8; }
  .pill-badge.sla-ok { color: var(--stage-won); background: #e5f3ec; }
  .pill-badge.sla-near { color: var(--accent); background: var(--accent-soft); }
  .pill-badge.sla-overdue { color: var(--stage-reject); background: #fbeae8; }

  #tickets-toolbar { display: flex; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; align-items: center; }
  #tickets-filters, #reports-date-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  #ticket-search-input { width: 200px; }
  #tickets-filters select, #tickets-filters input, #reports-date-filter select, #reports-date-filter input {
    font-size: 12.5px;
  }
  tr.ticket-row-overdue td:first-child { border-right: 3px solid var(--stage-reject); }

  #kanban-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  #kanban-filter-bar select, #kanban-filter-bar input { font-size: 12.5px; }
  #kanban-filter-owner, #kanban-filter-nationality { width: 200px; }
  #kanban-custom-date-fields { display: flex; gap: 8px; align-items: center; }

  .ticket-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .ticket-detail-box {
    background: #f7f8f7; border-radius: 8px; padding: 10px 12px; font-size: 12px;
  }
  .ticket-detail-box .lbl { color: var(--muted); font-size: 10.5px; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em; }
  .ticket-detail-box .val { font-weight: 700; color: var(--ink); }

  .settings-block { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
  .settings-block h4 {
    margin: 0 0 14px; font-size: 11.5px; font-weight: 800; color: var(--brand-600);
    text-transform: uppercase; letter-spacing: .06em;
  }
  .settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: var(--surface); padding: 9px 12px; border-radius: 8px; margin-bottom: 6px;
    box-shadow: var(--shadow-sm); font-size: 12.5px;
  }
  .settings-row .del-btn {
    background: none; border: none; color: #a53d34; cursor: pointer; font-size: 11.5px; font-weight: 700;
    font-family: var(--font-display); padding: 4px 9px; border-radius: 6px; transition: background .12s;
  }
  .settings-row .del-btn:hover { background: #fbeae8; }
  .sla-table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .sla-table th, .sla-table td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--line); }
  .sla-table input { width: 70px; padding: 5px 6px; border: 1.5px solid var(--line); border-radius: 6px; font-size: 12px; text-align: center; }

  /* ================================================================
     الاستجابة للشاشات الصغيرة (تابلت وموبايل)
     ================================================================ */
  @media (max-width: 860px) {
    #sidebar-toggle-btn { display: flex; }

    #sidebar {
      position: fixed; top: 0; right: 0; bottom: 0; width: 260px; z-index: 200;
      transform: translateX(100%); box-shadow: -20px 0 45px rgba(0,0,0,.28);
    }
    #sidebar.open { transform: translateX(0); }
    #sidebar-overlay.open {
      display: block; position: fixed; inset: 0; background: rgba(10,28,51,.5); z-index: 190;
    }

    #topbar { padding: 0 14px; gap: 10px; }
    #global-search { max-width: none; }
    #user-chip .name, #user-chip .role { display: none; }

    .view-header {
      flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px 16px 14px;
    }
    .view-header > *:last-child { width: 100%; }
    .view-header > div:last-child { display: flex; flex-wrap: wrap; }
    .view-body { padding: 16px 16px 30px; }

    .modal { padding: 18px; width: 94vw; }
    .modal-actions { flex-wrap: wrap; }
    .field-row { flex-direction: column; gap: 0; }

    .modal.modal-structured { padding: 0; width: 94vw; max-height: 92vh; }
    .modal-structured .modal-head, .modal-structured .modal-body, .modal-structured .modal-actions {
      padding-left: 16px; padding-right: 16px;
    }

    .ticket-detail-grid { grid-template-columns: 1fr; }

    #login-screen {
      flex: 1 1 auto; flex-direction: column; min-height: 0; height: 100dvh;
      overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
      overscroll-behavior-y: contain;
    }
    #login-brand { flex: none; padding: 32px 24px 20px; }
    #login-brand h1 { font-size: 26px; }
    #login-brand p { max-width: none; }
    #login-brand .stat-strip { margin-top: 22px; gap: 20px; }
    #login-panel { width: 100%; flex: none; box-shadow: none; padding: 20px 24px 40px; }
    #login-box { width: min(360px, 100%); }

    #kanban { padding-bottom: 8px; }
    .kanban-col { width: 240px; }
  }

  @media (max-width: 480px) {
    #login-brand { padding: 24px 20px 16px; }
    #login-logo-img { margin-bottom: 12px !important; }
    #login-brand .eyebrow { font-size: 10px; margin-bottom: 10px; letter-spacing: .08em; }
    #login-brand h1 { font-size: 24px; margin-bottom: 8px; }
    #login-brand p { font-size: 13px; line-height: 1.75; }
    #login-brand .stat-strip {
      display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px;
    }
    #login-brand .stat-strip div { min-width: 0; }
    #login-brand .stat-strip div span { font-size: 10px; }
    #login-panel { padding: 20px 20px 28px; }
    #login-box input, #login-box button { min-height: 44px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .view-header h1 { font-size: 19px; }
    .modal { padding: 14px; }
    .reports-grid { grid-template-columns: 1fr; }
    #tickets-filters select, #tickets-filters input[type="text"] { flex: 1 1 100%; }
  }
