/* Al-Salam ERP — identity: royal blue #254DB8, white, #F3F6FB, charcoal #151A24. Typeface: IBM Plex Sans Arabic (SIL OFL). */
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url("fonts/plex-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url("fonts/plex-latin-400.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url("fonts/plex-arabic-500.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url("fonts/plex-latin-500.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url("fonts/plex-arabic-600.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url("fonts/plex-latin-600.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --blue: #254DB8; --blue-d: #1c3c93; --blue-l: #e6ecfa;
  --bg: #F3F6FB; --ink: #151A24; --muted: #5d6677; --line: #dbe2ee; --white: #fff;
  --ok: #1f7a4d; --ok-l: #e3f4ea; --err: #b42318; --err-l: #fdecea; --warn: #8a5a00; --warn-l: #fff4d6;
  --r: 10px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; overflow-x: hidden; font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif; font-weight: 400;
       background: var(--bg); color: var(--ink); line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 .8rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.table td.num { text-align: start; }
code.big { font-size: 1.2rem; background: var(--white); padding: .1rem .5rem; border-radius: 6px; border: 1px solid var(--line); user-select: all; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: 58px; padding: 0 1.2rem;
          background: var(--blue); color: var(--white); }
.topbar a, .topbar .link { color: var(--white); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.05rem; }
.brand-mark { width: 34px; height: 34px; object-fit: contain; background: var(--white); border-radius: 8px; padding: 3px; }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.who form { margin: 0; }
.shell { display: flex; min-height: calc(100vh - 58px); }
.sidebar { width: 220px; flex-shrink: 0; background: var(--white); border-inline-end: 1px solid var(--line); padding: 1rem .6rem; }
.sidebar a { display: block; padding: .55rem .8rem; border-radius: 8px; color: var(--ink); font-weight: 500; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--blue-l); color: var(--blue); }
.main { flex: 1; min-width: 0; padding: 1.5rem; max-width: 1280px; }
.nav-toggle, .burger { display: none; }
@media (max-width: 860px) {
  .burger { display: block; cursor: pointer; font-size: 1.4rem; }
  .sidebar { display: none; position: fixed; top: 58px; bottom: 0; inset-inline-start: 0; z-index: 15; overflow-y: auto; }
  .nav-toggle:checked ~ .shell .sidebar { display: block; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .who span { display: none; }
  .main { padding: 1rem; }
}

/* Guest */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.guest-card { width: 100%; max-width: 400px; background: var(--white); border-radius: 14px; padding: 2rem; box-shadow: 0 10px 40px rgba(21,26,36,.08); }
.guest-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--blue); margin-bottom: 1.5rem; font-size: 1.1rem; }
.guest-brand .brand-mark { background: var(--blue-l); }

/* Components */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; margin-bottom: 1.2rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem; color: var(--ink); }
.stat { display: flex; flex-direction: column; gap: .2rem; }
a.stat:hover { border-color: var(--blue); text-decoration: none; }
.stat-n { font-size: 1.7rem; font-weight: 600; color: var(--blue); font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem 1rem; border-radius: 8px;
       border: 1px solid var(--line); background: var(--white); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--blue); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-d); }
