/* Diginova ERP demo styles. Logical properties are used throughout so Arabic (RTL) mirrors correctly. */
:root {
  --bg: #121a2e; --panel: #1d2742; --panel2: #263356; --field: #151d33;
  --line: rgba(255, 255, 255, .1); --line2: rgba(255, 255, 255, .22);
  --fg: #f1f4fc; --mut: #aab3cf; --acc: #5ce6ff; --acc2: #ff6fe0; --ink: #04141a; --link: #5ce6ff;
  --ok: #4ade80; --warn: #fbbf24; --bad: #ff7a8a;
  --display: "Unbounded", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  --body: "Manrope", "Noto Sans Devanagari", system-ui, sans-serif; --hh: 58px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --panel: #ffffff; --panel2: #e9edf6; --field: #ffffff;
  --line: rgba(18, 26, 46, .12); --line2: rgba(18, 26, 46, .3);
  --fg: #121a2e; --mut: #4a5471; --acc: #0a6f8a; --acc2: #b4278f; --ink: #ffffff; --link: #0a6f8a;
  --ok: #157a3c; --warn: #a55300; --bad: #c0213a;
  color-scheme: light;
}
html[lang="ar"] { --body: "IBM Plex Sans Arabic", "Manrope", system-ui, sans-serif; --display: "IBM Plex Sans Arabic", system-ui, sans-serif; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--fg); font: 15px/1.6 var(--body); min-height: 100vh; overflow-x: hidden; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.skip { position: absolute; inset-inline-start: 8px; top: -80px; z-index: 300; background: var(--acc); color: var(--ink); padding: 8px 14px; border-radius: 8px; text-decoration: none; font-weight: 700; }
.skip:focus { top: 8px; }
.mono { font-family: var(--mono); font-size: .92em; white-space: nowrap; }
.mut { color: var(--mut); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.warnTxt { color: var(--warn); }

/* ---------- shell ---------- */
#shell-top { position: sticky; top: 0; z-index: 50; height: var(--hh); display: flex; align-items: center; gap: 10px; padding-inline: 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
#shell-top .grow, .grow { flex: 1; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--fg); font-weight: 800; white-space: nowrap; }
.logo img { border-radius: 8px; }
.coname { color: var(--mut); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; padding: 3px; background: var(--bg); }
.seg button { border: 0; background: none; color: var(--mut); padding: 6px 11px; border-radius: 999px; font-weight: 700; font-size: 13px; line-height: 1.2; cursor: pointer; min-width: 40px; }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--ink); }
.iconbtn { min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); color: var(--fg); cursor: pointer; font-size: 16px; }
.iconbtn:hover { background: var(--panel2); }
#menuBtn { display: none; }
#banner { padding: 8px 16px; font-size: 13px; color: var(--mut); background: var(--panel2); border-bottom: 1px solid var(--line); }
.linkbtn { background: none; border: 0; color: var(--link); text-decoration: underline; cursor: pointer; padding: 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; background: var(--panel2); color: var(--mut); vertical-align: middle; }
.badge.warn { background: var(--warn); color: #1a1200; }
:root[data-theme="light"] .badge.warn { color: #fff; }
.layout { display: grid; grid-template-columns: 262px minmax(0, 1fr); align-items: start; }
#side { position: sticky; top: var(--hh); height: calc(100vh - var(--hh)); overflow-y: auto; padding: 12px; background: var(--panel); border-inline-end: 1px solid var(--line); }
#view { padding: 20px clamp(14px, 3vw, 32px) 60px; min-width: 0; outline: none; }
.nlink { display: block; padding: 7px 10px; border-radius: 8px; color: var(--mut); text-decoration: none; font-size: 14px; border-inline-start: 3px solid transparent; }
.nlink:hover { background: var(--panel2); color: var(--fg); }
.nlink[aria-current="page"] { background: var(--panel2); color: var(--fg); font-weight: 700; border-inline-start-color: var(--acc); }
.nlink.top { font-weight: 700; color: var(--fg); margin-bottom: 4px; }
.ngrp { margin-bottom: 4px; }
.ngrp summary { cursor: pointer; list-style: none; padding: 8px 10px; font-weight: 800; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.ngrp summary::-webkit-details-marker { display: none; }
.ngrp summary::after { content: "\25B8"; margin-inline-start: auto; color: var(--mut); transition: transform .15s; }
[dir="rtl"] .ngrp summary::after { content: "\25C2"; }
.ngrp[open] summary::after { transform: rotate(90deg); }
.ngrp summary:hover { background: var(--panel2); }
.ngrp .nlink { margin-inline-start: 14px; }
.ic { display: inline-block; width: 22px; text-align: center; }
.soon { margin-top: 16px; padding: 12px; border: 1px dashed var(--line2); border-radius: 10px; font-size: 12px; color: var(--mut); }
.soon ul { padding-inline-start: 18px; margin-top: 6px; }

/* ---------- page parts ---------- */
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.phead h1 { font-size: 22px; line-height: 1.3; }
html[lang="en"] .phead h1 { font-family: var(--display); font-size: 20px; }
.phead .sub { color: var(--mut); font-size: 14px; margin-top: 2px; }
.pact { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; color: var(--mut); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.card h2 { font-size: 16px; margin-bottom: 10px; }
.card.err { border-color: var(--bad); color: var(--bad); }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.cols2 > .card { margin-bottom: 0; }
.cols2 { margin-bottom: 16px; }
.grid2, .grid3, .grid4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.empty { color: var(--mut); text-align: center; padding: 18px 0; }
.err { color: var(--bad); min-height: 1.3em; font-size: 14px; }
.note { color: var(--mut); margin-top: 10px; font-size: 14px; }
.tot-line { margin-top: 10px; text-align: end; }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); color: var(--fg); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: var(--panel2); }
.btn.pri { background: var(--acc); color: var(--ink); border-color: var(--acc); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.btns.start { justify-content: flex-start; }
input, select, textarea { width: 100%; background: var(--field); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
input[type="checkbox"], input[type="file"] { width: auto; min-height: 0; padding: 0; border: 0; background: none; }
textarea { resize: vertical; }
input.search { max-width: 220px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld label { font-size: 13px; color: var(--mut); font-weight: 600; }
.fld.wide { grid-column: 1 / -1; }
.fld.chk label { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; }
.req { color: var(--bad); }
.hint { color: var(--mut); font-size: 12px; display: block; margin-top: 2px; }
.hint.bad { color: var(--bad); font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filters .fld { min-width: 160px; }
.qlinks { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; padding-bottom: 8px; }
.logoBox { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 12px 0; }
.logoPrev { max-height: 48px; max-width: 160px; background: #fff; border-radius: 6px; padding: 2px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--mut); font-weight: 700; white-space: nowrap; }
.tbl.small th, .tbl.small td { padding: 5px 8px; font-size: 13px; }
.tbl .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tbody tr:hover { background: var(--panel2); }
.tbl tfoot td { font-weight: 600; }
.tbl tr.tot td { font-weight: 800; border-top: 2px solid var(--line2); }
.tbl tr.sub td { color: var(--mut); font-style: italic; }
.tbl.lines td { padding: 4px 6px; }
.tbl.lines select { min-width: 190px; }
.tbl.lines input[type="number"] { min-width: 84px; }
.sticky { position: sticky; inset-inline-start: 0; background: var(--panel); z-index: 1; white-space: nowrap; }
.tbl.attbl th, .tbl.attbl td { padding: 3px 3px; text-align: center; }
.tbl.attbl th.sticky, .tbl.attbl td.sticky { text-align: start; padding-inline: 8px; }
.tbl.attbl .day.wk { background: var(--panel2); }
.att { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line2); background: none; color: var(--mut); font: 700 12px var(--mono); cursor: pointer; padding: 0; }
.att.a-P { color: var(--ok); border-color: var(--ok); }
.att.a-A { color: var(--bad); border-color: var(--bad); }
.att.a-L { color: var(--warn); border-color: var(--warn); }
.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.st-draft { color: var(--mut); } .st-submitted { color: var(--acc); } .st-partly-paid, .st-pending, .st-low { color: var(--warn); }
.st-paid, .st-approved { color: var(--ok); } .st-cancelled, .st-rejected { color: var(--bad); }
.linkchip { display: inline-block; padding: 2px 10px; border: 1px solid var(--line2); border-radius: 999px; font-size: 13px; text-decoration: none; margin-block: 2px; margin-inline-end: 6px; }
.links { margin-top: 10px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; }
.meta dt { font-size: 12px; color: var(--mut); font-weight: 700; }
.meta dd { font-size: 15px; }
.meta .wide { grid-column: 1 / -1; }
.fx .rule { background: var(--panel2); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13.5px; }
.fx h3 { font-size: 14px; margin: 14px 0 6px; }
.totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 14px 0; }
.totals > div { display: flex; gap: 28px; justify-content: space-between; min-width: min(280px, 100%); }
.totals .tot { font-size: 18px; font-weight: 800; border-top: 2px solid var(--line2); padding-top: 4px; }
.result { display: flex; justify-content: space-between; align-items: center; font-size: 18px; font-weight: 700; }
.result.profit b { color: var(--ok); } .result.loss b { color: var(--bad); }

/* ---------- dashboard and charts ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
a.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--fg); min-width: 0; }
a.tile:hover { border-color: var(--acc); }
.tile .tl { color: var(--mut); font-size: 13px; }
.tile b { font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile small { color: var(--warn); font-size: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.feed { list-style: none; font-size: 14px; }
.feed li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.vbars { display: flex; align-items: flex-end; gap: 8px; height: 210px; padding-top: 8px; }
.vb { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.vb i { display: block; width: 68%; max-width: 56px; min-height: 2px; height: calc(var(--h) * .74%); background: linear-gradient(var(--acc), var(--acc2)); border-radius: 6px 6px 0 0; }
.vb .vv { font-size: 11px; color: var(--mut); white-space: nowrap; }
.vb .vl { font-size: 12px; color: var(--mut); white-space: nowrap; }
.hbars { list-style: none; }
.hbars li { display: grid; grid-template-columns: minmax(80px, 32%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.hbars .bl { overflow-wrap: anywhere; font-size: 14px; }
.hbars .bt { height: 12px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.hbars .bt i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); border-radius: 99px; }
[dir="rtl"] .hbars .bt i { background: linear-gradient(270deg, var(--acc), var(--acc2)); }
.hbars .bv { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }

/* ---------- dialogs and toast ---------- */
dialog#dlg { border: 1px solid var(--line2); border-radius: 14px; background: var(--panel); color: var(--fg); padding: 20px; width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: auto; margin: auto; }
dialog#dlg.wide { width: min(860px, calc(100% - 24px)); }
dialog#dlg.small { width: min(420px, calc(100% - 24px)); }
dialog#dlg::backdrop { background: rgba(4, 8, 20, .66); }
dialog#dlg h2 { font-size: 18px; margin-bottom: 12px; }
#toast { position: fixed; inset-inline: 0; bottom: 22px; margin-inline: auto; width: fit-content; max-width: calc(100% - 28px); padding: 10px 18px; border-radius: 12px; background: var(--panel2); color: var(--fg); border: 1px solid var(--line2); box-shadow: 0 8px 28px rgba(0, 0, 0, .4); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; z-index: 400; }
#toast.show { opacity: 1; transform: none; }
#toast.ok { border-color: var(--ok); } #toast.err { border-color: var(--bad); color: var(--bad); }

/* ---------- printable sheet (always paper-like, in any theme) ---------- */
#printOverlay { position: fixed; inset: 0; z-index: 200; background: #dfe3ec; color: #111; overflow: auto; padding: 14px; }
.ptool { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0 12px; background: #dfe3ec; color: #333; }
.ptool .mut { color: #444; font-size: 13px; }
.ptool .btn { color: #111; background: #fff; border-color: #888; }
.ptool .btn.pri { background: #0a6f8a; color: #fff; border-color: #0a6f8a; }
.sheet { background: #fff; color: #111; max-width: 210mm; margin: 0 auto; padding: 12mm; box-shadow: 0 6px 30px rgba(0, 0, 0, .25); font-size: 12.5px; line-height: 1.45; font-family: var(--body); }
.sheet .mono { font-family: var(--mono); }
.shead { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 8px; }
.shead .side.ar { text-align: right; }
.shead .mid h1 { text-align: center; font-size: 18px; line-height: 1.3; }
.plogo { max-height: 44px; max-width: 150px; display: block; margin-bottom: 4px; }
.bi { display: inline-flex; flex-direction: column; line-height: 1.3; }
.bi [lang="ar"] { font-family: "IBM Plex Sans Arabic", var(--body); }
.sheet .ar { font-family: "IBM Plex Sans Arabic", var(--body); }
.sheet table { border-collapse: collapse; width: 100%; }
.pinfo td { padding: 4px 6px; border: 1px solid #999; vertical-align: top; }
.pinfo { margin-bottom: 8px; }
.ptbl th, .ptbl td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; }
.ptbl th { background: #eceff5; text-align: start; font-size: 11.5px; }
.sheet .num { text-align: end; white-space: nowrap; }
.pfoot { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; align-items: flex-start; flex-wrap: wrap; }
.qr { text-align: center; font-size: 11px; color: #555; }
.qrbox { width: 92px; height: 92px; border: 2px dashed #888; display: grid; place-items: center; font-weight: 800; color: #777; margin: 0 auto 4px; }
.sheet .ptot { width: auto; min-width: 300px; }
.ptot td { padding: 4px 8px; border: 1px solid #999; }
.ptot tr.grand td { font-weight: 800; background: #eceff5; font-size: 14px; }
.ptot tr.sub td { font-weight: 700; }
.words { margin-top: 10px; padding: 8px; border: 1px solid #999; }
.demo { margin-top: 10px; color: #a3262a; font-size: 11.5px; }
.hij { font-size: 11px; color: #555; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  #menuBtn { display: inline-block; }
  #side { position: fixed; top: var(--hh); bottom: 0; height: auto; inset-inline-start: 0; width: min(300px, 88vw); z-index: 60; transform: translateX(-102%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0, 0, 0, .4); }
  [dir="rtl"] #side { transform: translateX(102%); box-shadow: -8px 0 30px rgba(0, 0, 0, .4); }
  #side.open { transform: none; }
  .coname { display: none; }
}
@media (max-width: 560px) {
  #shell-top { gap: 6px; padding-inline: 8px; }
  .logo span { display: none; }
  .seg button { padding: 6px 8px; min-width: 34px; }
  .phead h1 { font-size: 18px; }
  html[lang="en"] .phead h1 { font-size: 16px; }
  input.search { max-width: none; width: 100%; }
  .shead { grid-template-columns: 1fr; }
  .shead .side.ar { text-align: start; }
}
@media (max-width: 560px) {
  /* line-item tables become stacked cards on phones */
  .tbl.lines, .tbl.lines tbody { display: block; }
  .tbl.lines thead { display: none; }
  .tbl.lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
  .tbl.lines td { display: block; padding: 0; border: 0; }
  .tbl.lines td:first-child { grid-column: 1 / -1; }
  .tbl.lines td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--mut); font-weight: 600; }
  .tbl.lines td.num { text-align: start; }
  .tbl.lines td.rm { grid-column: 1 / -1; text-align: end; }
  .tbl.lines select { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- print: only the sheet ---------- */
@media print {
  body.printing > :not(#printOverlay) { display: none !important; }
  body.printing { background: #fff; }
  #printOverlay { position: static; background: #fff; padding: 0; overflow: visible; }
  .no-print { display: none !important; }
  .sheet { box-shadow: none; max-width: none; padding: 0; }
  @page { size: A4; margin: 12mm; }
}
