/* خط Tajawal أنيق عبر Google Fonts؛ عند انقطاع الإنترنت تستخدم الصفحة خطوط الجهاز. */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700;800&display=swap');
/* يمكن وضع ملفات الخط المحلية في assets/fonts للعمل دون إنترنت. */
@font-face {
  font-family: 'Cairo';
  src: local('Cairo'), url('../fonts/Cairo.woff2') format('woff2');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: local('Tajawal'), url('../fonts/Tajawal-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
:root {
  --g900: #12432a; --g700: #1e6b41; --g600: #26834f; --g100: #e3f3ea; --g50: #f2f9f5;
  --amber: #b45309; --amber-bg: #fef3c7; --red: #b42318; --red-bg: #fee4e2;
  --blue: #175cd3; --blue-bg: #e0efff; --ink: #1b2a22; --muted: #5f7167; --line: #dbe5df;
  --bg: #f4f7f5; --card: #fff; --radius: 14px; --shadow: 0 1px 3px rgba(18,67,42,.08), 0 4px 14px rgba(18,67,42,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.7; font-size: 16px;
  font-family: 'Tajawal', 'Cairo', 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}
a { color: var(--g700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .2rem 0 .6rem; line-height: 1.4; }
h3 { margin: .2rem 0 .6rem; }
code { background: #eef2ef; padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: embed; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 40px; min-height: 70vh; }
.muted { color: var(--muted); } .small { font-size: .88rem; } .hidden { display: none !important; }
.narrow { max-width: 560px; margin: 0 auto; } .narrow.wide { max-width: 900px; }
.pad { padding: 18px; } .row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* الشريط العلوي */
.topbar { background: linear-gradient(90deg, var(--g900), var(--g700)); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.02rem; }
.brand:hover { text-decoration: none; } .brand-icon { color: #b7e4c7; flex: none; }
.topnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topnav a { color: #fff; } .userbox a { font-weight: 600; } .role-tag { background: rgba(255,255,255,.18); padding: 1px 8px; border-radius: 99px; margin-inline-start: 4px; }
.nav-toggle { display: none; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; font-size: 1.3rem; border-radius: 8px; padding: 2px 10px; cursor: pointer; }
.badge-count { background: #e11d48; color: #fff; border-radius: 99px; padding: 0 8px; font-size: .78rem; font-weight: 700; margin-inline-start: 4px; display: inline-block; min-width: 22px; text-align: center; }
.subnav { background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subnav-in { display: flex; gap: 4px; white-space: nowrap; }
.subnav a { padding: 12px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.subnav a.active { color: var(--g700); border-color: var(--g600); } .subnav a:hover { text-decoration: none; color: var(--g700); }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px 0 28px; }

/* أزرار ونماذج */
.btn { display: inline-block; background: var(--g700); color: #fff; border: 1px solid var(--g700); padding: 9px 18px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; transition: background .15s, transform .05s; }
.btn:hover { background: var(--g900); text-decoration: none; } .btn:active { transform: translateY(1px); }
.btn-outline { background: transparent; color: var(--g700); } .btn-outline:hover { background: var(--g100); color: var(--g900); }
.topnav .btn-outline { color: #fff; border-color: rgba(255,255,255,.6); } .topnav .btn-outline:hover { background: rgba(255,255,255,.15); }
.btn-danger { background: var(--red); border-color: var(--red); } .btn-danger:hover { background: #8f1c12; }
.btn-sm { padding: 4px 12px; font-size: .88rem; border-radius: 8px; } .btn-block { width: 100%; margin-top: 8px; }
.inline-form { display: inline; margin: 0; }
.form label { display: block; font-weight: 600; margin: 12px 0 4px; }
.form label.check, label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.form input[type=text], .form input[type=password], .form input:not([type]), .form input[type=search], .form select, .pkg-row select,
.searchbar input, .filters input, .filters select, .price-edit input, .pkg-row input:not([type=checkbox]):not([type=hidden]) {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 42px;
}
input:focus, select:focus { outline: 2px solid var(--g600); outline-offset: 1px; border-color: var(--g600); }
input[type=file] { width: 100%; padding: 8px 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.searchbar, .filters { display: flex; gap: 8px; margin: 12px 0 16px; flex-wrap: wrap; } .searchbar input { flex: 1; min-width: 180px; } .filters select, .filters input { width: auto; min-width: 150px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* تنبيهات */
.alert { padding: 11px 16px; border-radius: 10px; margin: 0 0 14px; border: 1px solid; }
.alert-success { background: #e6f6ec; color: #14532d; border-color: #b6e3c6; }
.alert-error { background: var(--red-bg); color: var(--red); border-color: #f5b5b0; }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: #b2d4ff; }
.alert-warning { background: var(--amber-bg); color: #7a3a05; border-color: #f4d58a; }
.notice-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chip { display: inline-block; background: #eef2ef; color: var(--muted); border-radius: 99px; padding: 0 10px; font-size: .78rem; font-weight: 600; margin-inline-start: 6px; }
.chip-new { background: var(--amber-bg); color: var(--amber); } .chip-ok { background: #e6f6ec; color: #14532d; }
.chip-off { background: var(--red-bg); color: var(--red); } .chip-warn { background: var(--amber-bg); color: var(--amber); }

/* الرئيسية */
.hero { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; background: linear-gradient(135deg, var(--g100), #fff); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.hero p { margin: 0; color: var(--muted); } .hero .searchbar { margin: 0; flex: 1; min-width: 260px; max-width: 480px; }
.notice-panel { background: #fff; border: 1px solid #f4d58a; border-right: 5px solid #f59e0b; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.notice-head { display: flex; justify-content: space-between; gap: 8px; } .notice-panel ul { margin: 8px 0 0; padding-inline-start: 20px; } .notice-panel time { color: var(--muted); font-size: .82rem; margin-inline-start: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.company-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 14px; color: var(--ink); position: relative; transition: transform .15s, box-shadow .15s, border-color .15s; }
.company-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(18,67,42,.15); border-color: var(--g600); text-decoration: none; }
.company-card:active { transform: scale(.98); }
.company-card h3 { margin: 10px 0 2px; font-size: 1.08rem; } .company-card p { margin: 0; }
.company-card .chip-new { position: absolute; top: 10px; inset-inline-start: 10px; margin: 0; }
.logo { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.logo-lg { width: 72px; height: 72px; } .cell-co .logo { width: 34px; height: 34px; border-radius: 8px; }
.logo-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--g100); color: var(--g700); font-weight: 800; font-size: 1.5rem; }
.cell-co .logo-fallback { font-size: 1rem; } .cell-co { display: flex; align-items: center; gap: 10px; }
.company-title { display: flex; align-items: center; gap: 14px; margin: 12px 0; } .company-title h1 { margin: 0; }
.page-head { margin-bottom: 8px; }

/* حالات فارغة */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-icon { font-size: 2.2rem; } .empty h3 { margin: 6px 0; color: var(--ink); }

/* الجداول */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: var(--g50); color: var(--g900); font-size: .9rem; position: sticky; top: 0; }
tr.pname td { background: var(--g50); border-top: 2px solid var(--line); }
tbody:last-child tr:last-child td { border-bottom: 0; }
td.price { font-weight: 800; color: var(--g900); font-size: 1.08rem; white-space: nowrap; }
.dt { color: var(--muted); font-size: .88rem; } .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } td.actions { min-width: 220px; }
.ltr-cell { text-align: right; } .row-err td { background: var(--red-bg); } .row-new td { background: #e6f6ec; } .row-upd td { background: var(--amber-bg); }
.price-edit input { min-width: 110px; padding: 6px 10px; min-height: 36px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 40%); padding: 18px 0 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 14px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--g700); line-height: 1.2; } .stat-warn .num { color: var(--amber); }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.plain-list { list-style: none; margin: 0; padding: 0; } .plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line); } .plain-list li:last-child { border: 0; }
.sample-box { border-color: #f4d58a; background: #fffdf5; }
.pkg-row { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--g50); }
.pkg-row label { margin-top: 0; font-size: .85rem; } .pkg-row select { width:100%; padding:9px 12px; border:1px solid var(--line); border-radius:10px; background:#fff; min-height:42px; } .pkg-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* الإشعارات */
.notif-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.notif { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.notif.unread { border-right: 5px solid #f59e0b; background: #fffdf5; font-weight: 600; } .notif a { flex: 1; color: var(--ink); display: flex; flex-direction: column; }
.notif time { color: var(--muted); font-size: .82rem; font-weight: 400; }

.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 20px 0; }
.page-link { padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.page-link.active { background: var(--g700); border-color: var(--g700); color: #fff; } .page-link:hover { text-decoration: none; background: var(--g100); } .page-link.active:hover { background: var(--g700); }
.page-dots { padding: 6px 4px; }

/* تسجيل الدخول والأخطاء */
.login-page .main { display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 26px; }
.login-brand { text-align: center; margin-bottom: 12px; color: var(--g700); } .login-brand h1 { font-size: 1.2rem; color: var(--ink); } .login-brand p { color: var(--muted); margin: 0; }
.login-brand .brand-icon { width: 54px; height: 54px; }
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.error-box { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; max-width: 460px; margin: 16px; } .error-box h1 { font-size: 3rem; color: var(--g700); margin: 0; }

/* الهاتف والتابلت */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .nav-toggle { display: inline-block; } .topnav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 8px 0 12px; gap: 8px; }
  .topnav.open { display: flex; } .topnav .inline-form .btn { width: 100%; }
  .brand span { font-size: .92rem; } .hero { padding: 14px; } .form-row, .two-col { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .company-card { padding: 16px 8px; } .company-card h3 { font-size: .98rem; }
  .pkg-row { grid-template-columns: 1fr 1fr; } .pkg-row > :first-child + div { grid-column: auto; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
  .data-table tbody tr { margin: 0; }
  tr { border-bottom: 1px solid var(--line); } tr:last-child { border-bottom: 0; } tr.pname td { border: 0; }
  td { border: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 14px; }
  td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .84rem; font-weight: 600; flex: none; }
  .data-table { background: transparent; } .data-table tbody { padding: 4px 0; }
  .price-edit input { min-width: 0; width: 55%; } td.actions { min-width: 0; justify-content: flex-start; }
  .data-table td.price, .prices-table td.price { font-size: 1.12rem; }
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } .pkg-row { grid-template-columns: 1fr; } }
@media print { .topbar, .subnav, .footer, .searchbar, .pagination, .btn { display: none !important; } }


/* شاشة الشركة: قائمة تصنيفات ومنتجات جانبية */
.company-workspace { display:grid; grid-template-columns: 260px minmax(0,1fr); gap:20px; align-items:start; }
.product-sidebar { background:#fff; border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); padding:12px; position:sticky; top:82px; }
.sidebar-heading { font-weight:800; color:var(--g900); padding:8px 10px 12px; border-bottom:1px solid var(--line); margin-bottom:8px; }
.category-link { display:block; padding:10px 12px; margin:4px 0; border-radius:10px; font-weight:700; color:var(--ink); }
.category-link:hover,.category-link.active { background:var(--g100); color:var(--g900); text-decoration:none; }
.sidebar-products { margin:3px 0 10px; padding:0 8px 0 0; border-right:2px solid var(--g100); }
.product-link { display:block; padding:7px 10px; margin:3px 0; border-radius:8px; color:var(--muted); font-size:.94rem; }
.product-link:hover,.product-link.active { background:#f0f7f2; color:var(--g900); text-decoration:none; font-weight:700; }
.company-main-title { background:linear-gradient(135deg,var(--g100),#fff); border:1px solid var(--line); border-radius:16px; padding:18px 20px; margin:12px 0 18px; }
.company-main-title h1 { margin:0; }
@media(max-width:760px) {
 .company-workspace { grid-template-columns:1fr; }
 .product-sidebar { position:static; }
 .sidebar-products { display:flex; flex-wrap:wrap; gap:4px; }
 .product-link { background:#f7faf8; }
}

@media(max-width:900px){.pkg-row{grid-template-columns:repeat(2,minmax(0,1fr));}}

/* Unified company sale-price list */
.company-price-list { width: 100%; border-collapse: collapse; }
.company-price-list th, .company-price-list td { padding: 12px 10px; vertical-align: middle; }
.company-price-list tbody tr:nth-child(even) { background: rgba(120, 130, 145, .045); }
.company-price-list tbody tr { scroll-margin-top: 18px; }
.company-price-list td:first-child { font-weight: 600; min-width: 150px; }

/* Updated compact company price screen */
.company-title-line { display:flex; align-items:center; justify-content:space-between; gap:8px 18px; flex-wrap:wrap; }
.company-updated { display:inline-flex; gap:5px; align-items:center; color:var(--muted); font-size:.9rem; }
.company-main-title { padding:14px 18px; margin:12px 0 12px; }
.company-main-title p { margin:5px 0 0; font-size:.92rem; }
.category-tabs { display:flex; align-items:center; gap:6px; overflow-x:auto; padding:3px 1px 9px; margin-bottom:8px; scrollbar-width:thin; }
.category-tab { display:inline-flex; align-items:center; justify-content:center; gap:7px; white-space:nowrap; padding:7px 12px; border:1px solid var(--line); border-radius:10px; background:#fff; color:var(--ink); font-weight:700; font-size:.92rem; }
.category-tab span { display:inline-flex; min-width:21px; height:21px; padding:0 5px; align-items:center; justify-content:center; border-radius:99px; background:#eef2ef; color:var(--muted); font-size:.78rem; }
.category-tab.active,.category-tab:hover { background:var(--g700); border-color:var(--g700); color:#fff; text-decoration:none; }
.category-tab.active span,.category-tab:hover span { background:rgba(255,255,255,.2); color:#fff; }
.company-tools { display:flex; align-items:center; gap:10px; margin:4px 0 12px; }
.company-search { flex:1; margin:0; min-width:180px; }
.sort-control { display:flex; align-items:center; gap:7px; white-space:nowrap; color:var(--muted); font-size:.9rem; }
.sort-control select { max-width:175px; min-height:38px; border:1px solid var(--line); border-radius:9px; padding:5px 8px; background:#fff; }
.company-price-list { table-layout:auto; }
.company-price-list th,.company-price-list td { padding:7px 8px; font-size:.9rem; }
.company-price-list thead th { position:sticky; top:60px; z-index:2; white-space:nowrap; }
.company-price-list td:first-child { min-width:125px; }
.company-price-list td.price { font-size:.95rem; white-space:nowrap; }
.product-name-cell { font-weight:700; }
.copy-cell { width:1%; white-space:nowrap; }
.copy-price { padding:3px 8px; min-width:44px; }
.copy-done { background:#14532d; color:#fff; border-color:#14532d; }
.compact-price-wrap { overflow-x:auto; }
.table-note { margin-top:8px; }
.global-search-link { display:inline-block; margin-top:10px; }
@media(max-width:760px) {
  .company-workspace { display:block; }
  .product-sidebar { display:none; }
  .company-main-title { padding:11px 12px; border-radius:12px; margin-top:8px; }
  .company-main-title h1 { font-size:1.18rem; }
  .company-updated { font-size:.78rem; }
  .company-title-line { gap:2px 8px; }
  .category-tabs { gap:5px; margin-inline:-2px; }
  .category-tab { padding:6px 9px; font-size:.83rem; border-radius:8px; }
  .company-tools { align-items:stretch; flex-direction:column; gap:6px; }
  .company-search { width:100%; }
  .sort-control { justify-content:flex-start; }
  .sort-control select { flex:1; max-width:none; }
  .compact-price-wrap.table-wrap { overflow-x:auto; background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:none; }
  .company-price-list { min-width:610px; }
  .company-price-list th,.company-price-list td { display:table-cell; width:auto; padding:5px 6px; font-size:.78rem; white-space:nowrap; }
  .company-price-list thead { display:table-header-group; }
  .company-price-list tbody { display:table-row-group; background:#fff; border:0; border-radius:0; margin:0; overflow:visible; box-shadow:none; }
  .company-price-list tr { display:table-row; border-bottom:1px solid var(--line); }
  .company-price-list td { border-bottom:1px solid var(--line); }
  .company-price-list td[data-label]::before { display:none; }
  .company-price-list td:first-child { min-width:140px; max-width:190px; white-space:normal; }
  .company-price-list td.price { font-size:.8rem; }
  .company-price-list .btn { font-size:.74rem; padding:2px 6px; }
  .page-head h2 { font-size:1.05rem; }
}


/* Final refinements requested: small category cards and compact desktop-style table on phones */
.category-tabs { display:grid; grid-template-columns:repeat(auto-fit,minmax(105px,1fr)); gap:7px; overflow:visible; padding:2px 0 10px; margin:0 0 10px; }
.category-tab { min-height:42px; padding:6px 8px; border-radius:9px; font-size:.86rem; box-shadow:0 1px 2px rgba(18,67,42,.05); }
.category-tab span { min-width:19px; height:19px; font-size:.72rem; }
.company-tools { display:flex; align-items:center; gap:8px; margin:4px 0 10px; }
.company-search { flex:1; min-width:0; }
@media(max-width:760px) {
  .category-tabs { grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; padding-bottom:8px; }
  .category-tab { display:flex; gap:4px; min-width:0; min-height:36px; padding:5px 4px; font-size:.76rem; border-radius:8px; }
  .category-tab span { min-width:17px; height:17px; padding:0 3px; font-size:.68rem; }
  .company-tools { display:block; margin:4px 0 9px; }
  .company-search { display:flex; width:100%; gap:5px; }
  .company-search input { min-width:0; min-height:36px; padding:6px 8px; font-size:.84rem; }
  .company-search .btn { padding:4px 8px; font-size:.78rem; }
  .compact-price-wrap.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .company-price-list { min-width:560px; table-layout:fixed; }
  .company-price-list th,.company-price-list td { padding:4px 5px; font-size:.72rem; line-height:1.35; }
  .company-price-list th:nth-child(1) { width:28%; }
  .company-price-list th:nth-child(2) { width:14%; }
  .company-price-list th:nth-child(3) { width:17%; }
  .company-price-list th:nth-child(4) { width:15%; }
  .company-price-list th:nth-child(5) { width:17%; }
  .company-price-list th:nth-child(6) { width:9%; }
  .company-price-list td:first-child { min-width:0; max-width:none; white-space:normal; overflow-wrap:anywhere; }
  .company-price-list td.price { font-size:.73rem; }
  .company-price-list .btn { padding:2px 4px; font-size:.68rem; min-width:0; }
}
@media(max-width:380px) {
  .category-tabs { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .company-price-list { min-width:530px; }
}

/* Fix: company price table header must scroll with products, never cover product names. */
.company-price-list thead th { position: static !important; top: auto !important; z-index: auto !important; }

/* تحسين جمالي للشريط العلوي */
.topbar { background: radial-gradient(circle at 12% 0%, rgba(255,255,255,.13), transparent 28%), linear-gradient(115deg, #0b3320 0%, #145333 48%, #217748 100%); border-bottom: 1px solid rgba(255,255,255,.18); box-shadow: 0 5px 20px rgba(9,45,26,.24); }
.topbar-in { min-height: 74px; padding-top: 8px; padding-bottom: 8px; }
.brand { gap: 12px; font-size: 1.05rem; letter-spacing: .1px; }
.brand-icon { width: 40px; height: 40px; padding: 5px; border-radius: 12px; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.topnav { gap: 7px; }
.topnav > a:not(.btn), .topnav .userbox { padding: 8px 11px; border-radius: 10px; transition: background .18s ease, transform .18s ease; }
.topnav > a:not(.btn):hover { background: rgba(255,255,255,.13); text-decoration: none; transform: translateY(-1px); }
.topnav .bell { background: rgba(255,255,255,.09); }
.topnav .userbox { border-inline-start: 1px solid rgba(255,255,255,.22); border-radius: 0; }
.topnav .btn-outline { border-radius: 10px; background: rgba(255,255,255,.08); }
.lang-toggle { border: 1px solid rgba(255,255,255,.48); color: #fff; background: rgba(255,255,255,.12); border-radius: 10px; padding: 7px 12px; font: inherit; font-weight: 700; cursor: pointer; transition: .18s ease; }
.lang-toggle:hover { background: rgba(255,255,255,.22); transform: translateY(-1px); }
html[dir="ltr"] body { font-family: 'Segoe UI', Arial, sans-serif; }
html[dir="ltr"] .notice-panel { border-right: 1px solid #f4d58a; border-left: 5px solid #f59e0b; }
html[dir="ltr"] .topnav .userbox { border-inline-start: 0; border-inline-end: 1px solid rgba(255,255,255,.22); }
@media (max-width: 760px) {
  .topbar-in { min-height: 64px; }
  .brand { font-size: .93rem; max-width: calc(100% - 52px); }
  .brand-icon { width: 34px; height: 34px; }
  .topnav { background: #12432a; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 10px; box-shadow: 0 10px 24px rgba(0,0,0,.2); }
  .lang-toggle { padding: 5px 10px; }
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
@media (max-width: 760px) { .topbar-actions { margin-inline-start: auto; } }


/* Company cards are arranged from right to left in both interface languages. */
#companies-grid { direction: rtl; }
#companies-grid > .company-card { direction: rtl; }
html[dir="ltr"] #companies-grid > .company-card { direction: ltr; }

/* Product list columns must always flow left-to-right in Arabic and English. */
.company-price-list {
  direction: ltr !important;
}
.company-price-list th,
.company-price-list td {
  direction: ltr;
  text-align: left;
}
.company-price-list .product-name-cell {
  text-align: left;
}


/* Definitive company product list direction/alignment fix for RTL and LTR. */
html[dir="rtl"] .company-products .compact-price-wrap table.company-price-list,
html[dir="ltr"] .company-products .compact-price-wrap table.company-price-list,
.company-products .compact-price-wrap table.company-price-list {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: isolate;
}
.company-products .compact-price-wrap table.company-price-list thead,
.company-products .compact-price-wrap table.company-price-list tbody,
.company-products .compact-price-wrap table.company-price-list tr {
  direction: ltr !important;
}
.company-products .compact-price-wrap table.company-price-list th,
.company-products .compact-price-wrap table.company-price-list td,
.company-products .compact-price-wrap table.company-price-list td.product-name-cell,
.company-products .compact-price-wrap table.company-price-list td.price {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: plaintext;
}
.company-products .compact-price-wrap table.company-price-list td.product-name-cell {
  text-align: left !important;
}


/* User-requested final direction: company product table flows right-to-left in all languages. */
.company-products .compact-price-wrap table.company-price-list {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: isolate;
}
.company-products .compact-price-wrap table.company-price-list thead,
.company-products .compact-price-wrap table.company-price-list tbody,
.company-products .compact-price-wrap table.company-price-list tr {
  direction: rtl !important;
}
.company-products .compact-price-wrap table.company-price-list th,
.company-products .compact-price-wrap table.company-price-list td,
.company-products .compact-price-wrap table.company-price-list td.product-name-cell,
.company-products .compact-price-wrap table.company-price-list td.price {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}


/* All products view: category headings appear inline before each category's products. */
.category-tab-all { border-color: var(--g700); }
.category-tab-all:not(.active) { background: #f0f8f3; color: var(--g900); }
.company-price-list .product-category-divider th { background: #e5f3e9; color: var(--g900); text-align: start; font-weight: 800; padding: 7px 9px; border-top: 2px solid var(--g500); border-bottom: 1px solid var(--line); }
@media(max-width:760px) { .company-price-list .product-category-divider th { padding: 6px 7px; font-size: .76rem; } }


/* User-selectable dark mode. Theme is controlled by html[data-theme] and saved per browser. */
.theme-toggle { border: 1px solid rgba(255,255,255,.48); color: #fff; background: rgba(255,255,255,.12); border-radius: 10px; min-width: 40px; min-height: 38px; padding: 5px 10px; font-size: 1.1rem; cursor: pointer; transition: background .18s ease, transform .18s ease; }
.theme-toggle:hover { background: rgba(255,255,255,.22); transform: translateY(-1px); }
html[data-theme="dark"] { color-scheme: dark; --g900:#d8f3e2; --g700:#79d6a0; --g600:#4dbb7b; --g100:#20392d; --g50:#1b2a22; --amber:#f6c453; --amber-bg:#493b1e; --red:#ff8c85; --red-bg:#482625; --blue:#8abaff; --blue-bg:#1e344e; --ink:#e8eee9; --muted:#b0beb5; --line:#35483d; --bg:#111a15; --card:#1a261f; --shadow:0 1px 3px rgba(0,0,0,.28), 0 6px 18px rgba(0,0,0,.18); }
html[data-theme="dark"] body { background:var(--bg); color:var(--ink); }
html[data-theme="dark"] a { color:#8fe0ad; }
html[data-theme="dark"] .card, html[data-theme="dark"] .product-sidebar, html[data-theme="dark"] .table-wrap, html[data-theme="dark"] .category-tab, html[data-theme="dark"] .notice-panel, html[data-theme="dark"] .empty, html[data-theme="dark"] .stat-card, html[data-theme="dark"] .form-card, html[data-theme="dark"] .modal, html[data-theme="dark"] .searchbar, html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background-color:var(--card); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color:#91a198; }
html[data-theme="dark"] th, html[data-theme="dark"] thead th { background:#24372b; color:#d8f3e2; border-color:var(--line); }
html[data-theme="dark"] td, html[data-theme="dark"] th { border-color:var(--line); }
html[data-theme="dark"] .category-tab span { background:#2c4033; color:#d0ded5; }
html[data-theme="dark"] .category-tab-all:not(.active) { background:#20392d; color:#d8f3e2; }
html[data-theme="dark"] .company-price-list .product-category-divider th { background:#263d2f; color:#d8f3e2; }
html[data-theme="dark"] .row-new td { background:#20392d; } html[data-theme="dark"] .row-upd td { background:#493b1e; } html[data-theme="dark"] .row-err td { background:#482625; }
html[data-theme="dark"] .subnav { background:#18231c; border-color:var(--line); } html[data-theme="dark"] .subnav a { color:var(--ink); } html[data-theme="dark"] .subnav a.active { background:#294936; color:#e8fff0; }
html[data-theme="dark"] .footer { color:#9caca4; border-color:var(--line); } html[data-theme="dark"] .logo { background:#f8faf8; }
html[data-theme="dark"] .hero, html[data-theme="dark"] .company-main-title { color:var(--ink); }
html[data-theme="dark"] .alert-info { background:#1e344e; color:#d5e7ff; border-color:#365b80; } html[data-theme="dark"] .alert-success { background:#20392d; color:#d8f3e2; border-color:#35684a; } html[data-theme="dark"] .alert-warning { background:#493b1e; color:#ffedbd; border-color:#75602c; } html[data-theme="dark"] .alert-danger { background:#482625; color:#ffd6d3; border-color:#7b3935; }
@media (max-width:760px) { html[data-theme="dark"] .topnav { background:#182b20; border-color:#35483d; } .theme-toggle { min-width:36px; min-height:34px; padding:4px 8px; } }


/* Explicit visual column order: product name is the rightmost/first column in every language.
   The PHP markup reverses the cell sequence so this remains consistent in all browsers. */
.company-products .compact-price-wrap table.company-price-list { direction:ltr !important; text-align:right !important; }
.company-products .compact-price-wrap table.company-price-list thead,
.company-products .compact-price-wrap table.company-price-list tbody,
.company-products .compact-price-wrap table.company-price-list tr { direction:ltr !important; }
.company-products .compact-price-wrap table.company-price-list th,
.company-products .compact-price-wrap table.company-price-list td { direction:rtl !important; text-align:right !important; }
.company-products .compact-price-wrap table.company-price-list td.product-name-cell { text-align:right !important; }
