/* نظام المزرعة: تصميم عربي من اليمين لليسار، يعمل على الهاتف والكمبيوتر */
:root {
  --bg: #f5f3ec;
  --surface: #ffffff;
  --surface-2: #efece2;
  --ink: #1e2a20;
  --muted: #69736a;
  --line: #e1dccd;
  --brand: #2f6b3a;
  --brand-ink: #ffffff;
  --brand-soft: #e2eee0;
  --accent: #b7791f;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --have: #2f6b3a; --have-bg: #e2eee0;
  --want: #8a5a00; --want-bg: #fbefd5;
  --trial: #275d8a; --trial-bg: #e0ecf6;
  --out: #6b6b6b; --out-bg: #ececec;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(30 42 32 / 6%), 0 4px 14px rgb(30 42 32 / 5%);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a15; --surface: #1c241d; --surface-2: #232d24; --ink: #e7ece4; --muted: #9aa69b; --line: #314033;
    --brand: #6fb07a; --brand-ink: #0f1a11; --brand-soft: #22382a; --accent: #e0a64a; --danger: #ef8a80; --danger-soft: #3a1f1d;
    --have: #8fd19a; --have-bg: #22382a; --want: #f0c46a; --want-bg: #3a3020; --trial: #8cc0ef; --trial-bg: #1f3040; --out: #b0b0b0; --out-bg: #2c2c2c;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.65; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .3em 0 .5em; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1.02rem; margin: 1em 0 .4em; }
p { margin: .4em 0 .8em; }
img, video { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); background: var(--danger-soft); padding: .6em .9em; border-radius: 10px; }
.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; flex: none; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
main.wide { max-width: 1500px; }

/* الشريط العلوي */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand img { width: 32px; height: 32px; }
.search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 0 12px; }
.search input { border: 0; background: transparent; padding: 8px 0; width: 100%; font: inherit; color: inherit; outline: none; }
.mainnav { display: flex; gap: 4px; }
.mainnav a, .me { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 10px; color: var(--ink); white-space: nowrap; }
.mainnav a:hover, .me:hover { background: var(--surface-2); text-decoration: none; }
.mainnav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.me { margin-inline-start: auto; color: var(--muted); }
.tabbar { display: none; }

@media (max-width: 860px) {
  .mainnav, .me span { display: none; }
  .brand span { display: none; }
  .search { max-width: none; }
  .me { margin: 0; padding: 7px; }
  .tabbar { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; font-size: .72rem; color: var(--muted); }
  .tabbar a .ic { width: 1.45em; height: 1.45em; }
  .tabbar a.on { color: var(--brand); font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }
  h1 { font-size: 1.3rem; }
}

/* عناصر عامة */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: .4em; }
.card-head h2, .card-head h3 { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; min-height: 40px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
form.inline { display: inline; margin: 0; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--danger); }