.btn-danger { background: var(--white); border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-l); }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.btn-row form { margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
button.link.danger { color: var(--err); }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-l); color: var(--ok); border-color: #b9e2c9; }
.flash-error { background: var(--err-l); color: var(--err); border-color: #f5c2bd; }
.flash-info { background: var(--blue-l); color: var(--blue-d); border-color: #c6d4f3; }
.flash-warn { background: var(--warn-l); color: var(--warn); border-color: #f2dc9a; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 500; background: var(--bg); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.badge.ok { background: var(--ok-l); color: var(--ok); border-color: #b9e2c9; }
.badge.off { background: var(--err-l); color: var(--err); border-color: #f5c2bd; }
.badge.s-confirmed, .badge.s-purchasing, .badge.s-ready { background: var(--blue-l); color: var(--blue); border-color: #c6d4f3; }
.badge.s-shipped, .badge.s-delivered { background: var(--ok-l); color: var(--ok); border-color: #b9e2c9; }
.badge.s-cancelled { background: var(--err-l); color: var(--err); border-color: #f5c2bd; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); }
.panel .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.table th { background: var(--bg); font-weight: 600; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfe; }
.actions { white-space: nowrap; display: flex; gap: .8rem; }
.pager { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; }
.pager a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.pager a.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* Forms */
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; margin-bottom: .9rem; }
.form input, .form select, .form textarea, .search input, .filters input, .filters select {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); width: 100%; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--blue-l); border-color: var(--blue); }
.form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1.2rem;
             background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; }
.form .wide { grid-column: 1 / -1; }
.form.narrow { max-width: 420px; }
.form-actions { margin-top: .5rem; }
.req { color: var(--err); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
.error { color: var(--err); font-weight: 400; }
.search { display: flex; gap: .5rem; max-width: 460px; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters > * { width: auto !important; }
.inline-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-top: 1rem; }
.inline-form label { margin: 0; flex: 1 1 160px; }
.danger-zone { margin-top: 1.5rem; }
.check { display: flex; flex-direction: row !important; align-items: center; gap: .5rem !important; font-weight: 400 !important; margin-bottom: .35rem !important; }
.check input { width: auto !important; }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.5rem; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; align-items: start; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .8rem; padding: .6rem .8rem; }
legend { font-weight: 600; padding: 0 .3rem; color: var(--blue); }

.error-page { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 4rem; font-weight: 600; color: var(--blue); line-height: 1; margin-bottom: 1rem; }
/* Tables placed directly in a panel scroll on their own on small screens */
.panel > .table { display: block; overflow-x: auto; }
@media (min-width: 861px) { .panel > .table { display: table; } }
button.link { white-space: nowrap; }
.table select { font: inherit; font-size: .9rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); }

/* Inventory & purchasing */
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
.tabs a { padding: .35rem .8rem; border-radius: 99px; background: var(--white); border: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.tabs a.active { background: var(--blue); border-color: var(--blue); color: var(--white); }
progress { width: 110px; height: 8px; vertical-align: middle; accent-color: var(--blue); }
.ok-text { color: var(--ok); } .err-text { color: var(--err); } .warn-text { color: var(--warn); }
.qty-input { width: 110px !important; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.qty-input:focus { outline: 2px solid var(--blue-l); border-color: var(--blue); }
.btn-row.tight { margin: 0; }
.receipt { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .6rem; }
.receipt ul { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
.table tfoot td { background: var(--bg); border-top: 2px solid var(--line); }
.badge.po-sent, .badge.po-partially_received { background: var(--blue-l); color: var(--blue); border-color: #c6d4f3; }
.badge.po-received { background: var(--ok-l); color: var(--ok); border-color: #b9e2c9; }
.badge.po-cancelled { background: var(--err-l); color: var(--err); border-color: #f5c2bd; }
.badge.mv-receipt, .badge.mv-transfer_in { background: var(--ok-l); color: var(--ok); border-color: #b9e2c9; }
.badge.mv-delivery, .badge.mv-transfer_out { background: var(--blue-l); color: var(--blue); border-color: #c6d4f3; }
.badge.mv-count, .badge.mv-adjustment { background: var(--warn-l); color: var(--warn); border-color: #f2dc9a; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.2rem 0 .6rem; }
pre { white-space: pre-wrap; background: var(--bg); padding: .5rem; border-radius: 6px; max-height: 240px; overflow: auto; }
.grid.panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1.2rem; }

/* Accounting */
tr.strike td { text-decoration: line-through; }
.table.profit td:last-child { width: 40%; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.neg { color: var(--err); }
.util { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.subnav { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.subnav a { padding: .35rem .8rem; border-radius: 8px; background: var(--white); border: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.subnav a.active { border-color: var(--blue); color: var(--blue); background: var(--blue-l); }
meter { width: 100%; height: 12px; }
.doc-row form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: 0; }
.doc-row input, .doc-row select { font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; }
.meta dd[dir="ltr"] { text-align: right; }
.table td.num[dir="ltr"], .stat-n[dir="ltr"] { text-align: right; }
