:root{
    /* JAD GROUP visual identity 2026: navy, blue, white */
    --navy:#161E29;
    --navy-2:#1F2A38;
    --navy-3:#2B384A;
    --navy-deep:#10161F;
    --blue:#1D7ABF;
    --blue-600:#17669F;
    --blue-soft:rgba(29,122,191,.11);
    --sky:#DFEBF8;
    --sky-2:#C3D8EC;
    --sky-3:#A8C3D6;

    /* Older rules and inline styles still say "gold"; it now resolves to the brand blue. */
    --gold:var(--blue);
    --gold-600:var(--blue-600);
    --gold-soft:var(--blue-soft);

    /* Workspace */
    --bg:#F1F4F8;
    --surface:#FFFFFF;
    --surface-2:#F7F9FC;
    --border:#E2E8EF;
    --border-2:#CCD6E1;

    /* Text */
    --text:#161E29;
    --muted:#5A6779;
    --faint:#93A0B0;

    /* Status */
    --success:#12805C; --success-soft:#E2F4EC;
    --danger:#C8322B;  --danger-soft:#FBE9E7;
    --warning:#B4610A;  --warning-soft:#FBEED8;
    --info:var(--blue-600); --info-soft:var(--sky);

    /* Design system (2026-11-24): one radius scale, navy shadows with a negative spread, one motion set. */
    --radius:20px;
    --radius-sm:12px;
    --r-shell:26px; --r-dialog:24px; --r-btn:14px; --r-pill:999px;
    --shadow:0 6px 16px -6px rgb(22 30 41 / .06);
    --shadow-hover:0 14px 28px -6px rgb(22 30 41 / .12);
    --shadow-shell:0 14px 30px -10px rgb(16 22 31 / .35);
    --shadow-pop:0 20px 40px -8px rgb(16 22 31 / .22);
    --ease-out:cubic-bezier(.33,1,.68,1);
    --ease-back:cubic-bezier(.34,1.56,.64,1);
    --blue-rgb:29 122 191;
}

*{box-sizing:border-box}
html,body{margin:0; padding:0}
body{
    font-family:'IBM Plex Sans Arabic','Rubik','Segoe UI',Tahoma,sans-serif;
    background:var(--bg); color:var(--text); font-size:15px; line-height:1.6;
    font-variant-numeric:tabular-nums; -webkit-font-smoothing:antialiased;
}
a{color:inherit; text-decoration:none}
[x-cloak]{display:none!important}

