/* حاسبتي — نظام التصميم
   الورق أبيض، الحبر أزرق داكن، الأخضر لون دفاتر الحسابات، والأصفر لون قلم التحديد على الإجابة. */
:root {
  --paper: #ffffff;
  --page: #f6f8f7;
  --ink: #1b2733;
  --ink-soft: #55636f;
  --rule: #dfe5e3;
  --ledger: #0d7a63;
  --ledger-dark: #095c4a;
  --ledger-tint: #e7f3ef;
  --marker: #fff1a8;
  --danger: #b4232f;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  --measure: 68ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--page);
  font-feature-settings: "tnum" 1;
}
a { color: var(--ledger-dark); text-underline-offset: 3px; }
a:hover { color: var(--ledger); }
:focus-visible { outline: 3px solid var(--ledger); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

/* ---------- رأس الصفحة ---------- */
.site-head { background: var(--paper); border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 22px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.site-nav { display: flex; gap: 4px; margin-inline-start: auto; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { white-space: nowrap; text-decoration: none; color: var(--ink-soft); font-size: 15px; padding: 6px 10px; border-radius: var(--radius-sm); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ledger-dark); background: var(--ledger-tint); }
@media (max-width: 760px) {
  .site-head .wrap { flex-wrap: wrap; gap: 0; padding-block: 8px; }
  .site-nav { width: 100%; margin: 4px 0 0; }
}

/* ---------- مسار الصفحة ---------- */
.crumbs { font-size: 14px; color: var(--ink-soft); margin: 18px 0 6px; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span[aria-hidden] { margin-inline: 6px; }

/* ---------- الصفحة الرئيسية ---------- */
.hero { padding: 48px 0 36px; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.hero-demo { transform: rotate(-2deg); max-width: 360px; justify-self: center; box-shadow: 0 18px 40px -24px rgba(27, 39, 51, .45); }
.hero-demo .words-out { font-size: 19px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: 28px; } .hero-demo { display: none; } }
.hero h1 { font-size: clamp(30px, 5.4vw, 52px); line-height: 1.25; margin: 0 0 12px; font-weight: 700; letter-spacing: -0.5px; max-width: 18ch; }
.hero p { margin: 0 0 26px; color: var(--ink-soft); max-width: 52ch; font-size: 18px; }
.finder { max-width: 620px; }
.finder-box { position: relative; }
.finder input {
  width: 100%; font: inherit; font-size: 19px; padding: 16px 52px 16px 18px;
  border: 2px solid var(--ink); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink);
}
.finder input:focus { outline: none; border-color: var(--ledger); box-shadow: 0 0 0 4px var(--ledger-tint); }
.finder svg { position: absolute; inset-inline-start: 18px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--ink-soft); pointer-events: none; }
.finder-results { list-style: none; margin: 8px 0 0; padding: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.finder-results:empty { display: none; }
.finder-results a { display: block; padding: 12px 18px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); }
.finder-results li:last-child a { border-bottom: 0; }
.finder-results a:hover, .finder-results a:focus { background: var(--ledger-tint); }
.finder-results small { display: block; color: var(--ink-soft); font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 15px; color: var(--ink-soft); align-items: center; }
.quick a { text-decoration: none; padding: 4px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--ink); }
.quick a:hover { border-color: var(--ledger); color: var(--ledger-dark); }

