/* مَراح — المكوّنات فوق رموز الهوية (assets/tokens.css) */

body { direction: rtl; }
/* مقاس افتراضي لكل أيقونة حتى لا تتمدد أي أيقونة بلا قاعدة خاصة (القواعد اللاحقة تتغلب عليه) */
svg[viewBox="0 0 24 24"] { width: 20px; height: 20px; flex: 0 0 auto; }
a { color: var(--g2); }

/* ---------- الشريط العلوي والتنقل ---------- */
.topbar { background: var(--deep); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .wrap { display: flex; align-items: center; gap: 14px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.brand svg { width: 38px; height: 38px; }
.brand b { font-family: var(--disp); font-size: 26px; line-height: 1; }
.brand small { display: block; font-size: 12px; opacity: .75; margin-top: 3px; }
.topbar .farm { margin-inline-start: auto; font-size: 13.5px; opacity: .85; text-align: left; }

.nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 62px; z-index: 19; }
.nav .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav .wrap::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 7px; padding: 13px 14px; color: var(--ink-2);
  text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a svg { width: 18px; height: 18px; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--g2); border-bottom-color: var(--g2); }

main { padding: 22px 0 60px; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h h1 { font-size: 21px; }
.page-h p { margin: 2px 0 0; color: var(--ink-3); font-size: 14px; }

/* ---------- بطاقات ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); padding: 20px 22px; }
.card.pad-0 { padding: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h3 { font-size: 16.5px; display: flex; align-items: center; gap: 9px; }
.card-h h3 svg { width: 19px; height: 19px; color: var(--g2); }
.card-b { padding: 18px 20px; }
.gap { display: grid; gap: 18px; }

/* ---------- الأزرار ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); border-radius: 11px; padding: 9px 17px; font: inherit; font-weight: 600;
  font-size: 14.5px; cursor: pointer; transition: .16s; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #b9cdda; background: var(--tint); }
.btn:active { transform: translateY(1px); }
.btn.p { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(46,127,184,.28); }
.btn.p:hover { filter: brightness(1.06); background: var(--grad); }
.btn.d { color: var(--dan); border-color: #f0cccc; }
.btn.d:hover { background: var(--dan-bg); }
.btn.g { color: var(--ok); border-color: #bfe3d1; }
.btn.g:hover { background: var(--ok-bg); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; border-radius: 9px; }
.btn svg { width: 17px; height: 17px; }
.btn.sm svg { width: 15px; height: 15px; }

/* ---------- رقائق ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12.5px;
  font-weight: 600; background: var(--tint); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: #bfe3d1; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: #edd9b0; }
.chip.dan  { background: var(--dan-bg);  color: var(--dan);  border-color: #f0cccc; }
.chip.info { background: var(--info-bg); color: var(--info); border-color: #c6ddef; }
.dotc { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ---------- الحقول ---------- */
label.f { display: block; }
label.f > span { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid var(--line-2);
  border-radius: 11px; padding: 9px 12px; transition: .15s; }
textarea { min-height: 80px; resize: vertical; line-height: 1.8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g2); box-shadow: 0 0 0 3.5px rgba(46,127,184,.14); }
input[type=number] { direction: ltr; text-align: right; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237e91a3' stroke-width='2.2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 16px; padding-inline-end: 36px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters > * { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 220px; flex: 1; }

/* ---------- الجداول ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.2px; }
table.tbl th, table.tbl td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
table.tbl thead th { background: var(--tint); font-weight: 600; color: var(--ink-2); font-size: 13.2px; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.tbl tbody tr:hover { background: #f8fbfd; }
table.tbl td.num, table.tbl th.num { text-align: center; }
table.tbl tfoot td { font-weight: 700; background: var(--tint); }
tr.click { cursor: pointer; }
.empty { padding: 34px 20px; text-align: center; color: var(--ink-3); }

/* ---------- الإحصاءات ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh-1); overflow: hidden; }
.stat::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--grad); }
.stat .k { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.stat .v { font-size: 28px; font-weight: 700; line-height: 1.3; }
.stat .s { font-size: 12.5px; color: var(--ink-2); }

.bar { height: 9px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.bar.over > i { background: var(--dan); }
.bar.high > i { background: var(--gold); }

/* ---------- التنبيهات ---------- */
.alerts { display: grid; gap: 9px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--tint); }
.alert svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 3px; }
.alert b { display: block; font-size: 14.5px; }
.alert span { font-size: 13.5px; color: var(--ink-2); }
.alert.dan { background: var(--dan-bg); border-color: #f0cccc; } .alert.dan svg { color: var(--dan); }
.alert.warn { background: var(--warn-bg); border-color: #edd9b0; } .alert.warn svg { color: var(--warn); }
.alert.info { background: var(--info-bg); border-color: #c6ddef; } .alert.info svg { color: var(--info); }
.alert.ok { background: var(--ok-bg); border-color: #bfe3d1; } .alert.ok svg { color: var(--ok); }
.alert .act { margin-inline-start: auto; }

/* ---------- الحظائر ---------- */
.barns { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.barn { background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: .16s; }
.barn:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.barn-top { padding: 14px 16px 12px; border-top: 5px solid var(--bc, var(--g2)); }
.barn-top h4 { font-size: 16.5px; }
.barn-top .t { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.pen { display: flex; flex-wrap: wrap; gap: 3px; padding: 10px 16px; background: var(--tint); border-block: 1px solid var(--line); min-height: 44px; align-content: flex-start; }
.pen i { width: 11px; height: 11px; border-radius: 4px; background: var(--bc, var(--g2)); opacity: .85; }
.pen i.l { width: 7px; height: 7px; border-radius: 50%; opacity: .55; align-self: center; }
.pen i.free { background: transparent; border: 1px dashed #c3d3df; opacity: 1; }
.barn-b { padding: 12px 16px 14px; display: grid; gap: 8px; font-size: 13.5px; }
.kv { display: flex; justify-content: space-between; gap: 8px; }
.kv span { color: var(--ink-3); }

/* ---------- الملف والتبويبات ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--g2); border-bottom-color: var(--g2); }
.profile-h { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar { width: 74px; height: 74px; border-radius: 20px; background: var(--tint); border: 1px solid var(--line); display: grid; place-items: center; }
.avatar svg { width: 52px; height: 52px; }
.tagno { font-size: 26px; font-weight: 700; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.fact { background: var(--tint); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; }
.fact span { display: block; font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.fact b { font-size: 15.5px; }

/* ---------- خط زمني ---------- */
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 96px 16px 1fr; gap: 10px; padding: 7px 0; font-size: 14px; }
.tl .d { color: var(--ink-3); font-size: 13px; text-align: left; }
.tl .p { position: relative; }
.tl .p::before { content: ''; position: absolute; inset-inline-start: 7px; top: -7px; bottom: -7px; width: 2px; background: var(--line); }
.tl .p::after { content: ''; position: absolute; inset-inline-start: 3px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--g2)); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }

/* ---------- نافذة ---------- */
.modal { position: fixed; inset: 0; background: rgba(3,59,69,.45); z-index: 50; display: grid; place-items: center; padding: 18px; animation: fade .15s; }
.modal-box { background: #fff; border-radius: var(--r-l); box-shadow: var(--sh-3); width: min(720px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal-box.lg { width: min(980px, 100%); }
.modal-h { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-h h3 { font-size: 17.5px; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; }
.x { background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 4px; }
.x svg { width: 22px; height: 22px; }
@keyframes fade { from { opacity: 0 } }

.toast { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); background: var(--deep); color: #fff; padding: 11px 20px; border-radius: 12px; box-shadow: var(--sh-3); z-index: 60; font-weight: 600; animation: fade .2s; }

/* ---------- اختيارات متعددة ---------- */
.picks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 12px; }
.pick { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 9px; padding: 5px 10px; font-size: 13.5px; cursor: pointer; user-select: none; background: #fff; }
.pick input { margin: 0; }
.pick.on { border-color: var(--g2); background: #eef6fc; color: #14486b; font-weight: 600; }

/* ---------- المخطط ومخطط الموقع ---------- */
.plan svg text { font-family: var(--ui); }
.guide h3 { font-size: 17px; margin-bottom: 8px; }
.guide p, .guide li { font-size: 14.5px; line-height: 1.9; }
.guide ul, .guide ol { padding-inline-start: 22px; margin: 6px 0; }
details.g { border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--sh-1); }
details.g summary { padding: 15px 20px; font-weight: 700; font-size: 16px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details.g summary svg { width: 20px; height: 20px; color: var(--g2); }
details.g summary::-webkit-details-marker { display: none; }
details.g summary::after { content: '+'; margin-inline-start: auto; color: var(--ink-3); font-size: 20px; }
details.g[open] summary::after { content: '−'; }
details.g .gb { padding: 0 22px 16px; }

.cols-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 960px) { .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .topbar .farm { display: none; }
  .card { padding: 16px; }
  .page-h h1 { font-size: 19px; }
  .stat .v { font-size: 24px; }
}

@media print {
  .nav { display: none !important; }
  table.tbl thead th { position: static; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chip, .bar > i, .stat::before, .pen i, .barn-top { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-h { display: block !important; margin-bottom: 10px; border-bottom: 2px solid var(--deep); padding-bottom: 6px; }
}
.print-h { display: none; }
