/* Fatorty — calm invoice tool. Colors are the agreed palette. */

:root {
  --navy: #1e3a5f;
  --navy-deep: #16304f;
  --teal: #14b8a6;
  --teal-press: #0d9488;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f1f5f9;
  --danger: #b42318;
  --shadow: 0 12px 40px rgba(30, 58, 95, 0.08);
  --radius: 16px;
  --font-ar: "IBM Plex Sans Arabic", "Inter", sans-serif;
  --font-en: "Inter", "IBM Plex Sans Arabic", sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

html[lang="en"] body { font-family: var(--font-en); }

img { max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--navy); }

::selection { background: rgba(20, 184, 166, 0.28); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.wrap {
  width: min(1180px, calc(100% - 28px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--navy);
  font-weight: 700;
  margin-inline-end: auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--navy);
  color: var(--teal);
  display: grid;
  place-items: center;
  font-family: Inter, sans-serif;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}

.brand-name { font-size: 1.02rem; }

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a {
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}

.nav a[aria-current="page"] {
  background: rgba(20, 184, 166, 0.14);
  color: var(--navy);
}

.lang-switch {
  display: flex;
  padding: 3px;
  background: var(--soft);
  border-radius: 999px;
  flex: 0 0 auto;
}

.lang-switch button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

.lang-switch button.is-active {
  background: white;
  color: var(--navy);
  box-shadow: 0 1px 2px rgba(30, 58, 95, 0.12);
}

.hero { padding: 28px 0 8px; }

.hero h1 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: clamp(1.55rem, 2.6vw, 2.15rem);
  line-height: 1.35;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 68ch;
}

.hero a { font-weight: 700; white-space: nowrap; }

.ad-slot {
  margin: 18px 0;
  min-height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 440px);
  gap: 22px;
  align-items: start;
  padding-bottom: 28px;
}

.form-column { min-width: 0; max-width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.02rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: var(--teal);
}

.hint { margin: -4px 0 12px; color: var(--muted); font-size: 0.88rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field.span-2 { grid-column: 1 / -1; }

.field span,
.item-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--navy);
}

/* The hidden attribute must win over display rules such as .field and .sum-row. */
[hidden] { display: none !important; }

/* Field label with a small info button (invoice number). */
.field-head { display: flex; align-items: center; gap: 4px; }
.field-head label { font-size: 0.86rem; font-weight: 600; color: var(--navy); }
.field .info-tip { position: relative; display: inline-flex; font-weight: 400; }
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; min-height: 26px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer;
}
.info-btn:hover, .info-tip.is-open .info-btn { color: var(--navy); background: var(--soft); }
.info-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; color: var(--navy); }
.field .info-pop {
  position: absolute; top: calc(100% + 6px); inset-inline-start: -8px; z-index: 40;
  width: max-content; max-width: min(280px, 72vw); padding: 8px 10px; border-radius: 10px;
  background: var(--navy); color: #ffffff; font-size: 0.8rem; font-weight: 400; line-height: 1.55;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s; pointer-events: none;
}
.info-tip:hover .info-pop, .info-tip.is-open .info-pop { opacity: 1; visibility: visible; transform: none; }
.info-tip.is-dismissed .info-pop { opacity: 0; visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .field .info-pop { transition: none; } }
.hint.qr-note { margin: 4px 0 10px; padding-inline-start: 28px; font-size: 0.76rem; line-height: 1.5; color: var(--muted); }
.footer-disclaimer { margin-top: 14px; margin-bottom: 0; font-size: 0.78rem; line-height: 1.6; color: var(--muted); }

input, select, textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

