/* ============================================================
   ERP Static Mockups — Shared Design System
   Generated from: ERP Modern Development Specification v2.0
   Light professional theme • bilingual-ready (logical props)
   ============================================================ */

:root {
  --brand: #1a56db;
  --brand-strong: #1240a8;
  --brand-soft: #e8effc;
  --side-bg: #101c36;
  --side-bg-2: #0b1428;
  --side-line: #24325a;
  --side-text: #b6c2e2;
  --side-text-hi: #ffffff;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e3e8f0;
  --line-strong: #cbd5e1;
  --text: #1f2937;
  --text-soft: #55617a;
  --muted: #6b7280;
  --ok: #047857;      --ok-bg: #e8f6f0;
  --warn: #b45309;    --warn-bg: #fdf3e4;
  --err: #b91c1c;     --err-bg: #fdecec;
  --info: #1d4ed8;    --info-bg: #e8effc;
  --neutral: #4b5563; --neutral-bg: #eef1f5;
  --violet: #6d28d9;  --violet-bg: #f1ebfd;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 28, 54, .06), 0 4px 14px rgba(16, 28, 54, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans", "Noto Naskh Arabic", Tahoma, sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --side-w: 264px;
  --top-h: 58px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
}
h1,h2,h3,h4 { margin: 0 0 .4rem; line-height: 1.25; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: .3rem 0 .8rem; }
small, .small { font-size: .82rem; color: var(--muted); }
code, .code { font-family: var(--mono); font-size: .85em; background: #f1f4f9; border: 1px solid var(--line); border-radius: 5px; padding: .05em .4em; }
pre.code { padding: .8rem 1rem; overflow-x: auto; line-height: 1.5; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- Layout shell ---------- */
.layout { min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w);
  background: linear-gradient(180deg, #101c36 0%, #0d1730 100%);
  color: var(--side-text); overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: #33436f transparent;
}
.side-brand {
  display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem .9rem;
  border-block-end: 1px solid var(--side-line);
}
.side-brand .logo {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, #2f6bff, #6d9bff);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .95rem;
}
.side-brand .name { color: #fff; font-weight: 650; font-size: .95rem; letter-spacing: .2px; }
.side-brand .env  { font-size: .68rem; color: #8fa3cf; text-transform: uppercase; letter-spacing: .8px; }
.side-nav { padding: .7rem .6rem 1.4rem; flex: 1; }
.nav-sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .9px; color: #7f8db0; padding: .9rem .6rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .48rem .6rem; margin: 1px 0;
  border-radius: 8px; color: var(--side-text); font-size: .875rem; text-decoration: none;
}
.nav-item .ic { width: 20px; text-align: center; flex: 0 0 auto; opacity: .85; font-style: normal; }
.nav-item:hover { background: #1b2a4e; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.side-foot { padding: .8rem 1.1rem; border-block-start: 1px solid var(--side-line); font-size: .72rem; color: #8fa3cf; }

.main { margin-inline-start: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  background: var(--surface); border-block-end: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding-inline: 1.25rem;
}
.ctx-select {
  display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 8px; padding: .35rem .7rem; background: #fbfcfe; cursor: pointer;
}
.ctx-select .sub { font-weight: 400; color: var(--muted); }
.top-search { flex: 1; max-width: 460px; position: relative; }
.top-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
  padding: .45rem .9rem; font: inherit; font-size: .85rem; color: var(--text);
}
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .55rem; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; font-size: .95rem; color: var(--text-soft); position: relative;
}
.icon-btn .dot-n { position: absolute; top: 5px; inset-inline-end: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--err); }
.lang-toggle {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; padding: .38rem .7rem; color: var(--text-soft);
}
.lang-toggle:hover, .icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}