.shelves { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 40px; padding: 8px 0 56px; }
.shelf h2 { font-size: 21px; margin: 24px 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.shelf h2 a { color: inherit; text-decoration: none; }
.shelf h2 small { font-size: 14px; font-weight: 400; color: var(--ink-soft); }
.tool-list { list-style: none; margin: 0; padding: 0; }
.tool-list a { display: flex; justify-content: space-between; gap: 16px; padding: 12px 2px; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.tool-list a:hover .t-name { color: var(--ledger-dark); text-decoration: underline; }
.t-name { font-weight: 600; }
.t-hint { color: var(--ink-soft); font-size: 14px; text-align: end; }

/* ---------- صفحة الأداة ---------- */
.tool-head { padding: 4px 0 18px; }
.tool-head h1 { font-size: clamp(26px, 4.2vw, 38px); line-height: 1.3; margin: 0 0 6px; }
.tool-head p { margin: 0; color: var(--ink-soft); max-width: var(--measure); }
.updated { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }

.workbench { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .workbench { grid-template-columns: 1fr; } }
@media (min-width: 861px) { .workbench .receipt { position: sticky; top: 16px; } }

.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 22px; }
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field .help { display: block; color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }
.row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; align-items: end; }
input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 18px; padding: 10px 12px; color: var(--ink);
  background: var(--paper); border: 1.5px solid #c9d2cf; border-radius: var(--radius-sm);
}
input:focus, select:focus { outline: none; border-color: var(--ledger); box-shadow: 0 0 0 3px var(--ledger-tint); }
input[type="number"] { direction: ltr; text-align: right; }
.unit-input { position: relative; }
.unit-input input { padding-inline-end: 64px; }
.unit-input span { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-size: 15px; pointer-events: none; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { cursor: pointer; padding: 7px 14px; border: 1.5px solid #c9d2cf; border-radius: 999px; font-size: 15px; background: var(--paper); }
.seg input:checked + label { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--ledger); outline-offset: 2px; }

.check { display: flex; gap: 8px; align-items: center; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ledger); }

.btn { font: inherit; font-size: 15px; cursor: pointer; border-radius: var(--radius-sm); padding: 9px 16px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--ledger-tint); border-color: var(--ledger); color: var(--ledger-dark); }
.btn-primary { background: var(--ledger); border-color: var(--ledger); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--ledger-dark); border-color: var(--ledger-dark); color: #fff; }
.btn svg { width: 18px; height: 18px; }

