/* STE Business Suite — one stylesheet, logical properties so Arabic (RTL) mirrors automatically. */
:root {
  --brand: #215FA7;
  --brand-2: #548DCA;
  --brand-soft: #eaf1fa;
  --ink: #1d2430;
  --ink-2: #5b6575;
  --line: #e3e7ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --good: #1f7a4d; --good-bg: #e6f4ec;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad:  #b42318; --bad-bg:  #fde8e6;
  --info: #215FA7; --info-bg: #eaf1fa;
  --radius: 10px;
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
}
[dir="rtl"] { --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14.5px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

/* Layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #0f2340; color: #c9d6ea; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 600; }
.side .logo img { height: 34px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.side .logo.has-img { background: #fff; border-radius: 10px; padding: 10px 14px; margin: 0 2px 16px; justify-content: center; }
.side .logo.has-img img { height: auto; width: 100%; max-width: 170px; padding: 0; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #c9d6ea; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; }
.side nav .sec { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #7f93b3; margin: 18px 10px 6px; }
.side svg { width: 18px; height: 18px; flex: none; }
.main { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); }
.top .who { display: flex; align-items: center; gap: 14px; }
.content { padding: 24px 28px 48px; max-width: 1280px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead .sub { color: var(--ink-2); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
.g3-1 { grid-template-columns: 2fr 1fr; }
.grid > * { min-width: 0; }
table.list th.num { text-align: end; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi .foot { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: #c5ccd8; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; }
form.inline { display: inline; }

/* Tables */
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
table.list th { font-size: 12.5px; color: var(--ink-2); font-weight: 600; background: #fafbfc; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: #fafcff; }
table.list a.sort { color: inherit; }
table.list tfoot td { font-weight: 600; background: #fafbfc; }
.card.flush { padding: 0; overflow: hidden; }
.empty { padding: 36px; text-align: center; color: var(--ink-2); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.muted { background: #eef0f4; color: var(--ink-2); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* Filters */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { min-width: 260px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }

/* Forms */
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #d3d9e3; border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 38px; }
.filters input, .filters select { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.field .help { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.field .err, .errorlist { color: var(--bad); font-size: 12.5px; margin: 4px 0 0; padding: 0; list-style: none; }
.field.wide { grid-column: 1 / -1; }
.field.check { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.field.check label { margin: 0; }
.formbar { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Line editor */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { font-size: 12px; color: var(--ink-2); text-align: start; padding: 6px; font-weight: 600; }
table.lines td { padding: 6px; vertical-align: top; border-top: 1px solid var(--line); }
table.lines td input, table.lines td select, table.lines td textarea { padding: 6px 8px; }
table.lines .c-qty { width: 84px; } table.lines .c-unit { width: 72px; } table.lines .c-price { width: 110px; }
table.lines .c-disc { width: 72px; } table.lines .c-total { width: 110px; } table.lines .c-del { width: 36px; }
table.lines .c-cost { width: 104px; }
table.lines tr.deleted { opacity: .35; }
.line-sub { display: grid; grid-template-columns: 1fr 1fr 180px; gap: 6px; margin-top: 6px; }
.totals { margin-inline-start: auto; width: 320px; margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .grand { border-top: 2px solid var(--ink); font-weight: 700; font-size: 16px; padding-top: 8px; }
.internal { color: var(--ink-2); font-size: 12.5px; }

/* Messages */
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msgs li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--info-bg); color: var(--info); }
.msgs li.success { background: var(--good-bg); color: var(--good); }
.msgs li.error { background: var(--bad-bg); color: var(--bad); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #0f2340 0%, #215FA7 100%); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login img { max-width: 170px; display: block; margin: 0 auto 18px; }

/* Responsive */
@media (max-width: 1000px) { .g4 { grid-template-columns: 1fr 1fr; } .g3-1, .g2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  [dir="rtl"] .side { transform: translateX(100%); }
  body.nav-open .side { transform: none; }
  .menu-btn { display: inline-flex; }
  .top, .content { padding-inline: 16px; }
  .form-grid, .g4 { grid-template-columns: 1fr; }
  .filters input[type=search] { min-width: 0; flex: 1; }
  .totals { width: 100%; }
  .g3-1 > :last-child { order: -1; }
  .line-sub { grid-template-columns: 1fr; }
}
