:root { --bg:#f3f5f2; --card:#fff; --ink:#1d2a22; --mut:#667468; --line:#d9e0d8; --pri:#1f6b45; --pri2:#17543a; --pri-soft:#e6f2ea; --warn:#b26a00; --bad:#b3261e; --ok:#1f6b45; --side:#16382a; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", Arial, sans-serif; font-size: 14.5px; color: var(--ink); background: var(--bg); line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pri); text-decoration: none; }
.loading { padding: 40px; text-align: center; color: var(--mut); }

/* الهيكل */
.shell { display: flex; min-height: 100vh; }
.side { width: 236px; flex: none; background: var(--side); color: #dfe9e2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: 16px 16px 12px; font-weight: 700; font-size: 17px; color: #fff; border-bottom: 1px solid #ffffff1f; }
.side .brand small { display: block; font-weight: 400; font-size: 12px; color: #a9c2b3; }
.side nav { flex: 1; padding: 8px 0; }
.side details > summary { cursor: pointer; padding: 8px 16px; font-weight: 600; color: #bcd3c5; list-style: none; font-size: 13.5px; }
.side details > summary::before { content: "▸ "; }
.side details[open] > summary::before { content: "▾ "; }
.side a.nav { display: block; padding: 7px 16px; color: #dfe9e2; border-inline-start: 3px solid transparent; }
.side details a.nav { padding-inline-start: 30px; font-size: 14px; }
.side a.nav:hover { background: #ffffff14; }
.side a.nav.on { background: #ffffff1f; border-inline-start-color: #7bd3a2; color: #fff; }
.side .me { padding: 12px 16px; border-top: 1px solid #ffffff1f; font-size: 13px; }
.side .me b { display: block; color: #fff; }
.side .me button { margin-top: 8px; margin-inline-end: 6px; background: transparent; border: 1px solid #ffffff55; color: #fff; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.main { flex: 1; min-width: 0; padding: 18px 22px 60px; }
.menu-btn { display: none; }
h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 16.5px; margin: 22px 0 8px; }
.sub { color: var(--mut); margin: 0 0 14px; font-size: 13.5px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.note { background: #fff8e6; border: 1px solid #ecd9a3; border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }
.note.info { background: var(--pri-soft); border-color: #bcd9c8; }
.note.bad { background: #fdecea; border-color: #f1b8b3; }

/* الأزرار والحقول */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f4f0; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri2); }
.btn.bad { color: var(--bad); border-color: #e6b7b3; }
.btn.sm { padding: 2px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld > span { font-size: 12.5px; color: var(--mut); }
.fld > span i { color: var(--bad); font-style: normal; }
.fld small { color: var(--mut); font-size: 12px; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=time], input[type=password], select, textarea { width: 100%; border: 1px solid #c4cdc4; border-radius: 6px; padding: 6px 8px; background: #fff; min-height: 34px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #6fbf95; outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: #f0f2ef; color: #444; }
textarea { min-height: 58px; resize: vertical; }
.chk { flex-direction: row; align-items: center; gap: 7px; padding-top: 18px; }
.chk input { width: 17px; height: 17px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .fld { width: 170px; }

/* الجداول */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 9px; border-bottom: 1px solid #e8ece7; text-align: start; vertical-align: top; }
th { background: #eef2ed; font-weight: 600; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; }
.tw table:not(.grid) tbody td:first-child, .tw table:not(.grid) tbody td:nth-child(2) { white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f4f8f4; }
tr.bold td { font-weight: 700; background: #f4f7f3; }
tfoot td { font-weight: 700; background: #eef2ed; border-top: 2px solid #cfd8ce; }
td.empty { text-align: center; color: var(--mut); padding: 20px; }
.grid td { padding: 3px 4px; vertical-align: middle; }
.grid input, .grid select { min-height: 30px; padding: 3px 6px; min-width: 76px; }
.grid td.n input { text-align: end; direction: ltr; }
.grid select.item { min-width: 200px; }
.grid .x { border: 0; background: transparent; color: var(--bad); font-size: 18px; cursor: pointer; padding: 0 6px; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12.5px; font-weight: 600; background: #e9ece8; color: #444; white-space: nowrap; }
.badge.draft { background: #eceff1; color: #455a64; }
.badge.pending { background: #fff3d6; color: #8a5a00; }
.badge.approved { background: #dff3e6; color: #17543a; }
.badge.rejected { background: #fde2df; color: #9a1f17; }
.badge.cancelled { background: #e4e4e4; color: #555; text-decoration: line-through; }
.badge.info { background: #e3ecfa; color: #24508f; text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; }
.kpi span { color: var(--mut); font-size: 12.5px; display: block; }
.kpi b { font-size: 19px; direction: ltr; display: inline-block; font-variant-numeric: tabular-nums; }
.sum { margin-inline-start: auto; width: min(100%, 380px); }
.sum div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #dfe5de; }
.sum div.big { font-weight: 700; font-size: 16px; border-bottom: 0; }
.sum div b { direction: ltr; font-variant-numeric: tabular-nums; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--mut); }
.meta b { color: var(--ink); font-weight: 600; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.perm-grid fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0; }
.perm-grid label { display: block; font-size: 13.5px; }
pre.json { direction: ltr; text-align: left; background: #f5f6f4; padding: 10px; border-radius: 6px; max-height: 60vh; overflow: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.jsonc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; font-size: 12px; color: var(--pri); cursor: pointer; }

/* النوافذ والتنبيهات */
.ov { position: fixed; inset: 0; background: #0b1d1480; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: min(100%, 560px); padding: 16px 18px; box-shadow: 0 12px 40px #0004; }
.modal.wide { width: min(100%, 980px); }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 16px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 16px; inset-inline-start: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(92vw, 460px); }
.toast { background: #1d2a22; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px #0003; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
.login { max-width: 380px; margin: 9vh auto; }
.login h1 { text-align: center; margin-bottom: 14px; }
.login .form { grid-template-columns: 1fr; }

#print { display: none; }
@media (max-width: 900px) {
  .side { position: fixed; inset-inline-start: 0; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  .shell.open .side { transform: none; }
  .menu-btn { display: inline-block; }
  .main { padding: 12px; }
}
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12.5px; }
  #app, #modals, #toasts { display: none !important; }
  #print { display: block; }
  .tw { border: 0; overflow: visible; }
  th { position: static; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  th, td { border: 1px solid #999; padding: 4px 6px; }
  .p-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 10px; }
  .p-head h2 { margin: 0; font-size: 18px; }
  .p-title { text-align: center; font-size: 17px; font-weight: 700; margin: 8px 0; }
  .p-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 20px; margin-bottom: 10px; }
  .p-sign { display: flex; justify-content: space-around; margin-top: 46px; text-align: center; }
  .p-sign div { border-top: 1px solid #333; padding-top: 4px; min-width: 150px; }
  .p-foot { margin-top: 18px; font-size: 11px; color: #555; text-align: center; }
  h2 { font-size: 14px; margin: 12px 0 5px; break-after: avoid; }
  .cards { grid-template-columns: repeat(4, 1fr); }
  .kpi { border: 1px solid #999; }
  .noprint { display: none !important; }
}