/* ---------- الإيصال: العنصر المميز ---------- */
.receipt {
  position: relative; background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 22px 22px 30px;
  border-top: 5px solid var(--ledger);
}
.receipt::after {
  content: ""; position: absolute; inset-inline: -1px; bottom: -12px; height: 12px;
  background: radial-gradient(circle at 10px -2px, transparent 9px, var(--paper) 10px) 0 0 / 20px 12px repeat-x;
  filter: drop-shadow(0 1px 0 var(--rule));
}
.receipt-label { font-size: 14px; color: var(--ink-soft); margin: 0; }
.receipt-total { font-size: clamp(30px, 6vw, 44px); font-weight: 700; line-height: 1.25; margin: 2px 0 4px; word-break: break-word; }
.receipt-total mark { background: linear-gradient(transparent 55%, var(--marker) 55%); color: inherit; padding: 0 2px; }
.receipt-sub { color: var(--ink-soft); margin: 0 0 14px; font-size: 15px; }
.receipt-empty { color: var(--ink-soft); }
.lines { list-style: none; margin: 0; padding: 0; border-top: 1.5px dashed #b8c4c0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dotted #cdd6d3; font-size: 15.5px; }
.lines li b { font-weight: 600; white-space: nowrap; }
.lines li b.rtl { direction: rtl; white-space: normal; text-align: end; }
.lines li.total { border-bottom: 0; border-top: 1.5px solid var(--ink); margin-top: 4px; font-weight: 700; }
.steps { margin: 16px 0 0; }
.steps summary { cursor: pointer; font-weight: 600; color: var(--ledger-dark); font-size: 15px; }
.steps ol { margin: 8px 0 0; padding-inline-start: 22px; font-size: 15px; color: var(--ink-soft); }
.steps ol li { margin-bottom: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.words-out { font-size: 22px; line-height: 1.8; font-weight: 600; margin: 4px 0 12px; }

.err { color: var(--danger); font-size: 14px; margin-top: 6px; }

/* ---------- المقال ---------- */
.ad-slot { margin: 28px 0; min-height: 0; }
.article { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; padding: 24px 0 56px; }
@media (max-width: 860px) { .article { grid-template-columns: 1fr; gap: 8px; } }
.prose { max-width: var(--measure); }
.prose h2 { font-size: 25px; line-height: 1.4; margin: 36px 0 10px; }
.prose h3 { font-size: 19px; margin: 24px 0 6px; }
.prose p, .prose li { color: #26333f; }
.prose table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 15.5px; background: var(--paper); }
.prose th, .prose td { border: 1px solid var(--rule); padding: 8px 10px; text-align: start; }
.prose th { background: var(--ledger-tint); }
.prose .example { background: var(--paper); border-inline-start: 4px solid var(--ledger); padding: 12px 16px; margin: 16px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.note { font-size: 14.5px; color: var(--ink-soft); background: var(--paper); border: 1px solid var(--rule); padding: 12px 14px; border-radius: var(--radius-sm); }
.faq details { border-bottom: 1px solid var(--rule); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }
.aside h2 { font-size: 17px; margin: 36px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
@media (max-width: 860px) { .aside h2 { margin-top: 12px; } }

/* ---------- صفحات عامة ---------- */
.page { padding: 8px 0 56px; }
.page h1 { font-size: clamp(28px, 4.4vw, 40px); margin: 6px 0 12px; }

.site-foot { background: var(--paper); border-top: 1px solid var(--rule); padding: 28px 0 36px; font-size: 15px; color: var(--ink-soft); }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-foot a { color: var(--ink-soft); }


/* ---------- مجموعات الحقول ---------- */
.group { border: 0; border-top: 1px solid var(--rule); margin: 0 0 6px; padding: 14px 0 4px; }
.panel > .group:first-child { border-top: 0; padding-top: 0; }
.group > legend, .group > summary { font-weight: 700; font-size: 17px; padding: 0; margin-bottom: 10px; }
.group > summary { cursor: pointer; list-style-position: inside; }
.group > summary small { display: block; font-weight: 400; font-size: 13.5px; color: var(--ink-soft); }
details.group[open] > summary { margin-bottom: 14px; }
input[type="file"] { font: inherit; font-size: 15px; max-width: 100%; }
.logo-preview { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.logo-preview img { max-height: 64px; max-width: 160px; border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 4px; background: #fff; }

/* ---------- النماذج ---------- */
.docs { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 20px 22px; margin-top: 28px; }
.docs h2 { margin: 0 0 4px; font-size: 21px; }
.docs p { margin: 0 0 14px; color: var(--ink-soft); }
.doc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-dialog { width: min(860px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 0; border: 0; border-radius: var(--radius-lg); background: #eef1f0; }
.doc-dialog::backdrop { background: rgba(27, 39, 51, .55); }
.doc-bar { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--paper); border-bottom: 1px solid var(--rule); }
#doc-sheet { padding: 16px; }
.doc { background: #fff; color: #111; max-width: 794px; margin: 0 auto; padding: 40px 44px; font-size: 14.5px; line-height: 1.9; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 12px; border-bottom: 2px solid #111; }
.doc-co strong { display: block; font-size: 18px; }
.doc-co small { display: block; color: #444; font-size: 12.5px; line-height: 1.6; }
.doc-logo { max-height: 72px; max-width: 180px; object-fit: contain; }
.doc-title { text-align: center; font-size: 21px; margin: 18px 0 2px; }
.doc-date { text-align: center; color: #444; margin: 0 0 16px; font-size: 13px; }
.doc-h { font-size: 15.5px; margin: 16px 0 6px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.doc-table th, .doc-table td { border: 1px solid #999; padding: 6px 8px; text-align: start; vertical-align: top; }
.doc-table th { background: #f1f4f3; font-weight: 600; white-space: nowrap; }
.doc-table.num td:last-child, .doc-table.num thead + tbody td { font-variant-numeric: tabular-nums; }
.doc-table tr.sum td { font-weight: 700; background: #fafbf7; }
.doc-table td.box { width: 90px; }
.doc-words { border: 1px dashed #777; padding: 8px 12px; font-weight: 600; margin: 12px 0; }
.doc-text p { margin: 0 0 12px; text-align: justify; }
.doc-note { font-size: 13px; color: #333; }
.blank { display: inline-block; border-bottom: 1px dotted #333; min-height: 1.2em; vertical-align: bottom; }
.doc-signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px 24px; margin-top: 36px; }
.doc-signs span { display: block; font-size: 13px; font-weight: 600; }
.doc-signs i { display: block; border-bottom: 1px solid #111; height: 40px; }
.doc-signs .print b { display: block; width: 70px; height: 70px; border: 1px solid #111; border-radius: 50%; margin-top: 6px; }
.doc-foot { margin-top: 28px; font-size: 11px; color: #777; text-align: center; }
@media (max-width: 600px) { .doc { padding: 20px 16px; font-size: 13px; } .doc-table th { white-space: normal; } }
#print-area { display: none; }
@media print {
  body.doc-printing > *:not(#print-area) { display: none !important; }
  body.doc-printing #print-area { display: block; }
  body.doc-printing .doc { box-shadow: none; padding: 0; max-width: none; }
  @page { size: A4; margin: 14mm; }
}

@media print {
  body:not(.doc-printing) .docs { display: none !important; }
  .site-head, .site-foot, .crumbs, .article, .actions, .panel, .ad-slot, .tool-head p { display: none !important; }
  body { background: #fff; }
  .workbench { display: block; }
  .receipt { border: 0; background-image: none; }
  .receipt::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* شريط النتيجة على الموبايل: بيظهر لما النتيجة تكون تحت الشاشة */
.peek { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 9; display: none; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: #fff; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-size: 15px; cursor: pointer; text-align: start; }
.peek b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek.on { display: flex; }
@media (min-width: 861px) { .peek.on { display: none; } }
@media print { .peek { display: none !important; } }
.group > legend { float: inline-start; width: 100%; }
.group > legend + * { clear: both; }

textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; color: var(--ink); background: var(--paper); border: 1.5px solid #c9d2cf; border-radius: var(--radius-sm); resize: vertical; }
textarea:focus { outline: none; border-color: var(--ledger); box-shadow: 0 0 0 3px var(--ledger-tint); }
.mini-wrap { overflow-x: auto; margin-bottom: 8px; }
.mini { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 420px; }
.mini th { text-align: start; font-weight: 600; color: var(--ink-soft); padding: 4px; }
.mini td { padding: 3px; }
.mini input { font-size: 15px; padding: 7px 8px; }
.mini .s-rest { font-weight: 600; white-space: nowrap; text-align: start; }
.icon-btn { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 4px 8px; border-radius: var(--radius-sm); }
.icon-btn:hover { color: var(--danger); background: #fbecee; }
.doc-co.en { text-align: left; }
.doc-co.en strong { font-size: 16px; }

/* ---------- السندات ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chips .help { margin: 0 4px 0 0; }
.chip { font: inherit; font-size: 13.5px; cursor: pointer; padding: 4px 10px; border: 1px dashed var(--ledger); border-radius: 999px; background: var(--ledger-tint); color: var(--ledger-dark); }
.chip:hover { background: #d5ebe4; }
.v-top { display: grid; grid-template-columns: 150px 1fr 150px; align-items: center; gap: 12px; margin-top: 14px; }
.v-top .doc-title { margin: 0; }
.v-copy { display: block; font-size: 12px; font-weight: 400; color: #555; }
.v-box { border: 1.5px solid #111; border-radius: 6px; padding: 4px 10px; text-align: center; }
.v-box span { display: block; font-size: 11.5px; color: #444; }
.v-box b { font-size: 17px; }
.v-body p { font-size: 15.5px; line-height: 2.2; }
.two-up .cut { border-top: 1.5px dashed #888; margin: 14px 0; position: relative; }
.doc.half { padding: 22px 30px; font-size: 13px; line-height: 1.7; }
.doc.half .doc-logo { max-height: 52px; }
.doc.half .doc-head { padding-bottom: 8px; }
.doc.half .v-body p { font-size: 14px; line-height: 1.9; margin-bottom: 6px; }
.doc.half .doc-signs { margin-top: 16px; gap: 10px 18px; }
.doc.half .doc-signs i { height: 26px; }
.doc.half .doc-date { margin-bottom: 8px; }
@media (max-width: 600px) { .v-top { grid-template-columns: 1fr 1fr; } .v-top .doc-title { grid-column: 1 / -1; grid-row: 1; } }
@media print {
  body.doc-printing .two-up .doc.half { padding: 0; }
  body.doc-printing .two-up .cut { margin: 8mm 0; }
}