input[dir="ltr"], .num-input { direction: ltr; text-align: start; }

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logo-thumb {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.file-btn { cursor: pointer; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1.2;
}

.btn-preview { background: white; color: var(--navy); border: 2px solid #14b8a6; }
.btn-preview:hover { background: rgba(20, 184, 166, 0.12); }
.btn-primary { background: #14b8a6; color: white; }
.btn-primary:hover { background: var(--teal-press); }
.btn-navy { background: var(--navy); color: white; }
.btn-navy:hover { background: var(--navy-deep); }
.btn-ghost { background: white; color: var(--navy); border-color: #cbd5e1; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-text { background: transparent; color: var(--danger); padding-inline: 8px; }
.btn:disabled { opacity: 0.65; cursor: progress; }
.btn-small { padding: 8px 10px; border-radius: 10px; font-size: 0.92rem; }

.action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.action-bar .btn-primary,
.action-bar .btn-preview { flex: 1 1 140px; }
.action-bar .btn-navy { flex: 0 1 120px; }

.phone-row { display: flex; gap: 8px; align-items: stretch; }
.phone-country { width: 132px; flex: 0 0 auto; }
.phone-row input { flex: 1; min-width: 0; }

.field-error {
  color: #b42318;
  font-size: 0.78rem;
  line-height: 1.45;
}
.field.is-invalid input,
.field.is-invalid textarea,
.field.is-invalid select {
  border-color: #b42318;
  background: #fff7f7;
}
.item-row.is-invalid { outline: 1px solid #b42318; border-radius: 12px; }

.form-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
}
.form-alert strong { display: block; }
.form-alert ul { margin: 6px 0 0; padding-inline-start: 1.2em; }

.preview-modal[hidden] { display: none !important; }
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  flex-direction: column;
}
.preview-modal-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.preview-modal-bar .btn-primary { flex: 1 1 160px; }
.preview-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px 12px 28px;
}
.preview-modal-stage { margin: 0 auto; }
body.modal-open { overflow: hidden; }

.status {
  min-height: 1.3em;
  margin: -6px 0 12px;
  font-size: 0.9rem;
  color: var(--navy);
}

.status.is-error { color: var(--danger); }

.items-head,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 110px 100px 40px;
  gap: 8px;
  align-items: center;
}

.items-head {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 2px 6px;
}

.items-head .col-c,
.item-row .qty,
.item-row .price,
.item-row .line-total {
  text-align: center;
}

.item-row { margin-bottom: 8px; }
body.is-contract .items-head { grid-template-columns: minmax(0, 1fr) 40px; }
body.is-contract .items-head .col-c,
body.is-contract .qty-field,
body.is-contract .price-field,
body.is-contract .line-total { display: none; }
body.is-contract .item-row { grid-template-columns: minmax(0, 1fr) 40px; }
.line-error { grid-column: 1 / -1; margin: 0; color: var(--danger); font-size: 0.8rem; font-weight: 600; }

.item-remove {
  width: 36px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.item-cap {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.line-total {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--navy);
  font-size: 0.92rem;
}

.add-row { margin-top: 4px; }

.summary {
  margin-top: 12px;
  background: var(--soft);
  border-radius: 12px;
  padding: 10px 12px;
}

.sum-row, .tot-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}

.sum-row strong, .tot-row strong { font-weight: 700; }

.sum-grand, .tot-row.grand {
  margin-top: 6px;
  background: var(--navy);
  color: white;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
}

.words {
  margin: 8px 0 0;
  color: var(--navy);
  font-size: 0.92rem;
  line-height: 1.7;
}

.words .en {
  display: block;
  font-family: var(--font-en);
  color: var(--muted);
  direction: ltr;
  text-align: left;
}

.secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preview-column { min-width: 0; }

@media (min-width: 1021px) {
  .preview-column { position: sticky; top: 82px; }
  .mobile-only { display: none !important; }
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.preview-toolbar h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1rem;
}

.live-note { color: var(--muted); font-size: 0.82rem; }

.preview-shell {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.preview-scaler {
  width: 794px;
  flex: 0 0 auto;
  transform-origin: top center;
}

.faq { padding: 8px 0 36px; }

.faq h2 { color: var(--navy); margin: 0 0 12px; }

.faq details {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
}

.faq summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.faq p { margin: 8px 0 2px; color: var(--text); }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 32px;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a { font-weight: 700; }

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
}

.seo-links a { font-weight: 600; }

.more-tools strong {
  flex: 1 0 100%;
  color: var(--navy);
  font-size: 0.85rem;
}

.check-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 12px;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex: 0 0 18px;
  margin: 0.22em 0 0;
  padding: 0;
  accent-color: var(--navy);
}

.check-row span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  font-weight: 600;
}

