/* Emissa ERP — one stylesheet for Arabic (RTL), Turkish and English (LTR). Logical properties only. */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #667085;
  --line: #e1e6ed;
  --brand: #0f4c5c;
  --brand-2: #16697a;
  --brand-ink: #ffffff;
  --accent: #e36414;
  --ok: #2e7d32;
  --warn: #b26a00;
  --err: #b3261e;
  --tr: #c62828;
  --sy: #2e7d32;
  --both: #5b3a9e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif;
  line-height: 1.55; -webkit-text-size-adjust: 100%;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: plaintext; }
.wide { grid-column: 1 / -1; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem !important; }
.req { color: var(--err); }
.inline { display: inline; margin: 0; }
img { max-width: 100%; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: 0 0 232px; background: var(--brand); color: var(--brand-ink);
  padding: 1rem 0; position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
}
.side .brand { padding: .25rem 1.1rem 1rem; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .15); margin-bottom: .6rem; }
.side .brand small { display: block; font-weight: 400; opacity: .75; font-size: .78rem; margin-top: .15rem; color: inherit; }
.side nav a {
  display: block; padding: .55rem 1.1rem; color: rgba(255, 255, 255, .86);
  border-inline-start: 3px solid transparent;
}
.side nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.side nav a.on { background: rgba(255, 255, 255, .14); color: #fff; border-inline-start-color: var(--accent); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: .55rem 1.25rem;
}
.top .tools { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-block; background: #e6f1f3; color: var(--brand); border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; font-weight: 600; }
.lng { padding: .15rem .55rem; border-radius: 6px; color: var(--muted); font-size: .85rem; }
.lng.on { background: var(--brand); color: #fff; }
.lng:hover { text-decoration: none; background: #e6f1f3; color: var(--brand); }
.lng.on:hover { background: var(--brand); color: #fff; }
.content { padding: 1.25rem; max-width: 1280px; width: 100%; margin-inline: auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions, .btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row { margin: .5rem 0; }

/* ---------- cards / tables ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; margin-bottom: 1rem; }
.card.table-wrap { padding: 0; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.card-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: .55rem .75rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { background: #f7f9fb; font-weight: 600; font-size: .85rem; color: #475467; white-space: nowrap; }
table.grid tbody tr:hover { background: #fafcfd; }
table.grid td.act, table.grid th.act { text-align: end; white-space: nowrap; width: 1%; }
table.grid td.num, table.grid th.num { text-align: end; }
table.grid tr.total td { font-weight: 700; background: #f7f9fb; }
table.grid input, table.grid select { width: 100%; min-width: 90px; }
table.grid tr.neg td { color: var(--err); }
.card > .table-wrap { margin: 0 -1.15rem; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .4rem 0; border-bottom: 1px dashed var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.files { list-style: none; margin: .5rem 0; padding: 0; }
ul.files li { padding: .3rem 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.desc { white-space: normal; background: #fafbfc; border-inline-start: 3px solid var(--line); padding: .5rem .8rem; margin: .5rem 0; }

dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem 1.25rem; margin: 0; }
dl.facts > div { min-width: 0; }
dl.facts dt { font-size: .78rem; color: var(--muted); margin-bottom: .1rem; }
dl.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- dashboard cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stat { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; color: var(--ink); }
.stat:hover { text-decoration: none; border-color: var(--brand-2); }
.stat b { display: block; font-size: 1.7rem; color: var(--brand); line-height: 1.2; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.link b { font-size: 1.05rem; margin-bottom: .2rem; }

/* ---------- buttons / forms ---------- */
.btn, button.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
  padding: .45rem .9rem; border-radius: 8px; font: inherit; font-size: .9rem; line-height: 1.3; text-decoration: none;
}
.btn:hover { background: #eef3f6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff; border-color: #e7b7b3; color: var(--err); }
.btn.danger:hover { background: #fdecea; }
.btn.small { padding: .2rem .6rem; font-size: .8rem; }

input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=month], input[type=search], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; padding: .45rem .6rem; background: #fff;
  border: 1px solid #cfd6df; border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(22, 105, 122, .35); border-color: var(--brand-2); }
textarea { resize: vertical; }
input[readonly] { background: #f2f4f7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1.25rem; }
.field { min-width: 0; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: #344054; }
.field .help { display: block; margin-top: .2rem; font-size: .78rem; }
.field input[type=file] { width: 100%; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
label.check input { width: auto; }
.form-actions { display: flex; gap: .5rem; padding-top: .5rem; }
.form-actions.wide { grid-column: 1 / -1; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding: .7rem 1rem; }
.filters input, .filters select { width: auto; min-width: 140px; max-width: 100%; }
.inline-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
.pct { max-width: 110px; }
.logo-prev { max-height: 64px; display: block; margin-bottom: .4rem; }

/* ---------- messages ---------- */
.flash, .notice { border-radius: 8px; padding: .65rem .9rem; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: #e8f5e9; border-color: #b7dcb9; color: #1b5e20; }
.flash.err { background: #fdecea; border-color: #f2b8b5; color: #8c1d18; }
.flash.warn { background: #fff4e0; border-color: #f2d49b; color: #7a4a00; }
.flash.info, .notice { background: #eaf3f8; border-color: #c4dbe6; color: #0b3c4d; }
.warn-text { color: var(--warn); }
.issues { border-color: #f2d49b; background: #fffaf0; }
.issues ul { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
.ts-total.ok { color: var(--ok); font-weight: 700; }
.ts-total.over { color: var(--err); font-weight: 700; }

/* ---------- badges / bars ---------- */
.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #eef0f3; color: #475467; white-space: nowrap; }
.b-active, .b-approved, .b-received, .b-completed, .b-paid, .b-posted, .b-human, .b-full, .b-closed.ok { background: #e3f3e5; color: #1b5e20; }
.b-submitted, .b-issued, .b-ongoing, .b-po, .b-in_use, .b-partial, .b-ai, .b-stale { background: #fff1d6; color: #7a4a00; }
.b-rejected, .b-cancelled, .b-suspended, .b-disposed, .b-ended { background: #fde3e1; color: #8c1d18; }
.b-draft, .b-planning, .b-planned, .b-stored, .b-none, .b-src { background: #e8eef5; color: #3b4b60; }
.b-closed { background: #e4e7ec; color: #475467; }
.s-TR { background: #fde3e1; color: var(--tr); }
.s-SY { background: #e3f3e5; color: var(--sy); }
.s-BOTH { background: #ece4fa; color: var(--both); }
.bar { height: 8px; background: #e7ebf0; border-radius: 99px; overflow: hidden; min-width: 90px; margin-bottom: .15rem; }
.bar span { display: block; height: 100%; background: var(--brand-2); }
.bar.warn span { background: #e0a100; }
.bar.over span { background: var(--err); }

/* ---------- login ---------- */
body.bare, .bare-wrap { background: var(--bg); }
.bare-wrap { max-width: 440px; margin: 0 auto; padding: 1.25rem; min-height: 100vh; }
.bare-tools { justify-content: center; margin-bottom: 1rem; display: flex; gap: .4rem; }
.login { margin-top: 2rem; }
.login h1 { text-align: center; color: var(--brand); }
.login .field { margin-bottom: .85rem; }
.login .btn { width: 100%; }
body.bare .bare-wrap { max-width: none; padding: 0; }

/* ---------- documents (screen + print) ---------- */
.tx-edit { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .85rem; padding: .6rem .85rem; }
.tx-edit legend { font-weight: 600; padding: 0 .4rem; }
.tx-langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.tx-lang label { font-size: .8rem; font-weight: 600; display: block; margin-bottom: .2rem; }

.doc { position: relative; background: #fff; color: #111; max-width: 210mm; margin: 0 auto 2rem; padding: 14mm 15mm; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 11pt; line-height: 1.45; overflow: hidden; }
.doc .watermark { position: absolute; inset: 40% 0 auto 0; text-align: center; font-size: 90pt; font-weight: 800; color: rgba(180, 0, 0, .07); transform: rotate(-24deg); pointer-events: none; letter-spacing: .1em; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--brand); padding-bottom: .6rem; margin-bottom: .8rem; }
.doc-brand .org { font-weight: 700; font-size: 12pt; color: var(--brand); }
.doc-brand .logo { max-height: 18mm; display: block; margin-bottom: 2mm; }
.doc-ents { text-align: end; font-size: 9pt; }
.doc-ents .ent { margin-bottom: 1.5mm; }
.doc-ents .ent-info { color: #555; }
.doc-title { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 1.2em; margin: .3rem 0 .7rem; font-size: 15pt; text-align: center; color: var(--brand); }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: .8rem; font-size: 10pt; }
.doc-meta th, .doc-meta td { border: 1px solid #cfd6df; padding: 1.2mm 2.5mm; vertical-align: top; text-align: start; }
.doc-meta th { width: 36%; background: #f4f6f9; font-weight: 600; }
.doc .lb { display: block; }
.doc .lb + .lb { font-weight: 400; color: #444; font-size: 9pt; }
.doc .vl { display: block; }
.doc .vl[dir=auto] { display: inline-block; max-width: 100%; }
.doc .vl + .vl { color: #333; font-size: 10pt; }
.doc-text { margin-bottom: .7rem; }
.doc-text h3 { font-size: 11pt; margin: 0 0 1mm; }
.doc-text h3 .lb + .lb { font-size: 9pt; }
.doc .tx { margin: 0 0 1.5mm; padding: 1.5mm 2.5mm; border-inline-start: 2px solid #cfd6df; background: #fbfcfd; }
.doc .tag { display: inline-block; font-size: 7.5pt; font-weight: 700; color: #fff; background: #667085; border-radius: 3px; padding: 0 1.5mm; margin-inline-end: 2mm; vertical-align: middle; }
.doc-static p { margin: 0 0 2mm; font-size: 10pt; text-align: justify; }
.doc-table { margin-bottom: .8rem; }
.doc-table h3 { font-size: 11pt; margin: 0 0 1.5mm; }
table.doc-grid { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
table.doc-grid th, table.doc-grid td { border: 1px solid #b9c2cf; padding: 1.2mm 2mm; vertical-align: top; text-align: start; }
table.doc-grid th { background: #eef2f6; font-weight: 600; }
table.doc-grid td.num { text-align: end; }
table.doc-grid tr.foot td { background: #f4f6f9; font-weight: 700; }
table.doc-grid .tx { border: 0; background: none; padding: 0 0 .5mm; margin: 0; }
.doc-sign { display: flex; gap: 8mm; margin-top: 14mm; page-break-inside: avoid; }
.doc-sign .sig { flex: 1; text-align: center; font-size: 9.5pt; }
.doc-sign .sig-line { border-bottom: 1px solid #333; height: 14mm; margin-bottom: 1.5mm; }
.doc-sign .sig-date { color: #555; font-size: 8.5pt; margin-top: 1mm; }
.doc-foot { display: flex; justify-content: space-between; margin-top: 8mm; padding-top: 2mm; border-top: 1px solid #cfd6df; font-size: 8.5pt; color: #666; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; flex: none; padding: .5rem 0; }
  .side nav { display: flex; flex-wrap: wrap; padding: 0 .5rem; }
  .side nav a { border-inline-start: 0; border-radius: 6px; padding: .4rem .7rem; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: .85rem; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .side, .top, .noprint, .flash, .page-head .actions { display: none !important; }
  .shell, .main { display: block; }
  .content { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .doc .watermark { position: fixed; inset: 35% 0 auto 0; }
  table.doc-grid tr, .doc-text, .doc-sign { page-break-inside: avoid; }
  a { color: inherit; }
}