/* ---------- Content ---------- */
.content { padding: 1.4rem 1.6rem 3rem; max-width: 1480px; width: 100%; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .55rem; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin-inline: .4rem; opacity: .6; }
.crumbs .here { color: var(--text); font-weight: 600; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; }
.page-head .grow { flex: 1; min-width: 260px; }
.page-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -.2px; }
.page-sub { color: var(--text-soft); font-size: .9rem; max-width: 70ch; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.req-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.req-chip {
  font-size: .7rem; font-weight: 650; letter-spacing: .3px; color: var(--brand-strong);
  background: var(--brand-soft); border: 1px solid #c9d9f7; border-radius: 999px; padding: .12rem .55rem;
}

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.kpi .k-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 1.5rem; font-weight: 700; margin-top: .15rem; letter-spacing: -.3px; }
.kpi .k-hint { font-size: .76rem; color: var(--muted); margin-top: .1rem; }
.kpi .up   { color: var(--ok); font-weight: 600; }
.kpi .down { color: var(--err); font-weight: 600; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.1rem; }
.card-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; border-block-end: 1px solid var(--line); }
.card-title { font-size: .95rem; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1rem 1.1rem; }
.card-body.tight { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.1rem; align-items: start; }
.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.chip {
  font-size: .78rem; font-weight: 600; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text-soft); border-radius: 999px; padding: .28rem .75rem; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .x { margin-inline-start: .35rem; opacity: .7; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600; padding: .48rem .95rem;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: #a9b6c9; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.sm { padding: .28rem .65rem; font-size: .78rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.input, .select, textarea.input {
  font: inherit; font-size: .86rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: .45rem .7rem; width: 100%;
}
.input:focus, .select:focus, .btn:focus-visible, .chip:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem 1.1rem; }
.field label { display: block; font-size: .78rem; font-weight: 650; color: var(--text-soft); margin-bottom: .3rem; }
.field .req-star { color: var(--err); }
.field .help { font-size: .74rem; color: var(--muted); margin-top: .25rem; }
.field .error { font-size: .76rem; color: var(--err); font-weight: 600; margin-top: .25rem; }
.field.invalid .input, .field.invalid .select { border-color: var(--err); background: #fffafa; }
.field .lock { font-size: .72rem; color: var(--muted); }
.fieldset-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 1.1rem 0 .6rem; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: .5rem; font-size: .84rem; cursor: pointer; }
.toggle .tr { width: 34px; height: 19px; border-radius: 999px; background: #cbd5e1; position: relative; flex: 0 0 auto; }
.toggle .tr::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; }
.toggle.on .tr { background: var(--ok); }
.toggle.on .tr::after { inset-inline-start: 17px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .845rem; }
.tbl thead th {
  text-align: start; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: .6rem .9rem; border-block-end: 1px solid var(--line);
  background: #fafbfd; white-space: nowrap; position: sticky; top: 0;
}
.tbl tbody td { padding: .58rem .9rem; border-block-end: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: #f7f9fd; }
.tbl tbody tr.selected { background: var(--brand-soft); }
.tbl .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .main-cell { font-weight: 600; color: var(--text); }
.tbl .sub-cell { font-size: .75rem; color: var(--muted); font-weight: 400; }
.tbl tfoot td { padding: .6rem .9rem; font-weight: 700; border-block-start: 2px solid var(--line-strong); }
.pager { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; font-size: .8rem; color: var(--muted); }
.pager .spacer { flex: 1; }

/* ---------- Badges (status never by color alone: always text) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .73rem; font-weight: 650;
  border-radius: 999px; padding: .14rem .6rem; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge.ok      { color: var(--ok); background: var(--ok-bg); }
.badge.warn    { color: var(--warn); background: var(--warn-bg); }
.badge.err     { color: var(--err); background: var(--err-bg); }
.badge.info    { color: var(--info); background: var(--info-bg); }
.badge.muted   { color: var(--neutral); background: var(--neutral-bg); }
.badge.violet  { color: var(--violet); background: var(--violet-bg); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .2rem; border-block-end: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  border: 0; background: none; font: inherit; font-size: .86rem; font-weight: 600; color: var(--text-soft);
  padding: .55rem .9rem; cursor: pointer; border-block-end: 2.5px solid transparent; margin-block-end: -1px;
}
.tab.active { color: var(--brand-strong); border-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Banners ---------- */
.banner {
  display: flex; gap: .7rem; align-items: flex-start; border-radius: var(--radius-sm);
  padding: .75rem 1rem; font-size: .85rem; margin-bottom: 1rem; border: 1px solid;
}
.banner .b-title { font-weight: 700; display: block; margin-bottom: .15rem; }
.banner.info    { background: var(--info-bg); border-color: #c3d4f8; color: #173a8a; }
.banner.warn    { background: var(--warn-bg); border-color: #f2ddb8; color: #7a3f08; }
.banner.danger  { background: var(--err-bg); border-color: #f3c6c6; color: #7f1d1d; }
.banner.success { background: var(--ok-bg); border-color: #bfe5d5; color: #065f46; }

/* ---------- Inline dialog demo ---------- */
.dialog-demo { background: #0f1e3d0f; border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 1.6rem; display: grid; place-items: center; margin-bottom: 1.1rem; }
.dialog { background: var(--surface); border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(15, 30, 61, .25); width: min(560px, 100%); }
.dialog-head { padding: .95rem 1.2rem; border-block-end: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.dialog-body { padding: 1.1rem 1.2rem; font-size: .88rem; }
.dialog-foot { padding: .8rem 1.2rem; border-block-start: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .55rem; background: #fafbfd; border-radius: 0 0 12px 12px; }

/* ---------- Steps / lifecycle ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 0; counter-reset: step; margin-bottom: 1.1rem; }
.step { display: flex; align-items: center; gap: .5rem; padding: .45rem .9rem; font-size: .8rem; font-weight: 600; color: var(--muted); position: relative; }
.step::before {
  counter-increment: step; content: counter(step);
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--neutral-bg); color: var(--neutral); font-size: .72rem; font-weight: 700;
}
.step.done { color: var(--ok); }
.step.done::before { background: var(--ok); color: #fff; content: "✓"; }
.step.current { color: var(--brand-strong); }
.step.current::before { background: var(--brand); color: #fff; }
.step + .step { margin-inline-start: 1.2rem; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: 1.6rem; padding-block-end: 1rem; border-inline-start: 2px solid var(--line); margin-inline-start: .5rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -6px; top: .2rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); }
.timeline .t-time { font-size: .72rem; color: var(--muted); }
.timeline .t-title { font-weight: 650; font-size: .86rem; }
.timeline .t-meta { font-size: .8rem; color: var(--text-soft); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .9rem; overflow-x: auto; padding-block-end: .5rem; }
.kcol { background: #eef1f7; border-radius: var(--radius); padding: .6rem; }
.kcol-head { font-size: .78rem; font-weight: 700; padding: .3rem .5rem .55rem; display: flex; justify-content: space-between; color: var(--text-soft); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .55rem; font-size: .82rem; box-shadow: 0 1px 2px rgba(16,28,54,.05); }
.kcard .k-title { font-weight: 650; }
.kcard .k-meta { font-size: .74rem; color: var(--muted); margin-top: .2rem; }

/* ---------- Calendar ---------- */
.cal { width: 100%; border-collapse: collapse; font-size: .8rem; }
.cal th { padding: .5rem; border: 1px solid var(--line); background: #fafbfd; font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.cal td { border: 1px solid var(--line); vertical-align: top; height: 92px; padding: .35rem; width: 14.28%; }
.cal .d { font-size: .72rem; color: var(--muted); font-weight: 600; }
.cal td.today { background: var(--brand-soft); }
.cal-evt { display: block; font-size: .7rem; font-weight: 600; border-radius: 5px; padding: .12rem .4rem; margin-top: .25rem; background: var(--info-bg); color: var(--info); border-inline-start: 3px solid var(--info); }
.cal-evt.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.cal-evt.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

/* ---------- Misc data display ---------- */
.stat-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; font-size: .85rem; margin: 0; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-weight: 600; }
.masked { font-family: var(--mono); letter-spacing: 1px; color: var(--text-soft); }
.who { display: flex; align-items: center; gap: .55rem; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-size: .64rem; font-weight: 700; flex: 0 0 auto; }
.tree { list-style: none; padding-inline-start: 1.1rem; margin: 0; font-size: .86rem; }
.tree > li { padding: .18rem 0; }
.tree li { position: relative; }
.tree .node { display: inline-flex; align-items: center; gap: .45rem; padding: .15rem .4rem; border-radius: 6px; }
.tree .node:hover { background: var(--brand-soft); }
.tree .node.sel { background: var(--brand); color: #fff; }
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty .e-ic { font-size: 1.6rem; display: block; margin-bottom: .4rem; }
.progress { height: 8px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.err > span { background: var(--err); }

/* ---------- Diff ---------- */
.diff { font-family: var(--mono); font-size: .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.diff .ln { display: block; padding: .18rem .8rem; white-space: pre-wrap; }
.diff .add { background: #e9f7ef; color: #14532d; }
.diff .del { background: #fdeeee; color: #7f1d1d; text-decoration: line-through; }
.diff .ctx { color: var(--text-soft); }

/* ---------- Simple CSS bar chart (with table alternative for a11y) ---------- */
.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 70px; align-items: center; gap: .7rem; font-size: .8rem; }
.bar-row .bar { height: 14px; border-radius: 4px; background: var(--brand); min-width: 2px; }
.bar-row .bar.alt { background: #7fa4ef; }
.bar-row .val { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Process flow (workflow maps) ---------- */
.flow { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: .4rem 0 .8rem; }
.flow .fnode {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: .45rem .8rem; font-size: .8rem; font-weight: 600; color: var(--text);
}
.flow .fnode.start { border-color: var(--info); background: var(--info-bg); color: var(--info); }
.flow .fnode.gate  { border-color: #f2ddb8; background: var(--warn-bg); color: var(--warn); }
.flow .fnode.term  { border-color: #bfe5d5; background: var(--ok-bg); color: var(--ok); }
.flow .fnode.fail  { border-color: #f3c6c6; background: var(--err-bg); color: var(--err); }
.flow .farrow { color: var(--muted); font-weight: 700; font-size: .85rem; }
[dir="rtl"] .flow .farrow { transform: scaleX(-1); }

/* ---------- Footer note ---------- */
.note-foot {
  margin-top: 2rem; padding-top: .9rem; border-top: 1px solid var(--line);
  font-size: .74rem; color: var(--muted);
}

/* ---------- RTL helpers ---------- */
[dir="rtl"] .num, [dir="rtl"] .tbl .num { direction: ltr; unicode-bidi: embed; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar { display: none; }
  .main { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-inline-start: 0; }
  .split { grid-template-columns: 1fr; }
}
