@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url(/fonts/cairo-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url(/fonts/cairo-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url(/fonts/cairo-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url(/fonts/cairo-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url(/fonts/cairo-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url(/fonts/cairo-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f4f6f9; --surface: #fff; --ink: #1c2733; --muted: #66758a; --line: #dfe5ec;
  --brand: #1f4e79; --brand-2: #2d6aa3; --brand-soft: #e6eef7; --ok: #1b7f4b; --ok-soft: #e3f5ea; --warn: #9a6200; --warn-soft: #fff3d6;
  --bad: #b3261e; --bad-soft: #fde7e5; --info: #1d5fa8; --info-soft: #e3effc; --radius: 10px; --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
a { color: var(--brand-2); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); } .ltr { direction: ltr; unicode-bidi: plaintext; text-align: right; }

/* layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: #12304d; color: #dbe7f3; padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; border-bottom: 1px solid #27486a; margin-bottom: 8px; }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.brand b { display: block; color: #fff; font-size: 16px; } .brand small { color: #9fb6cc; }
.nav-group { margin: 12px 8px 4px; font-size: 12px; color: #8fa9c2; letter-spacing: .3px; }
.nav a { display: block; padding: 7px 12px; border-radius: 8px; color: #dbe7f3; font-size: 14.5px; }
.nav a:hover { background: #1c426a; } .nav a.active { background: var(--brand-2); color: #fff; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.content { padding: 20px 22px 40px; max-width: 1300px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.card h3 { font-size: 16px; margin-bottom: 10px; }
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k { color: var(--muted); font-size: 13px; } .kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; direction: ltr; text-align: right; }
.kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }

/* controls */
.input { width: 100%; padding: 8px 10px; border: 1px solid #c8d1dc; border-radius: 8px; background: #fff; min-height: 38px; }
.input:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: var(--brand-2); }
.input[readonly], .input:disabled { background: #f0f3f7; color: var(--muted); }
textarea.input { min-height: 70px; resize: vertical; }
.toolbar .input { width: auto; min-width: 160px; }
.btn { border: 1px solid #c8d1dc; background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; min-height: 38px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f1f5f9; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 3px 10px; min-height: 30px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--brand-2); padding: 3px 6px; min-height: 0; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.field { display: flex; flex-direction: column; gap: 4px; } .field-label { font-weight: 600; font-size: 13.5px; } .hint { color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; } .form-grid .full { grid-column: 1 / -1; }
.req::after { content: ' *'; color: var(--bad); }
.check { display: flex; align-items: center; gap: 8px; } .check input { width: 18px; height: 18px; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { background: #eef2f7; text-align: right; padding: 9px 12px; font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; } .table tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: left; direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: #eef2f7; border-top: 2px solid var(--line); }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table td.act { white-space: nowrap; width: 1%; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 10px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: #eef2f7; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.info { background: var(--info-soft); color: var(--info); }
.neg { color: var(--bad); } .pos { color: var(--ok); }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 48, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow-y: auto; } .modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.confirm-msg { margin: 0 0 10px; font-size: 16px; }
#toasts { position: fixed; bottom: 18px; left: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: #153a5b; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 380px; transition: opacity .35s; }
.toast.err { background: var(--bad); } .toast.hide { opacity: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #12304d, #2d6aa3); }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .brand-logo { background: var(--brand); color: #fff; margin: 0 auto 8px; width: 54px; height: 54px; font-size: 24px; }
.login-card h1 { text-align: center; font-size: 22px; } .login-card p.sub { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.login-card .field { margin-bottom: 12px; } .login-err { color: var(--bad); min-height: 22px; font-size: 14px; }

/* invoice editor */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 20; inset-inline: 0; top: 100%; background: #fff; border: 1px solid #c8d1dc; border-radius: 8px; max-height: 280px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.picker-item { padding: 7px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f0f3f7; }
.picker-item:hover, .picker-item.sel { background: var(--brand-soft); } .picker-item small { color: var(--muted); }
.lines input.input { min-width: 80px; padding: 4px 8px; min-height: 32px; }
.totals { margin-inline-start: auto; width: min(380px, 100%); }
.totals .row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; min-height: 40px; border-bottom: 1px dashed var(--line); }
.totals .row.big { font-size: 18px; font-weight: 700; border-bottom: 2px solid var(--ink); }
.totals .row input { width: 120px; text-align: left; direction: ltr; }

/* chart */
.chart { width: 100%; height: 200px; } .chart text { font-family: inherit; font-size: 11px; fill: var(--muted); }
.bar { fill: var(--brand-2); } .bar:hover { fill: var(--brand); }
.hbar { display: grid; grid-template-columns: 140px 1fr 90px; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.hbar .track { background: #eef2f7; border-radius: 99px; height: 10px; overflow: hidden; } .hbar .fill { background: var(--brand-2); height: 100%; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .hbar .val { direction: ltr; text-align: left; color: var(--muted); }

/* printable documents */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 30px; max-width: 900px; margin: 0 auto; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 14px; }
.doc-head h1 { font-size: 22px; color: var(--brand); } .doc-title { font-size: 20px; font-weight: 700; text-align: left; }
.doc-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 24px; margin-bottom: 14px; }
.doc-meta div b { display: inline-block; min-width: 110px; color: var(--muted); font-weight: 600; }
.doc .table th { background: #eef2f7; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-foot { margin-top: 26px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: center; color: var(--muted); }
.doc-foot div { border-top: 1px solid #999; padding-top: 6px; }
.watermark { color: var(--bad); border: 3px solid var(--bad); display: inline-block; padding: 2px 16px; font-weight: 700; font-size: 20px; transform: rotate(-6deg); }
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; }

@media (max-width: 960px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .kpis, .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12.5px; }
  .no-print, .side, .topbar, #toasts { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  .doc { border: none; padding: 0; max-width: none; }
  .table-wrap { border: none; overflow: visible; } .table th, .table td { padding: 5px 8px; }
  .card { border: none; padding: 0; } tr { page-break-inside: avoid; }
}
@media screen { .print-only { display: none; } }

/* v4: part IDs & lots */
.id-preview { background: var(--surface-2, #f1f5f9); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 14px; margin-top: 8px; min-height: 52px; }
.lotcell { min-width: 190px; } .lotcell .input { margin-bottom: 3px; }
.kpi-link { text-decoration: none; color: inherit; display: block; } .kpi-link:hover .kpi { border-color: var(--primary, #0d6efd); }
.newlot { display: grid; gap: 8px; }
.steps { margin: 0 0 12px; padding-inline-start: 22px; line-height: 1.9; }

.version { margin: 14px 12px; font-size: 12px; color: #9fb3c8; }
.demo-flag { margin-top: 4px; color: #ffd27a; font-weight: 700; }

/* English (left-to-right) adjustments */
html[dir="ltr"] .table th { text-align: left; }
html[dir="ltr"] .table td.num, html[dir="ltr"] .table th.num { text-align: right; }
html[dir="ltr"] .ltr, html[dir="ltr"] .kpi .v { text-align: left; }
html[dir="ltr"] .totals .row input, html[dir="ltr"] .hbar .val { text-align: right; }
html[dir="ltr"] .doc-title { text-align: right; }
html[dir="ltr"] #toasts { left: auto; right: 18px; }

/* v1.08: case form tabs, summary strip, supply sections */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 9px 9px 0 0; padding: 9px 18px; cursor: pointer; font-weight: 600; min-height: 42px; }
.tab:hover { background: #f1f5f9; } .tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; margin-inline-end: 7px; } .tab .dot.done { background: var(--ok); } .tab .dot.todo { background: var(--warn); }
.strip { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px 22px; flex-wrap: wrap; align-items: center; background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; margin-bottom: 12px; font-size: 14px; }
.strip b { font-weight: 700; } .strip .sep { color: var(--muted); }
.supply-types { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0 14px; }
.supply-types .check { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.supply-sec { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; background: #fff; }
.supply-sec > summary { cursor: pointer; padding: 9px 14px; font-weight: 700; background: #f7f9fc; border-radius: var(--radius); display: flex; justify-content: space-between; gap: 10px; }
.supply-sec[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.supply-sec .inner { padding: 12px 14px; }
.ref-row { display: flex; gap: 6px; align-items: center; } .ref-row select { flex: 1; }
.pane[hidden] { display: none; }
.nav-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
