/* مكتب المحاسب — النسخة المبسطة (دون مكتبات) */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #047857; --green-dark: #065f46; --green-light: #ecfdf5;
  --ink: #1e293b; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc;
  --border-doc: #334155;
}

body { font-family: "Segoe UI", Tahoma, Arial, sans-serif; background: var(--bg); color: var(--ink); direction: rtl; }
.hidden { display: none !important; }

/* ===== الهيكل ===== */
#app { display: flex; min-height: 100vh; }
aside { width: 250px; background: #fff; border-left: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--green); color: #fff; font-size: 20px; font-weight: 800; display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 15px; }
.brand-sub { font-size: 10.5px; color: var(--muted); }
nav { flex: 1; overflow-y: auto; }
.nav-sec { font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px; color: #475569; }
.nav-item:hover { background: var(--green-light); color: var(--green-dark); }
.nav-item.active { background: var(--green); color: #fff; font-weight: 700; }
.side-foot { padding: 10px 6px 0; }
.chip { display: inline-block; background: var(--green-light); color: var(--green-dark); font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }

main { flex: 1; padding: 28px 34px; max-width: 1150px; }
h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 15px; margin-bottom: 10px; color: var(--green-dark); }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ===== مكونات ===== */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: 1fr 1fr 1fr; } .g4 { grid-template-columns: repeat(4, 1fr); }
label.f { display: block; font-size: 12px; font-weight: 600; color: #475569; }
label.f input, label.f select { width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 9px; font-size: 13px; background: #fff; outline: none; }
label.f input:focus, label.f select:focus { border-color: var(--green); box-shadow: 0 0 0 3px #d1fae5; }
.btn { padding: 8px 16px; border-radius: 9px; border: 1px solid #cbd5e1; background: #fff; color: #475569; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.sm { padding: 3px 9px; font-size: 11.5px; border-radius: 7px; }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.t th { background: #f1f5f9; padding: 8px 6px; border: 1px solid var(--line); font-size: 11px; }
.t td { padding: 7px 6px; border: 1px solid var(--line); text-align: center; }
.t td.r { text-align: right; }
.t .num { font-weight: 700; }
.t tr.total td { background: var(--green-light); font-weight: 800; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .lbl { font-size: 11px; color: var(--muted); font-weight: 700; }
.stat .val { font-size: 19px; font-weight: 800; margin-top: 3px; }
.msg { position: fixed; bottom: 24px; right: 50%; transform: translateX(50%); background: #1e293b; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 13px; font-weight: 700; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

/* ===== عرض الوثيقة ===== */
#doc-view { min-height: 100vh; padding: 20px; background: var(--bg); }
.doc-toolbar { display: flex; justify-content: space-between; align-items: center; max-width: 210mm; margin: 0 auto 14px; }
.doc-actions { display: flex; gap: 8px; }
.sheet { background: #fff; width: 210mm; min-height: 290mm; margin: 0 auto; padding: 14mm 12mm; box-shadow: 0 4px 24px rgba(0,0,0,.15); font-size: 13px; line-height: 1.75; color: #0f172a; }

/* عناصر الوثائق الرسمية */
.d-center { text-align: center; }
.d-title { font-weight: 800; }
.d-xl { font-size: 16px; font-weight: 800; }
.d-box { display: inline-block; border: 2px solid var(--border-doc); padding: 2px 24px; font-weight: 800; }
.d-line { border-bottom: 1px dotted #64748b; display: inline-block; min-width: 80px; text-align: center; font-weight: 700; padding: 0 6px; }
.d-row { display: flex; align-items: flex-end; gap: 6px; }
.d-row .lbl { font-weight: 600; white-space: nowrap; }
.d-row .fill { flex: 1; border-bottom: 1px dotted #64748b; min-height: 18px; font-weight: 700; padding: 0 6px; }
.d-th { background: #eef2f7 !important; font-weight: 800; }
table.d { width: 100%; border-collapse: collapse; margin-top: 6px; }
.d th, .d td { border: 1px solid var(--border-doc); padding: 3px 5px; text-align: center; font-size: 11.5px; line-height: 1.5; }
.d td.r { text-align: right; }
.d .sig { text-align: center; font-weight: 800; }
.d .sig-line { border-bottom: 1px dotted #64748b; width: 150px; margin: 42px auto 0; }
.d .muted { color: #94a3b8; font-size: 10px; }
.rib span { display: inline-block; width: 15px; border: 1px solid #94a3b8; text-align: center; font-size: 10px; margin-inline: 1px; }
.d-flex-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mt2 { margin-top: 10px; } .mt3 { margin-top: 16px; } .mt4 { margin-top: 26px; }
.flex-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.mb2 { margin-bottom: 10px; }

/* ===== الطباعة: الوثيقة فقط ===== */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  html, body { direction: ltr; background: #fff; }
  #app, .doc-toolbar, .no-print, .msg { display: none !important; }
  #doc-view { display: block !important; padding: 0; background: #fff; }
  .sheet { width: 190mm; min-height: auto; margin: 0 auto; box-shadow: none; padding: 0; }
  .sheet.landscape-page { width: 277mm; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