/* ===== Layout shell ===== */
.app{display:flex; min-height:100vh}
.sidebar{
    width:248px; flex-shrink:0; background:var(--navy); color:#fff;
    display:flex; flex-direction:column; position:sticky; top:0; height:100vh;
}
.sidebar .brand{display:flex; align-items:center; gap:11px; padding:22px 20px 16px}
.sidebar .brand img{height:30px}
.sidebar .brand .wm{font-weight:700; font-size:18px; letter-spacing:.3px}
.sidebar .brand .wm .g{font-weight:400; color:var(--sky-3); margin-inline-start:5px}
.sidebar nav{padding:6px 12px 14px; display:flex; flex-direction:column; gap:2px; flex:1; overflow-y:auto}
.nav-group{font-size:12px; font-weight:500; color:#73839A; padding:16px 13px 6px}
.nav-item{
    display:flex; align-items:center; gap:11px; padding:9px 13px; border-radius:var(--radius-sm);
    color:#B4C0CF; font-size:14.5px; font-weight:500; transition:background .15s,color .15s; cursor:pointer;
}
.nav-item:hover{background:var(--navy-2); color:#fff}
.nav-item.active{background:var(--blue); color:#fff}
.nav-item .icon{width:19px; height:19px; flex-shrink:0; opacity:.9}
.icon{width:18px; height:18px; display:inline-block; vertical-align:-3px}
.sidebar .foot{padding:14px 20px; font-size:12px; color:#73839A}

.main{flex:1; display:flex; flex-direction:column; min-width:0}
.topbar{
    height:62px; background:var(--surface); border-bottom:1px solid var(--border);
    display:flex; align-items:center; justify-content:space-between; padding:0 26px; position:sticky; top:0; z-index:5;
}
.topbar .page-title{font-size:17px; font-weight:600}
.topbar .user{display:flex; align-items:center; gap:12px}
.topbar .user .who{display:flex; flex-direction:column; align-items:flex-end; line-height:1.3}
.topbar .user .who .n{font-size:13.5px; font-weight:600}
.topbar .user .who .r{font-size:11.5px; color:var(--muted)}
.avatar{width:38px; height:38px; border-radius:50%; background:var(--sky); color:var(--blue-600); display:flex; align-items:center; justify-content:center; font-weight:600; font-size:14px}
.content{padding:26px 30px; flex:1; width:100%; max-width:1360px; margin-inline:auto}

/* ===== Buttons ===== */
.btn{
    display:inline-flex; align-items:center; gap:8px; justify-content:center;
    font-family:inherit; font-size:14px; font-weight:600; cursor:pointer;
    padding:10px 18px; border-radius:var(--radius-sm); border:1px solid transparent; transition:.15s;
}
.btn-primary{background:var(--blue); color:#fff}
.btn-primary:hover{background:var(--blue-600)}
.btn:disabled,.btn[disabled]{opacity:.55; cursor:not-allowed}
.btn-danger{background:var(--surface); color:var(--danger); border-color:#EBC4C0}
.btn-danger:hover{background:var(--danger-soft)}
.btn-ghost{background:var(--surface); color:var(--text); border-color:var(--border-2)}
.btn-ghost:hover{background:var(--surface-2); border-color:var(--sky-3)}
.btn-sm{padding:7px 13px; font-size:13px}

/* ===== Cards ===== */
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow)}
.card-pad{padding:20px 22px}
.card-head{display:flex; align-items:center; justify-content:space-between; padding:16px 22px; border-bottom:1px solid var(--border)}
.card-head h3{margin:0; font-size:15.5px; font-weight:600}

/* ===== Page header ===== */
.page-header{display:flex; align-items:center; justify-content:space-between; margin-bottom:22px}
.page-header h1{margin:0; font-size:23px; font-weight:700; letter-spacing:-.2px}
.page-header .sub{color:var(--muted); font-size:13.5px; margin-top:2px}

/* ===== Stat cards ===== */
.stats{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:14px}
.stat{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow)}
.stat .n{font-size:28px; font-weight:600; line-height:1}
.stat .l{color:var(--muted); font-size:13px; margin-top:7px}

/* ===== Inputs ===== */
.label{display:block; font-size:13px; color:var(--muted); font-weight:500; margin-bottom:6px}
.input,select.input,textarea.input{
    width:100%; background:var(--surface); border:1px solid var(--border-2); color:var(--text);
    border-radius:var(--radius-sm); padding:10px 13px; font-size:14.5px; font-family:inherit; outline:none; transition:.15s;
}
.input:focus,select.input:focus,textarea.input:focus{border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-soft)}
.field{margin-bottom:15px}

/* ===== Table ===== */
.table-wrap{overflow-x:auto}
table.tbl{width:100%; border-collapse:collapse; font-size:14px}
table.tbl th{
    text-align:start; font-weight:500; color:var(--muted); font-size:12.5px;
    padding:11px 14px; border-bottom:1px solid var(--border); background:var(--surface-2); white-space:nowrap;
}
table.tbl td{padding:13px 14px; border-bottom:1px solid var(--border); vertical-align:middle}
table.tbl tr:last-child td{border-bottom:none}
table.tbl tbody tr:hover{background:#F5F9FD}
table.tbl td a:hover{color:var(--blue-600)}

/* ===== Badges ===== */
.badge{display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:600; padding:3px 10px; border-radius:999px; line-height:1.5}
.badge-dot{width:7px; height:7px; border-radius:50%; background:currentColor}
.badge-gray{background:#E9EEF4; color:#4B5869}
.badge-success{background:var(--success-soft); color:var(--success)}
.badge-danger{background:var(--danger-soft); color:var(--danger)}
.badge-warning{background:var(--warning-soft); color:var(--warning)}
.badge-info{background:var(--info-soft); color:var(--info)}

/* ===== Misc ===== */
.empty{text-align:center; color:var(--muted); padding:46px 20px}
.empty .ic{font-size:34px; opacity:.4}
.row-between{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap}
.muted{color:var(--muted)}


/* ===== Leads screen additions ===== */
.filters{display:grid; grid-template-columns:2fr 1fr 1fr; gap:12px}
.filters-4{grid-template-columns:2fr 1fr 1fr 1fr}
@media (max-width:700px){.filters,.filters-4{grid-template-columns:1fr}}

/* Tabs (تبويبات حسب الحالة) */
.tabs{display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px}
.tab{background:var(--surface); border:1px solid var(--border-2); color:var(--muted); font:inherit; font-size:13.5px;
    font-weight:600; padding:7px 14px; border-radius:999px; cursor:pointer; transition:.15s;
    display:inline-flex; align-items:center; gap:7px}
.tab:hover{border-color:var(--gold); color:var(--text)}
.tab.on{background:var(--navy); border-color:var(--navy); color:#fff}
.tab-cnt{background:rgba(0,0,0,.09); font-size:11.5px; font-weight:700; padding:1px 7px; border-radius:999px; line-height:1.5}
.tab.on .tab-cnt{background:rgba(255,255,255,.18)}

/* Sortable table headers */
th.th-sort{cursor:pointer; user-select:none}
th.th-sort:hover{color:var(--text)}
.sort-ar{font-size:9px; color:var(--gold); margin-inline-start:3px}

/* Table cell helpers */
.cell-sub{font-size:12px; color:var(--muted); margin-top:1px}
.lc-cell{max-width:210px}
.lc-text{font-size:12.5px; color:var(--text); line-height:1.5; white-space:normal}
.lc-attempts{font-size:11.5px; color:var(--danger); font-weight:600; margin-top:3px; white-space:nowrap}
.badge-svc{background:var(--gold-soft); color:var(--gold-600); font-size:11px; padding:3px 8px}
.svc-badges{display:flex; gap:4px; flex-wrap:wrap; max-width:180px}

/* Smart create form (هل رد الليد؟) */
.seg{display:inline-flex; border:1px solid var(--border-2); border-radius:var(--radius-sm); overflow:hidden}
.seg-b{background:var(--surface); border:0; padding:9px 20px; cursor:pointer; font:inherit; font-size:14px;
    font-weight:600; color:var(--muted); transition:.15s}
.seg-b.on,.seg-b.active{background:var(--navy); color:#fff}
.hint-box{background:var(--sky); border:1px solid var(--sky-2); border-radius:var(--radius-sm);
    padding:10px 14px; font-size:13px; color:var(--navy-3); line-height:1.7}
.svc-picker{display:grid; grid-template-columns:1fr 1fr; gap:4px 12px; max-height:180px; overflow-y:auto;
    border:1px solid var(--border-2); border-radius:var(--radius-sm); padding:10px 13px; background:var(--surface)}
@media (max-width:700px){.svc-picker{grid-template-columns:1fr}}
.svc-check{display:flex; align-items:center; gap:8px; font-size:13.5px; cursor:pointer; padding:4px 0}
.svc-check input{width:15px; height:15px; accent-color:var(--gold); flex-shrink:0}

.flash{background:var(--success-soft); color:var(--success); border:1px solid #BFE3D2; padding:11px 16px; border-radius:var(--radius-sm); margin-bottom:16px; font-weight:500; font-size:14px}

.err{color:var(--danger); font-size:12.5px; margin-top:5px}

.pager{display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-top:1px solid var(--border)}

.modal-overlay{position:fixed; inset:0; background:rgba(16,22,31,.6); display:flex; align-items:flex-start; justify-content:center; padding:40px 16px; z-index:50; overflow-y:auto}
.modal{background:var(--surface); width:100%; max-width:620px; border-radius:var(--radius); box-shadow:var(--shadow-pop)}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--border)}
.modal-head h3{margin:0; font-size:16.5px; font-weight:600}
.modal-x{background:transparent; border:none; cursor:pointer; font-size:16px; color:var(--muted)}
.modal-body{padding:20px 22px}
.modal-foot{display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--border)}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px}
@media (max-width:600px){.form-grid{grid-template-columns:1fr}}
.form-grid .field{margin-bottom:0}

/* ===== Custom select arrow (RTL) ===== */
select.input{
    appearance:none; -webkit-appearance:none; -moz-appearance:none;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6779' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat:no-repeat;
    background-position:left 13px center;
    padding-left:36px; cursor:pointer;
}
select.input::-ms-expand{display:none}

/* date/number fields stay LTR-friendly inside RTL */
input[type=date].input,input[type=number].input{direction:ltr; text-align:right}

/* ===== Lead detail + timeline ===== */
.back-link{color:var(--muted); font-size:13px; display:inline-flex; gap:6px; align-items:center; margin-bottom:10px}
.back-link:hover{color:var(--text)}
.detail-grid{display:grid; grid-template-columns:1.7fr 1fr; gap:18px; align-items:start}
@media (max-width:900px){.detail-grid{grid-template-columns:1fr}}

.info-list{display:flex; flex-direction:column}
.info-list .ir{display:flex; justify-content:space-between; gap:12px; padding:11px 0; border-bottom:1px solid var(--border); font-size:14px}
.info-list .ir:last-child{border-bottom:none}
.info-list .k{color:var(--muted)}
.info-list .v{font-weight:500; text-align:left}

.timeline{display:flex; flex-direction:column}
.tl-item{position:relative; padding:0 22px 20px; border-inline-start:2px solid var(--border)}
.tl-item:last-child{padding-bottom:2px}
.tl-dot{position:absolute; inset-inline-start:-7px; top:2px; width:12px; height:12px; border-radius:50%; background:var(--gold); border:2px solid var(--surface)}
.tl-head{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:5px}
.tl-type{font-weight:700; font-size:14px}
.tl-meta{font-size:12px; color:var(--faint)}
.tl-summary{font-size:14px; color:var(--text); line-height:1.7; white-space:pre-line}
.tl-next{margin-top:8px; font-size:12.5px; color:var(--warning); background:var(--warning-soft); display:inline-block; padding:3px 10px; border-radius:7px}

/* ===== Lead services blocks (balanced layout) ===== */
.svc-total{font-size:13px; color:var(--muted)}
.svc-total b{color:var(--text); font-weight:700}
.svc-add{display:flex; gap:10px; margin-bottom:16px}
.svc-list{display:flex; flex-direction:column; gap:12px}
.svc-line{border:1px solid var(--border); border-radius:11px; padding:14px 16px; background:var(--surface-2)}
.svc-line-top{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:13px}
.svc-name{font-weight:700; font-size:14.5px}
.svc-prices{display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:11px}
.svc-price .label{margin-bottom:6px}
.svc-price .input{background:var(--surface)}
.svc-hint{font-size:11px; color:var(--faint); margin-top:5px; min-height:14px}
.svc-notes{font-size:13px; background:var(--surface)}
.svc-remove{background:var(--surface); border:1px solid var(--border-2); color:var(--muted); width:30px; height:30px;
    border-radius:8px; cursor:pointer; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:13px; line-height:1}
.svc-remove:hover{color:var(--danger); border-color:var(--danger)}
@media (max-width:520px){.svc-prices{grid-template-columns:1fr}}

/* ===== Global consistency tweaks ===== */
.btn{line-height:1.2}
.input,select.input{height:42px}
textarea.input{height:auto}
.svc-add .btn{height:42px}


/* ============================================================
   RESPONSIVE — موبايل وتابلت (درج منزلق + لمسات أكبر)
   ============================================================ */

/* همبرغر + خلفية الدرج — مخفيين على الكمبيوتر */
.hamb{display:none; background:transparent; border:1px solid var(--border-2); border-radius:var(--radius-sm);
    width:40px; height:40px; align-items:center; justify-content:center; font-size:19px;
    color:var(--text); cursor:pointer; flex-shrink:0}
.hamb:hover{background:var(--surface-2)}
.nav-backdrop{display:none; position:fixed; inset:0; background:rgba(10,14,20,.5); z-index:55}

/* تابلت + موبايل: السايدبار يصير درج منزلق من اليمين */
@media (max-width:1024px){
    .hamb{display:inline-flex}
    .sidebar{
        position:fixed; top:0; right:0; height:100vh; width:270px;
        transform:translateX(100%); transition:transform .25s ease;
        z-index:60; box-shadow:-10px 0 34px rgba(0,0,0,.22);
    }
    .app.nav-open .sidebar{transform:translateX(0)}
    /* تأكيد ظهور كل النصوص داخل الدرج */
    .sidebar .brand .wm,.sidebar .nav-item span.lbl,.sidebar .foot{display:revert}
    .nav-item{justify-content:flex-start}
    .app.nav-open .nav-backdrop{display:block}

    .main{width:100%; min-width:0}
    .content{padding:18px 15px; max-width:none}
    .topbar{padding:0 14px; gap:10px}
    .topbar .page-title{font-size:16px; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
    .topbar .user{gap:9px}
    .topbar .user .who{display:none}
}

/* لمسات وتخطيط أصغر للموبايل */
@media (max-width:560px){
    body{font-size:14.5px}
    .content{padding:15px 12px}

    /* رؤوس الصفحات تترتّب فوق بعض */
    .page-header,.page-head{flex-direction:column; align-items:stretch; gap:12px}
    .page-header h1,.page-title{font-size:19px}

    /* أزرار أكبر للّمس */
    .btn{padding:11px 16px; min-height:44px}
    .btn-sm{min-height:38px; padding:8px 13px}

    /* بطاقات الإحصائيات: عمودين */
    .stats{grid-template-columns:1fr 1fr; gap:11px}
    .stat{padding:15px 16px}
    .stat .n{font-size:23px}

    /* الجداول: تمرير أفقي ناعم + خلية أنحف */
    .table-wrap{overflow-x:auto; -webkit-overflow-scrolling:touch}
    table.tbl{font-size:13px}
    table.tbl th,table.tbl td{padding:10px 11px; white-space:nowrap}

    /* المودالات تقريباً ملء الشاشة */
    .modal-overlay{padding:10px}
    .modal{max-width:none; border-radius:14px}
    .modal-body{padding:16px 16px; max-height:75vh; overflow-y:auto}
    .modal-head,.modal-foot{padding:14px 16px}
    .modal-foot{flex-wrap:wrap}
    .modal-foot .btn{flex:1; min-width:120px}

    /* الكانبان: عمود واحد تقريباً ملء العرض (سحب بين الأعمدة) */
    .kb-col{flex:0 0 82vw !important; max-height:none}
    .kb-filters > *{width:100%}
    .kb-fsel{min-width:0}

    /* فلاتر الليدات عمود واحد */
    .filters{grid-template-columns:1fr}

    /* السطر الزمني وإضافة الخدمة */
    .svc-add{flex-direction:column}
    .svc-add .btn{width:100%}
}


/* ============================================================
   Shared pieces that pages used to restyle inline
   ============================================================ */
a.link,.back-link:hover,.card a:not(.btn):not(.nav-item):hover{color:var(--blue-600)}
h1,h2,h3{font-weight:600}
b,strong{font-weight:600}
.label{font-weight:500}
input[type=checkbox],input[type=radio]{accent-color:var(--blue)}
input[type=file].input{height:auto; padding:8px 10px; font-size:13.5px}
input[type=file].input::file-selector-button{
    font:inherit; font-size:13px; font-weight:600; margin-inline-end:10px; padding:5px 12px; cursor:pointer;
    border:1px solid var(--border-2); border-radius:6px; background:var(--surface-2); color:var(--text);
}

/* Keyboard focus is always visible, in the brand blue. */
:focus-visible{outline:2px solid var(--blue); outline-offset:2px}
.input:focus-visible{outline:none}
.nav-item:focus-visible{outline-color:#fff}

@media (prefers-reduced-motion:reduce){
    *,*::before,*::after{transition:none !important; animation:none !important}
}

/* Rubik is the identity's primary Latin face: the wordmark and big numbers. */
.sidebar .brand .wm,.stat .n{font-family:'Rubik','IBM Plex Sans Arabic',sans-serif}
.hint-box.hint-danger{background:var(--danger-soft); border-color:#EBC4C0; color:#8E211C}
.chev{transition:transform .15s}
.chev.open{transform:rotate(-90deg)}
.empty{padding:34px 20px; font-size:14px}

/* Three older pages name their header differently; same look as .page-header. */
.page-head{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:22px}
h1.page-title{margin:0; font-size:23px; font-weight:700; letter-spacing:-.2px}
.page-sub{margin:2px 0 0; color:var(--muted); font-size:13.5px}
.nw{white-space:nowrap}

/* Onboarding checklist */
[x-cloak]{display:none !important}
.link-btn{background:none; border:0; padding:0; font:inherit; font-size:12.5px; color:var(--muted); cursor:pointer; text-decoration:underline}
.link-btn:hover{color:var(--blue)}

/* ============================================================
   Design system layer (phase 1, CSS only)
   Structure from the frontend design guide, colours and type from JAD GROUP.
   ============================================================ */

/* ---- Shell: floating navy sidebar ---- */
.sidebar{
    margin:12px; height:calc(100vh - 24px); top:12px; border-radius:var(--r-shell);
    background:linear-gradient(180deg,var(--navy),var(--navy-deep));
    border:1px solid rgb(var(--blue-rgb) / .22); box-shadow:var(--shadow-shell); overflow:hidden;
}
.sidebar nav{gap:3px; scrollbar-width:thin; scrollbar-color:rgb(255 255 255 / .16) transparent}
.nav-group{font-size:11.5px; font-weight:700; color:rgb(255 255 255 / .38); padding:18px 13px 6px}
.nav-item{
    position:relative; min-height:44px; padding:0 13px; border-radius:14px; border:1px solid transparent;
    transition:background .2s var(--ease-out),color .2s var(--ease-out),border-color .2s var(--ease-out);
}
.nav-item .icon,.nav-item .lbl{transition:transform .2s var(--ease-out)}
.nav-item:hover{background:rgb(255 255 255 / .07)}
.nav-item:hover .icon{transform:scale(1.12)}
.nav-item:hover .lbl{transform:translateX(-4px)}
.nav-item.active{
    background:linear-gradient(to left,rgb(var(--blue-rgb) / .55),rgb(var(--blue-rgb) / .14));
    border-color:rgb(var(--blue-rgb) / .55); box-shadow:0 0 18px rgb(var(--blue-rgb) / .28);
}
.nav-item.active .lbl{font-weight:600}
.nav-item.active::before{
    content:""; position:absolute; inset-inline-start:-1px; top:50%; width:4px; height:22px; margin-top:-11px;
    border-radius:var(--r-pill); background:#fff; animation:ds-indicator .32s var(--ease-back) both;
}
@keyframes ds-indicator{from{transform:scaleY(0)}}

.topbar{background:rgb(255 255 255 / .86); backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px)}
.topbar .page-title{font-weight:700}

@media (max-width:1024px){
    .sidebar{margin:0; height:100vh; top:0; border-radius:var(--r-shell) 0 0 var(--r-shell); border-width:0 0 0 1px; box-shadow:none}
    .app.nav-open .sidebar{box-shadow:var(--shadow-shell)}
}

/* ---- Page entry: sections arrive one after the other, once ---- */
@keyframes ds-enter-up{from{opacity:0; transform:translateY(8px)}}
@keyframes ds-pop{from{opacity:0; transform:scale(.94)}}
.content > * > *:not(.modal-overlay){animation:ds-enter-up .2s var(--ease-out) backwards}
.content > * > *:nth-child(2){animation-delay:.03s}
.content > * > *:nth-child(3){animation-delay:.06s}
.content > * > *:nth-child(n+4){animation-delay:.09s}

/* ---- Headings ---- */
.page-header h1,h1.page-title{font-size:24px; font-weight:700; line-height:1.2}
.card-head h3,.modal-head h3{font-weight:700}

/* ---- Cards ---- */
.card{transition:box-shadow .22s var(--ease-out),border-color .22s var(--ease-out)}
.card:hover{border-color:var(--sky-2)}
a.card{display:block; transition:transform .22s var(--ease-out),box-shadow .22s var(--ease-out),border-color .22s var(--ease-out)}
a.card:hover{transform:translateY(-3px); box-shadow:var(--shadow-hover); border-color:rgb(var(--blue-rgb) / .35)}
.card > .table-wrap:first-child{border-start-start-radius:19px; border-start-end-radius:19px}
.card > .table-wrap:last-child,.card > .pager:last-child{border-end-start-radius:19px; border-end-end-radius:19px}

/* ---- Stat cards ---- */
.stat{
    position:relative; overflow:hidden; border-radius:var(--radius); animation:ds-pop .24s var(--ease-back) backwards;
    transition:transform .22s var(--ease-out),box-shadow .22s var(--ease-out),border-color .22s var(--ease-out);
}
.stat::after{
    content:""; position:absolute; inset-inline-end:-30px; top:-30px; width:80px; height:80px; border-radius:50%;
    border:14px solid rgb(var(--blue-rgb) / .07); pointer-events:none;
}
.stat:hover{transform:translateY(-3px); box-shadow:var(--shadow-hover); border-color:rgb(var(--blue-rgb) / .35)}
.stat:nth-child(2){animation-delay:.03s}
.stat:nth-child(3){animation-delay:.06s}
.stat:nth-child(n+4){animation-delay:.09s}
.stat .n{font-size:26px; font-weight:700}

/* ---- Buttons ---- */
.btn{
    border-radius:var(--r-btn);
    transition:transform .1s var(--ease-out),box-shadow .15s var(--ease-out),background .12s var(--ease-out),border-color .12s var(--ease-out),color .12s var(--ease-out);
}
.btn-sm{border-radius:11px}
.btn-primary{box-shadow:0 8px 16px -8px rgb(var(--blue-rgb) / .55)}
.btn:not(:disabled):hover{transform:translateY(-2px)}
.btn-primary:not(:disabled):hover{box-shadow:0 12px 22px -8px rgb(var(--blue-rgb) / .6)}
.btn-ghost:not(:disabled):hover{border-color:rgb(var(--blue-rgb) / .45); box-shadow:var(--shadow)}
.btn:not(:disabled):active{transform:translateY(0) scale(.96)}
.btn:disabled,.btn[disabled]{box-shadow:none}

/* ---- Inputs ---- */
.label{font-weight:600}
.input,select.input,textarea.input{
    border-color:var(--border); font-weight:500;
    transition:border-color .2s,box-shadow .25s var(--ease-out),background .2s;
}
.input,select.input{height:44px}
textarea.input,input[type=file].input{height:auto}
.input::placeholder{color:var(--faint); font-weight:400}
.input:hover{border-color:var(--border-2)}
.input:focus,select.input:focus,textarea.input:focus{border-color:var(--blue); box-shadow:0 0 0 4px rgb(var(--blue-rgb) / .13)}
.svc-add .btn{height:44px}
.err{font-weight:600; animation:ds-enter-up .22s var(--ease-out)}

/* ---- Tables ---- */
table.tbl th{background:transparent; font-size:12px; font-weight:600; padding:13px 14px}
table.tbl tbody tr{transition:background .18s var(--ease-out)}
table.tbl tbody tr td{transition:box-shadow .18s var(--ease-out)}
table.tbl tbody tr:hover{background:rgb(var(--blue-rgb) / .05)}
table.tbl tbody tr:hover td:first-child{box-shadow:inset -3px 0 0 var(--blue)}

/* ---- Chips ---- */
.badge{font-size:11.5px; font-weight:700; padding:4px 10px}
.badge-dot{width:6px; height:6px}
.badge-svc{padding:3px 9px}

/* ---- Tabs and segmented toggle ---- */
.tab{border-color:var(--border); transition:background .25s var(--ease-out),color .25s var(--ease-out),border-color .25s var(--ease-out)}
.tab:hover{border-color:rgb(var(--blue-rgb) / .5)}
.tab.on{background:linear-gradient(135deg,var(--navy-3),var(--navy)); box-shadow:0 8px 16px -8px rgb(22 30 41 / .5)}
.seg{border:0; background:var(--surface-2); border-radius:12px; padding:4px; gap:2px; overflow:visible; box-shadow:inset 0 0 0 1px var(--border)}
.seg-b{background:transparent; border-radius:9px; padding:7px 18px; font-size:13px; transition:background .25s var(--ease-out),color .25s var(--ease-out),box-shadow .25s var(--ease-out)}
.seg-b.on,.seg-b.active{background:var(--surface); color:var(--text); font-weight:700; box-shadow:0 2px 8px rgb(22 30 41 / .12)}

/* ---- Notes ---- */
.hint-box{border-radius:14px}

/* ---- Toast: every saved / done message, top centre, leaves by itself ---- */
@keyframes ds-toast{
    0%{opacity:0; transform:translate(-50%,-60%)}
    6%{opacity:1; transform:translate(-50%,0)}
    94%{opacity:1; transform:translate(-50%,0)}
    100%{opacity:0; transform:translate(-50%,-30%); visibility:hidden}
}
@keyframes ds-countdown{to{transform:scaleX(0)}}
.flash{
    position:fixed; top:16px; left:50%; z-index:120; width:max-content; max-width:min(440px,calc(100vw - 24px)); margin:0;
    background:var(--surface); color:var(--text); border:1px solid rgb(18 128 92 / .3); border-radius:16px;
    padding:13px 18px 15px; font-weight:600; box-shadow:0 14px 30px -6px rgb(16 22 31 / .2); overflow:hidden;
    display:flex; align-items:center; gap:10px; animation:ds-toast 4s var(--ease-out) forwards;
}
.flash::before{
    content:"\2713"; flex-shrink:0; width:26px; height:26px; border-radius:50%; background:var(--success-soft); color:var(--success);
    display:flex; align-items:center; justify-content:center; font-size:14px; font-weight:700;
}
.flash::after{
    content:""; position:absolute; inset-inline:0; bottom:0; height:3px; background:var(--success);
    transform-origin:right; animation:ds-countdown 4s linear forwards;
}
.flash:hover,.flash:hover::after{animation-play-state:paused}

/* ---- Dialogs ---- */
@keyframes ds-fade{from{opacity:0}}
@keyframes ds-dialog{from{opacity:0; transform:scale(.92)}}
@keyframes ds-sheet{from{transform:translateX(-100%)}}
@keyframes ds-sheet-up{from{transform:translateY(100%)}}

/* Every add / edit form is a side sheet on the end edge (left in RTL). */
.modal-overlay{background:rgb(16 22 31 / .45); animation:ds-fade .15s var(--ease-out); padding:0; align-items:stretch; justify-content:flex-end; overflow:hidden}
.modal{
    width:520px; max-width:100%; height:100vh; height:100dvh; display:flex; flex-direction:column;
    border-radius:var(--r-dialog) 0 0 var(--r-dialog); overflow:hidden; animation:ds-sheet .26s var(--ease-out);
}
.modal-head{
    flex-shrink:0; padding:22px 24px; border-bottom:0; color:#fff;
    background:linear-gradient(135deg,var(--navy-3),var(--navy),var(--navy-deep));
}
.modal-head h3{font-size:19px; font-weight:700; color:#fff}
.modal-x{width:34px; height:34px; border-radius:11px; background:rgb(255 255 255 / .1); color:#fff; transition:background .15s}
.modal-x:hover{background:rgb(255 255 255 / .2)}
.modal-body{flex:1; overflow-y:auto; background:var(--bg); padding:22px 24px}
.modal-foot{flex-shrink:0; background:var(--surface); padding:16px 24px}
.modal-foot .btn-primary{min-width:170px}

/* Short questions stay a centred dialog. */
.modal.modal-dialog{
    width:100%; height:auto; margin:auto; border-radius:var(--r-dialog); animation:ds-dialog .22s var(--ease-back);
}
.modal.modal-dialog .modal-body{flex:none; background:var(--surface)}

@media (max-width:640px){
    .modal-overlay{align-items:flex-end; justify-content:center}
    .modal{width:100%; max-width:none !important; height:92vh; height:92dvh; border-radius:var(--r-dialog) var(--r-dialog) 0 0; animation-name:ds-sheet-up}
    .modal-body{max-height:none; padding:18px 16px}
    .modal.modal-dialog{height:auto; margin:auto 12px; border-radius:var(--r-dialog); animation-name:ds-dialog}
}

/* ---- Small pieces ---- */
.avatar{font-weight:700}
.svc-line{border-radius:16px}
.svc-remove{border-radius:10px}
:focus-visible{outline:2px solid var(--blue); outline-offset:2px; box-shadow:0 0 0 4px rgb(var(--blue-rgb) / .14)}
.nav-item:focus-visible{box-shadow:none}
.input:focus-visible{box-shadow:0 0 0 4px rgb(var(--blue-rgb) / .13)}

@media (prefers-reduced-motion:reduce){
    *,*::before,*::after{transition:none !important; animation:none !important}
}

/* ============================================================
   Design system layer, phases 2 and 3
   ============================================================ */

/* ---- Instant feedback: a pressed button shows it is working before the server answers ---- */
@keyframes ds-spin{to{transform:rotate(360deg)}}
@keyframes ds-bar{0%{transform:translateX(100%)} 100%{transform:translateX(-100%)}}
.is-busy{pointer-events:none}
.btn.is-busy{opacity:.85}
.btn.is-busy::after{
    content:""; width:13px; height:13px; flex-shrink:0; border-radius:50%;
    border:2px solid currentColor; border-top-color:transparent; animation:ds-spin .6s linear infinite;
}
html.is-loading::before{
    content:""; position:fixed; top:0; left:0; right:0; height:3px; z-index:200; pointer-events:none;
    background:linear-gradient(90deg,transparent,var(--blue),transparent); animation:ds-bar .9s linear infinite;
}

/* ---- Confirm dialog (replaces the browser's own box) ---- */
.confirm-overlay{
    position:fixed; inset:0; z-index:150; background:rgb(16 22 31 / .45); display:flex; align-items:center; justify-content:center;
    padding:16px; animation:ds-fade .12s var(--ease-out);
}
.confirm-box{
    width:100%; max-width:420px; background:var(--surface); border-radius:var(--r-dialog); box-shadow:var(--shadow-pop);
    padding:26px 24px 20px; text-align:center; animation:ds-dialog .2s var(--ease-back);
}
.confirm-ic{
    width:60px; height:60px; margin:0 auto 14px; border-radius:50%; background:var(--warning-soft); color:var(--warning);
    display:flex; align-items:center; justify-content:center; font-size:26px; font-weight:700;
}
.confirm-box.is-danger .confirm-ic{background:var(--danger-soft); color:var(--danger)}
.confirm-title{font-size:18px; font-weight:700; margin-bottom:8px}
.confirm-msg{font-size:14px; color:var(--muted); background:var(--surface-2); border-radius:12px; padding:12px 14px; line-height:1.7; white-space:pre-line}
.confirm-actions{display:flex; gap:10px; margin-top:18px}
.confirm-actions .btn{flex:1; border-radius:12px; height:44px}
.confirm-box.is-danger .btn-primary{background:var(--danger); box-shadow:0 8px 16px -8px rgb(200 50 43 / .55)}

/* ---- Empty state ---- */
@keyframes ds-breathe{to{transform:scale(1.06)}}
.empty{padding:40px 20px; font-size:14px}
.empty::before{
    content:""; display:block; width:72px; height:72px; margin:0 auto 14px; border-radius:50%;
    background:radial-gradient(circle,rgb(var(--blue-rgb) / .2) 0 42%,rgb(var(--blue-rgb) / .08) 43% 100%);
    animation:ds-breathe 1.6s ease-in-out infinite alternate;
}
.empty .ic{display:none}

@media (prefers-reduced-motion:reduce){
    *,*::before,*::after{transition:none !important; animation:none !important}
    .flash{animation:ds-toast 4s steps(1,end) forwards !important}
}

/* ---- Contract text as the client will read it ---- */
.contract-preview{
    background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:18px 20px;
    max-height:420px; overflow-y:auto; font-size:13.5px; line-height:1.85;
}
.contract-preview h3{font-size:15px; margin:16px 0 4px}
.contract-preview h3:first-child{margin-top:0; text-align:center; font-size:16px}
.contract-preview p{margin:0 0 9px}


/* Project page sections as tabs: one section on screen at a time instead of one long scroll. */
.tabs-bar{position:sticky; top:0; z-index:5; margin:0 0 18px; padding:10px 0; flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none;
  background:linear-gradient(var(--bg) 78%,transparent)}
.tabs-bar::-webkit-scrollbar{display:none}
.tabs-bar .tab{flex:none; white-space:nowrap; min-height:40px}
.tabs-bar .tab:focus-visible{outline:2px solid var(--blue); outline-offset:2px}
.tab-pane > .card:last-child{margin-bottom:0}
.pane-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr)); gap:18px; align-items:start}
.pane-grid > .card{margin-bottom:0 !important}

/* ---- Sidebar: the setup links fold away ---- */
.nav-fold{
    display:flex; align-items:center; justify-content:space-between; width:100%; background:transparent; border:0;
    font-family:inherit; cursor:pointer; text-align:start; border-radius:10px; margin-top:6px; padding-top:12px; padding-bottom:10px;
}
.nav-fold:hover{color:rgb(255 255 255 / .75)}
.nav-fold:focus-visible{outline:2px solid #fff; outline-offset:-2px}
.nav-fold .icon{width:15px; height:15px; transform:rotate(-90deg); transition:transform .2s var(--ease-out)}
.nav-fold.is-open .icon{transform:rotate(90deg)}
.nav-more{display:none; flex-direction:column; gap:3px}
.nav-fold.is-open + .nav-more{display:flex}
a.seg-b{text-decoration:none; color:inherit; display:inline-flex; align-items:center}

/* ---- Dashboard: what needs attention, then one block per part of the business ---- */
.dash-h{display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin:26px 2px 12px}
.dash-h h2{margin:0; font-size:16.5px; font-weight:700}
.dash-h a{font-size:13px; color:var(--muted)}
.dash-h a:hover{color:var(--text)}
a.stat{display:block; color:inherit; text-decoration:none}
.dash-need{display:flex; align-items:center; gap:14px; padding:13px 22px; border-bottom:1px solid var(--border); color:inherit; text-decoration:none}
.dash-need:last-child{border-bottom:0}
.dash-need:hover{background:var(--surface-2)}
.dash-need:focus-visible{outline:2px solid var(--blue); outline-offset:-2px}
.dash-need .c{min-width:34px; text-align:center; font-weight:700; font-size:15px; color:var(--danger); background:var(--danger-soft); border-radius:9px; padding:4px 8px; font-family:'Rubik','IBM Plex Sans Arabic',sans-serif}
.dash-need .t{flex:1; font-weight:600}
.dash-need .icon{width:16px; height:16px; color:var(--muted)}
.dash-ok{padding:18px 22px; color:var(--success); font-weight:600}
.dash-row{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 22px; border-bottom:1px solid var(--border); color:inherit; text-decoration:none}
.dash-row:last-child{border-bottom:0}
.dash-row:hover{background:var(--surface-2)}
.dash-lists{display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:18px; align-items:start; margin-top:18px}


/* ============================================================
   Jad Signature additions
   ============================================================ */
.env-bar{position:fixed; bottom:0; left:0; right:0; z-index:9999; background:#B42318; color:#fff; text-align:center; font-size:13px; font-weight:600; padding:5px 10px; pointer-events:none}
.sidebar .brand .wm .g{font-size:13px; letter-spacing:1.2px}
a.stat{display:block; transition:.15s} a.stat:hover{box-shadow:var(--shadow-hover); transform:translateY(-1px)}
.stat .n small{font-size:15px; color:var(--muted); font-weight:500}
.topbar .user .who{text-decoration:none}

.lang-switch{display:inline-flex; border:1px solid var(--border-2); border-radius:var(--r-pill); overflow:hidden; background:var(--surface)}
.lang-switch button{border:0; background:transparent; font:inherit; font-size:12px; font-weight:600; color:var(--muted); padding:6px 11px; cursor:pointer}
.lang-switch button.on{background:var(--navy); color:#fff}

.strip{display:flex; align-items:center; justify-content:center; gap:14px; flex-wrap:wrap; background:var(--sky); color:var(--navy-3); font-size:13.5px; font-weight:500; padding:8px 16px; border-bottom:1px solid var(--sky-2)}
.strip-warn{background:var(--warning-soft); color:var(--warning); border-color:#EFD9B0}
.strip-danger{background:var(--danger-soft); color:var(--danger); border-color:#EBC4C0}
.flash-err{background:var(--danger-soft); color:var(--danger); border-color:#EBC4C0}

.chips{display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin-bottom:12px}
.chip{border:1px solid var(--border-2); background:var(--surface-2); color:var(--text); font:inherit; font-size:12.5px; font-weight:500; padding:4px 11px; border-radius:var(--r-pill); cursor:pointer}
.chip:hover{border-color:var(--blue); color:var(--blue-600)}
.chip-own{background:var(--blue-soft); border-color:var(--sky-2); color:var(--blue-600); font-weight:600}
.editor-wrap .ql-toolbar{border-color:var(--border-2); border-radius:var(--radius-sm) var(--radius-sm) 0 0; direction:ltr}
.editor-wrap .ql-container{border-color:var(--border-2); border-radius:0 0 var(--radius-sm) var(--radius-sm); font-family:inherit; font-size:15px}
.editor-wrap .ql-editor{min-height:420px; line-height:1.8}
.qr svg{width:170px; height:170px; border:1px solid var(--border); border-radius:var(--radius-sm); background:#fff}

.upload{display:flex; align-items:center; gap:12px; flex-wrap:wrap; border:1px dashed var(--border-2); border-radius:var(--radius-sm); padding:10px 12px; background:var(--surface-2)}
.upload img{height:54px; max-width:150px; object-fit:contain; background:#fff; border:1px solid var(--border); border-radius:8px; padding:3px}
.upload input[type=file]{font:inherit; font-size:13px; max-width:100%}
.brand-preview{display:flex; align-items:flex-end; justify-content:space-between; gap:14px; padding:14px 4px 10px; border-bottom:3px solid var(--blue); background:var(--surface)}
.brand-preview img{height:48px; max-width:140px; object-fit:contain}

/* The document text as the business wrote it in the editor (same rules as public/css/sign.css). */
.doc-body{font-size:14.5px; line-height:1.8; overflow-wrap:anywhere}
.doc-body h1{font-size:20px} .doc-body h2{font-size:17px} .doc-body h3{font-size:15.5px; margin:16px 0 6px}
.doc-body p{margin:0 0 10px}
.doc-body table{border-collapse:collapse; width:100%} .doc-body td,.doc-body th{border:1px solid var(--border); padding:6px 8px}
.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}
.ql-size-small{font-size:.82em}.ql-size-large{font-size:1.35em}.ql-size-huge{font-size:1.9em}

/* Sign-in and registration */
body.guest{display:flex; min-height:100vh; background:var(--bg)}
.guest-side{width:42%; max-width:520px; background:linear-gradient(160deg,var(--navy-3),var(--navy),var(--navy-deep)); color:#fff; padding:34px 38px; display:flex; flex-direction:column; justify-content:space-between}
.guest-side .brand{display:flex; align-items:center; gap:11px}
.guest-side .brand img{height:34px}
.guest-side .wm{font-weight:700; font-size:19px; letter-spacing:.3px}
.guest-side .wm .g{font-weight:400; color:var(--sky-3); margin-inline-start:6px; font-size:13px; letter-spacing:1.2px}
.guest-side h2{font-size:30px; line-height:1.35; margin:0 0 14px; font-weight:700}
.guest-side p{color:#B4C0CF; font-size:15.5px; line-height:1.8; margin:0}
.guest-side .foot{font-size:12px; color:#73839A}
.guest-main{flex:1; display:flex; flex-direction:column; align-items:center; padding:22px 18px 40px}
.guest-card{width:100%; max-width:440px; margin:auto; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:28px 28px 24px}
.guest-card h1{margin:0 0 16px; font-size:24px; font-weight:700}
@media (max-width:860px){ body.guest{flex-direction:column} .guest-side{width:100%; max-width:none; padding:22px 20px; gap:18px} .guest-side h2{font-size:21px} .guest-side p,.guest-side .foot{display:none} }

/* English runs left to right: flip the few rules written for the right-hand side. */
[dir=ltr] select.input{background-position:right 13px center; padding-left:13px; padding-right:36px}
[dir=ltr] input[type=date].input,[dir=ltr] input[type=number].input{text-align:left}
[dir=ltr] .info-list .v{text-align:right}
@media (max-width:1024px){
    [dir=ltr] .sidebar{right:auto; left:0; transform:translateX(-100%); box-shadow:10px 0 34px rgba(0,0,0,.22)}
    [dir=ltr] .app.nav-open .sidebar{transform:translateX(0)}
}
@media (max-width:700px){ .detail-grid{grid-template-columns:1fr !important} }
