
:root{
  --navy:#0a2342; --navy2:#0f3460; --blue:#1565c0; --blue2:#1e88e5; --sky:#e8f1fb;
  --gold:#f5b301; --green:#16a34a; --red:#dc2626; --orange:#ea580c; --purple:#7c3aed;
  --bg:#eef2f7; --card:#fff; --text:#0f172a; --muted:#64748b; --line:#e2e8f0;
  --radius:14px; --shadow:0 4px 18px rgba(15,35,70,.08);
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:'Cairo',Tahoma,sans-serif;background:var(--bg);color:var(--text);display:flex;flex-direction:column;overflow:hidden;font-size:calc(14px*var(--fz,1))}
svg.i{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
button{font-family:inherit;cursor:pointer;border:0;background:none;color:inherit}

/* ===== Title bar ===== */
.titlebar{height:38px;background:var(--navy);color:#fff;display:flex;align-items:center;padding:0 14px;gap:12px;flex-shrink:0}
.titlebar .logo{width:26px;height:26px;border-radius:7px;background:linear-gradient(135deg,var(--gold),#ff8f00);display:grid;place-items:center;font-weight:900;color:var(--navy);font-size:calc(14px*var(--fz,1))}
.titlebar .company{font-weight:700;font-size:calc(14px*var(--fz,1))}
.titlebar .ver{font-size:calc(11px*var(--fz,1));opacity:.6;background:rgba(255,255,255,.08);padding:2px 8px;border-radius:20px}
.titlebar .sp{flex:1}
.winbtns{display:flex;gap:2px}
.winbtns button{width:36px;height:28px;border-radius:6px;display:grid;place-items:center;opacity:.8}
.winbtns button:hover{background:rgba(255,255,255,.12);opacity:1}
.winbtns button.x:hover{background:var(--red)}
.winbtns svg{width:15px;height:15px}

/* ===== Menu bar ===== */
.menubar{height:40px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 10px;gap:2px;flex-shrink:0;position:relative;z-index:30}
.menu{position:relative}
.menu>button{padding:6px 14px;border-radius:8px;font-weight:600;font-size:calc(13.5px*var(--fz,1));color:#1e293b}
.menu>button:hover,.menu:focus-within>button{background:var(--sky);color:var(--blue)}
.dropdown{display:none;position:absolute;top:100%;right:0;min-width:210px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 30px rgba(15,35,70,.15);padding:6px;margin-top:4px}
.menu:hover .dropdown,.menu:focus-within .dropdown{display:block}
.dropdown a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;color:#334155;text-decoration:none;font-size:calc(13px*var(--fz,1))}
.dropdown a:hover{background:var(--sky);color:var(--blue)}
.dropdown{max-height:calc(100vh - 140px);overflow-y:auto;min-width:250px;scrollbar-width:thin}
.dropdown.wide{min-width:300px}
.dropdown a{padding:7px 10px;white-space:nowrap}
.dropdown a.soon{color:#64748b}
.dropdown a.soon::after{content:"قريباً";margin-right:auto;font-size:calc(10px*var(--fz,1));font-weight:700;color:#94a3b8;background:#f1f5f9;padding:1px 7px;border-radius:10px}
.dropdown a[data-open]{font-weight:700;color:#1e293b}
.dropdown a[data-open] svg.i{color:var(--blue)}
.dropdown a.danger{color:var(--red);font-weight:700}
.dropdown a.danger:hover{background:#fee2e2;color:var(--red)}
.dropdown .sep{height:1px;background:var(--line);margin:5px 8px}
.dropdown svg.i{width:17px;height:17px}
.menu.exit>button{color:var(--red)}
.menu.exit>button:hover{background:#fee2e2;color:var(--red)}
.tb-toggle{margin-right:auto;display:flex;align-items:center;gap:6px;height:30px;padding:0 12px;border-radius:10px;font-size:calc(12.5px*var(--fz,1));font-weight:700;color:var(--blue);background:var(--sky)}
.tb-toggle:hover{background:#d6e6f8}
.tb-toggle svg.i{width:16px;height:16px;transition:transform .25s}
.tb-toggle.off svg.i{transform:rotate(180deg)}
.menubar .search{margin-right:8px;display:flex;align-items:center;gap:8px;background:var(--bg);border-radius:10px;padding:0 12px;height:30px;width:260px;color:var(--muted)}
.menubar .search input{border:0;background:none;outline:none;font-family:inherit;font-size:calc(13px*var(--fz,1));width:100%}
.menubar .search svg{width:16px;height:16px}

/* ===== Toolbar ===== */
.toolbar{background:linear-gradient(180deg,#fff,#f8fafc);border-bottom:1px solid var(--line);padding:4px 12px;display:flex;gap:4px;flex-shrink:0;overflow-x:auto;max-height:90px;transition:max-height .25s,padding .25s,opacity .2s}
.toolbar.hidden{max-height:0;padding-top:0;padding-bottom:0;opacity:0;border-bottom:0;overflow:hidden}
.tool{display:flex;flex-direction:column;align-items:center;gap:3px;min-width:72px;padding:5px 6px;border-radius:12px;transition:.2s;font-size:calc(11px*var(--fz,1));font-weight:600;color:#475569}
.tool .ic{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;color:#fff;box-shadow:0 4px 10px rgba(0,0,0,.12);transition:.2s}
.tool .ic svg{width:18px;height:18px}
.tool:hover{background:#fff;box-shadow:var(--shadow)}
.tool:hover .ic{transform:translateY(-2px) scale(1.05)}
.tool-sep{width:1px;background:var(--line);margin:6px 4px}
.c1{background:linear-gradient(135deg,#64748b,#334155)}
.c2{background:linear-gradient(135deg,#0ea5e9,#0369a1)}
.c3{background:linear-gradient(135deg,#22c55e,#15803d)}
.c4{background:linear-gradient(135deg,#f59e0b,#b45309)}
.c5{background:linear-gradient(135deg,#ef4444,#b91c1c)}
.c6{background:linear-gradient(135deg,#6366f1,#4338ca)}
.c7{background:linear-gradient(135deg,#14b8a6,#0f766e)}
.c8{background:linear-gradient(135deg,#8b5cf6,#6d28d9)}
.c9{background:linear-gradient(135deg,#ec4899,#be185d)}
.c10{background:linear-gradient(135deg,#1e88e5,#0d47a1)}

/* ===== Layout ===== */
.body{flex:1;display:flex;min-height:0}
.sidebar{width:250px;background:var(--navy);color:#cbd5e1;display:flex;flex-direction:column;flex-shrink:0;transition:width .25s}
.sidebar.collapsed{width:64px}
.sb-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid rgba(255,255,255,.07)}
.sb-head b{color:#fff;font-size:calc(13.5px*var(--fz,1));white-space:nowrap}
.sb-head button{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;color:#94a3b8}
.sb-head button:hover{background:rgba(255,255,255,.08);color:#fff}
.sb-scroll{flex:1;overflow-y:auto;padding:6px 10px 14px}
.sb-scroll::-webkit-scrollbar{width:5px}.sb-scroll::-webkit-scrollbar-thumb{background:rgba(255,255,255,.15);border-radius:5px}
.grp{font-size:calc(11px*var(--fz,1));font-weight:700;color:#64748b;padding:12px 8px 6px;letter-spacing:.3px;white-space:nowrap}
.nav{display:flex;align-items:center;gap:11px;width:100%;padding:8px 10px;border-radius:9px;font-size:calc(13.5px*var(--fz,1));font-weight:600;color:#cbd5e1;text-align:right;white-space:nowrap;position:relative;transition:.15s}
.nav svg.i{width:18px;height:18px;color:#7dd3fc}
.nav:hover{background:rgba(255,255,255,.07);color:#fff}
.nav.active{background:linear-gradient(90deg,transparent,rgba(30,136,229,.35));color:#fff}
.nav.active::before{content:"";position:absolute;right:-10px;top:8px;bottom:8px;width:3px;border-radius:3px;background:var(--gold)}
.nav .badge{margin-right:auto;font-size:calc(10.5px*var(--fz,1));background:var(--gold);color:var(--navy);padding:0 7px;border-radius:10px;font-weight:800}
.nav.hot svg.i{color:var(--gold)}
.nav.warn svg.i{color:#fca5a5}
.sidebar.collapsed .grp,.sidebar.collapsed .nav span,.sidebar.collapsed .sb-head b,.sidebar.collapsed .nav .badge{display:none}
.sidebar.collapsed .nav{justify-content:center;padding:10px}

.main{flex:1;overflow-y:auto;padding:18px 20px 24px}
.main.framed{padding:12px 14px;display:flex;flex-direction:column}
#view{display:none;flex-direction:column;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.main.framed #view{display:flex;flex-shrink:0}
.main.framed #home{display:none}

.rv{padding:6px 8px 8px;background:#eef2f7}
.rv-sec{background:#e3e9f1;border:1px solid #d5dde8;border-radius:12px;padding:7px 12px;margin-bottom:4px}
.rv-row{display:grid;gap:10px}
.rv-row.g4{grid-template-columns:repeat(4,1fr)}.rv-row.g3{grid-template-columns:1fr 2fr 1fr}.rv-row.g3w{grid-template-columns:1fr 1.6fr 2.4fr}.rv-row.g1{grid-template-columns:1fr;margin-top:5px}
.rv label{display:flex;flex-direction:column;gap:3px}
.rv label b{font-size:calc(12.5px*var(--fz,1));color:#334155;font-weight:700}
.rv input,.rv select,.rv textarea{font-family:inherit;font-size:calc(13.5px*var(--fz,1));border:1px solid #d5dde8;background:#fff;border-radius:9px;padding:7px 10px;outline:none;width:100%;resize:none;color:var(--text)}
.rv input:focus,.rv select:focus,.rv textarea:focus{border-color:var(--blue2);box-shadow:0 0 0 3px rgba(30,136,229,.15)}
.rv input[readonly]{background:#f8fafc}
.rv .ltr{direction:ltr;text-align:right}.rv .strong{font-weight:800;color:var(--blue)}
.rv .words{color:#15803d;font-weight:700}
.rv.locked input:not([readonly]),.rv.locked select,.rv.locked textarea{background:#f1f5f9;pointer-events:none}
.rv-bar{margin-top:0;background:#e3e9f1;border:1px solid #d5dde8;border-radius:12px;padding:8px}
.rv-btns,.rv-nav{display:grid;gap:8px}
.rv-btns{grid-template-columns:repeat(7,1fr)}
.rv-nav{grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr;margin-top:6px;align-items:center}
.rv-bar button{height:36px;border-radius:9px;font-weight:800;font-size:calc(13.5px*var(--fz,1));display:flex;align-items:center;justify-content:center;gap:8px;border:1px solid #d5dde8;transition:.15s}
.rv-bar button:focus-visible,.st-run:focus-visible{outline:3px solid var(--blue2);outline-offset:2px}
.rv-bar button:hover{filter:brightness(.96);transform:translateY(-1px)}
.rv-bar kbd{font-family:Consolas,monospace;font-size:calc(10.5px*var(--fz,1));padding:1px 6px;border-radius:5px;background:rgba(0,0,0,.08)}
.b-save{background:var(--gold);color:var(--navy);border-color:var(--gold)!important}
.b-add{background:var(--navy);color:#fff;border-color:var(--navy)!important}.b-add kbd{background:rgba(255,255,255,.18)}
.b-edit{background:#fce7f3;color:#be185d}
.b-del{background:#fee2e2;color:var(--red)}
.b-w{background:#fff;color:var(--text)}
.rv-nav button{background:#dbe7f6;color:var(--blue)}
.rv-nav .cnt{height:36px;background:#fff;border:1px solid #d5dde8;border-radius:9px;display:grid;place-items:center;font-weight:800;direction:ltr}
.rv-nav .hp{flex-direction:row;align-items:center;gap:6px;font-size:calc(12.5px*var(--fz,1));font-weight:700;color:#334155;justify-content:center}
.rv-nav .hp input{width:16px;height:16px}
.rv-msg{position:fixed;bottom:44px;left:50%;transform:translateX(-50%);background:var(--navy);color:#fff;padding:8px 18px;border-radius:10px;font-weight:700;font-size:calc(13px*var(--fz,1));opacity:0;transition:.25s;pointer-events:none;z-index:99}
.rv-msg.on{opacity:1}

.rv{display:none}
#view .rv.on{display:block}
.rv.pay .rv-sec{margin-bottom:0;border-radius:0;border-bottom-width:0}
.rv.pay .rv-sec:first-child{border-radius:12px 12px 0 0}
.rv.pay .rv-bar{border-radius:0 0 12px 12px}
@media (min-width:761px){
  .rv.pay{padding:4px 6px 6px}
  .rv.pay .rv-sec{padding:4px 10px 5px}
  .rv.pay .rv-row{gap:8px}
  .rv.pay .rv-row.g1{margin-top:3px}
  .rv.pay label{gap:1px}
  .rv.pay label.chk,.rv.pay label.hp{gap:6px}
  .rv.pay label b{font-size:calc(11.5px*var(--fz,1))}
  .rv.pay .sec-t{font-size:calc(12.5px*var(--fz,1));margin-bottom:2px}
  .rv.pay .sec-t i{height:13px}
  .rv.pay input,.rv.pay select,.rv.pay textarea{padding:4px 9px;font-size:calc(13px*var(--fz,1));border-radius:7px}
  .rv.pay textarea{height:30px}
  .rv.pay .amt{font-size:calc(14.5px*var(--fz,1))}
  .rv.pay .rv-bar{padding:5px}
  .rv.pay .rv-bar button,.rv.pay .rv-nav .cnt{height:30px;font-size:calc(12.5px*var(--fz,1))}
  .rv.pay .rv-btns{gap:5px}
  .rv.pay .rv-nav{gap:5px;margin-top:4px}
}
.main.framed .view-h{padding:5px 12px}
.rv-row.g3e{grid-template-columns:repeat(3,1fr)}
.sec-t{display:flex;align-items:center;gap:8px;font-weight:800;font-size:calc(13px*var(--fz,1));margin-bottom:5px;color:var(--text)}
.sec-t i{width:4px;height:16px;border-radius:2px;background:var(--blue2)}
.rv.pay .sec-t i{background:var(--red)}
.sec-t .chk{flex-direction:row!important;align-items:center;gap:6px;margin-right:auto;font-size:calc(12.5px*var(--fz,1));cursor:pointer}
.sec-t .chk input{width:16px;height:16px;accent-color:var(--red)}
.rv.pay .amt{color:var(--red);font-size:calc(16px*var(--fz,1))}
.rv.pay .words{color:#8a5a00;background:#fff8e1}
.rv input:disabled{background:#e8ecf2!important;color:#9aa4b2}
@media (max-width:820px){.rv-row.g3e{grid-template-columns:1fr 1fr}.rv-row.g3e>label:last-child{grid-column:1/-1}}
@media (max-width:520px){.rv-row.g3e{grid-template-columns:1fr}}
.sv-h{display:grid;grid-template-columns:repeat(6,1fr);gap:5px 8px}
.sv-h .w2{grid-column:span 2}
.sv-h b.tx{color:#c2410c}
.rv.sale .inv{color:#be185d;background:#fdf2f8;border-color:#f9a8d4;font-weight:800;letter-spacing:1px}
.sv-grid{background:#fff;border:1px solid #cfdcec;border-radius:10px;overflow:auto;height:clamp(277px,calc(100vh - 443px),727px);height:clamp(277px,calc(100dvh - 443px),727px);margin:4px 0;-webkit-overflow-scrolling:touch}
.sv-grid table{min-width:640px;table-layout:fixed;font-size:calc(13px*var(--fz,1))}
.sv-grid th{position:sticky;top:0;z-index:1;background:linear-gradient(180deg,#2f5288,#1c355e);color:#fff;font-size:calc(12.5px*var(--fz,1));font-weight:800;text-align:center;padding:6px 4px;border-left:1px solid rgba(255,255,255,.15)}
.sv-grid td{padding:0;border-top:0;border-bottom:1px solid #e2e8f0;border-left:1px solid #e2e8f0}
.sv-grid tr:nth-child(even) td{background:#f6f8fc}
.sv-grid tr:hover td{background:#eef4fc}
.sv-grid tr.cur td{background:#e0ebfa}
.sv-grid td.sel{text-align:center;font-weight:800;color:#64748b;cursor:pointer;font-size:calc(12px*var(--fz,1))}
.sv-grid tr.cur td.sel{background:#1c355e;color:#fff}
.rv .sv-grid td input{border:0;border-radius:0;background:transparent;height:28px;padding:0 8px;font-size:calc(13.5px*var(--fz,1));font-weight:700;box-shadow:none}
.rv .sv-grid td input:focus{background:#fff;box-shadow:inset 0 0 0 2px #2f5288}
.rv .sv-grid td input.n{direction:ltr;text-align:center}
.rv .sv-grid td.tot input{color:#1c355e;font-weight:800}
.sv-foot{display:grid;grid-template-columns:1.5fr repeat(5,1fr);gap:6px;align-items:end;margin-bottom:4px}
.sv-foot b.red{color:var(--red)}
.sv-stat{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid #d5dde8;border-radius:9px;height:32px;overflow:hidden;font-weight:700;font-size:calc(12.5px*var(--fz,1));color:#334155}
.sv-stat span{min-width:42px;height:100%;display:grid;place-items:center;background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff;font-weight:800;font-size:calc(15px*var(--fz,1))}
.sv-stat em{font-style:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.rv .tb{direction:ltr;text-align:left;font-weight:800;height:32px}
.rv .tb.big{background:linear-gradient(135deg,#10b981,#059669)!important;color:#fff;border:0;font-size:calc(16px*var(--fz,1))}
.rv.sale .rv-btns{grid-template-columns:repeat(6,1fr)}
@media (min-width:761px){
  .rv.sale{padding:4px 6px 6px}
  .rv.sale .rv-sec{padding:4px 10px 6px;margin-bottom:0}
  .rv.sale label{gap:1px}
  .rv.sale label.hp{gap:6px}
  .rv.sale label b{font-size:calc(11.5px*var(--fz,1))}
  .rv.sale .sv-h input,.rv.sale .sv-h select,.rv.sale .sv-foot input{padding:4px 9px;font-size:calc(13px*var(--fz,1));border-radius:7px;height:30px}
  .rv.sale .rv-bar{padding:5px}
  .rv.sale .rv-bar button,.rv.sale .rv-nav .cnt{height:30px;font-size:calc(12.5px*var(--fz,1))}
  .rv.sale .rv-btns{gap:5px}
  .rv.sale .rv-nav{gap:5px;margin-top:4px}
}
@media (max-width:1100px){
  .sv-h{grid-template-columns:repeat(3,1fr)}
  .sv-foot{grid-template-columns:repeat(3,1fr)}
  .sv-stat{grid-column:1/-1}
  .rv.sale .rv-btns{grid-template-columns:repeat(3,1fr)}
}
@media (max-width:760px){.sv-grid{height:417px}}
@media (max-width:520px){
  .sv-h{grid-template-columns:1fr 1fr}
  .sv-foot{grid-template-columns:1fr 1fr}
  .sv-foot label:last-child{grid-column:1/-1}
  .rv.sale .rv-btns button:last-child{grid-column:auto}
}
.rv.sale.ret .inv{color:var(--red);background:#fff1f2;border-color:#fecdd3}
.rv.sale.stock .sv-foot{grid-template-columns:2fr 1fr 1fr}
.sv-h .w3{grid-column:span 3}
@media (max-width:1100px){.rv.sale.stock .sv-foot{grid-template-columns:1fr 1fr}.sv-h .w3{grid-column:1/-1}}
@media (max-width:520px){.sv-h .w2{grid-column:1/-1}}
#tabbar{display:none;gap:4px;align-items:flex-end;overflow-x:auto;overflow-y:hidden;flex-shrink:0;scrollbar-width:none;padding:0 2px;margin-bottom:-1px;position:relative;z-index:1}
#tabbar::-webkit-scrollbar{display:none}
.main.has-tabs #tabbar{display:flex}
.main.has-tabs:not(.framed) #tabbar{margin-bottom:10px}
.tab{display:flex;align-items:center;gap:6px;height:32px;padding:0 10px;border:1px solid var(--line);border-bottom:0;border-radius:10px 10px 0 0;background:#e2e8f0;color:#475569;font-weight:700;font-size:calc(12.5px*var(--fz,1));white-space:nowrap;flex-shrink:0;transition:.15s}
.tab:hover{background:#edf2f8;color:var(--text)}
.tab.on{background:#fff;color:var(--blue);height:35px;box-shadow:0 -3px 0 var(--gold) inset,0 -2px 8px rgba(15,35,70,.06)}
.tab.on{box-shadow:inset 0 3px 0 var(--gold)}
.tab svg.i{width:15px;height:15px}
.tab .x{width:18px;height:18px;border-radius:5px;display:grid;place-items:center;font-size:calc(10px*var(--fz,1));color:#94a3b8;margin-right:2px}
.tab .x:hover{background:#fee2e2;color:var(--red)}
.tab.closeall{background:transparent;border-color:transparent;color:var(--red);font-size:calc(11.5px*var(--fz,1));margin-right:auto}
.tab.closeall:hover{background:#fee2e2}
.main.framed #view{border-top-right-radius:0}
.sv-h .w4{grid-column:span 4}
.rv.jv .rv-btns{grid-template-columns:repeat(7,1fr)}
.jv-foot{grid-template-columns:1.4fr 1.1fr .9fr 1fr 1fr 1fr}
.sv-delrow{height:32px;border-radius:9px;border:1.5px dashed #fca5a5;background:#fff5f5;color:var(--red);font-weight:800;font-size:calc(12.5px*var(--fz,1))}
.sv-delrow:hover{background:var(--red);color:#fff;border-color:var(--red)}
.rv label.chk.rep{flex-direction:row;align-items:center;gap:6px;height:32px;font-size:calc(12.5px*var(--fz,1));font-weight:700;color:#334155;cursor:pointer}
.rv label.chk.rep input{width:16px;height:16px;accent-color:var(--blue)}
.rv .tb.diff.bad{color:var(--red);border-color:#fca5a5;background:#fff5f5}
.rv .tb.diff.ok{color:var(--green);border-color:#86efac;background:#f0fdf4}
.rv.locked input[type=checkbox]{pointer-events:auto!important}
.st-run{height:32px;align-self:end;border-radius:9px;background:linear-gradient(180deg,#f8fafc,#e2e8f0);border:1px solid #cbd5e1;font-weight:800;font-size:calc(14px*var(--fz,1));color:var(--navy);display:flex;align-items:center;justify-content:center;gap:10px}
.st-run:hover{background:var(--navy);color:#fff}
.st-run kbd{font-family:Consolas,monospace;font-size:calc(11px*var(--fz,1));padding:1px 7px;border-radius:5px;background:rgba(0,0,0,.08)}
.st-grid table{min-width:760px}
.st-grid td{padding:6px 8px;font-weight:600;font-size:calc(12.5px*var(--fz,1))}
.st-grid td.c{text-align:center;direction:ltr}
.st-grid td.m{direction:ltr;text-align:left;font-weight:700}
.st-grid td.bal{color:var(--blue);font-weight:800;direction:rtl;text-align:left}
.st-grid td.bal.neg{color:var(--red)}
.st-grid tr.st-open td{background:#fffbeb;font-weight:800;color:#92400e}
.st-grid .st-empty{text-align:center;color:var(--muted);padding:30px 8px;background:#fff!important}
.st-grid tfoot td{position:sticky;bottom:0;background:#1c355e;color:#fff;font-weight:800;padding:7px 8px;direction:ltr;text-align:left}
.st-grid tfoot td:first-child{text-align:right;direction:rtl}
.st-grid tfoot td:last-child{direction:rtl}
.st-foot{grid-template-columns:2fr 1fr 1fr 1fr 1.2fr}
.rv .st-btns{grid-template-columns:repeat(4,1fr)!important}
.rv.stm .sv-grid{height:clamp(277px,calc(100vh - 383px),767px);height:clamp(277px,calc(100dvh - 383px),767px)}
@media (max-width:1100px){
  .sv-h .w4{grid-column:1/-1}
  .rv.jv .rv-btns{grid-template-columns:repeat(4,1fr)}
  .jv-foot,.st-foot{grid-template-columns:repeat(3,1fr)}
  .rv .st-btns{grid-template-columns:repeat(2,1fr)!important}
}
@media (max-width:760px){.rv.stm .sv-grid{height:447px}}
@media (max-width:520px){
  .rv.jv .rv-btns{grid-template-columns:repeat(3,1fr)}
  .jv-foot,.st-foot{grid-template-columns:1fr 1fr}
  .jv-foot .sv-delrow{grid-column:1/-1}
}
/* ===== تجاوب جميع الأجهزة ===== */
body{height:100vh;height:100dvh}
.mob-menu,.sb-overlay{display:none}
.rv-row>label{min-width:0}
.menu>button{white-space:nowrap}
@media (max-width:1000px){
  .menubar{overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .menubar::-webkit-scrollbar{display:none}
  .menu:hover .dropdown{display:none}
  .menu:focus-within .dropdown{display:block;position:fixed;top:82px;right:8px;min-width:240px}
  .tb-toggle span{display:none}
  .tb-toggle{flex-shrink:0}
}
@media (max-width:1100px){
  .rv-row.g4{grid-template-columns:repeat(2,1fr)}
  .rv-btns{grid-template-columns:repeat(4,1fr)}
  .rv-nav{grid-template-columns:repeat(4,1fr)}
  .rv-nav .cnt{grid-column:1/-1;order:-1}
  .rv-nav .hp{grid-column:1/-1}
}
@media (max-width:820px){
  .rv-row.g3,.rv-row.g3w{grid-template-columns:1fr 1fr}
  .rv-row.g3>label:last-child,.rv-row.g3w>label:last-child{grid-column:1/-1}
}
@media (max-width:760px){
  /* الهيكل العام على الجوال والتابلت الصغير */
  .titlebar{height:44px;padding:0 10px;gap:8px}
  .titlebar .ver,.winbtns{display:none}
  .titlebar .company{font-size:calc(13px*var(--fz,1));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
  .mob-menu{display:grid;place-items:center;width:36px;height:36px;border-radius:9px;background:rgba(255,255,255,.1);color:#fff}
  .menubar{overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .menubar::-webkit-scrollbar{display:none}
  .menu>button{white-space:nowrap;padding:6px 10px;font-size:calc(13px*var(--fz,1))}
  .menu:hover .dropdown{display:none}
  .menu:focus-within .dropdown{display:block;position:fixed;top:88px;right:8px;left:8px;min-width:0}
  .tb-toggle span{display:none}
  .tb-toggle{flex-shrink:0;margin-right:8px}
  .toolbar{-webkit-overflow-scrolling:touch}
  .tool{min-width:64px}
  .sidebar,.sidebar.collapsed{position:fixed;top:0;bottom:0;right:0;width:270px!important;z-index:200;transform:translateX(105%);transition:transform .25s;box-shadow:-10px 0 30px rgba(0,0,0,.3)}
  body.sb-open .sidebar{transform:none}
  body.sb-open .sb-overlay{display:block;position:fixed;inset:0;background:rgba(10,35,66,.45);z-index:150}
  .sidebar .grp,.sidebar .nav span,.sidebar .sb-head b,.sidebar .nav .badge{display:revert!important}
  .sidebar .nav{justify-content:flex-start!important;padding:10px!important}
  .sidebar .nav .badge{margin-right:auto}
  .main{padding:10px}
  .main.framed{padding:6px}
  .statusbar{overflow:hidden}
  .statusbar div:nth-child(3),.statusbar div:nth-child(5){display:none}
  .hero{border-radius:14px}
  .clock{display:none}
  .quick{grid-template-columns:repeat(4,1fr);gap:8px}
  .qa{padding:10px 4px;font-size:calc(11.5px*var(--fz,1))}
  .grid2 .panel{overflow-x:auto}
  /* سند القبض */
  .rv input,.rv select,.rv textarea{font-size:calc(16px*var(--fz,1));padding:9px 10px}
  .rv-bar button{height:42px}
  .view-h{padding:8px 10px}
}
@media (max-width:520px){
  .kpis{grid-template-columns:1fr 1fr;gap:8px}
  .kpi{padding:10px;gap:8px;flex-direction:column;align-items:flex-start}
  .kpi b{font-size:calc(18px*var(--fz,1))}
  .hero h1{font-size:calc(22px*var(--fz,1))}
  .hero p{font-size:calc(12px*var(--fz,1))}
  .btn{padding:8px 12px;font-size:calc(12.5px*var(--fz,1))}
  .rv{padding:4px}
  .rv-sec{padding:7px 8px}
  .rv-row{gap:7px}
  .rv-row.g3,.rv-row.g3w{grid-template-columns:1fr}
  .rv-btns{grid-template-columns:repeat(3,1fr);gap:6px}
  .rv-btns button:last-child{grid-column:1/-1}
  .rv-nav{gap:6px}
  .rv-bar kbd{display:none}
  .rv-bar button{font-size:calc(13px*var(--fz,1))}
}
@media (max-width:360px){
  .rv-row.g4{grid-template-columns:1fr}
  .quick{grid-template-columns:repeat(3,1fr)}
}
@media (hover:none){.rv-bar button:hover,.qa:hover,.tool:hover .ic{transform:none}}
@media print{body *{visibility:hidden}#view .rv,#view .rv *{visibility:visible}#view .rv{position:absolute;inset:0;background:#fff}.rv-bar,.rv-msg{display:none!important}}
.view-h{display:flex;align-items:center;gap:10px;padding:8px 14px;border-bottom:1px solid var(--line);background:#f8fafc}
.view-h h4{font-size:calc(14.5px*var(--fz,1));font-weight:800;display:flex;align-items:center;gap:8px;flex:1}
.view-h h4 svg{color:var(--blue)}
.view-h button{display:flex;align-items:center;gap:6px;padding:6px 12px;border-radius:9px;font-weight:700;font-size:calc(12.5px*var(--fz,1));color:var(--blue);background:var(--sky)}
.view-h button:hover{background:#d6e6f8}
.view-h button svg.i{width:16px;height:16px}


/* Hero */
.hero{position:relative;overflow:hidden;border-radius:18px;background:linear-gradient(120deg,var(--navy) 0%,var(--navy2) 45%,var(--blue) 100%);color:#fff;height:4.5cm;padding:0 30px;display:flex;align-items:center;gap:30px;box-shadow:0 10px 30px rgba(10,35,66,.25)}
.hero::before{content:"";position:absolute;inset:0;background-image:radial-gradient(rgba(255,255,255,.07) 1px,transparent 1px);background-size:22px 22px}
.hero::after{content:"";position:absolute;left:-80px;top:-80px;width:320px;height:320px;border-radius:50%;background:radial-gradient(circle,rgba(245,179,1,.28),transparent 70%)}
.hero-txt{position:relative;z-index:1;flex:1}
.hero .kicker{display:inline-flex;align-items:center;gap:6px;background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.15);padding:4px 12px;border-radius:30px;font-size:calc(12px*var(--fz,1));margin-bottom:12px}
.hero .kicker i{width:7px;height:7px;border-radius:50%;background:#4ade80;box-shadow:0 0 0 3px rgba(74,222,128,.25)}
.hero h1{font-size:calc(32px*var(--fz,1));font-weight:900;line-height:1.2;letter-spacing:-.5px}
.hero h1.brand-en{direction:ltr;text-align:right;letter-spacing:1px;font-family:"Segoe UI",Cairo,sans-serif}
.hero h1 span{background:linear-gradient(90deg,var(--gold),#ffd54f);-webkit-background-clip:text;background-clip:text;color:transparent}
.hero p{opacity:.8;margin-top:4px;font-size:calc(13.5px*var(--fz,1))}
.hero-actions{display:flex;gap:10px;margin-top:12px;flex-wrap:wrap}
.btn{display:inline-flex;align-items:center;gap:8px;padding:10px 18px;border-radius:11px;font-weight:700;font-size:calc(13.5px*var(--fz,1));transition:.2s}
.btn svg.i{width:18px;height:18px}
.btn-gold{background:var(--gold);color:var(--navy)}
.btn-gold:hover{background:#ffc62b;transform:translateY(-1px)}
.btn-glass{background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2);color:#fff}
.btn-glass:hover{background:rgba(255,255,255,.2)}
.clock{position:relative;z-index:1;text-align:center;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.14);backdrop-filter:blur(6px);border-radius:16px;padding:10px 24px;min-width:210px}
.clock .t{font-size:calc(30px*var(--fz,1));font-weight:800;letter-spacing:1px;direction:ltr}
.clock .d{font-size:calc(13px*var(--fz,1));opacity:.8;margin-top:2px}
.clock .h{font-size:calc(12px*var(--fz,1));color:var(--gold);margin-top:4px}

/* KPIs */
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-top:18px}
.kpi{background:var(--card);border-radius:var(--radius);padding:16px 18px;box-shadow:var(--shadow);display:flex;gap:14px;align-items:center;border:1px solid var(--line)}
.kpi .ic{width:48px;height:48px;border-radius:13px;display:grid;place-items:center}
.kpi .ic svg{width:24px;height:24px}
.kpi small{color:var(--muted);font-weight:600;font-size:calc(12.5px*var(--fz,1))}
.kpi b{display:block;font-size:calc(22px*var(--fz,1));font-weight:800;line-height:1.3}
.kpi b em{font-style:normal;font-size:calc(12px*var(--fz,1));color:var(--muted);font-weight:600;margin-right:3px}
.kpi .tr{font-size:calc(11.5px*var(--fz,1));font-weight:700}
.up{color:var(--green)}.dn{color:var(--red)}

/* Quick actions */
.sec-title{display:flex;align-items:center;justify-content:space-between;margin:22px 2px 10px}
.sec-title h3{font-size:calc(16px*var(--fz,1));font-weight:800}
.sec-title a{font-size:calc(12.5px*var(--fz,1));color:var(--blue);text-decoration:none;font-weight:700}
.quick{display:grid;grid-template-columns:repeat(8,1fr);gap:12px}
.qa{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px 8px;display:flex;flex-direction:column;align-items:center;gap:10px;font-weight:700;font-size:calc(13px*var(--fz,1));transition:.2s}
.qa .ic{width:46px;height:46px;border-radius:14px;display:grid;place-items:center}
.qa .ic svg{width:23px;height:23px}
.qa:hover{transform:translateY(-3px);box-shadow:0 10px 24px rgba(15,35,70,.12);border-color:transparent}

/* Panels */
.grid2{display:grid;grid-template-columns:1.6fr 1fr;gap:14px;margin-top:6px}
.panel{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.panel-h{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--line)}
.panel-h h4{font-size:calc(14.5px*var(--fz,1));font-weight:800;display:flex;align-items:center;gap:8px}
.panel-h h4 svg{color:var(--blue)}
.panel-h a{font-size:calc(12px*var(--fz,1));color:var(--blue);font-weight:700;text-decoration:none}
table{width:100%;border-collapse:collapse;font-size:calc(13px*var(--fz,1))}
th{background:#f8fafc;color:var(--muted);font-weight:700;font-size:calc(12px*var(--fz,1));text-align:right;padding:10px 16px}
td{padding:11px 16px;border-top:1px solid var(--line)}
tr:hover td{background:#fafcff}
.tag{display:inline-block;padding:2px 10px;border-radius:20px;font-size:calc(11.5px*var(--fz,1));font-weight:700}
.t-g{background:#dcfce7;color:#15803d}.t-b{background:#dbeafe;color:#1d4ed8}.t-o{background:#ffedd5;color:#c2410c}.t-r{background:#fee2e2;color:#b91c1c}.t-p{background:#ede9fe;color:#6d28d9}
.num{font-weight:800;direction:ltr;text-align:left}
.stock{padding:6px 18px 14px}
.st{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px dashed var(--line)}
.st:last-child{border:0}
.st .n{flex:1;font-weight:700;font-size:calc(13px*var(--fz,1))}
.st .n small{display:block;color:var(--muted);font-weight:600;font-size:calc(11.5px*var(--fz,1))}
.bar{height:6px;background:#f1f5f9;border-radius:6px;overflow:hidden;width:90px}
.bar i{display:block;height:100%;border-radius:6px}
.st .q{font-weight:800;font-size:calc(13px*var(--fz,1));min-width:34px;text-align:left}

/* Status bar */
.statusbar{height:32px;background:var(--navy);color:#94a3b8;display:flex;align-items:center;font-size:calc(12px*var(--fz,1));flex-shrink:0}
.statusbar div{display:flex;align-items:center;gap:7px;padding:0 16px;height:100%;border-left:1px solid rgba(255,255,255,.07)}
.statusbar svg.i{width:14px;height:14px;color:#7dd3fc}
.statusbar b{color:#e2e8f0;font-weight:700}
.statusbar .grow{flex:1;border:0}
.dot{width:8px;height:8px;border-radius:50%;background:#4ade80;box-shadow:0 0 0 3px rgba(74,222,128,.2)}

@media (max-width:1300px){.quick{grid-template-columns:repeat(4,1fr)}.kpis{grid-template-columns:repeat(2,1fr)}}
@media (max-width:1000px){.grid2{grid-template-columns:1fr}.hero{flex-direction:column;align-items:stretch;height:auto;padding:20px}.hero h1{font-size:calc(28px*var(--fz,1))}.sidebar{width:64px}.sidebar .grp,.sidebar .nav span,.sidebar .sb-head b,.sidebar .nav .badge{display:none}.menubar .search{display:none}}