input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; min-height: 40px; }
textarea { resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; min-height: 0; }
label.check.big { font-weight: 600; align-self: end; padding-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 520px; }
.row2, .row3 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { grid-template-columns: repeat(3, 1fr); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
@media (max-width: 600px) { .row2, .row3 { grid-template-columns: 1fr; } }
.num { width: 80px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: .84rem; border: 1px solid transparent; white-space: nowrap; }
.chip.link:hover { border-color: var(--brand); text-decoration: none; }
.chip.chosen { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.chip.pr { background: #f6ead2; color: #7a5200; }
.chip.st-have { background: var(--have-bg); color: var(--have); }
.chip.st-want { background: var(--want-bg); color: var(--want); }
.chip.st-trial { background: var(--trial-bg); color: var(--trial); }
.chip.st-out { background: var(--out-bg); color: var(--out); }
.chips, .chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
button.chip { cursor: pointer; font: inherit; font-size: .84rem; }
button.chip.on { background: var(--brand); color: var(--brand-ink); }
.star { color: var(--accent); }

.toast { position: fixed; top: 70px; inset-inline-start: 50%; transform: translateX(50%); background: var(--ink); color: var(--bg); padding: 8px 18px; border-radius: 999px; z-index: 50; animation: toast 3s forwards; box-shadow: var(--shadow); }
@keyframes toast { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; border: 1.5px dashed var(--line); border-radius: var(--radius); margin: 8px 0 14px; }
.empty p { margin: 0; }
.crumbs { font-size: .86rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.crumbs .sep { opacity: .6; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-inline-end: auto; }
.page-head .actions { margin: 0; }
.h-sec { margin: 22px 0 10px; font-size: 1.1rem; }
.h-cat { margin: 22px 0 10px; font-size: 1.02rem; display: flex; gap: 8px; align-items: baseline; }

/* الرئيسية */
.hello h1 { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat b { font-size: 1.6rem; line-height: 1.2; color: var(--brand); }
.stat span { font-size: .85rem; color: var(--muted); }
.stat:hover { text-decoration: none; border-color: var(--brand); }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.sec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.sec-grid.big { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.sec-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.sec-card:hover { border-color: var(--brand); text-decoration: none; }
.sec-card .muted { font-size: .85rem; }
.sec-card .count { font-size: .85rem; color: var(--brand); margin-top: 4px; font-weight: 600; }
.sec-ic { font-size: 1.6rem; line-height: 1.2; }
h1 .sec-ic { font-size: 1.3em; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.activity { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.activity li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* فهرس القسم */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { flex: 2 1 200px; }
.filters select { flex: 1 1 150px; width: auto; }
.filters .btn { flex: none; }
.list-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 6px 0; }
.letters { display: flex; flex-wrap: wrap; gap: 3px; }
.letters a { min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: .88rem; padding: 0 6px; }
.letters a.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.letters a:hover { text-decoration: none; border-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg a { padding: 5px 12px; color: var(--ink); font-size: .9rem; }
.seg a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
@media (max-width: 480px) { .item-grid { grid-template-columns: 1fr 1fr; gap: 8px; } }
.item-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.item-card:hover { border-color: var(--brand); text-decoration: none; }
.ic-cover { aspect-ratio: 16 / 10; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; }
.ic-cover img { width: 100%; height: 100%; object-fit: cover; }
.ic-body { padding: 9px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.ic-body strong { font-size: 1rem; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; background: var(--surface); }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: start; vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
table.data td { min-width: 110px; }
table.data.compact td { min-width: 0; }
table.data tr.inactive { opacity: .55; }
details.intro summary { cursor: pointer; font-weight: 600; }

/* صفحة الصنف */
.item-hero { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; margin: 6px 0 16px; }
.hero-cover { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 4rem; border: 1px solid var(--line); }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.hero-text h1 { margin: 0; }
.latin { margin: 0; color: var(--muted); font-style: italic; direction: ltr; unicode-bidi: plaintext; text-align: right; }
html[dir="ltr"] .latin { text-align: left; }
.summary { margin-top: 10px; }
@media (max-width: 640px) { .item-hero { grid-template-columns: 1fr; } .hero-cover { aspect-ratio: 16 / 9; } }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; position: sticky; top: 57px; background: var(--bg); z-index: 10; scrollbar-width: thin; }
.tabs a { padding: 9px 13px; white-space: nowrap; color: var(--muted); border-bottom: 2.5px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.empty-tab { opacity: .6; }
.js .panel { display: none; }
.js .panel.on { display: block; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 18px; margin: 0; }
.facts.one { grid-template-columns: 1fr; }
.facts div { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.prose { overflow-wrap: anywhere; }
.prose h3 { color: var(--brand); }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: .4em 0 .9em; }
.prose li { margin: .2em 0; }
.prose blockquote { margin: .5em 0 1em; padding: .5em .9em; border-inline-start: 3px solid var(--accent); background: var(--surface-2); border-radius: 6px; color: var(--muted); font-size: .9rem; }
.row-form { display: flex; gap: 8px; margin-top: 12px; }
.row-form select { flex: 1; }
.link-wrap { padding-inline-end: 4px; }

/* الوسائط */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 10px 0; }
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; }
.gallery figcaption { font-size: .84rem; padding: 4px 2px; overflow-wrap: anywhere; }
.thumb { position: relative; display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; inset: auto auto 8px 8px; background: rgb(0 0 0 / 60%); color: #fff; border-radius: 999px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: .8rem; }
.filebox { height: 100%; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; padding: 8px; color: var(--muted); font-size: .8rem; text-align: center; overflow-wrap: anywhere; }
.filebox .ic { width: 2em; height: 2em; }
.filebox.big { min-height: 240px; background: var(--surface-2); border-radius: var(--radius); }
.media-view { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.viewer img, .viewer video { width: 100%; max-height: 78vh; object-fit: contain; background: #000; border-radius: var(--radius); display: block; }
.viewer audio { width: 100%; margin-top: 20px; }
@media (max-width: 860px) { .media-view { grid-template-columns: 1fr; } }
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.rec.recording { background: var(--danger); color: #fff; border-color: var(--danger); }
.picked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.picked li { display: flex; gap: 8px; align-items: center; background: var(--surface-2); padding: 4px 10px; border-radius: 8px; }
.picked li img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; }
.picked li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { position: relative; height: 26px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress div { position: absolute; inset: 0 0 0 auto; width: 0; background: var(--brand); transition: width .2s; }
.progress span { position: relative; display: block; text-align: center; font-size: .82rem; line-height: 26px; font-weight: 600; mix-blend-mode: difference; color: #fff; }
.tag-filter { margin: 4px 0 8px; }
.edit-box { margin: 10px 0; }
.edit-box summary { cursor: pointer; color: var(--brand); }

/* السجل */
.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.timeline li { position: relative; padding: 2px 16px 14px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline .prose { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }
.timeline .prose p:last-child { margin-bottom: 0; }

/* الموردون */
.sup-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.sup-list .card { margin: 0; }
.sup p { margin: .2em 0; }

/* الإعدادات */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 14px; }
.link-card { display: flex; flex-direction: column; gap: 4px; color: var(--ink); margin: 0; }
.link-card .ic { width: 1.6em; height: 1.6em; color: var(--brand); }
.link-card:hover { border-color: var(--brand); text-decoration: none; }
.roles-help { margin: 0; padding-inline-start: 1.2em; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }
.stack.mini { min-width: 240px; margin-top: 8px; }
.result-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.result-list li { padding: 9px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.result-list li:last-child { border-bottom: 0; }
.danger-zone { margin-top: 30px; color: var(--muted); }
.danger-zone summary { cursor: pointer; font-size: .9rem; }
.danger-zone form { margin-top: 10px; }
.hint { font-size: .9rem; color: var(--muted); }
.hint summary { cursor: pointer; }
.hint code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; direction: rtl; }
.article-editor { min-height: 50vh; font-size: 1rem; }
.sticky-save { position: sticky; bottom: 70px; display: flex; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
@media (min-width: 861px) { .sticky-save { bottom: 12px; } }
.pager { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin: 16px 0; }
.pager a { padding: 4px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); }
.pager a.on { background: var(--brand); color: var(--brand-ink); }

/* صفحات الدخول */
.auth-card { max-width: 420px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow); }
.auth-logo { text-align: center; }
.auth-logo img { width: 64px; height: 64px; }
.auth-card h1 { text-align: center; }

/* أصناف بلا صور بعد: عنصر نائب أصغر */
.ic-cover.noimg { aspect-ratio: 16 / 7; font-size: 1.8rem; }
@media (max-width: 640px) {
  .item-hero:has(.noimg) { grid-template-columns: 76px 1fr; gap: 12px; }
  .hero-cover.noimg { aspect-ratio: 1; font-size: 2.2rem; }
  .item-hero:has(.noimg) .actions { grid-column: 1 / -1; }
}

/* جداول داخل المحتوى */
.prose .table-wrap { margin: .4em 0 1em; }
.prose table.data.md td, .prose table.data.md th { min-width: 0; }

/* المصاريف */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bars li { display: grid; grid-template-columns: minmax(110px, 1.2fr) 2fr auto auto; gap: 10px; align-items: center; font-size: .9rem; }
.bars .bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bars .bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bars b { white-space: nowrap; }
@media (max-width: 600px) { .bars li { grid-template-columns: 1fr auto; } .bars .bar { grid-column: 1 / -1; order: 3; } .bars small { display: none; } }
.num-cell { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
table.data tfoot th { background: var(--surface-2); }
.big-amount { font-size: 2rem; font-weight: 700; color: var(--brand); margin: 0 0 .4em; font-variant-numeric: tabular-nums; }
.inline-label { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.inline-label input { width: auto; }
.stat b { font-variant-numeric: tabular-nums; }

/* الخصوصية */
.privacy-list { display: grid; gap: .25rem; }
.privacy-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line, #e5e5e5); }
.privacy-row:last-child { border-bottom: 0; }
.privacy-row > div { display: grid; gap: .15rem; }
.privacy-row select { width: auto; min-width: 11rem; }
@media (max-width: 600px) { .privacy-row { flex-direction: column; align-items: stretch; } .privacy-row select { width: 100%; } }

/* القائمة العلوية: أيقونات فقط في الشاشات المتوسطة */
@media (min-width: 861px) and (max-width: 1320px) {
  .mainnav a span { display: none; }
  .mainnav a.on span { display: inline; }
}

/* المهام */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg a { padding: 6px 14px; border-radius: 9px; color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; }
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .inline { margin: 0; }
.tick { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--brand); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin-top: 1px; color: var(--brand); }
.tick:hover::after, .tick.done::after { content: '✓'; font-weight: 700; }
.tick:hover { background: var(--brand-soft); }
.tick.done { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); cursor: default; }
.tick.off { border-color: var(--line); cursor: default; }
.task.urgent .tick { border-color: var(--danger); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; color: var(--ink); }
.task.closed .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .84rem; color: var(--muted); margin-top: 3px; align-items: center; }
.task-meta a { color: var(--muted); }
.task-meta .ic { width: 1em; height: 1em; vertical-align: -2px; }
.due { font-weight: 600; color: var(--brand); }
.due.late { color: var(--danger); }
.task-group h2 { font-size: 1.05rem; margin: 0 0 4px; }
.task-group.late { border-color: var(--danger); }
.task-group.late h2 { color: var(--danger); }
.task-actions .actions { margin-top: 8px; }
.chip.urgent { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.stat.warn b { color: var(--danger); }
.my-tasks { margin-top: 12px; }
.my-tasks h2 { display: flex; align-items: center; gap: 6px; font-size: 1.1rem; margin: 0; }
.my-tasks h2 .ic { color: var(--brand); }
.warn-line { margin: 8px 0 0; color: var(--danger); }

/* الوحدات */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 12px; }
.unit-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: var(--ink); margin: 0; }
.unit-card:hover { border-color: var(--brand); text-decoration: none; }
.unit-cover { aspect-ratio: 16 / 9; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.unit-cover.noimg { aspect-ratio: 16 / 6; font-size: 2.4rem; }
.unit-cover img { width: 100%; height: 100%; object-fit: cover; }
.unit-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; }
.unit-items { list-style: none; padding: 0; margin: 0 0 8px; }
.unit-items li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.unit-items li:last-child { border-bottom: 0; }
.unit-items li form { margin-inline-start: auto; }
.unit-items.past li { font-size: .92rem; }

/* صفحة المزيد */
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.more-grid .link-card { align-items: center; text-align: center; padding: 18px 10px; }

[hidden] { display: none !important; }

/* الإنتاج */
.prod-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.prod-tile { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); }
.prod-tile:hover { text-decoration: none; outline: 2px solid var(--brand); }
.prod-tile b { font-size: 1.5rem; color: var(--brand); line-height: 1.2; }
.prod-tile small { color: var(--muted); }
.seg-radio { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg-radio label { display: block; margin: 0; cursor: pointer; position: relative; }
.seg-radio input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.seg-radio span { display: block; padding: 7px 14px; border-radius: 9px; }
.seg-radio input:checked + span { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--brand); }
.big-input { font-size: 1.3rem; font-weight: 600; }
.loss, .loss-row td { color: var(--danger); }

/* المبيعات */
.lines-table td { vertical-align: top; }
.lines-table select, .lines-table input { min-width: 0; max-width: 100%; }
.lines-table .line-price { width: 100%; }
.lines-table .line-qty, .lines-table .line-unit { width: 6.5em; }
.lines-table .line-desc { margin-top: 6px; }
.add-line { margin: 8px 0 14px; }
.totals-inputs { align-items: end; }
.grand { display: flex; flex-direction: column; align-items: flex-end; padding: 8px 12px; background: var(--brand-soft); border-radius: 12px; }
.grand b { font-size: 1.4rem; color: var(--brand); }
.muted-row td { color: var(--muted); text-decoration: line-through; }
.steps { display: flex; list-style: none; padding: 0; margin: 0 0 10px; gap: 4px; flex-wrap: wrap; counter-reset: st; }
.steps li { flex: 1; min-width: 80px; text-align: center; padding: 6px 4px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: .85rem; }
.steps li.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.deliv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.deliv { margin: 0; }
.deliv.late { border-color: var(--danger); }
.deliv h2 { font-size: 1.1rem; margin: 0; }
.deliv-lines { margin: 6px 0; padding-inline-start: 1.2em; }
.deliv-due { font-size: 1.05rem; }
.deliv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.deliver-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0; }
.deliver-form input { width: 7em; }
@media (max-width: 600px) {
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody { display: block; width: 100%; min-width: 0; }
  .sale-form .table-wrap { overflow: visible; }
  .lines-table tr.sale-line { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .lines-table tr.sale-line td { border: 0; padding: 0; }
  .lines-table tr.sale-line td:first-child { grid-column: 1 / -1; }
  .lines-table .line-qty, .lines-table .line-unit { width: 100%; }
  .lines-table .line-total { align-self: center; font-weight: 600; }
  .lines-table td:last-child { text-align: end; }
  .lines-table input { width: 100%; box-sizing: border-box; }
}

/* التقارير */
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat.good b, .gain { color: var(--brand); }
.stat.warn b, .loss { color: var(--danger); }
.bar span.warn { background: var(--danger); }
.mchart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 8px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.mcol { flex: 1; min-width: 30px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.mbars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.mbar { width: 42%; max-width: 22px; min-height: 2px; border-radius: 4px 4px 0 0; }
.mbar.s, .legend i.s { background: var(--brand); }
.mbar.e, .legend i.e { background: var(--accent, #d39b3a); }
.mcol small { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin: 8px 0 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
main.wide .two-col { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
@media (max-width: 600px) { main.wide .two-col { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* اختيار متعدد على شكل شرائح (أنواع المورد) */
.kind-pick { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
.kind-pick legend { padding: 0 6px; font-weight: 600; }
.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chips label { position: relative; margin: 0; cursor: pointer; display: block; }
.check-chips input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.check-chips span { display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.check-chips input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink, #fff); font-weight: 600; }
.check-chips input:checked + span::before { content: '✓ '; }
.check-chips input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.card-head .chip + .chip { margin-inline-start: 4px; }

/* اختيار اللغة */
.lang-switch { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.lang-switch:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.lang-float { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.lang-pick { display: inline-flex; gap: 6px; margin-top: 6px; }
.lang-pick a { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.lang-pick a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink, #fff); font-weight: 600; }
.lang-pick a:hover { text-decoration: none; border-color: var(--brand); }

/* مراجعة الترجمات */
.tr-list { display: grid; gap: 10px; }
.tr-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: start; margin: 0; }
.tr-src { padding: 8px 0; text-align: right; }
.tr-row textarea { width: 100%; text-align: left; }
.tr-meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
@media (max-width: 700px) { .tr-row { grid-template-columns: 1fr; } .tr-meta { flex-direction: row; justify-content: space-between; } }
.notice { background: var(--want-bg); color: var(--want); padding: 8px 12px; border-radius: 10px; }

/* محرر المقال بلغتين */
.bi-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.bi-ref { max-height: 75vh; overflow: auto; text-align: right; }
.bi-ref h2, .bi-form h2 { font-size: 1rem; margin: 0 0 8px; color: var(--muted); }
.bi-form textarea { text-align: left; }
@media (max-width: 900px) { .bi-editor { grid-template-columns: 1fr; } .bi-ref { max-height: 40vh; } }

/* متجر العملاء */
.shop-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.shop-head img { width: 56px; height: 56px; }
.shop-head h1 { margin: 0; }
.shop-head p { margin: 2px 0 0; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.product { padding: 0; overflow: hidden; margin: 0; display: flex; flex-direction: column; transition: border-color .15s; }
.product.picked-product { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.product-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.product-body h2 { font-size: 1.05rem; margin: 0; }
.product-body p { margin: 0; }
.product-price { margin-top: 4px !important; color: var(--brand); }
.qty { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; }
.qty input { width: 64px; text-align: center; font-weight: 600; }
.qty-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.2rem; cursor: pointer; color: var(--ink); }
.qty-btn:hover { border-color: var(--brand); }
.shop-checkout { position: sticky; bottom: 12px; }
.shop-total { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--brand-soft); border-radius: 12px; }
.shop-total b { font-size: 1.4rem; color: var(--brand); }
.btn.big { font-size: 1.1rem; padding: 12px 18px; }
.hp { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
.notice-ok { border-color: var(--brand); background: var(--brand-soft); }
.notice-ok h2 { margin-top: 0; color: var(--brand); }
.shop-alert { display: block; margin-top: 12px; border-color: var(--danger); color: var(--ink); font-size: 1.05rem; }
.shop-alert:hover { text-decoration: none; background: var(--danger-soft); }
.shop-closed img { margin-bottom: 8px; }
@media (max-width: 600px) { .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } .qty-btn { width: 32px; height: 34px; } .qty input { width: 48px; } .shop-checkout { position: static; } }
.shop-email { text-align: center; margin-top: 18px; }

/* ───── التنبيهات ───── */
.alert-bar { background: #b3261e; color: #fff; border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.alert-row + .alert-row { border-top: 1px solid rgba(255,255,255,.25); padding-top: 8px; }
.alert-text { flex: 1 1 260px; min-width: 0; }
.alert-when { opacity: .9; font-size: .88rem; white-space: nowrap; }
.alert-reason { font-size: .9rem; opacity: .95; margin-top: 2px; overflow-wrap: anywhere; }
.alert-more { color: #fff; font-weight: 600; text-decoration: underline; font-size: .9rem; }
.rem-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rem-actions form.inline { display: inline; margin: 0; }
.btn.on-red { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.55); }
.btn.on-red:hover { background: rgba(255,255,255,.28); text-decoration: none; }
.btn.on-red .ic { stroke: #fff; }
.rem-snooze { position: relative; }
.rem-snooze > summary { list-style: none; cursor: pointer; }
.rem-snooze > summary::-webkit-details-marker { display: none; }
.rem-pop { position: absolute; z-index: 30; top: calc(100% + 6px); inset-inline-start: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: var(--shadow); width: max-content; max-width: min(300px, 86vw); display: flex; flex-direction: column; gap: 8px; }
.rem-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.rem-date { display: flex; gap: 6px; align-items: flex-end; }
.rem-date label { flex: 1; font-size: .85rem; }
.rems { list-style: none; margin: 0; padding: 0; }
.rem { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rem:last-child { border-bottom: 0; }
.rem-main { flex: 1 1 260px; min-width: 0; }
.rem-reason { color: var(--muted); font-size: .92rem; margin-top: 2px; overflow-wrap: anywhere; }
.rem.hot .rem-title b { color: var(--danger); }
.rem.closed { opacity: .75; }
.auto-rules { list-style: none; margin: 0; padding: 0; }
.auto-rules li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.auto-rules li:last-child { border-bottom: 0; }
.auto-rules p { margin: 2px 0 6px; }
.auto-rules .check { display: flex; gap: 8px; align-items: center; }
.auto-rules .check input { width: auto; }
.inline-num { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.inline-num input { width: 90px; }
.inline-edit { display: inline-block; position: relative; }
.inline-edit > summary { list-style: none; cursor: pointer; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] form { margin-top: 6px; }