.tool-type { margin-bottom: 12px; }
.doc-current {
  margin: 0;
  color: var(--navy);
  font-size: 1.45rem;
  line-height: 1.3;
}

.doc-menu { position: relative; }
.doc-menu-btn {
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.doc-menu-btn:hover,
.doc-menu-btn:focus-visible { background: rgba(20, 184, 166, 0.14); color: var(--navy); }
.doc-menu-panel {
  display: none;
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: min(680px, 78vw);
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 50;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}
.doc-menu.is-open .doc-menu-panel { display: grid; }
.doc-group-title {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal-press);
}
.doc-menu-panel a {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-decoration: none;
  color: var(--text);
  border-radius: 10px;
  padding: 6px;
}
.doc-menu-panel a:hover,
.doc-menu-panel a.is-current { background: var(--soft); }
.doc-menu-panel a strong { display: block; color: var(--navy); font-size: 0.92rem; }
.doc-menu-panel a small { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.doc-ico {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #1e3a5f;
  color: #5eead4;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: var(--navy);
  color: white;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  padding: 12px 14px;
  cursor: pointer;
}
.menu-toggle .caret { display: inline-block; transition: transform 0.15s ease; }
.menu-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.mobile-docs { margin-top: 4px; width: 100%; }
.mobile-docs summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.mobile-docs a {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  border-radius: 10px;
}
.mobile-docs a strong { display: block; color: var(--navy); }
.mobile-docs a small { display: block; color: var(--muted); font-weight: 500; font-size: 0.8rem; line-height: 1.35; }
.mobile-docs a.is-current { background: var(--soft); }

.contract-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  font-size: 13px;
}
.contract-box strong { display: block; color: #1e3a5f; }

.type-hint { margin: 10px 0 0; color: var(--text); font-size: 0.95rem; }

.doc-about {
  margin-top: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.doc-about summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.doc-about p { margin: 8px 0 2px; }

.doc-type-legacy { display: none; }

.seo-copy { padding-bottom: 8px; }
.seo-copy .page-copy { margin-top: 8px; }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.crumbs a { color: var(--navy); font-weight: 700; text-decoration: none; }

.article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 22px 18px;
}

.article h1 { margin: 8px 0 12px; }
.article h2 { margin: 22px 0 8px; color: var(--navy); font-size: 1.2rem; }
.article p { margin: 0 0 12px; }
.article ul { margin: 0 0 12px; padding-inline-start: 1.2em; }
.article li { margin: 0 0 6px; }

.note {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  padding: 10px 12px;
  color: #115e59;
  font-size: 0.92rem;
}

.inline-cta {
  background: #f8fafc;
  border-inline-start: 4px solid #14b8a6;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 16px 0;
}

.guide-list { display: grid; gap: 12px; margin-top: 16px; }

.guide-card {
  display: block;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.guide-card strong { color: var(--navy); display: block; margin-bottom: 4px; }
.guide-card:hover { border-color: #14b8a6; }

.page-copy {
  max-width: 68ch;
  margin-top: 12px;
}

.page-copy p { margin: 0 0 10px; }

.page-copy h2 {
  margin: 18px 0 8px;
  color: var(--navy);
  font-size: 1.15rem;
}

/* Invoice paper — fixed A4 at 96dpi so the PDF matches the preview. */
.paper {
  width: 794px;
  min-height: 1123px;
  background: white;
  color: #1f2937;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(30, 58, 95, 0.14);
}

.paper.lang-ar,
.paper.lang-bi { font-family: "IBM Plex Sans Arabic", Inter, sans-serif; }
.paper.lang-en { font-family: Inter, "IBM Plex Sans Arabic", sans-serif; }

.paper-accent { height: 8px; background: #14b8a6; flex: 0 0 auto; }
.paper-navybar { height: 4px; background: #1e3a5f; flex: 0 0 auto; }

.paper-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 36px 22px;
}

.top-band {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.doc-title { text-align: end; flex: 0 0 auto; max-width: 48%; }

.paper-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.inv-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.seller-block { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.seller-name { font-size: 22px; font-weight: 700; color: #1e3a5f; line-height: 1.35; }
.seller-meta, .client-meta { color: #4b5563; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
}

.inv-id { text-align: end; flex: 0 0 auto; }
.inv-kicker .lbl-ar { display: block; font-size: 30px; font-weight: 700; color: #1e3a5f; line-height: 1.1; }
.inv-kicker .lbl-en {
  display: block;
  font-family: Inter, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #14b8a6;
}
.paper.lang-en .inv-kicker .lbl-en {
  font-size: 30px;
  letter-spacing: 0.08em;
  color: #1e3a5f;
}
.paper .inv-kicker.tax-bilingual .lbl-ar,
.paper .inv-kicker.tax-bilingual .lbl-en { display: block !important; }
.paper.lang-ar .inv-kicker.tax-bilingual .lbl-en,
.paper.lang-bi .inv-kicker.tax-bilingual .lbl-en {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #0f766e;
}
.paper.lang-en .inv-kicker.tax-bilingual .lbl-ar {
  font-size: 16px;
  font-weight: 700;
  color: #0f766e;
}
.inv-kicker.tax-bilingual.en-first { display: flex; flex-direction: column; }
.inv-kicker.tax-bilingual.en-first .lbl-en { order: 0; }
.inv-kicker.tax-bilingual.en-first .lbl-ar { order: 1; }
.paper .tot-row.both-lang .lbl-ar,
.paper .tot-row.both-lang .lbl-en { display: inline !important; }
.paper .tot-row.both-lang .lbl-en::before { content: " / "; color: #9ca3af; }
.inv-number {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  color: #0f766e;
  direction: ltr;
}

.paper.lang-ar .lbl-en,
.paper.lang-ar .tafqeet-en { display: none !important; }
.paper.lang-en .lbl-ar,
.paper.lang-en .tafqeet-ar { display: none !important; }
.paper.lang-bi .lbl-en {
  display: block;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}
.paper.lang-bi .inv-kicker .lbl-en { font-size: 12px; color: #14b8a6; letter-spacing: 0.16em; }
.paper.lang-bi .inv-table th .lbl-en { color: white; opacity: 0.85; }
.paper.lang-bi .tot-row.grand .lbl-en,
.paper.lang-bi .tot-row.grand .lbl-ar { color: white; }
.paper.lang-bi .seller-meta .lbl-en::before,
.paper.lang-bi .client-meta .lbl-en::before { content: " / "; color: #9ca3af; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.meta-chip {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 120px;
}

.meta-chip .lbl-ar,
.meta-chip .lbl-en { display: block; font-size: 11px; color: #6b7280; font-weight: 600; }
.meta-chip .lbl-en { font-family: Inter, sans-serif; }
.paper.lang-ar .meta-chip,
.paper.lang-bi .meta-chip { text-align: right; }
.paper.lang-en .meta-chip { text-align: left; }
.meta-chip strong {
  display: block;
  color: #1e3a5f;
  font-size: 14px;
  text-align: inherit;
}
.paper.lang-ar .meta-chip strong,
.paper.lang-bi .meta-chip strong { text-align: right; }
.paper.lang-en .meta-chip strong { text-align: left; direction: ltr; }
.meta-chip strong bdi[dir="ltr"] {
  unicode-bidi: isolate;
  direction: ltr;
}

.billto {
  margin-top: 16px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
}

.eyebrow { font-size: 12px; font-weight: 700; color: #0f766e; }
.eyebrow .lbl-en { font-family: Inter, sans-serif; font-weight: 600; color: #6b7280; }
.paper.lang-bi .eyebrow .lbl-en::before { content: " / "; color: #9ca3af; }
.client-name { font-size: 16px; font-weight: 700; color: #1e3a5f; margin-top: 2px; }
.ph { color: #9ca3af; }

.inv-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 16px;
  font-size: 13px;
  table-layout: fixed;
}

.inv-table th {
  background: #1e3a5f;
  color: white;
  font-weight: 600;
  text-align: start;
  padding: 8px;
  font-size: 12px;
}

.inv-table th .lbl-en {
  display: block;
  font-family: Inter, sans-serif;
  font-weight: 500;
  opacity: 0.8;
  font-size: 10px;
}

.inv-table td {
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

.inv-table tbody tr:nth-child(even) td { background: #f8fafc; }
.inv-table th,
.inv-table td {
  padding: 8px;
}
.inv-table th.col-qty,
.inv-table th.col-price,
.inv-table th.col-total,
.inv-table td.qty,
.inv-table td.num {
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}
.inv-table th.col-qty .lbl-ar,
.inv-table th.col-qty .lbl-en,
.inv-table th.col-price .lbl-ar,
.inv-table th.col-price .lbl-en,
.inv-table th.col-total .lbl-ar,
.inv-table th.col-total .lbl-en,
.num-iso {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  text-align: center;
  unicode-bidi: isolate;
}
.num-iso {
  direction: ltr;
}
.inv-table td.qty,
.inv-table td.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.col-n { width: 42px; text-align: center; }
.col-qty { width: 88px; }
.col-price { width: 120px; }
.col-total { width: 120px; }
.empty-row td { text-align: center; color: #9ca3af; background: white !important; }

.totals {
  width: 300px;
  margin-top: 14px;
  margin-inline-start: auto;
  font-size: 13.5px;
}

.tot-row span:last-child { direction: ltr; font-variant-numeric: tabular-nums; }
.tot-row.grand span:last-child { font-size: 16px; }

.tafqeet {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-inline-start: 4px solid #14b8a6;
  border-radius: 10px;
  padding: 10px 12px;
}

.tafqeet p { margin: 0; line-height: 1.75; font-size: 14px; }
.tafqeet-en {
  font-family: Inter, sans-serif;
  direction: ltr;
  text-align: left;
  color: #374151;
  margin-top: 4px !important;
}

.notes { margin-top: 16px; }
.notes-body { margin: 4px 0 0; white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: #1f2937; }

.paper-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.paper-foot .lbl-en { font-family: Inter, sans-serif; }

.made-with {
  margin: 8px 0 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.45;
  font-weight: 400;
  color: #9ca3af;
}

.template-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  border-radius: 12px;
  padding: 8px 6px 10px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
.template-btn.is-active { border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.thumb {
  width: 100%;
  height: 58px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: white;
  position: relative;
  overflow: hidden;
}
.thumb-classic::before { content: ""; position: absolute; inset: 5px; border: 1.5px solid #1e3a5f; }
.thumb-classic::after { content: ""; position: absolute; left: 10px; right: 10px; top: 24px; height: 7px; background: #1e3a5f; }
.thumb-modern { background: #1e3a5f; border-color: #1e3a5f; }
.thumb-modern::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 8px; height: 7px; background: #14b8a6; border-radius: 2px; }
.thumb-simple::before { content: ""; position: absolute; left: 8px; top: 12px; width: 46%; height: 3px; background: #111827; }
.thumb-simple::after { content: ""; position: absolute; left: 8px; right: 8px; top: 24px; height: 1px; background: #d1d5db; box-shadow: 0 7px 0 #d1d5db, 0 14px 0 #d1d5db; }
.thumb-elegant { background: linear-gradient(to left, #1e3a5f 30%, #ffffff 30%); }
.thumb-elegant::after { content: ""; position: absolute; left: 8px; top: 16px; width: 42%; height: 16px; background: #0f766e; border-radius: 2px; }

.mark-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.mark-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font-weight: 700; color: var(--navy); }

.not-tax {
  margin: 12px 0 0;
  padding: 6px 10px;
  border: 1px solid #14b8a6;
  border-radius: 8px;
  color: #0f766e;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}
.voucher-amount { margin-top: 16px; }
.voucher-figure { font-size: 28px; font-weight: 700; color: #1e3a5f; margin-top: 4px; }
.voucher-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}
.sign-row { display: flex; justify-content: flex-end; gap: 18px; margin-top: 18px; }
.sign-box { width: 160px; text-align: center; }
.mark-img { width: 120px; height: 80px; object-fit: contain; display: block; margin: 6px auto 0; }
.qr-block { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.qr-img { width: 108px; height: 108px; flex: 0 0 auto; }
.qr-caption { margin: 0; color: #6b7280; font-size: 11px; line-height: 1.45; }

.paper.tpl-classic { border: 2px solid #1e3a5f; box-shadow: none; }
.paper.tpl-classic .top-band { border-bottom: 2px solid #1e3a5f; padding-bottom: 12px; }
.paper.tpl-classic .meta-row { border: 1px solid #1e3a5f; padding: 0; gap: 0; }
.paper.tpl-classic .meta-chip {
  background: #fff;
  border: none;
  border-radius: 0;
  border-inline-end: 1px solid #1e3a5f;
  flex: 1;
  margin: 0;
}
.paper.tpl-classic .meta-chip:last-child { border-inline-end: none; }
.paper.tpl-classic .inv-table { border: 1px solid #1e3a5f; }
.paper.tpl-classic .inv-table th,
.paper.tpl-classic .inv-table td { border: 1px solid #d1d5db; }
.paper.tpl-classic .totals { border: 1px solid #1e3a5f; padding: 8px 10px; }

.paper.tpl-modern .paper-accent,
.paper.tpl-modern .paper-navybar,
.paper.tpl-simple .paper-accent,
.paper.tpl-simple .paper-navybar,
.paper.tpl-elegant .paper-accent,
.paper.tpl-elegant .paper-navybar { display: none; }

.paper.tpl-modern .paper-inner { padding-top: 0; }
.paper.tpl-modern .top-band {
  background: #1e3a5f;
  margin: 0 -36px 18px;
  padding: 26px 36px 22px;
  align-items: flex-end;
}
.paper.tpl-modern .top-band .seller-name,
.paper.tpl-modern .top-band .seller-meta,
.paper.tpl-modern .top-band .lbl-ar,
.paper.tpl-modern .top-band .inv-number { color: #f8fafc; }
.paper.tpl-modern .top-band .lbl-en,
.paper.tpl-modern .top-band .inv-kicker .lbl-en { color: #5eead4; }
.paper.tpl-modern .doc-title .lbl-ar { font-size: 40px; line-height: 1.05; }
.paper.lang-en.tpl-modern .doc-title .lbl-en { font-size: 36px; color: #f8fafc; letter-spacing: 0.04em; }
.paper.tpl-modern .inv-table th { background: #0f766e; }
.paper.tpl-modern .inv-table tbody tr:nth-child(odd) td { background: #f8fafc; }
.paper.tpl-modern .inv-table tbody tr:nth-child(even) td { background: #ffffff; }
.paper.tpl-modern .totals {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 14px;
  padding: 10px 12px;
  width: 320px;
}

.paper.tpl-simple .paper-inner { padding: 52px 50px 36px; }
.paper.tpl-simple .top-band { border-bottom: 1px solid #e5e7eb; padding-bottom: 20px; }
.paper.tpl-simple .doc-title .lbl-ar { font-size: 44px; font-weight: 400; color: #111827; }
.paper.lang-en.tpl-simple .doc-title .lbl-en { font-size: 40px; font-weight: 400; letter-spacing: 0.02em; color: #111827; }
.paper.tpl-simple .doc-title .inv-number { font-weight: 500; color: #6b7280; }
.paper.tpl-simple .meta-chip,
.paper.tpl-simple .billto { background: transparent; border: none; border-radius: 0; }
.paper.tpl-simple .meta-chip { border-bottom: 1px solid #e5e7eb; }
.paper.tpl-simple .inv-table th {
  background: transparent;
  color: #6b7280;
  font-weight: 500;
  border-bottom: 1px solid #111827;
}
.paper.tpl-simple .inv-table th .lbl-en,
.paper.lang-bi.tpl-simple .inv-table th .lbl-en { color: #6b7280; opacity: 1; }
.paper.tpl-simple tbody tr:nth-child(even) td { background: transparent; }
.paper.tpl-simple .tot-row.grand {
  background: transparent;
  color: #111827;
  border-top: 1px solid #111827;
  border-radius: 0;
  font-weight: 500;
}
.paper.lang-bi.tpl-simple .tot-row.grand .lbl-ar,
.paper.lang-bi.tpl-simple .tot-row.grand .lbl-en { color: #111827; }
.paper.tpl-simple .tafqeet { background: transparent; border: none; padding-inline: 0; }

.side-panel { display: none; }
.side-marks { display: contents; }

.paper.tpl-elegant {
  position: relative;
  min-height: 1123px;
}
.paper.tpl-elegant .paper-inner {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 0;
  flex: 1;
  min-height: 1123px;
}
.paper.tpl-elegant .top-band { display: contents; }
.paper.tpl-elegant .inv-head {
  grid-column: 1;
  grid-row: 1 / span 3;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  background: #1e3a5f;
  margin: 0;
  padding: 28px 16px 18px;
  min-height: 100%;
  height: auto;
}
.paper.tpl-elegant .seller-block {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.paper.tpl-elegant .logo {
  width: 76px;
  height: 76px;
  background: #fff;
  padding: 4px;
}
.paper.tpl-elegant .seller-name {
  font-size: 20px;
  margin-top: 8px;
  color: #f8fafc;
}
.paper.tpl-elegant .inv-head .seller-meta,
.paper.tpl-elegant .inv-head .lbl-ar,
.paper.tpl-elegant .inv-head .lbl-en { color: #f8fafc; }
.paper.tpl-elegant .inv-head .seller-meta::before {
  display: block;
  margin-top: 12px;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #5eead4;
}
.paper.lang-ar.tpl-elegant .inv-head .seller-address::before { content: "العنوان"; }
.paper.lang-en.tpl-elegant .inv-head .seller-address::before { content: "Address"; }
.paper.lang-bi.tpl-elegant .inv-head .seller-address::before { content: "العنوان  ·  Address"; }
.paper.lang-ar.tpl-elegant .inv-head .seller-phone::before { content: "الهاتف"; }
.paper.lang-en.tpl-elegant .inv-head .seller-phone::before { content: "Phone"; }
.paper.lang-bi.tpl-elegant .inv-head .seller-phone::before { content: "الهاتف  ·  Phone"; }
.paper.lang-ar.tpl-elegant .inv-head .seller-email::before { content: "البريد"; }
.paper.lang-en.tpl-elegant .inv-head .seller-email::before { content: "Email"; }
.paper.lang-bi.tpl-elegant .inv-head .seller-email::before { content: "البريد  ·  Email"; }
.paper.lang-ar.tpl-elegant .inv-head .seller-tax::before { content: "الرقم الضريبي"; }
.paper.lang-en.tpl-elegant .inv-head .seller-tax::before { content: "Tax / VAT No."; }
.paper.lang-bi.tpl-elegant .inv-head .seller-tax::before { content: "الرقم الضريبي  ·  Tax / VAT No."; }
.paper.tpl-elegant .inv-head .seller-tax .lbl-ar,
.paper.tpl-elegant .inv-head .seller-tax .lbl-en { display: none !important; }
.paper.tpl-elegant .side-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
}
.paper.tpl-elegant .side-kicker { font-size: 10px; font-weight: 700; color: #5eead4; }
.paper.tpl-elegant .side-kicker .lbl-en { color: #99f6e4; }
.paper.tpl-elegant .side-num {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-align: start;
  margin-bottom: 10px;
}
.paper.tpl-elegant .side-due {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}
.paper.tpl-elegant .doc-title {
  grid-column: 2;
  grid-row: 1;
  max-width: none;
  text-align: start;
  padding: 26px 28px 0;
  align-self: start;
}
.paper.tpl-elegant .doc-title .lbl-ar { color: #0f766e; font-size: 32px; }
.paper.tpl-elegant .doc-title .inv-number { display: none; }
.paper.tpl-elegant .inv-head { padding-bottom: 250px; }
.paper.tpl-elegant .not-tax { grid-column: 2; grid-row: 2; margin: 12px 28px 0; }
.paper.tpl-elegant .paper-body {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
  padding: 4px 28px 0;
}
.paper.tpl-elegant .inv-table th { background: #0f766e; }
.paper.tpl-elegant .tot-row.grand { background: #0f766e; padding: 14px 16px; }
.paper.tpl-elegant .side-marks {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  position: absolute;
  inset-inline-start: 14px;
  bottom: 16px;
  width: 208px;
  margin: 0;
  z-index: 2;
}
.paper.tpl-elegant .sign-row {
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
  gap: 8px;
}
.paper.tpl-elegant .sign-box { width: 100%; text-align: start; }
.paper.tpl-elegant .sign-box .lbl-ar,
.paper.tpl-elegant .sign-box .lbl-en,
.paper.tpl-elegant .qr-caption { color: #d1fae5; }
.paper.tpl-elegant .mark-img {
  margin: 4px 0 0;
  background: #fff;
  border-radius: 8px;
}
.paper.tpl-elegant .qr-block { flex-direction: column; align-items: flex-start; gap: 6px; margin: 0; }
.paper.tpl-elegant .qr-img { background: #fff; border-radius: 6px; }
.paper.tpl-elegant .paper-foot {
  margin-top: auto;
  margin-inline: -28px;
  background: #16304f;
  color: #f8fafc;
  padding: 12px 28px 2px;
  border-top: none;
}
.paper.tpl-elegant .paper-foot .lbl-ar,
.paper.tpl-elegant .paper-foot .lbl-en { color: #f8fafc; }
.paper.tpl-elegant .made-with {
  margin: 0 -28px 0;
  padding: 0 28px 12px;
  background: #16304f;
  color: #cbd5e1;
}
@media print {
  .paper.tpl-elegant,
  .paper.tpl-elegant .paper-inner,
  .paper.tpl-elegant .inv-head { min-height: 297mm; }
}

.paper[data-doctype="receipt"] .doc-title { max-width: 280px; }
.paper[data-doctype="receipt"] .inv-kicker .lbl-ar {
  font-size: 22px;
  line-height: 1.25;
}
.paper.lang-en[data-doctype="receipt"] .inv-kicker .lbl-en,
.paper.lang-bi[data-doctype="receipt"] .inv-kicker .lbl-en {
  font-size: 13px;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.paper.lang-en[data-doctype="receipt"] .inv-kicker .lbl-en {
  font-size: 18px;
}

/* Tafqeet tool */
.tool-card { max-width: 820px; }
.tool-output {
  margin-top: 14px;
  background: var(--soft);
  border-radius: 12px;
  padding: 14px;
  min-height: 92px;
}
.tool-output .ar-out {
  margin: 0;
  font-size: 1.35rem;
  color: var(--navy);
  font-weight: 700;
  line-height: 1.7;
}
.tool-output .en-out {
  margin: 8px 0 0;
  font-family: var(--font-en);
  direction: ltr;
  text-align: left;
  color: var(--muted);
}
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.examples button { direction: ltr; }
.cta-row { margin-top: 16px; }

.noscript {
  background: #fff7ed;
  color: #9a3412;
  padding: 10px 14px;
  text-align: center;
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr; }
  .nav { display: none; }
  .header-inner { flex-wrap: wrap; padding-bottom: 10px; }
  .menu-toggle { display: flex; order: 3; flex: 1 0 100%; }
  .lang-switch { order: 2; }
  .header-links { display: none; flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 12px; }
  .header-links.is-open { display: flex; }
  .header-nav-mobile { display: flex; }
  body { padding-bottom: 86px; }
  .action-bar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 40;
    background: white;
    border-top: 1px solid var(--line);
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(30, 58, 95, 0.06);
  }
}

.header-links {
  display: none;
  gap: 12px;
  padding: 0 0 10px;
  font-weight: 700;
}
.header-links a { color: var(--navy); text-decoration: none; }

@media (max-width: 1020px) {
  .header-inner { min-height: 60px; }
}

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .mark-grid { grid-template-columns: 1fr; }
  .template-pick { grid-template-columns: 1fr 1fr; }
  .items-head { display: none; }
  .item-row {
    grid-template-columns: 1fr 1fr 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 10px;
  }
  .item-row .desc-field { grid-column: 1 / -1; }
  .item-row .line-total { grid-column: 1 / -1; text-align: start; }
  .item-row label { display: flex; flex-direction: column; gap: 4px; }
  .item-cap {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--navy);
  }
  .brand-name { font-size: 0.95rem; }
  .hero { padding-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: white; padding: 0; }
  .site-header, .hero, .ad-slot, .faq, .site-footer, .form-column,
  .preview-toolbar, .no-print, .noscript, .header-links,
  .preview-modal, #modal-paper { display: none !important; }
  .workspace, .preview-column, .preview-shell { display: block; width: auto; height: auto !important; overflow: visible; position: static; }
  .preview-scaler { transform: none !important; width: auto; }
  .paper {
    transform: none !important;
    box-shadow: none !important;
    width: 210mm !important;
    min-height: 297mm !important;
  }
}
